- backend.tfvars
- setup
-- main.tf
-- variables.tf
- base
-- main.tf (symlink to ../setup/main.tf)
-- variables.tf (symlink to ../setup/variables.tf)
-- backend.tf (symlink to ../common/backend.tf)
- common
-- backend.tf
Created
February 22, 2018 10:08
-
-
Save jandudulski/6a92f07d172a6cd4f5140d9d9106e3f8 to your computer and use it in GitHub Desktop.
Chicken or the Egg. Terraform’s Remote Backend
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this won't work | |
terraform { | |
backend "s3" { | |
bucket = "${var.bucket}" | |
dynamodb_table = "${var.dynamodb_table}" | |
# reminder of the config... | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# setup/main.tf | |
provider "aws" { | |
profile = "${var.profile}" | |
region = "${var.region}" | |
} | |
module "backend" { | |
source = "../modules/backend" | |
# configuration goes here | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Initialize the local Terraform backend | |
terraform init setup | |
# Set up remote backend infrastructure | |
terraform apply -var-file=backend.tfvars setup | |
# Initialize the remote Terraform backend and migrate local to remote | |
terraform init -backend-config=backend.tfvars base |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment