【问题标题】:How do I use user inputted parameter as reference in Fn:Join in the resource section of AWS Cloudformation如何在 AWS Cloudformation 资源部分的 Fn:Join 中使用用户输入的参数作为参考
【发布时间】:2021-10-14 14:54:46
【问题描述】:
{

    "AWSTemplateFormatVersion": "2010-09-09",
  
    "Parameters": {
        "EnterIpAddress":{
            "Type": "String"
        }
    },
    "Resource":{
        "XyZ":{
            "Type": "AWS::ECS::TaskDefinition",
            "ContainerDefinitions": [
                {
                    "Command": [

                        
                        {
                          "Fn::Join": [
                            "=", [
                              "--beacon_ip",
                              {
                                "Ref": "EnterIpAddress"
                              }
                            ]
                          ]
                        }
                      ]
                }
            ]
        }
    }
    
}

我想将该参数用作 Fn::Join 中的引用,以便我的最终输出为

"--beacon_ip=xx.xxx.xxx.xx"

我希望用户在哪里输入 IP 地址(xx.xxx.xxx.xx)

但我在将模板上传到堆栈时收到此错误:

Template format error: Unresolved resource dependencies [EnterIpAddress] in the Resources block of the template

请告诉我如何实现所需的输出。谢谢

【问题讨论】:

    标签: json amazon-web-services amazon-cloudformation


    【解决方案1】:

    由于您似乎还没有发布您的整个堆栈,这可能只是某个地方的拼写错误吗?据我所知,语法看起来是正确的,但由于它是 CloudFormation 文件的缩写版本,因此其中可能存在一些不可见的错误。

    话虽如此,我更喜欢使用Fn::Sub 而不是使用Fn::Join,只是因为它更容易理解为 CloudFormation 文件的阅读器:

    {
      "Fn::Sub": "--beacon_ip=${EnterIpAddress}"
    }
    
    

    【讨论】:

      猜你喜欢
      • 2018-01-29
      • 2020-12-02
      • 1970-01-01
      • 2021-12-03
      • 2017-11-30
      • 2016-05-14
      • 2020-08-29
      • 2016-07-07
      • 2021-03-17
      相关资源
      最近更新 更多