Skip to content

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

@aislandiegofc

Description

@aislandiegofc

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions