Alternative to creating bucket for every terraform state: terraform-aws-multi-stack-backends
schollii opened this issue · 1 comments
This is not a bug report but rather just wanted to point out an alternative to creating a bucket and dyndb table specifically for the EKS. In your readme in the Configuring a terraform backend section you say "To use the s3 backend, you will need to create the bucket upfront. You need the S3 bucket as well as a Dynamo table for state locks".
I recently created a module https://registry.terraform.io/modules/schollii/multi-stack-backends/aws, that makes this unnecessary, in that once you install this module, it creates a bucket that can be used to store multiple terraform states. Some people prefer one state per bucket, but I find this very noisy, and IMO not a good idea especially with big stacks nowadays it is good practice to split the terraform state into a few parts. And with bucket replication, there is not much risk of loss. My module really simplifies the management of the backends and makes it obvious what states belong together, and provides individual IAM for the state files for those who need it, and generates the backend files for you.
It is still early stage but I have used it in several projects. Any feedback for improvements are naturally welcome.
I will take a look this weekend, sounds interesting. At work, I use terragrunt which creates the state bucket and dynamodb table, but a native terraform solution is a good thing.