amazon-ec2 - 云形成 : EC2 is not finding VPC and is not launching

标签 amazon-ec2 aws-cloudformation amazon-vpc

我正在尝试在 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

最佳答案

错误原因如下:

    InstanceTenancy: dedicated

VPC 已配置为仅允许通过专用租赁启动实例。

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

这导致了错误:

The requested configuration is currently not supported. Please check the documentation for supported configurations.

删除 InstanceTenancy 要求或选择 instance type that is supported by dedicated tenancy .

关于amazon-ec2 - 云形成 : EC2 is not finding VPC and is not launching,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48137089/

相关文章:

node.js - 如何实现 Node.js 应用程序日志记录到 CloudWatch

linux - EC2 用户访问或文件访问问题?

amazon-web-services - Sid 属性在关键策略中有何用途?

amazon-web-services - 如何避免 S3 和 EC2 之间跨账户的数据传输成本?

amazon-web-services - 将旧 RDS 流量重定向到 AWS 中的新 RDS

java - EC2 Java Api 等待创建 Ec2 实例。

ssl - HTTPS 不工作(在基于 AWS Elastic Beanstalk 的站点上)

windows - 用于 Bootstrap 文件下载的 AWS CloudFormation 和 Windows Server 2008 R2

amazon-web-services - CloudFormation - Transit Gateway 的路由表路由传播

amazon-web-services - 有没有办法在没有 VPC 的情况下将静态 IP 分配给 AWS Lambda?