1.资源定义格式不正确



0

我正在编写一个在EC2中安装SSM的云形成模板。但是当我在Cfn中上传模板时。我得到一个名为"资源定义格式不正确"的错误。


Description: This Template Create an EC2 in public subnet with SSM.
Resources:
SSMIAMRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Action:
- sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore

EC2InstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Path: /
Roles:
- !Ref SSMIAMRole
Instance:
Type: AWS::EC2::Instance
Properties:
IamInstanceProfile: !Ref EC2InstanceProfile
ImageId: ami-0aa7d40eeae50c9a9
VPCId: vpc-04ef73b29000f4f54 
SubnetId: subnet-0699037225107e8b2
InstanceType: !FindInMap [EnvironmentToInstanceType, !Ref EnvironmentType, InstanceType]
Tags:
- Key: Name
Value: !Join [ '-', [ !Ref EnvironmentType, webserver ] ]

我不知道还能尝试什么。这是我正在使用的模板。。

您的YAML缩进是错误的。您应该在资源名称下方缩进Type,例如

Resources:
SSMIAMRole:
Type: AWS::IAM::Role
Properties: ...

最新更新