Introduction:
AWS Aurora global DB cluster can be created directly from resource block aws_rds_global_cluster. However, there is a way where we can also migrate regional cluster to global res cluster using two methods:
1. Global cluster restored from a snapshot
2. New global cluster from existing rds cluster
Problem: When global cluster created directly, the major and minor upgradation works well by changing the engine version. But, when the aws_rds_global_cluster is created from existing regional RDS cluster, it could ends up with such error:
operation error RDS: ModifyDBCluster, https response error StatusCode: 400, RequestID:xxxxxxxxxx, api error InvalidParameterCombination: Major Version Upgrade isn't supported in a single member of a global cluster. Use ModifyGlobalCluster to upgrade all the members.
Error: Conflicting configuration arguments││ with aws_rds_global_cluster.example,│ on providers.tf line xx, in resource "aws_rds_global_cluster" "example-name":│ 27: source_db_cluster_identifier = aws_rds_cluster.postgresql.arn││ "source_db_cluster_identifier": conflicts with engine
Solution:
As per usual process to upgrade migrated global cluster to lets say, 16.6, the changes that needs to be made are as below:
-
- comment engine_version = "15.10" > resource "aws_rds_cluster" "postgresql" {.. #engine_version = "15.10"..}
- engine_version = "15.10"> resource "aws_rds_global_cluster" "example" {..engine_version = "16.6"..}
- add lifecycle block >
lifecycle {ignore_changes = [global_cluster_identifier,engine_version]
} in aws_rds_cluster resource.
To fix error, comment source_db_cluster_identifier = aws_rds_cluster.postgresql.arn
inside global cluster resource block. Example code as below:
provider "aws" {
region = "xxx"
}
resource "aws_rds_cluster" "postgresql" {
cluster_identifier = "aurora-cluster-demo"
engine = "aurora-postgresql"
engine_version = "15.10" #commented while upgrading to 16.6
database_name = "mydb"
master_username = "xxx"
master_password = "xxx"
backup_retention_period = 5
preferred_backup_window = "07:00-09:00"
skip_final_snapshot = true
lifecycle {
ignore_changes = [global_cluster_identifier,engine_version]
}
}
resource "aws_rds_global_cluster" "example" {
force_destroy = true
global_cluster_identifier = "postgresql"
engine = "aurora-postgresql"
engine_version = "15.10" #upgraded to 16.6
source_db_cluster_identifier = aws_rds_cluster.postgresql.arn #commented at the time of major version upgrade
}
resource "aws_rds_cluster_instance" "cluster_instances" {
count = 1
identifier = "aurora-cluster-demo-${count.index}"
cluster_identifier = aws_rds_cluster.postgresql.id
engine = aws_rds_cluster.postgresql.engine
engine_version = aws_rds_cluster.postgresql.engine_version
instance_class = "db.r5.large"
}
Outcome: You would be able to upgrade global cluster which is created from existing cluster.
Additional Information:
- If you're still experiencing issues, please contact HCP Terraform Support by submitting a ticket through our support portal