output_planfile: state has no output for key plan_content_json
talset opened this issue · 3 comments
I tried to get the plan file locally with the following config:
resources:
- name: tfstate
type: terraform
source:
backend_config:
path: "terraform.tfstate"
backend_type: local
env:
AWS_ACCESS_KEY_ID: ((aws.access_key))
AWS_DEFAULT_REGION: eu-west-1
AWS_SECRET_ACCESS_KEY: ((aws.secret_key))
env_name: test
...
resource_types:
- name: terraform
type: docker-image
source:
repository: ljfranklin/terraform-resource
tag: 0.12.26-b11328e
jobs:
- name: terraform-plan
plan:
- do:
- get: git_terraform
trigger: true
- put: tfstate
params:
plan_only: true
terraform_source: git_terraform/
get_params:
output_planfile: true
But after the end of the task with Successfully Ran Terraform Plan!
the put output say 2020/06/08 12:24:51 state has no output for key plan_content_json
The local
backend type isn't supported. Concourse requires that all state is persisted outside the container. Added an error message and docs to describe that here: db907cb. You'll have to use one of the other backend types that saves the statefile somewhere other than the local filesystem.
@ljfranklin Agree that we need to have the tfstate persistent but since we have output_statefile
and output_planfile
available, a user can easily have a custom task to get/push the tfstate generated localy in the terraform resource.
It should be up to the user to give an external backend or provide terraform_source
with the local tfstate. WDYT ?
It should be up to the user to give an external backend or provide terraform_source with the local tfstate
Unfortunately no. To give more detail, a Concourse put
cannot output any local files. The put
must persist any required state somewhere outside the container. After each put
a get
automatically runs to download that state and output into a directory so that subsequent tasks can consume the outputs. There is no way for a Terraform put
to write a planfile to terraform_source
directory so that a subsequent task could read it.