gpt4 book ai didi

yaml - Fn::GetAZs + Fn::Select 不合作

转载 作者:行者123 更新时间:2023-12-01 01:53:00 34 4
gpt4 key购买 nike

所以我的网络模板中有这个 CloudFormation 资源:

Resources:
...

PubSubnetAz2:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref Vpc
CidrBlock: !FindInMap [VpcCidrs, !Ref "AWS::Region", pubsubnet2]
AvailabilityZone: !Select
- 1
- Fn::GetAZs: !Ref "AWS::Region"

当我尝试创建此堆栈时收到此错误:

17:40:06 UTC-0700   CREATE_FAILED   AWS::EC2::Subnet    PubSubnetAz2    Template error: Fn::Select cannot select nonexistent value at index 1

模板验证,我有一个 PubSubnetAz1 block ,它是相同的并且通过了(尽管它选择了 index=0)。

我使用 Fn::GetAZs 是否错误?

PS。我正在使用 us-west-2 区域,据我所知,该区域有 > 1 个可用区。

最佳答案

以下模板成功在 us-west-2 中跨多个子网部署 VPC:

---
AWSTemplateFormatVersion: '2010-09-09'
Resources:
vpc1:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
InstanceTenancy: default
EnableDnsSupport: true
EnableDnsHostnames: false
Tags:
- Key: Name
Value: My-VPC
subnet1:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone:
Fn::Select:
- 0
- Fn::GetAZs: ''
CidrBlock: 10.0.0.0/24
VpcId:
Ref: vpc1
Tags:
- Key: Name
Value: Subnet-A
subnet2:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone:
Fn::Select:
- 1
- Fn::GetAZs: ''
CidrBlock: 10.0.1.0/24
VpcId:
Ref: vpc1
Tags:
- Key: Name
Value: Subnet-B

我手动创建了VPC,使用Hava要将其转换为 JSON CloudFormation 模板,请手动插入 Select 语句,然后使用 json2yaml.com 转换为 YAML .

关于yaml - Fn::GetAZs + Fn::Select 不合作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42776016/

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