Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENV_FILE - pratical use for terraform debug/trace enabled #136

Open
aislandiegofc opened this issue Jan 14, 2022 · 0 comments
Open

ENV_FILE - pratical use for terraform debug/trace enabled #136

aislandiegofc opened this issue Jan 14, 2022 · 0 comments

Comments

@aislandiegofc
Copy link

aislandiegofc commented Jan 14, 2022

Hey guys,
@caioquirino - thanks for the heads up, hope this issue may help others with the same difficult.

Can we have an example of using the env_file in the pipeline?
I'm looking for enable the terraform debug/trace.

I've created a file .tfenv with the following content, and it's located inside the terraform folder where all my tf files are.

TF_LOG=trace
TF_LOG_CORE=trace
TF_LOG_PROVIDER=trace

And the way I've been calling the env_file in my pipeline:


---
kind: pipeline
name: default

concurrency:
  limit: 1

anchors:

#------------------------------------
# Shared plugin initialization vars
#------------------------------------

  terraform_common: &terraform_common
    root_dir: terraform
    tf_version: "1.0.8"
    env_file:
      - .tfenv
    vars:
      repo_name: ${DRONE_REPO_NAME}

#------------------------------------
# Setup UAT specific vars
#------------------------------------

  terraform_settings_uat: &terraform_settings_uat
    <<: *terraform_common
    init_options:
      backend-config:
      - config/uat/terraform.remote
      - key=eu-west-1/${DRONE_REPO_NAME}/uat.tfstate
    var_files:
    - config/uat/terraform.tfvars
    tf_data_dir: .terraform-uat

However it does not load the content of the env_file and no debug is displayed during the plan step.

Your examples would be very much appreciated.
Thanks in advance.

EDIT:

The correct syntax for using the env_file is:

---
kind: pipeline
name: default

concurrency:
  limit: 1

anchors:

#------------------------------------
# Shared plugin initialization vars
#------------------------------------

  terraform_common: &terraform_common
    root_dir: terraform
    tf_version: "1.0.8"
    env_file: terraform/.tfenv
    vars:
      repo_name: ${DRONE_REPO_NAME}

where: terraform is a folder created in the root of my project and .tfenv is the file with the VARS that will be shared in the shell environment.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant