gpt4 book ai didi

amazon-web-services - cloudformation 输出部分验证错误

转载 作者:行者123 更新时间:2023-12-03 07:24:09 24 4
gpt4 key购买 nike

我正在使用弹性 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"
}
}

}

最佳答案

我认为原因是你有额外的逗号:

        }, # <---- here
},
"Outputs" : {
"PublicIP": {
"Value": { "Fn::GetAtt": [ "Instance", "PublicIp"]},
"Description": "Public IP of the machine"
}
}

此外,如果您的实例不是公共(public),模板将失败,因为私有(private)实例没有PublicIp,因此您可以不输出它。

更新完整模板(在 us-east-1 和默认 VPC 中测试):

enter image description here

关于amazon-web-services - cloudformation 输出部分验证错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63147137/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com