[英]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.