我正在使用弹性 IP 和安全组创建一个实例。在添加输出部分之前,一切正常。将输出部分添加到现有模板后,我收到了无效的 templateBody 错误。该模板在没有“输出”部分的情况下可以正常工作。下面是相关代码:
"Resources": {
"InstanceProfile" : {
"Type" : "AWS::IAM::InstanceProfile",
"Properties" : {
"Path" : "/",
"Roles" : ["TEST_Role"]
}
},
"Instance": {
"Properties": {
"IamInstanceProfile" : {"Ref" : "InstanceProfile"},
"BlockDeviceMappings": [
{
"DeviceName": "/dev/sda1",
"Ebs": {
"VolumeSize": {
"Ref": "EBSVolumeSize"
}
}
}
],
"ImageId": {
"Ref": "AMI"
},
"InstanceType": {
"Ref": "InstanceType"
},
"KeyName": {
"Ref": "KeyName"
},
"SecurityGroupIds": [
{
"Ref": "SecurityGroup"
}
],
"SubnetId": {
"Ref": "Subnet"
}
},
"Type": "AWS::EC2::Instance"
},
"EIPAddress": {
"Type": "AWS::EC2::EIP"
},
"IPAssoc": {
"Type": "AWS::EC2::EIPAssociation",
"Properties": {
"InstanceId": {
"Ref": "Instance"
},
"EIP": {
"Ref": "EIPAddress"
}
}
},
},
"Outputs" : {
"PublicIP": {
"Value": { "Fn::GetAtt": [ "Instance", "PublicIp"]},
"Description": "Public IP of the machine"
}
}
}