Reputation: 175
I'm creating an instance with Elastic IP and the security group.Everything works fine until I add the outputs section. I'm getting invalid templateBody error after adding the outputs section to the existing template. The template works fine without the Outputs section. Below is the relevant code:
"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"
}
}
}
Upvotes: 1
Views: 204
Reputation: 238727
I think the reason is that you have extra comma:
}, # <---- here
},
"Outputs" : {
"PublicIP": {
"Value": { "Fn::GetAtt": [ "Instance", "PublicIp"]},
"Description": "Public IP of the machine"
}
}
Also, if your instance is not public, the template will fail, because private instances don't have PublicIp
, thus you can't output it.
Update on the full template (tested in us-east-1
and default VPC):
Upvotes: 1