【问题标题】:Cloudformation with OpsWorks handle empty value使用 OpsWorks 的 Cloudformation 处理空值
【发布时间】:2016-12-24 06:33:40
【问题描述】:

在我的 cloudformation 模板中,我有一个可以为空的参数,但 Fn::Join 假设一个值,这就是示例:

 "Parameters": {
  "ConfigureRecipe": {
   "Description": "Configure recipe.",
   "Type": "String"
  }

"Configure": [ { "Fn::Join": [ "", [ "myChefRecipe::", { "Ref": "ConfigureRecipe" } ] ] } ]

如果 ConfigureRecipe 为空,Cloudfomation 会将配方“myChefRecipe::”传递给 OpsWorks,并在配置启动时给我一个错误,因为一个好的变量是“myChefRecipe::mysql”。我该如何处理?如果 ConfigureRecipe 为空,则可能使用 AWS::NoValue。

【问题讨论】:

    标签: json amazon-cloudformation aws-opsworks


    【解决方案1】:

    也许你可以试试这个:

        "Parameters": {
        "ConfigureRecipe": {
        "Description": "Configure recipe.",
        "Type": "String"
        }
    
       "Conditions" : {
    "CreateLayerWithoutRecipie" : {"Fn::Not" : [{"Ref" : "ConfigureRecipe"}]}
        },
    
        "Layer":{
         "Type":"AWS::OpsWorks::Layer",
         ....
         ....
         ....
         "Configure": [ "Fn::If" : [ "CreateLayerWithoutRecipie", {"Ref" : "AWS::NoValue"}, { "Fn::Join": [ "", [ "myChefRecipe::", { "Ref": "ConfigureRecipe" }  ] ] } ]]
         }
    

    【讨论】:

      猜你喜欢
      • 2016-11-22
      • 2018-05-08
      • 2023-03-05
      • 2020-12-29
      • 1970-01-01
      • 1970-01-01
      • 2016-07-13
      • 2010-09-09
      • 2019-03-22
      相关资源
      最近更新 更多