且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

AWS CloudFormation:如何输出机器的PublicIP?

更新时间:2023-01-18 13:25:13

假设您的模板中有一个名为 Server 的EC2实例资源:

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

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

您输出引用其资源名称的公共IP地址:

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

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