AWS CloudFormation: How to output a machine's PublicIP?

前端 未结 2 935
夕颜
夕颜 2021-02-15 15:17

I wrote a CloudFormation template which creates a linux docker host.

I want to display the PublicIP of the machine under the "Outputs" section.

This is t

2条回答
  •  终归单人心
    2021-02-15 15:22

    Assuming your have an EC2 instance resource in your template named Server:

    "Server" : {
        "Type" : "AWS::EC2::Instance",
        "Properties" : {
        }
    }
    

    You output the public IP address referencing it's resource name:

    "Outputs" : {
        "PublicIp" : {
          "Value" : { "Fn::GetAtt" : [ "Server", "PublicIp" ]},
          "Description" : "Server's PublicIp Address"
        }
    }
    

提交回复
热议问题