Skip to content

在CloudFormation中使用伪参数作为默认值

0

【以下的问题经过翻译处理】 我在尝试创建一个CloudFormation脚本,在其中使用AWS Pseudo-Parameters设置两个默认参数。 cloudformation validate-template cli告诉我:“调用ValidateTemplate操作时发生错误(ValidationError):模板格式错误:每个Default成员必须是一个字符串。“

这是我的代码现在的状态:

Parameters: BuildRegion: Type: String AllowedValues: - us-east-1 - us-east-2 - us-west-1 - us-west-2 - ca-central-1 - ap-south-1 - ap-northeast-2 - ap-southeast-1 - ap-southeast-2 - ap-northeast-1 - eu-central-1 - eu-west-1 - eu-west-2 - sa-east-1 Default: !Sub AWS::Region NewBucketName: Type: String Default: !Join - '' - - Fn::Base64: - !Sub AWS::AccountId - '-bucket'

EXPERT
asked 9 years ago81 views
1 Answer
0

【以下的回答经过翻译处理】 您的配置不是有效的配置。

您正在使用“string”资源类型,但提供的默认值不是“string”。

Region不是AWS特殊参数类型: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html#aws-specific-parameter-types

要解决这个问题,您可能需要从您的AllowedValues中选择一个默认值(如“us-east-1”),这比当前区域填充略微不方便。

顺便说一句,CloudFormation不跨区域运作。因此,如果您打算在资源创建期间再使用此区域参数,则可能不起作用!

EXPERT
answered 9 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.