由于小写字母,CloudFormation 无法找到 RDS 子网组
CloudFormation fails to find RDS Subnet Group because of lowercase
我通过 CloudFormation 引用参数 ProjectName
创建了我的 RDS 子网组
DB:
Type: AWS::RDS::DBInstance
Properties:
DBSubnetGroupName: !Ref RDSSubnetGroup
现在的问题是 CloudFormation 说它找不到我的子网组:
DB subnet group 'AbcDef' does not exist because its actually abcdef ... how can I resolve this?
我试图寻找一个 toLower 函数,但似乎有 none?
另一个选项似乎是重新创建堆栈?
不幸的是,您在 CloudFormation
模板中所做的一切都区分大小写,包括 属性 名称和参数值。您可能需要重新创建堆栈。
正如您正确指出的那样,没有 Fn::ToLower
函数。如果你真的想实现你正在尝试的目标,那么到目前为止唯一的方法是创建 Lambda backed custom resource
,它基本上会将你的字符串转换为小写和 return 但它不值得做因为在处理自定义资源时您会遇到很多挑战。
我还发现在 RDS 控制台中查看时,数据库子网组的名称被强制更改为小写。非常不寻常的行为。
但是,我在 CloudFormation 中创建了它们,并没有导致您描述的错误。以下是我的 CloudFormation 模板中的内容:
###########
# DB Subnet Group
###########
DBSubnetGroup:
Type: AWS::RDS::DBSubnetGroup
Properties:
DBSubnetGroupDescription: Lab DB Subnet Group
DBSubnetGroupName: Lab DB Subnet Group
SubnetIds:
- !Ref PrivateSubnet1
- !Ref PrivateSubnet2
Tags:
-
Key: Name
Value: DBSubnetGroup
###########
# RDS Database
###########
RDSDatabase:
Type: AWS::RDS::DBInstance
Properties:
DBName: inventory
DBInstanceIdentifier: inventory-db
AllocatedStorage: 5
DBInstanceClass: db.t2.micro
Engine: MySQL
MasterUsername: master
MasterUserPassword: lab-password
MultiAZ: false
DBSubnetGroupName: !Ref DBSubnetGroup
VPCSecurityGroups:
- !Ref DBSecurityGroup
Tags:
-
Key: Name
Value: inventory-db
我建议将 function_name 和 DBSubnetGroup
的名称重写为 dbsubnetgroup
这将解决我认为的问题。
遇到了同样的问题,尝试了所有可能的方法,解决的唯一方法是创建一个名为 lower 的新数据库子网组:
rdssubnetgrouplower:
Type: "AWS::RDS::DBSubnetGroup"
Properties:
DBSubnetGroupDescription: "Private subnet group to keep the cluster private"
DBSubnetGroupName: rdssubnetgrouplower
SubnetIds:
- !Ref PrivateSubnet1
- !Ref PrivateSubnet2
Tags:
-
Key: Name
Value: rdssubnetgrouplower
然后在 RDS 定义中使用它:
MySQLABC:
Type: "AWS::RDS::DBCluster"
Properties:
DBSubnetGroupName: !Ref rdssubnetgrouplower
...
...
这有效并启动了集群。在 TF 中有较低的功能 :)
我通过 CloudFormation 引用参数 ProjectName
创建了我的 RDS 子网组 DB:
Type: AWS::RDS::DBInstance
Properties:
DBSubnetGroupName: !Ref RDSSubnetGroup
现在的问题是 CloudFormation 说它找不到我的子网组:
DB subnet group 'AbcDef' does not exist because its actually abcdef ... how can I resolve this?
我试图寻找一个 toLower 函数,但似乎有 none?
另一个选项似乎是重新创建堆栈?
不幸的是,您在 CloudFormation
模板中所做的一切都区分大小写,包括 属性 名称和参数值。您可能需要重新创建堆栈。
正如您正确指出的那样,没有 Fn::ToLower
函数。如果你真的想实现你正在尝试的目标,那么到目前为止唯一的方法是创建 Lambda backed custom resource
,它基本上会将你的字符串转换为小写和 return 但它不值得做因为在处理自定义资源时您会遇到很多挑战。
我还发现在 RDS 控制台中查看时,数据库子网组的名称被强制更改为小写。非常不寻常的行为。
但是,我在 CloudFormation 中创建了它们,并没有导致您描述的错误。以下是我的 CloudFormation 模板中的内容:
###########
# DB Subnet Group
###########
DBSubnetGroup:
Type: AWS::RDS::DBSubnetGroup
Properties:
DBSubnetGroupDescription: Lab DB Subnet Group
DBSubnetGroupName: Lab DB Subnet Group
SubnetIds:
- !Ref PrivateSubnet1
- !Ref PrivateSubnet2
Tags:
-
Key: Name
Value: DBSubnetGroup
###########
# RDS Database
###########
RDSDatabase:
Type: AWS::RDS::DBInstance
Properties:
DBName: inventory
DBInstanceIdentifier: inventory-db
AllocatedStorage: 5
DBInstanceClass: db.t2.micro
Engine: MySQL
MasterUsername: master
MasterUserPassword: lab-password
MultiAZ: false
DBSubnetGroupName: !Ref DBSubnetGroup
VPCSecurityGroups:
- !Ref DBSecurityGroup
Tags:
-
Key: Name
Value: inventory-db
我建议将 function_name 和 DBSubnetGroup
的名称重写为 dbsubnetgroup
这将解决我认为的问题。
遇到了同样的问题,尝试了所有可能的方法,解决的唯一方法是创建一个名为 lower 的新数据库子网组:
rdssubnetgrouplower:
Type: "AWS::RDS::DBSubnetGroup"
Properties:
DBSubnetGroupDescription: "Private subnet group to keep the cluster private"
DBSubnetGroupName: rdssubnetgrouplower
SubnetIds:
- !Ref PrivateSubnet1
- !Ref PrivateSubnet2
Tags:
-
Key: Name
Value: rdssubnetgrouplower
然后在 RDS 定义中使用它:
MySQLABC:
Type: "AWS::RDS::DBCluster"
Properties:
DBSubnetGroupName: !Ref rdssubnetgrouplower
...
...
这有效并启动了集群。在 TF 中有较低的功能 :)