我正在嘗試為使用無服務器構建的應用程式生成 Aurora 無服務器資料庫。
我為我的這部分設定復制了我在網上找到的 CloudFormation 模板。我從我的 Serverless.yml 檔案中參考了以下資源(我已將其排除,因為它非常大)。
無服務器失敗并顯示以下訊息:
發生錯誤:AuroraCluster - 屬性 DBSubnetGroupName 的值必須是字串型別。
我對此感到困惑,因為據我觀察,DBSubnetGroupName 是一個字串(如您所見,它設定為“db-subnet-group”的值)。
我是 Serverless 和 CloudFormation 的新手,并且正在盡我所能為我正在構建的產品拼湊一個解決方案。任何有關如何解決此問題的建議將不勝感激。
下面是我的無服務器檔案。非常感謝您的任何幫助!
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
uj5u.com熱心網友回復:
在你的AWS::RDS::DBCluster應該是:
DBSubnetGroupName: !Ref AuroraSubnetGroup
uj5u.com熱心網友回復:
在您的示例中,您DBSubnetGroupName作為陣列而不是字串傳遞:
DBSubnetGroupName:
- Ref: AuroraSubnetGroup
為了將其作為字串傳遞,您應該使用以下表示法:
DBSubnetGroupName: Ref: AuroraSubnetGroup
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/405037.html
標籤:
