terraform-aws-rds-cluster
terraform-aws-rds-cluster copied to clipboard
CreateDBInstance can't be used to create a DB instance in a Multi-AZ DB cluster. Use CreateDBCluster instead.
Describe the Bug
i am using minimal config to provision the db cluster, the cluster on console works properly but the terraform scripts fails in the end with the error message
│ Error: creating RDS Cluster (prod-mysql) Instance (prod-mysql-1): InvalidParameterValue: CreateDBInstance can't be used to create a DB instance in a Multi-AZ DB cluster. Use CreateDBCluster instead. │ status code: 400, request id: 7ec7b266-62c3-46b0-89f3-8ad0782e73ef │ │ with module.rds_mysql_idp.aws_rds_cluster_instance.default[0], │ on .terraform/modules/rds_mysql/main.tf line 251, in resource "aws_rds_cluster_instance" "default": │ 251: resource "aws_rds_cluster_instance" "default" {
Expected Behavior
script should not fail as cluster is up and running
Steps to Reproduce
` source = "cloudposse/rds-cluster/aws" version = "1.9.0"
name = "name" cluster_family = "mysql8.0" engine = "mysql" engine_mode = "provisioned" engine_version = "8.0" cluster_size = 1 namespace = var.namespace stage = var.environment admin_user = var.db_admin_username admin_password = var.db_admin_password db_name = "db_name" db_port = 3306 db_cluster_instance_class = var.db_instance_type vpc_id = var.vpc_id security_groups = [] subnets = var.subnets zone_id = var.zone_id storage_type = "io1" iops = 1000 allocated_storage = 100`
the tf script used
│ Error: creating RDS Cluster (bloom-prod-idpmysql) Instance (bloom-prod-idpmysql-1): InvalidParameterValue: CreateDBInstance can't be used to create a DB instance in a Multi-AZ DB cluster. Use CreateDBCluster instead. │ status code: 400, request id: 7ec7b266-62c3-46b0-89f3-8ad0782e73ef │ │ with module.rds_mysql_idp.aws_rds_cluster_instance.default[0], │ on .terraform/modules/rds_mysql_idp/main.tf line 251, in resource "aws_rds_cluster_instance" "default": │ 251: resource "aws_rds_cluster_instance" "default" {
Screenshots
No response
Environment
module version : 1.9.0 Terraform v1.5.0 on darwin_amd64
- provider registry.terraform.io/hashicorp/aws v4.67.0
- provider registry.terraform.io/hashicorp/local v2.5.1
- provider registry.terraform.io/hashicorp/null v3.2.2
- provider registry.terraform.io/hashicorp/random v3.6.0
- provider registry.terraform.io/hashicorp/tls v4.0.5
Additional Context
No response
I found this by chance. I had a similar issue with RDS when migrating a DB from Aurora to non-Aurora. Same error as you, and also had the cluster running but not the instance.
This part of the docs solved the issue for me:
To manage cluster instances that inherit configuration from the cluster (when not running the cluster in serverless engine mode), see the aws_rds_cluster_instance resource. To manage non-Aurora DB instances (e.g., MySQL, PostgreSQL, SQL Server, etc.), see the aws_db_instance resource
Basically, for Aurora, use aws_rds_cluster and aws_rds_cluster_instance. For non-Aurora, use aws_rds_cluster too, but use aws_db_instance instead of aws_rds_cluster_instance.