Open dmrzzz opened 7 years ago
@dmrzzz
just curious about the terraform {}
block, as per the documentation https://www.terraform.io/docs/configuration/terraform.html
The terraform block configures the behavior of Terraform itself.
The currently only allowed configuration within this block is required_version.
assuming the configuration block works for you (regardless the manual bucket and table creation) I think the documentation needs to be updated to include the backend configuration.
@adilnaimi I agree the documentation page you reference is out of date, but that has nothing to do with the enhancement I am requesting/suggesting in this issue. Perhaps you should open a separate issue for the documentation page?
@dmrzzz documentation out of date issue created https://github.com/hashicorp/terraform/issues/13064
This is a bit hacky, but as a workaround-- if you run apply without the backend
settings (just comment them out temporarily) and specify the bucket/table in your TF, it should run and create them (along with everything else)-- then you can uncomment the settings and it will transition your state into the now existing bucket pretty seamlessly.
In the same pattern @jyoungs mentioned, I put together a terraform module along with a guide for dealing with particular issue. It is a work in progress, but supports most AWS Backend use cases and includes instructions for bootstrapping your project.
@jyoungs and @samstav That's clever, but not really what I'm looking for.
To clarify my feature request, I specifically would like to avoid managing this S3 bucket as a resource "aws_s3_bucket"
within my config, because I never want Terraform to destroy it.
That's in part because I like to keep all of my Terraform state for many many different configs in just one S3 bucket per AWS account (carefully making sure the keys are unique so they don't step on each other), which means that if any one of those configs decided it was king of the bucket and destroyed the bucket, all the other ones would suddenly be up the proverbial creek.
My current solution is to create the state-management resources manually with
aws s3api create-bucket --create-bucket-configuration LocationConstraint=us-east-2 \
--bucket $BUCKET
aws s3api put-bucket-versioning --versioning-configuration Status=Enabled \
--bucket $BUCKET
aws dynamodb create-table --region us-east-2 --table-name $TABLE \
--attribute-definitions AttributeName=LockID,AttributeType=S \
--key-schema AttributeName=LockID,KeyType=HASH \
--provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1
and that accomplishes precisely what I need. Since I only do it once per AWS account, it's not even that hard. I just want Terraform to do it for me because I'm lazy and writing a separate tool for this feels like massive overkill. :)
Any update on this? In the latest docs bucket_name is still required field. https://www.terraform.io/docs/backends/types/s3.html
Terraform Version
Terraform v0.9.0
Affected Resource(s)
Terraform Configuration Files
Feature Request
I'm very excited about the new backend configuration in Terraform 0.9, but it's inconvenient that I have to manually create both an S3 bucket and a DynamoDB table before I can get started. (If I enjoyed manually creating resources, I wouldn't need Terraform!)
Terragrunt (with Terraform <= 0.8.x) handles this extremely conveniently by:
I would love to see Terraform 0.9+ do the same (perhaps during
terraform init
?)Here's how the equivalent configuration behaves using Terragrunt, starting from a blank slate: