【问题标题】:CloudFormation: EC2 is not finding VPC and is not launchingCloudFormation:EC2 未找到 VPC 且未启动
【发布时间】:2018-06-16 15:39:22
【问题描述】:

我正在尝试在 VPC 中启动 ec2,但它没有检测到 VPC 并且没有启动也建议检查文档。

您能否检查下面的代码,它看起来是一些安全组问题

AWSTemplateFormatVersion: '2010-09-09'
Resources:
# vpc creation

    VPC:
      Type: AWS::EC2::VPC
      Properties:
        CidrBlock: 10.0.0.0/16
        EnableDnsSupport: 'true'
        EnableDnsHostnames: 'true'
        InstanceTenancy: dedicated
        Tags:
        - Key: test
          Value: test1

    #internet gateway creation      

    InternetGateway:
      Type: AWS::EC2::InternetGateway      

    VPCGatewayAttachment:
      Type: AWS::EC2::VPCGatewayAttachment
      Properties:
        VpcId: !Ref VPC
        InternetGatewayId: !Ref InternetGateway      

    SubnetA:
      Type: AWS::EC2::Subnet
      Properties:
        AvailabilityZone: us-east-1a
        VpcId: !Ref VPC
        CidrBlock: 10.0.0.0/20
        MapPublicIpOnLaunch: true

    SubnetB:
      Type: AWS::EC2::Subnet
      Properties:
        AvailabilityZone: us-east-1b
        VpcId: !Ref VPC
        CidrBlock: 10.0.16.0/20
        MapPublicIpOnLaunch: true

    SubnetC:
      Type: AWS::EC2::Subnet
      Properties:
        AvailabilityZone: us-east-1c
        VpcId: !Ref VPC
        CidrBlock: 10.0.32.0/20
        MapPublicIpOnLaunch: true

    RouteTable:
      Type: AWS::EC2::RouteTable
      Properties:
        VpcId: !Ref VPC

    InternetRoute:
      Type: AWS::EC2::Route
      DependsOn: InternetGateway
      Properties:
        DestinationCidrBlock: 0.0.0.0/0
        GatewayId: !Ref InternetGateway
        RouteTableId: !Ref RouteTable

    SubnetARouteTableAssociation:
      Type: AWS::EC2::SubnetRouteTableAssociation
      Properties:
        RouteTableId: !Ref RouteTable
        SubnetId: !Ref SubnetA

    SubnetBRouteTableAssociation:
      Type: AWS::EC2::SubnetRouteTableAssociation
      Properties:
        RouteTableId: !Ref RouteTable
        SubnetId: !Ref SubnetB

    SubnetCRouteTableAssociation:
      Type: AWS::EC2::SubnetRouteTableAssociation
      Properties:
        RouteTableId: !Ref RouteTable
        SubnetId: !Ref SubnetC              

    AppNode:
      Type: AWS::EC2::Instance
      Properties:
        InstanceType: t2.micro
        ImageId: ami-c29e1cb8
        KeyName: test_devops_east_1
        AvailabilityZone: us-east-1c
        SecurityGroupIds:
        - !Ref AppNodeSG 
        SubnetId: !Ref SubnetC    

    AppNodeSG:
      Type: AWS::EC2::SecurityGroup
      Properties:
        GroupDescription: Test Ec2 ssh and VPC
        VpcId: !Ref VPC 
        SecurityGroupIngress:
        - IpProtocol: tcp
          CidrIp: 0.0.0.0/0
          FromPort: '22'
          ToPort: '22'
        - IpProtocol: tcp
          CidrIp: 0.0.0.0/0
          FromPort: '80'
          ToPort: '80' 

运行自:

aws cloudformation create-stack --stack-name test --template-body file://~/Downloads/CFT/stack.yml --profile devops --region us-east-1

【问题讨论】:

    标签: amazon-ec2 amazon-cloudformation amazon-vpc


    【解决方案1】:

    错误原因在这里:

        InstanceTenancy: dedicated
    

    VPC 已配置为仅允许使用专用租户启动的实例。

    但是,t2.micro 不适用于专用租赁,因此配置失败。

    这导致了错误:

    当前不支持请求的配置。请查看支持配置的文档。

    要么删除InstanceTenancy 要求,要么选择instance type that is supported by dedicated tenancy

    【讨论】:

    • 谢谢,你说的我明白了,谢谢支持
    猜你喜欢
    • 2022-10-14
    • 1970-01-01
    • 2021-11-01
    • 2015-07-21
    • 2013-02-04
    • 2015-11-19
    • 1970-01-01
    • 2020-01-24
    • 1970-01-01
    相关资源
    最近更新 更多