You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过CloudFormation自定义AWS Aurora MySQL集群名称

How to Customize AWS Aurora Cluster Name in CloudFormation

Got it, let's sort out how to set a custom name for your Aurora DB cluster instead of letting CloudFormation auto-generate that long, random-suffixed name you're seeing right now.

The Root Cause

By default, if you don't explicitly define a DBClusterName property in your AWS::RDS::DBCluster resource, CloudFormation will create a name combining your stack name, resource name, and a random hash — which is exactly what you're experiencing.

Step 1: Update Your CloudFormation Template

You need to add the DBClusterName attribute to your DB cluster resource in the JSON template. Here are two ways to do this:

Option 1: Hardcode the Custom Name

If you want a fixed, unchangeable cluster name, add the property directly to your resource:

"Resources": {
  "YourDBClusterResource": {
    "Type": "AWS::RDS::DBCluster",
    "Properties": {
      "DBClusterName": "my-custom-aurora-cluster", // Replace with your desired name
      "Engine": "aurora-mysql",
      "MasterUsername": {"Ref": "DBMasterUsername"},
      "MasterUserPassword": {"Ref": "DBMasterUserPassword"},
      // Include all your existing required properties here (VpcSecurityGroups, BackupRetentionPeriod, etc.)
    }
  }
}

Option 2: Use a Stack Parameter (More Flexible)

For the ability to specify the cluster name when creating the stack (instead of hardcoding it), add a parameters section first:

"Parameters": {
  "CustomClusterName": {
    "Type": "String",
    "Description": "Enter a custom name for your Aurora DB Cluster",
    "Default": "my-default-aurora-cluster",
    "MinLength": "1",
    "MaxLength": "63",
    "AllowedPattern": "^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$"
  }
}

Then reference this parameter in your DB cluster resource:

"Resources": {
  "YourDBClusterResource": {
    "Type": "AWS::RDS::DBCluster",
    "Properties": {
      "DBClusterName": {"Ref": "CustomClusterName"},
      // Rest of your cluster properties...
    }
  }
}

Step 2: Deploy the Updated Template

Once you've modified the template, you'll need to create a new stack (or update an existing one if it hasn't been finalized yet with the auto-generated name). If you use the parameter option, your CLI command would look like this:

aws cloudformation create-stack --stack-name test-rds-3 --template-body file:///home/mahendra/clodcft/cft-rd.json --parameters ParameterKey=CustomClusterName,ParameterValue=my-desired-cluster-name

Key Notes to Remember

  • Naming Rules: Your custom cluster name must be 1-63 characters long, can only include letters, numbers, and hyphens, and can't start or end with a hyphen. AWS enforces these rules, so double-check your name!
  • Uniqueness: The name must be unique in your AWS account and region — if another cluster already uses that name, CloudFormation will fail to create the stack.
  • Immutable Property: Once the cluster is created, you can't change DBClusterName later. Make sure you're happy with the name before deploying.

After making these changes, your Aurora cluster will use the exact name you specified, no random suffix included!

内容的提问来源于stack exchange,提问作者mahendra rathod

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:30:31