gpt4 book ai didi

amazon-ec2 - EC2 实例 Cloudformation - 可用区作为参数传递

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

我编写了一个简单的 cloudformation 模板,参数很少。所有参数都有效。但是,当我通过可用区时,模板在创建过程中给出错误,提示“不是有效的可用区”。这是我的错误和代码如下:

11:48:47 UTC-0700 CREATE_FAILED AWS::EC2::Instance EC2Instance 无效可用区:

   {
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "EC2 Head Node Instance ",
"Parameters": {
"AZ": {
"Description": "Availablity Zone",
"Type": "String"

},
"Region":{
"Description": "Dev/Test/Prod regions",
"Type": "String"
},
"AMI": {
"Description": "AMI to start virtual server",
"Type": "String",
"MaxLength": 12,
"MinLength": 12
},

"Subnet": {
"Description": "subnet to launch virtual server in",
"Type": "AWS::EC2::Subnet::Id"
}

},
"Resources": {
"EC2Instance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId": {"Ref": "AMI"},
"SubnetId": {"Ref": "Subnet"},
"AvailabilityZone": {"Ref":"AZ"},
"Tags": [
{
"Key": "Name",
"Value": "QRM Head Node in DEV region"
}
]
}
}

},
"Outputs": {
"InstanceId": {
"Value": {"Ref": "EC2Instance"},
"Description": "ID of virtual server"
},

"PublicIPAddress": {
"Value": {"Fn::GetAtt": ["EC2Instance", "PublicIp"]},
"Description": "public IP address of virtual server"
}
}

}

最佳答案

只需将参数更改为:

"Parameters": {
"AZ": {
Description": "Availability Zone of the Subnet",
"Type": "AWS::EC2::AvailabilityZone::Name"
},
....
}

关于amazon-ec2 - EC2 实例 Cloudformation - 可用区作为参数传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45065619/

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