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

terraform test does not recognize TF_VAR_* env variables when it is set in GitHub Actions #35158

Closed
dreinhardt89 opened this issue May 14, 2024 · 1 comment
Labels
bug new new issue not yet triaged

Comments

@dreinhardt89
Copy link

Terraform Version

v1.8.1

Terraform Configuration Files

jobs:
  tf-test:
    runs-on: ubuntu-latest
    env:
      TF_VAR_aws_provider_role_arn: "arn"
    steps:
    - name: Checkout Repo
      uses: actions/checkout@v4
    - name: Terraform - Setup
      uses: hashicorp/setup-terraform@v3
      with:
        terraform_version: 1.8.1
    - name: Terraform - Init
      id: init
      run: |
        terraform init -input=false -lock=false
    - name: Terraform Test
      id: test
      run: |
        terraform init -input=false -lock=false
        terraform validate
        terraform test
      shell: bash

tests/setup/main.tf

terraform {
  required_providers {
    aws = {
      source = "hashicorp/aws"
    }
  }
  required_version = ">= 0.14"
}
  
provider "aws" {
  assume_role {
    role_arn = var.aws_provider_role_arn
  }
}
  
variable "aws_provider_role_arn" {
  description = "IAM Role ARN for AWS provider to assume."
  type        = string
}

tftest.hcl

run "setup_tests" {
  module {
    source = "./tests/setup"
  }
}

Debug Output

tests/argo_app_multi_source.tftest.hcl... in progress
  run "setup_tests"... fail

│ Error: Required variable not set
│   64: variable "aws_provider_role_arn" {
│ 
│ The variable "aws_provider_role_arn" is required, but is not set.

Expected Behavior

The variable should have been set by setting the TF_VAR_aws_provider_role_arn env var.

Actual Behavior

The variable was not set

Steps to Reproduce

  1. terraform init
  2. terraform test

Additional Context

No response

References

No response

@dreinhardt89 dreinhardt89 added bug new new issue not yet triaged labels May 14, 2024
@dreinhardt89
Copy link
Author

this seems to be fixed in 1.8.3

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

No branches or pull requests

1 participant