我开始学习云形成模板,当我在AWS云形成->中验证模板创建新堆栈时,我遇到了一些问题。我正在用Pycharm中的CloudFormation插件编写模板。以下是我在CloudFormation中验证时得到的几条错误消息:
1/10/2022,5:41:06 PM -模板包含错误。:模板格式错误: YAML格式不正确。(第27行,第16栏)
1/10/2022,5:40:06 PM -模板包含错误。:模板格式错误: YAML格式不正确。(第24行,第12栏)
下面是我的简单代码:
AWSTemplateFormatVersion: "2010-09-09"
# Description:
Resources:
#Create the VPC
MyCustomVPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: '10.3.0.0/16'
EnableDnsHostnames: true
EnableDnsSupport: true
Tags:
- key: Name
value: !Sub '${AWS::StackName}-application-vpc-acg'
# Create the Subnets
PublicSubnetA:
Type: AWS::EC2::Subnet
Properties:
CidrBlock: '10.3.0.0/24'
MapPublicIpOnLaunch: false
AvailabilityZone: !Select [ 0, !GetAZs]
Tags:
- Key: Name
Value: !Sub '${AWS::StackName}-public-subnet-A'
VpcId: !Ref MyCustomVPC
PublicSubnetB:
Type: AWS::EC2::Subnet
Properties:
CidrBlock: '10.3.1.0/24'
MapPublicIpOnLaunch: false
AvailabilityZone: !Select [1, !GetAz]
Tags:
- Key: Name
Value: !Sub '${AWS::StackName}-public-subnet-B'
VpcId: !Ref MyCustomVPC
#Create Internet Gateway
MyInternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- key: Name
Value: !Sub '${AWS::StackName}-Internet-Gateway
#Attach Internet Gateway to VPC
MyIGWAttachment:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
InternetGatewayId: !Ref MyInternetGateway
VpcId: !Ref MyCustomVPC
任何帮助我指出正确的方向是非常感谢的。谢谢!
发布于 2022-01-11 02:51:13
有许多问题,例如拼写错误、省略括号、错误的函数。正确的版本是:
AWSTemplateFormatVersion: "2010-09-09"
# Description:
Resources:
#Create the VPC
MyCustomVPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: '10.3.0.0/16'
EnableDnsHostnames: true
EnableDnsSupport: true
Tags:
- Key: Name
Value: !Sub '${AWS::StackName}-application-vpc-acg'
# Create the Subnets
PublicSubnetA:
Type: AWS::EC2::Subnet
Properties:
CidrBlock: '10.3.0.0/24'
MapPublicIpOnLaunch: false
AvailabilityZone: !Select [ 0, !GetAZs ""]
Tags:
- Key: Name
Value: !Sub '${AWS::StackName}-public-subnet-A'
VpcId: !Ref MyCustomVPC
PublicSubnetB:
Type: AWS::EC2::Subnet
Properties:
CidrBlock: '10.3.1.0/24'
MapPublicIpOnLaunch: false
AvailabilityZone: !Select [1, !GetAZs ""]
Tags:
- Key: Name
Value: !Sub '${AWS::StackName}-public-subnet-B'
VpcId: !Ref MyCustomVPC
#Create Internet Gateway
MyInternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: !Sub '${AWS::StackName}-Internet-Gateway'
#Attach Internet Gateway to VPC
MyIGWAttachment:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
InternetGatewayId: !Ref MyInternetGateway
VpcId: !Ref MyCustomVPC
https://stackoverflow.com/questions/70661033
复制相似问题