-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Description
Terraform Version
Terraform v0.11.7
Terraform Configuration Files
terraform {
required_version = "0.11.7"
backend "s3" {
dynamodb_table = "terraform-state-lock"
bucket = "s3-tfstate-bucket"
key = "s3/key/terraform.tfstate"
profile = "aws_profile"
region = "eu-west-1"
}
}Context
First, I only use AWS so I'm not sure how this is solved in other backend providers.
I think it's a common problem that Terraform requires that all the resources part of the initial configuration should exist prior invoking terraform init. And that produce chicken-egg situation where something should be created and part of the state prior being able to initialise the same state.
Such resources are S3 bucket holding the state as well as DynamoDB table for managing locks.
Possible solution
Now it'd be great if we could tell terraform to create those resources for us prior initialising the state and further put those resources into the state.
Creating a bucket is usually idempotent operation (if the bucket already exist it will simply return true).
Same should apply to DynamoDB tables, though configuration there might differ for different use cases.