无法识别的资源类型
Unrecognized Resource Types
我正在尝试了解无服务器的工作原理。我已经浏览了很多他们的文档/教程,但是当我到达我想要构建特定内容(如 RDS 实例)的部分时,我没有参考框架来了解 MVP 的外观。
我发现这个 Q/A post 显示了建立 RDS 实例的基础知识。我将区域换成更本地的区域,然后尝试了一下:
service: sandbox
app: sandbox
org: # omitting
provider:
name: aws
runtime: nodejs12.x
resources:
Resources:
Vpc:
Type: AWS:EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
InstanceTenancy: default
PublicSubnet:
Type: AWS::EC2::Subnet
Properties:
CidrBlock: 10.0.0.0/18
VpcId:
Ref: Vpc
PrivateSubnet1:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: ca-central-1a
CidrBlock: 10.0.64.0/18
VpcId:
Ref: Vpc
PrivateSubnet2:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: ca-central-1b
CidrBlock: 10.0.128.0/18
VpcId:
Ref: Vpc
Database:
Type: AWS::RDS:DBInstance
Properties:
Engine: aurora
EngineVersion: 5.6.10a
DBInstanceClass: db.r5.large
DBName: MyDatabase
MasterUsername: test
MasterUserPassword: # ommitting
DBSubnetGroupName:
Ref: DBSubnetGroup
VPCSecurityGroups:
- Ref: DatabaseVpcSecurityGroup
DBSubnetGroup:
Type: "AWS::RDS::DBSubnetGroup"
Properties:
DBSubnetGroupName: PrivateDbSubnet
DBSubnetGroupDescription: PrivateDbSubnet
SubnetIds:
- Ref: PrivateSubnet1
- Ref: PrivateSubnet2
DatabaseVpcSecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
GroupName: DBSecurityGroup
GroupDescription: Allow local access
SecurityGroupIngress:
- CidrIp: 10.0.0.0/16
IpProtocol: tcp
FromPort: 3306
ToPort: 3306
VpcId:
Ref: Vpc
当我尝试使用无服务器部署它时,出现以下错误:
The CloudFormation template is invalid: Template format error: Unrecognized resource types: [AWS:EC2::VPC, AWS::RDS:DBInstance]
我可以看到 AWS 上存在这些资源:
所以...这个错误是什么意思?我做错了什么?
您的资源类型有拼写错误。在这两种情况下,您都有一个冒号 (:),而您应该有一个双冒号 (::)
如果您收到无法识别的“资源类型”错误,则表示您的代码中存在语法问题。
检查“无法识别的资源类型”后的拼写错误:
Unrecognized resource types: [AWS::Dynamo::Table]
在这种情况下,应该是
Type: AWS::DynamoDB::Table
我正在尝试了解无服务器的工作原理。我已经浏览了很多他们的文档/教程,但是当我到达我想要构建特定内容(如 RDS 实例)的部分时,我没有参考框架来了解 MVP 的外观。
我发现这个 Q/A post 显示了建立 RDS 实例的基础知识。我将区域换成更本地的区域,然后尝试了一下:
service: sandbox
app: sandbox
org: # omitting
provider:
name: aws
runtime: nodejs12.x
resources:
Resources:
Vpc:
Type: AWS:EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
InstanceTenancy: default
PublicSubnet:
Type: AWS::EC2::Subnet
Properties:
CidrBlock: 10.0.0.0/18
VpcId:
Ref: Vpc
PrivateSubnet1:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: ca-central-1a
CidrBlock: 10.0.64.0/18
VpcId:
Ref: Vpc
PrivateSubnet2:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: ca-central-1b
CidrBlock: 10.0.128.0/18
VpcId:
Ref: Vpc
Database:
Type: AWS::RDS:DBInstance
Properties:
Engine: aurora
EngineVersion: 5.6.10a
DBInstanceClass: db.r5.large
DBName: MyDatabase
MasterUsername: test
MasterUserPassword: # ommitting
DBSubnetGroupName:
Ref: DBSubnetGroup
VPCSecurityGroups:
- Ref: DatabaseVpcSecurityGroup
DBSubnetGroup:
Type: "AWS::RDS::DBSubnetGroup"
Properties:
DBSubnetGroupName: PrivateDbSubnet
DBSubnetGroupDescription: PrivateDbSubnet
SubnetIds:
- Ref: PrivateSubnet1
- Ref: PrivateSubnet2
DatabaseVpcSecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
GroupName: DBSecurityGroup
GroupDescription: Allow local access
SecurityGroupIngress:
- CidrIp: 10.0.0.0/16
IpProtocol: tcp
FromPort: 3306
ToPort: 3306
VpcId:
Ref: Vpc
当我尝试使用无服务器部署它时,出现以下错误:
The CloudFormation template is invalid: Template format error: Unrecognized resource types: [AWS:EC2::VPC, AWS::RDS:DBInstance]
我可以看到 AWS 上存在这些资源:
所以...这个错误是什么意思?我做错了什么?
您的资源类型有拼写错误。在这两种情况下,您都有一个冒号 (:),而您应该有一个双冒号 (::)
如果您收到无法识别的“资源类型”错误,则表示您的代码中存在语法问题。
检查“无法识别的资源类型”后的拼写错误:
Unrecognized resource types: [AWS::Dynamo::Table]
在这种情况下,应该是
Type: AWS::DynamoDB::Table