我希望我的CloudFormation模板使用现有的子网和VPC,不想创建新的。如何设置参数?当我查看AWS :: EC2 :: VPC和AWS :: EC2 :: Subnet的文档时,似乎这些资源仅用于创建新的VPC和子网。是这样吗?我是否应该直接将实例资源指向要使用的现有VPC和子网?例如,如果我的模板中有一个实例资源,并且我直接将其指向现有的子网,像这样:
我在验证模板时遇到了这个错误:
我尝试使用映射来实现这个,但仍然出现错误:
{
"Resources": {
"MyServer": {
"Type": "AWS::EC2::Instance",
"Properties": {
"InstanceType": {
"Ref": "InstanceType"
},
"SubnetId": {
"Ref": "subnet-abc123"
},
...
我在验证模板时遇到了这个错误:
Template contains errors.: Template format error: Unresolved resource dependencies [subnet-abc123] in the Resources block of the template
我尝试使用映射来实现这个,但仍然出现错误:
"Mappings": {
"SubnetID": {
"TopKey": {
"Default": "subnet-abc123"
}
}
在这个实例资源中:
"SubnetId": {
"Fn::FindInMap": [
"SubnetID",
{
"Ref": "TopKey"
},
"Default"
]
}
在进行验证时,我遇到了以下错误:
Template contains errors.: Template format error: Unresolved resource dependencies [TopKey] in the Resources block of the template