我正在尝试使用CloudFormation创建EC2实例。 以下是我的配置文件。
Description: This script create EC2 with Public IP
Resources:
EC2CloudFormation:
Type: 'AWS::EC2::Instance'
Properties:
AvailabilityZone: !Select
- '0'
- !GetAZs ''
IamInstanceProfile: !Ref EC2CloudformationInstanceProfilee
ImageId: 'ami-06f1fab1ab342f0f7'
InstanceType: t2.medium
KeyName: mykey
NetworkInterfaces:
- AssociatePublicIpAddress: "true"
DeviceIndex: "0"
GroupSet:
- 'sg-XXXXXXXXXXXXX'
SubnetId: 'subnet-XXXXXXXXXXX'
EC2Role:
Type: 'AWS::IAM::Role'
Properties:
RoleName: EC2CloudFormationRole
Description: Role for CloudFormation EC2 Instance
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Action:
- 'sts:AssumeRole'
Path: /
EC2CloudformationInstanceProfilee:
Type: 'AWS::IAM::InstanceProfile'
Properties:
Path: /
Roles:
- !Ref EC2Role
EC2CloudFormationPolicies:
Type: 'AWS::IAM::Policy'
Properties:
PolicyName: EC2CloudFormationPolicy
PolicyDocument:
Statement:
- Sid: Stmt1566203227305
Action:
- 'cloudformation:*'
Effect: Allow
Resource: '*'
Roles:
- !Ref EC2Role
但是我面临以下错误:
The requested configuration is currently not supported. Please check the documentation for supported configurations. (Service: AmazonEC2; Status Code: 400; Error Code: Unsupported; Request ID: c7edeeb4-14e1-48b3-a90a-4ea79498b1e8)
我无法理解问题的根本原因。
其他资源(“角色”,“实例配置文件”和“策略”)仅在未创建EC2::Instance
的情况下创建。
答案 0 :(得分:1)
您的模板对我来说效果很好。
我替换为:
它运行得很好,所以您的问题很可能是上述问题之一。