简体   繁体   中英

How do I put cloudformation intrinsic functions inside a string in json

"Integration": { "IntegrationHttpMethod" : "GET", "Type" : "HTTP", "Uri" : "http://{"Fn::GetAtt" : [ "MyEC2Instance", "PublicIp" ] }:8080 /休息”

I would check out the Sub function. If you wanted to put the result of {"Fn::GetAtt" : [ "MyEC2Instance", "PublicIp" ] } in a your example string, it could be done with

"MyGatewayMethod": {
  "Type": "AWS::ApiGateway::Method",
  "Properties": {

    ...

    "Integration": {
      "Type": "HTTP",
      "IntegrationHttpMethod": "GET",
      "Uri": { "Fn::Sub":"http://${MyEC2Instance.PublicIp}:8080/rest" }
    }
  }
}

The Sub method can be used to substitute both GetAtt values and Ref values.

Thanks. I solved it using this function Fn::Join

"Integration": { "IntegrationResponses": [{"StatusCode": 200}], "IntegrationHttpMethod" : "GET", "Type" : "HTTP", "Uri" : {"Fn::Join" : [ "", [ "http://", {"Fn::GetAtt" : [ "MyEC2Instance", "PublicIp" ] }, ":8080/rest" ] ] } }

} }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM