Bucket replication managed by this module
Have a question? Please checkout our Slack Community or visit our Slack Archive.
Describe the Feature
Currently the bucket for replicating tf state as backup must be created manually. It would be really useful to have the module create it, since it is inherently tied to the backend setup.
Expected Behavior
When bucket replication is turned on, the module requires another region to be specified in the file, and a bucket name. It will create that bucket in the new region.
Use Case
Currently I have to create a replication bucket myself then give its ARN to the backend module. This is extra work that could easily be encapsulated into this module.
This is actually by design. If we added provisioning of the second bucket, we would change the interface to the module by always requiring a secondary provider to be passed to the module. It also complicates the naming convention of the bucket resource, as the secondary bucket should be disambiguated from the primary bucket. Our convention is to use the environment to connote the region (e.g. ue2 for us-east-2), but since we allow the user to provision that secondary bucket - they can name it whatever they want. Furthermore, by not defining the secondary destination within the module, it allows for maximum flexibility of the secondary bucket. The caller can provision that secondary bucket using this module using whatever other settings they want. It's also how we manage it in our reference architecture.
So you mean the HCL2 does not currently support provider being enabled / disabled so it would always have to be given even if replication is not desired?
What about in that case providing a module that creates an s3 bucket suitable as a tfstate bucket replica for referencing in the backend module vars?
Closing as "wontfix". @schollii for your reference:
What about in that case providing a module that creates an s3 bucket suitable as a tfstate bucket replica for referencing in the backend module vars?
You can use https://github.com/cloudposse/terraform-aws-s3-bucket
I ended up creating my own https://registry.terraform.io/modules/schollii/multi-stack-backends
because I needed more automation than what the cloudposse module provided.