Amazon web services CloudFormation:如何在映射中使用AWS::AccountId?
我有一个如下所示的映射:Amazon web services CloudFormation:如何在映射中使用AWS::AccountId?,amazon-web-services,yaml,amazon-cloudformation,Amazon Web Services,Yaml,Amazon Cloudformation,我有一个如下所示的映射: Mappings: AccountToParams: aws-1234567890: sshSecurityGroup: sg-abcedf12 我想通过AccountId检索变量,但这并没有通过“验证”步骤 错误是 16/08/2017, 16:36:18 - Template contains errors.: Template error: every Fn::FindInMap object requires three parame
Mappings:
AccountToParams:
aws-1234567890:
sshSecurityGroup: sg-abcedf12
我想通过AccountId检索变量,但这并没有通过“验证”步骤
错误是
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
而不是!子
:
SecurityGroupIds:
- !FindInMap [AccountToParams, !Ref "AWS::AccountId", sshSecurityGroup]
如果需要将“aws”字符串前置到帐户ID,请使用该命令。您不需要映射。您在YAML文档中有四(4)个映射。完美、简单和简洁使用数字作为映射键时,您不会遇到此错误吗?模板格式错误:[/Mappings/TargetAzMap]映射键必须是字符串;改为接收数字[xxxxx]
SecurityGroupIds:
- !FindInMap [AccountToParams, !Ref "AWS::AccountId", sshSecurityGroup]