首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >参数groupName不能与参数subnet一起使用

参数groupName不能与参数subnet一起使用
EN

Stack Overflow用户
提问于 2020-05-28 16:08:34
回答 1查看 496关注 0票数 2
代码语言:javascript
复制
AWSTemplateFormatVersion: 2010-09-09
Parameters:
  MyKeyName:
    Description: Select the key name from the list
    Type: AWS::EC2::KeyPair::KeyName
  Instancetypes:
    Type: String
    AllowedValues:
    - t2.micro
    - t2.nano

Resources:
  myEC2Instance:
    Type: AWS::EC2::Instance
    Properties:
      KeyName: !Ref MyKeyName  
      ImageId: ami-0323c3dd2da7fb37d
      InstanceType: !Ref Instancetypes
      SecurityGroupIds:
        - default        
        - !Ref SSHSecurityGroup
      SubnetId: !Ref subnet1
      Tags:
        - Key: Name 
          Value: EC2

  SSHSecurityGroup:
    Type: 'AWS::EC2::SecurityGroup'
    Properties: 
      GroupDescription: my new SSH security group
      SecurityGroupIngress:
        - IpProtocol: tcp
          FromPort: '22'
          ToPort: '22'
          CidrIp: 0.0.0.0/0
      VpcId: !Ref LocalVPC

  LocalVPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: 10.0.0.0/16
      EnableDnsSupport: true

  subnet1:
    Type: AWS::EC2::Subnet
    Properties:
      AvailabilityZone: us-east-1a
      VpcId: !Ref LocalVPC
      CidrBlock: 10.0.1.0/24

  subnet2:
    Type: AWS::EC2::Subnet
    Properties:
      AvailabilityZone: us-east-1b
      VpcId: !Ref LocalVPC
      CidrBlock: 10.0.2.0/24

  subnet3:
    Type: AWS::EC2::Subnet
    Properties:
      AvailabilityZone: us-east-1c
      VpcId: !Ref LocalVPC
      CidrBlock: 10.0.3.0/24

  routeTable:
    Type: AWS::EC2::RouteTable
    Properties:
      VpcId:
        Ref: LocalVPC

  routeName:
    Type: AWS::EC2::Route
    Properties:
      RouteTableId: !Ref routeTable
      DestinationCidrBlock: 0.0.0.0/0
      GatewayId: !Ref igwName

  routeTableAssocName:
    Type: AWS::EC2::SubnetRouteTableAssociation
    Properties:
      SubnetId: !Ref subnet1
      RouteTableId: !Ref routeTable

  igwName:
    Type: AWS::EC2::InternetGateway
    Properties:
      Tags:
        - Key: keyname
          Value: valuea

  AttachGateway:
    Type: AWS::EC2::VPCGatewayAttachment
    Properties:
      VpcId: !Ref LocalVPC
      InternetGatewayId: !Ref igwName

enter image description here

EN

回答 1

Stack Overflow用户

发布于 2020-05-28 16:13:42

SecurityGroupIds采用组ID,而不是组名:

代码语言:javascript
复制
  SecurityGroupIds:
    - !GetAtt SSHSecurityGroup.GroupId
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62059915

复制
相关文章

相似问题

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