gpt4 book ai didi

amazon-web-services - AWS CloudFormation RDS 实例无法创建 - 找不到 DBCluster

转载 作者:行者123 更新时间:2023-12-03 07:17:29 24 4
gpt4 key购买 nike

我正在使用 cloudformation,并遇到了无法解决的 DBSubnetGroup 问题。我的目标是构建一个简单的设置:

  • 具有两个子网的 VPC
  • 这些子网上的 RDS 数据库子网组
  • 该数据库子网中的 RDS 数据库集群
  • 该集群中的单个 RDS 实例

在cloudformation中,我不断收到错误:

Could not find DB Cluster: MyRDSClusterId (Service: AmazonRDS; Status Code: 
404; Error Code: DBClusterNotFoundFault; Request ID: ...)

在我看来,一切都正确,cloudformation 表示我的 DBCluster 已正确创建。我在这里做错了什么?任何对我做错的事情的见解将不胜感激。

这是我的云信息模板:

AWSTemplateFormatVersion: "2010-09-09"
Description: Stack with DBSubnetGroup, DBCluster, and one DBInstance
Resources:
MyAppVPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 192.168.0.0/16
EnableDnsSupport: true
EnableDnsHostnames: true
InstanceTenancy: default
MyAppRDSSubnetA:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: us-east-1a
VpcId: !Ref MyAppVPC
CidrBlock: 192.168.0.0/24
MapPublicIpOnLaunch: true
MyAppRDSSubnetB:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: us-east-1b
VpcId: !Ref MyAppVPC
CidrBlock: 192.168.1.0/24
MapPublicIpOnLaunch: true
MyDBSubnetGroup:
Type: AWS::RDS::DBSubnetGroup
Properties:
DBSubnetGroupDescription: My App DBSubnetGroup for RDS
SubnetIds:
- !Ref MyAppRDSSubnetA
- !Ref MyAppRDSSubnetB
MyRDSCluster:
Type: AWS::RDS::DBCluster
Properties:
BackupRetentionPeriod: 1
DatabaseName: MyDB
DBClusterIdentifier: MyRDSClusterId
DBSubnetGroupName: !Ref MyDBSubnetGroup
Engine: aurora
MasterUsername: exampleUsername
MasterUserPassword: examplePassword
MyRDSInstance:
Type: AWS::RDS::DBInstance
Properties:
DBClusterIdentifier: !Ref MyRDSCluster
DBInstanceClass: db.t2.small
DBSubnetGroupName: !Ref MyDBSubnetGroup
Engine: aurora

最佳答案

DBClusterIdentifier 名称中的某些字符为大写。cloudformation 的作用是,它自动将所有大写字符转换为小写。现在,当您尝试在 DBCluster 下附加 DBInstances 时,无法使用您提到的 DBClusterIdentifier 找到它,因为它包含一些大写字母。

MyRDSCluster:
Type: AWS::RDS::DBCluster
Properties:
BackupRetentionPeriod: 1
DatabaseName: MyDB
DBClusterIdentifier: MyRDSClusterId <- here it converts all string to lowercase
DBSubnetGroupName: !Ref MyDBSubnetGroup
Engine: aurora
MasterUsername: exampleUsername
MasterUserPassword: examplePassword
MyRDSInstance:
Type: AWS::RDS::DBInstance
Properties:
DBClusterIdentifier: !Ref MyRDSCluster <- here it does not, so mismatch in name
DBInstanceClass: db.t2.small
DBSubnetGroupName: !Ref MyDBSubnetGroup
Engine: aurora

解决方案是:将 DBClusterIdentifier 全部小写。

我希望您能得到答案:)

关于amazon-web-services - AWS CloudFormation RDS 实例无法创建 - 找不到 DBCluster,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51575502/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com