aws-ia / terraform-aws-control_tower_account_factory

AWS Control Tower Account Factory
Apache License 2.0
604 stars 386 forks source link

S3 error when tf_backend_secondary_region variable is modified or deleted #463

Closed dmkim22-lguplus closed 3 weeks ago

dmkim22-lguplus commented 4 weeks ago

Terraform Version & Prov: Terraform Cloud v1.6.5

AFT Version: 1.12.0

Bug Description AFT was installed with tf_backend_secondary_region = "us-west-1" variable, and I want to change the region to "us-east-1".

I tried changing the region value for tf_backend_secondary_region and also tried deleting the whole variable, but in both cases, I am getting following error for Terraform Plan.

Related Logs image

dmkim22-lguplus commented 3 weeks ago

I'm not sure if this is the best way, but managed to workaround the issue by modifing count = var.secondary_region == "" ? 0 : 1 to count = var.secondary_region == "" ? 0 : 0 for every secondary-backend-bucket related resource on aft-backend/main.tf.

Looks like, if tf_backend_secondary_region variable is removed in order to remove replication, terraform can't find the S3 bucket as count and provider both rely on same secondary region variable.