amazon-web-services - CloudFormation - 引用资源作为参数的默认值

标签 amazon-web-services aws-cloudformation

我有一个参数“SecretKey”,我想为其提供默认值( http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html ),默认值将是生成的随机字符串。我已经有一个lambda function生成 key 和自定义资源(称为 RandomSecretKey )以获取值。最终,我希望能够在参数部分中执行此操作:

"SecretKey": {<br/> ... "Default": { "Fn::GetAtt": ["RandomSecretKey", "Value"] } }

这个参数会在某个地方被引用。

但这不起作用,因为 CloudFormation 需要基于错误消息的静态字符串。有办法做到这一点吗?

最佳答案

没有。 CloudFormation 不可能有动态默认值。原因是在收集参数时模板根本没有执行。

如果您希望将其作为参数,则必须在模板外部生成生成的值并将其作为参数传递到模板中。您可以通过引导创建脚本来执行此操作。

或者,您应该能够在模板中使用自定义资源来生成随 secret 钥。它应该能够通过堆栈更新持续存在。

引用文献:

关于amazon-web-services - CloudFormation - 引用资源作为参数的默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35213196/

相关文章:

amazon-web-services - CDK 将预先存在的存储桶用于 CI CD Pipeline for Artifacts

amazon-web-services - 无法从 S3 存储桶( Parquet 文件)将数据加载到 EMR 上的 pig 中

sql - Redshift 选择随机记录但避免重复

python - aws Sagemaker 的 AnnotationConsolidation lambda 事件的空字典

amazon-web-services - AWS AutoScalingGroup HealthCheckType 'ELB' 过早考虑实例 "InService"

amazon-web-services - 创建 ApiGateway::Resource 时为 "Unable to parse HTTP response content"

c# - ASP.NET 将文件上传到 Amazon S3

amazon-web-services - 如何将无服务器应用程序模型 (SAM) 模板转换为 Cloudformation?

amazon-web-services - YAML 中的 AWS Cloudformation 模板中的 `Ref: logicalName` 和 `!Ref logicalName` 有什么区别?

amazon-web-services - 用户数据ec2未执行