Moe
Moe

Reputation: 2852

AWS/Terraform: Is there a way to toggle the replication_configuration block on an aws_s3_bucket?

I am looking for suggestions on how I can toggle the replication_configuration block on an aws_S3_bucket resource.

I am trying to have the replication_configuration block be applied only if my variable enable_crr is set to true in terraform.

The issue I face is that the block doesn't support enabled or count, so I'm hoping someone knows an alternative way of implementing this.

Does anyone have any suggestions?

Upvotes: 1

Views: 583

Answers (1)

Moe
Moe

Reputation: 2852

So I found a way that works... I added some logic to do two things:

1) ${var.enable_replication} == true ? <my backup bucket> : <a placeholder bucket arn>}

2) I toggle the replication status between Enabled / Disabled

By doing this, if it's enabled it points to my backup bucket, and if its disabled it points to my placeholder bucket.

edit: if you're reading this, in version 0.12.x you can use dynamicto do this.

Upvotes: 2

Related Questions