[英]AWS CloudFormation Template : How to hide parameter?
I want to add a Boolean parameter that defines if another parameter is shown or not.我想添加一个布尔参数来定义是否显示另一个参数。
For example:例如:
{
"Parameters":{
"ShowParam":{
"AllowedValues":[
"true",
"false"
],
"Default":"false",
"Type":"String"
},
"Param":{
"Type":"String"
}
}
}
I want to show "Param" if "ShowParam" is set to true.如果“ShowParam”设置为true,我想显示“Param”。
There is a way to achieve that ?有办法实现吗?
Unfortunately "conditions" is not working for parameters/parameter groups.不幸的是,“条件”不适用于参数/参数组。 You can set the visibility/usability for resources and outputs.您可以设置资源和输出的可见性/可用性。 You can just create some parameter groups and set a comment as "optional".您可以只创建一些参数组并将注释设置为“可选”。 And for resources, if "param" is blank, you can set the resource value to "AWS::NoValue" to say "Cloudformation please ignore it!"对于资源,如果“param”为空,您可以将资源值设置为“AWS::NoValue”以表示“Cloudformation 请忽略它!”
There are two options to get this done:有两种选择可以完成这项工作:
put the information into a secret and reference directly in the template like this:将信息放入秘密并直接在模板中引用,如下所示:
{{resolve:secretsmanager:MySecret:SecretString:password:EXAMPLE1-90ab-cdef-fedc-ba987EXAMPLE}}
( https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html ) ( https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html )
if the value can be hard coded into the template, you could use mappings如果该值可以硬编码到模板中,则可以使用映射
Mappings: Variables: VpcId: Value: vpc-xxxxxxx
and then reference it like this:然后像这样引用它:
!FindInMap [Variables, VpcId, Value]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.