Fix Terraform Error: CloudWatch Log Group Already Exists
Fix terraform CloudWatch Log Group ResourceAlreadyExistsException. Import orphaned log groups, prevent Lambda auto-creation
DevOps
How to fix InvalidParameterCombination errors when modifying RDS instances in Terraform. Handle instance class, storage type, IOPS, Multi-AZ, and engine...
You're combining RDS parameters that AWS doesn't allow together — wrong instance class for the engine, IOPS with gp2 storage, Multi-AZ with an unsupported engine, or changing too many things at once. Check parameter compatibility with aws rds describe-orderable-db-instance-options and apply changes incrementally.
Error modifying DB Instance: InvalidParameterCombination:
Cannot upgrade postgres from 14.9 to 16.1 and change instance class
from db.t3.micro to db.r6g.large at the same timeOther common variants:
InvalidParameterCombination: IOPS is not supported for db.t3.micro
InvalidParameterCombination: Cannot specify both IOPS and storage type gp2
InvalidParameterCombination: Multi-AZ is not supported for db.t3.micro with engine sqlserver-expressAWS limits which RDS modifications can happen simultaneously. Changing instance class + engine version + storage in one apply will fail.
# ❌ IOPS requires io1, io2, or gp3 — NOT gp2
resource "aws_db_instance" "main" {
storage_type = "gp2"
iops = 3000 # InvalidParameterCombination
}Not all instance classes support all engines, versions, or AZs.
SQL Server Express and some micro instances don't support Multi-AZ.
# List valid instance class + storage combinations
aws rds describe-orderable-db-instance-options \
--engine postgres \
--engine-version 16.1 \
--query 'OrderableDBInstanceOptions[?DBInstanceClass==`db.r6g.large`].[DBInstanceClass,StorageType,SupportsIops,MultiAZCapable]' \
--output table
# Check what's available in your region
aws rds describe-orderable-db-instance-options \
--engine postgres \
--region us-east-1 \
--query 'OrderableDBInstanceOptions[*].DBInstanceClass' \
--output text | tr '\t' '\n' | sort -u# ✅ gp3 with provisioned IOPS
resource "aws_db_instance" "main" {
engine = "postgres"
engine_version = "16.1"
instance_class = "db.r6g.large"
allocated_storage = 100
storage_type = "gp3"
iops = 3000
storage_throughput = 125
}
# ✅ io1 with IOPS (legacy but supported)
resource "aws_db_instance" "main" {
storage_type = "io1"
iops = 3000
allocated_storage = 100 # io1 minimum 100GB
}
# ✅ gp2 without IOPS (IOPS scales with storage size)
resource "aws_db_instance" "main" {
storage_type = "gp2"
allocated_storage = 100
# No iops parameter — gp2 provides 3 IOPS/GB automatically
}# Step 1: Upgrade engine version first
# Change only engine_version in config
terraform apply
# Step 2: Then change instance class
# Change only instance_class in config
terraform apply
# Step 3: Then modify storage
# Change storage_type/iops in config
terraform applyUse apply_immediately = true to avoid waiting for the maintenance window:
resource "aws_db_instance" "main" {
apply_immediately = true # Don't wait for maintenance window
# ... other config
}# ❌ SQL Server Express doesn't support Multi-AZ
resource "aws_db_instance" "sql" {
engine = "sqlserver-ex"
instance_class = "db.t3.micro"
multi_az = true # Error!
}
# ✅ Use Standard or Enterprise for Multi-AZ
resource "aws_db_instance" "sql" {
engine = "sqlserver-se"
instance_class = "db.r6i.large"
multi_az = true
}| Parameter A | Parameter B | Issue |
|---|---|---|
storage_type = "gp2" | iops = 3000 | gp2 doesn't support custom IOPS |
instance_class = "db.t3.micro" | multi_az = true | T3.micro doesn't support Multi-AZ for some engines |
| Engine version upgrade | Instance class change | Can't do both simultaneously |
storage_type change | allocated_storage change | Apply separately |
engine = "sqlserver-ex" | multi_az = true | Express edition doesn't support Multi-AZ |
apply_immediately set to avoid maintenance window delays?aws rds describe-orderable-db-instance-optionsgp3 for new databases — it supports IOPS and throughput tuningInvalidParameterCombination means AWS can't apply the RDS changes you requested together. Use aws rds describe-orderable-db-instance-options to verify compatibility, apply changes incrementally (engine version → instance class → storage), and use gp3 storage for flexible IOPS configuration.
Fix terraform CloudWatch Log Group ResourceAlreadyExistsException. Import orphaned log groups, prevent Lambda auto-creation
Fix terraform import errors when a resource already exists in state. Covers state rm, state show, reimport workflow, import blocks
Fix terraform too many command line arguments errors. Correct -var syntax, quote values with spaces, and learn proper Terraform CLI argument format for plan
Fix terraform invalid escape sequence errors. Double backslashes for Windows paths, use heredocs for regex, and learn all valid HCL escape sequences.