jenkins-x / terraform-aws-eks-jx

A Terraform module for creating Jenkins X infrastructure on AWS
Apache License 2.0
63 stars 42 forks source link

Alternative to creating bucket for every terraform state: terraform-aws-multi-stack-backends #284

Open schollii opened 3 years ago

schollii commented 3 years ago

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.

ankitm123 commented 3 years ago

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.