terragrunt --version
terragrunt version v0.12.15
terraform --version
Terraform v0.9.4
I'm trying to follow the model outlined in the README, where I have a child terraform.tfvars and a parent terraform.tfvars.
My child looks like this:
terragrunt = {
include {
path = "${find_in_parent_folders()}"
}
}
My Parent looks like this:
terragrunt = {
remote_state {
backend = "s3"
config {
bucket = "my_bucket-${get_env("TF_VAR_region", "PLEASE_SUPPLY_REGION")}-${get_aws_account_id()}"
key = "state/${path_relative_to_include()}/terraform.tfstate"
region = "${get_env("TF_VAR_region", "PLEASE_SUPPLY_REGION")}"
encrypt = true
}
}
}
After poking around the tmp directory, I can see that all the resources are actually in the terraform.tfstate file and there is no backend set in the file
cat /tmp/terragrunt-download/p7PRMQn3UEi0IaAMEIJAYJnoNN8/xHwmtCx0_z7OWwadwwx_ofKNb0o/module/terraform.tfstate | grep -c backend
0
So I'm not entirely sure what I'm doing wrong, but given the output below, it seems to indicate it's trying to configure the remote backend (via the terraform init command), however it doesn't seem to be doing that successfully.
Here is the (cleaned up) output from the apply:
terragrunt apply
[terragrunt] [/my_path/env/dev] 2017/05/03 11:22:09 Running command: terraform --version
[terragrunt] 2017/05/03 11:22:09 Reading Terragrunt config file at /my_path/env/dev/terraform.tfvars
[terragrunt] 2017/05/03 11:22:09 Cleaning up existing *.tf files in /tmp/terragrunt-download/p7PRMQn3UEi0IaAMEIJAYJnoNN8/xHwmtCx0_z7OWwadwwx_ofKNb0o
[terragrunt] 2017/05/03 11:22:09 Downloading Terraform configurations from file:///my_path into /tmp/terragrunt-download/p7PRMQn3UEi0IaAMEIJAYJnoNN8/xHwmtCx0_z7OWwadwwx_ofKNb0o
[terragrunt] 2017/05/03 11:22:09 Running command: terraform init -backend=false -get=false file:///my_path /tmp/terragrunt-download/p7PRMQn3UEi0IaAMEIJAYJnoNN8/xHwmtCx0_z7OWwadwwx_ofKNb0o
Initializing configuration from: "file:///my_path"...
Terraform initialized in an empty directory!
The directory has no Terraform configuration files. You may begin working
with Terraform immediately by creating Terraform configuration files.
[terragrunt] 2017/05/03 11:22:10 Copying files from /my_path/env/dev into /tmp/terragrunt-download/p7PRMQn3UEi0IaAMEIJAYJnoNN8/xHwmtCx0_z7OWwadwwx_ofKNb0o/module
[terragrunt] 2017/05/03 11:22:10 Setting working directory to /tmp/terragrunt-download/p7PRMQn3UEi0IaAMEIJAYJnoNN8/xHwmtCx0_z7OWwadwwx_ofKNb0o/module
[terragrunt] 2017/05/03 11:22:10 Initializing remote state for the s3 backend
[terragrunt] 2017/05/03 11:22:10 Configuring remote state for the s3 backend
[terragrunt] 2017/05/03 11:22:10 Running command: terraform init -backend-config=encrypt=true -backend-config=bucket=my_bucket -backend-config=key=state/my_module/env/dev/terraform.tfstate -backend-config=region=us-east-1
Downloading modules (if any)...
Get: git::ssh://[email protected]/my_org/my_repo.git
Get: git::ssh://[email protected]/my_org/my_repo.git
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your environment. If you forget, other
commands will detect it and remind you to do so if necessary.
[terragrunt] 2017/05/03 11:22:10 Running command: terraform apply -var-file=/my_path/env/dev/terraform.tfvars -var-file=/my_path/env/dev/us-east-1.tfvars
data.aws_vpc.vpc: Refreshing state...
...trimmed output of my resource list...
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
And of course as soon as I posted this I realized my mistake. I failed to include the backend setting in an actual .tf file. IE
terraform {
backend "s3" {}
}
You saved me! I've been thinking why it was not working for me and I had just to add main.tf with the above!
Most helpful comment
And of course as soon as I posted this I realized my mistake. I failed to include the backend setting in an actual
.tffile. IE