gpt4 book ai didi

amazon-web-services - AWS Parameter Store 结果作为 CloudFormation 模板中的列表

转载 作者:行者123 更新时间:2023-12-03 07:14:01 24 4
gpt4 key购买 nike

我正在尝试使用 SSM 参数存储“StringList”动态获取我的 S3 存储桶名称,而不是直接在 CloudFormation 中列出它们。但在 CF 模板中,我必须使用 SSM 值,因此当我创建堆栈时,它不会显示值,而是显示键,而且我也没有成功将 SSM 解析为列表。

步骤:

创建参数存储作为 StringList

Name: /s3/lists
Value: sample1,sample2

云形成模板

Parameters:
myS3Buckets:
Type: AWS::SSM::Parameter::Value<List<String>>
AllowedValues: ['{{resolve:ssm:/s3/lists}}']

然后在我创建堆栈时查看 S3 存储桶列表。

更新#1

为了更好地解释自己,这里是完整的示例:

Parameters:
InstanceTypeDefault:
Type: String
AllowedValues:
- t1.micro
- t2.nano
- t2.micro
- t2.small

InstanceTypesDynamic:
Type: AWS::SSM::Parameter::Value<List<String>>
AllowedValues:
- /ec2/lists

Resources:
MyInstance:
Type: AWS::EC2::Instance
Properties:
AvailabilityZone: us-east-1a
ImageId: ami-0742b4e673072066f
InstanceType: !Ref InstanceTypesDynamic

按照正常方式,我们设置AllowedValues,例如InstanceTypeDefault,但我尝试通过 API 调用获取列表或将它们放入 SSM 参数存储中,而不是每次都编辑模板。

我希望能够看到 InstanceTypesDynamic,例如带有 AllowedValuesInstanceTypeDefault 下拉列表。

enter image description here

最佳答案

The documentation声明如下:

For SSM Parameters, the reference-key segment is composed of the parameter name and version number.

还有

CloudFormation doesn't support using parameter labels or public parameters in dynamic references.A parameter label is a user-defined alias to help you manage different versions of a parameter.

因此您没有正确引用参数,您应该在模板中包含参数的版本:例如,{{resolve:ssm:/s3/lists:1}}

关于amazon-web-services - AWS Parameter Store 结果作为 CloudFormation 模板中的列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69615366/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com