【发布时间】:2021-06-29 11:43:05
【问题描述】:
最近我开始探索 AWS CloudFormation。我对使用 Fn::GetAZs 动态获取可用区有疑问吗?我希望可用区不被硬编码。 YAML 格式的代码如下:-
AWSTemplateFormatVersion: 2010-09-09
Description: Hardcoded Value of Availability zone
Parameters:
MyKeyName:
Description: Arshan Select the key Name from the boelow
Type: AWS::EC2::KeyPair::KeyName
MyZone:
Description: Select the MyAZone
Type: String
Default: us-east-1
AllowedValues:
- us-east-1
- us-east-2
Resources:
DevEC2Instance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.micro
ImageId: ami-04aa88aebb9fefd83
KeyName: !Ref MyKeyName
SecurityGroup: !Ref SSHSecurityGroup
AvailabilityZone: !Ref MyZone
SSHSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: My Sg
SecurityIngress:
IpProtocol: tcp
ToPort: 22
FromPort: 22
Cidr: 0.0.0.0/0
SecurityEgress:
IpProtocol: tcp
ToPort: 8080
FromPort: 8080
Cidr: 0.0.0.0/0
【问题讨论】:
-
您的问题是什么?使用
AvailabilityZone: !Select [ 0, !GetAZs ] -
@jarmod 我的问题是我想使用 Fn::GetAZs,返回一个可用区的值,然后从中选择任何可用区
-
您在使用 Fn::GetAZs 时遇到什么问题?
标签: amazon-web-services amazon-s3 amazon-ec2 aws-lambda amazon-cloudformation