Reputation: 11
I was trying to create an EC2 instance with the existing values in my AWS account. The CloudFormation console says the template is valid. But when I try to create the stack, it failed with the below error:
CREATE_FAILED AWS::EC2::Instance Ec2Instance The requested configuration is currently not supported. Please check the documentation for supported configurations.**
Can someone help me out with the error. My CloudFormation template is shown below.
Thankyou.
AWSTemplateFormatVersion: 2010-09-09
Description: CloudFormation template for creating an ec2 instance
Parameters:
VPC:
Description: 'vpc'
Type: List<AWS::EC2::VPC::Id>
AvailabilityZone:
Description: 'test a-z'
Type: List<AWS::EC2::AvailabilityZone::Name>
KeyName:
Description: Key Pair name
Type: AWS::EC2::KeyPair::KeyName
Default: kskey-1
InstanceType:
Description: 'The instance type for the EC2 instance.'
Type: String
Default: t2.micro
AllowedValues:
- t2.micro
- t2.small
- t2.medium
Name:
Description: 'Then name of the EC2 instance'
Type: String
Default: 'KS-Test'
Subnet:
Description: ' The subnet id'
Type: String
SecurityGroups:
Description: 'The security group'
Type: List<AWS::EC2::SecurityGroup::Id>
Mappings:
RegionMap:
ap-south-1:
AMI: ami-b46f48db
Resources:
Ec2Instance:
Type: 'AWS::EC2::Instance'
Properties:
SecurityGroupIds: !Ref SecurityGroups
KeyName: !Ref KeyName
ImageId: !FindInMap
- RegionMap
- !Ref 'AWS::Region'
- AMI
SubnetId: !Ref Subnet
Upvotes: 1
Views: 572
Reputation: 7366
The problem here is that you have not defined the EC2 instance type in your CloudFormation template. You have it defined in the Parameters section and not in the Resources section. Adding that will fix the issue for you.
The problem you are encountering is that, if you don't specify the instance type, CloudFormation will select the default value which is m3.medium
. This is an old instance type and newer generation instances (m5 series) has been launched.
Add the following line to the end of your CloudFormation template:
InstanceType: !Ref InstanceType
References:
Upvotes: 3