Reputation: 49
I am trying to do launch ec2 in VPC but it is not detecting VPC and not launching also suggesting to check Documentation.
Could you please check below code it looks some security group issue
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'
Run from:
aws cloudformation create-stack --stack-name test --template-body file://~/Downloads/CFT/stack.yml --profile devops --region us-east-1
Upvotes: 1
Views: 169
Reputation: 269191
The cause of the error is here:
InstanceTenancy: dedicated
The VPC has been configured to only permit instances launched with Dedicated tenancy.
However, t2.micro
is not available for dedicated tenancy, therefore the configuration fails.
This resulted in the error:
The requested configuration is currently not supported. Please check the documentation for supported configurations.
Either remove the InstanceTenancy
requirement or choose an instance type that is supported by dedicated tenancy.
Upvotes: 2