我正在尝试为一个使用serverless构建应用程序的应用程序创建一个Aurora无服务器数据库。
我在网上为我的设置的这一部分复制了一个CloudFormation模板。我从我的Serverless.yml文件中引用了下面的资源(我已经排除了它,因为它非常大)。
Serverless在消息中失败:
发生了一个错误:属性DBSubnetGroupName的AuroraCluster -值必须是字符串类型.
我对此感到困惑,因为在我的观察中,DBSubnetGroupName是一个字符串(如您所见,它被设置为‘db-子网组’的值)。
我对Serverless和CloudFormation都是新手,我正在尽我最大的努力为我正在构建的产品拼凑一个解决方案。任何关于如何解决这个问题的建议都将不胜感激。
下面是我的Serverless文件。非常感谢您的帮助!
Resources:
ServerlessSecurityGroup:
DependsOn: VPC
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: SecurityGroup for Serverless Functions
VpcId:
Ref: VPC
PrivateSubnetA:
DependsOn: VPC
Type: AWS::EC2::Subnet
Properties:
VpcId:
Ref: VPC
AvailabilityZone: "eu-west-1a"
CidrBlock: "10.0.1.0/24"
PrivateSubnetB:
DependsOn: VPC
Type: AWS::EC2::Subnet
Properties:
VpcId:
Ref: VPC
AvailabilityZone: "eu-west-1b"
CidrBlock: "10.0.64.0/19"
AuroraSubnetGroup:
Type: AWS::RDS::DBSubnetGroup
Properties:
DBSubnetGroupDescription: Subnet group for Aurora Database
DBSubnetGroupName: "db-subnet-group"
SubnetIds:
- Ref: PrivateSubnetA
- Ref: PrivateSubnetB
AuroraCluster:
Type: AWS::RDS::DBCluster
DeletionPolicy: ${self:custom.deletion_policy}
Properties:
DBClusterIdentifier: ${self:custom.aurora_db_name}
MasterUsername: !Sub ${self:custom.aurora_db_name}
MasterUserPassword: asdfasdfasdf223
DatabaseName: "somename"
Engine: aurora
EngineMode: serverless
DBSubnetGroupName:
- Ref: AuroraSubnetGroup
VpcSecurityGroupIds:
- Ref: ServerlessSecurityGroup
EnableHttpEndpoint: true
ScalingConfiguration:
AutoPause: true
MinCapacity: 1
MaxCapacity: 2
SecondsUntilAutoPause: 3600
Outputs:
AuroraCluster:
Value:
Ref: AuroraCluster发布于 2022-01-06 10:37:23
在您的AWS::RDS::DBCluster中,应该是:
DBSubnetGroupName: !Ref AuroraSubnetGroup发布于 2022-01-06 12:48:23
在您的示例中,您将DBSubnetGroupName作为数组传递,而不是字符串:
DBSubnetGroupName:
- Ref: AuroraSubnetGroup为了将它作为字符串传递,应该使用以下表示法:
DBSubnetGroupName: Ref: AuroraSubnetGrouphttps://stackoverflow.com/questions/70605017
复制相似问题