首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >云形成模板误差

云形成模板误差
EN

Stack Overflow用户
提问于 2022-01-11 02:37:51
回答 1查看 372关注 0票数 1

我开始学习云形成模板,当我在AWS云形成->中验证模板创建新堆栈时,我遇到了一些问题。我正在用Pycharm中的CloudFormation插件编写模板。以下是我在CloudFormation中验证时得到的几条错误消息:

1/10/2022,5:41:06 PM -模板包含错误。:模板格式错误: YAML格式不正确。(第27行,第16栏)

1/10/2022,5:40:06 PM -模板包含错误。:模板格式错误: YAML格式不正确。(第24行,第12栏)

下面是我的简单代码:

代码语言:javascript
运行
复制
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

任何帮助我指出正确的方向是非常感谢的。谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-01-11 02:51:13

有许多问题,例如拼写错误、省略括号、错误的函数。正确的版本是:

代码语言:javascript
运行
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70661033

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档