简体   繁体   English

AWS CloudFormation 模板:如何隐藏参数?

[英]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:有两种选择可以完成这项工作:

  1. 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 )

  2. 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.

相关问题 AWS:如何在CloudFormation模板中指定布尔参数 - AWS: How to specify a boolean parameter in a CloudFormation template 如何在 Cloudformation 模板条件中使用 AWS SSM 参数存储值? - How to use AWS SSM parameter store values in Cloudformation template conditionals? 如何在 aws cloudformation yaml 模板中格式化数据类型 json 的参数? - How to format parameter of data type json in a aws cloudformation yaml template? AWS CloudFormation模板缺少什么参数? - What parameter is missing for AWS CloudFormation template? AWS Parameter Store 结果作为 CloudFormation 模板中的列表 - AWS Parameter Store result as list in CloudFormation template AWS cloudformation 错误:模板验证错误:模板参数属性无效 - AWS cloudformation error: Template validation error: Invalid template parameter property 如何将 AWS 资源转换为 cloudformation 堆栈或模板? - How to convert AWS resources to a cloudformation stack or template? 如何将 AWS Lambda 转换回 CloudFormation 模板 - How to convert AWS Lambda back into CloudFormation template 如何在 AWS CloudFormation 模板中使用参考号 function? - How is the !Ref function used in an AWS CloudFormation template? 如何在AWS CloudFormation模板中提取常用行? - How to extract common lines in AWS CloudFormation template?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM