![](/img/trans.png)
[英]How to use Mappings in AWS CloudFormation templates in nested stacks
[英]CloudFormation: How to use AWS::AccountId in Mappings?
我有一個看起來像這樣的映射:
Mappings:
AccountToParams:
aws-1234567890:
sshSecurityGroup: sg-abcedf12
而且我想通過AccountId檢索變量,但這不會超出“驗證”步驟
SecurityGroups:
- !FindInMap [AccountToParams, !Sub "aws-${AWS::AccountId}", sshSecurityGroup]
錯誤是
16/08/2017, 16:36:18 - Template contains errors.: Template error:
every Fn::FindInMap object requires three parameters,
the map name, map key and the attribute for return value
目標是使某些配置由運行該帳戶的帳戶(因此環境)驅動。 而且我似乎無法使用accountId作為映射中的鍵,否則AWS不滿意,因為它不包含字母數字字符
將地圖更改為:
Mappings:
AccountToParams:
"1234567890":
sshSecurityGroup: sg-abcedf12
並使用!Ref
代替!Sub
:
SecurityGroupIds:
- !FindInMap [AccountToParams, !Ref "AWS::AccountId", sshSecurityGroup]
如果需要在堆棧中進一步使用,請使用FN :: Join將“ aws”字符串添加到帳戶ID。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.