hashicorp / hashicorp/tfc-workflows-github

Error: Variables not allowed

Open
#22 6 comments 3 reactions 0 assignees View on GitHub
Dominant language
HCL
Stars
178
Forks
30
PR merge metrics
No merged PRs in 30d

Description

I'm struggling to pass in a variable at runtime.
I used the [learn tfc tutorial](https://github.com/hashicorp/learn-terraform-cloud) to get a basic project going.

The projects works fine, when declaring variable in the interface, but it doesn't work at all, when trying to pass them in via en variables.
I modified the 'main.tf' file:
```
variable "access_key" {
description = "value of AWS access key"
type = string
default = null
}

variable "secret_key" {
description = "value of AWS secret key"
type = string
default = null
}

provider "aws" {
region = "us-west-2"
access_key = var.access_key
secret_key = var.secret_key
}
```

And try to run tf in an action:
```
- name: Create Plan Run
uses: hashicorp/tfc-workflows-github/actions/create-run@v1.0.0
id: plan-run
with:
workspace: ${{ env.TF_WORKSPACE }}
configuration_version: ${{ steps.plan-upload.outputs.configuration_version_id }}
plan_only: true
env:
TF_VAR_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
TF_VAR_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
```

However in the tfc console I receive the error:
```
2023-08-30T12:12:41.859Z [DEBUG] backend/local: Skipping interactive prompts for variables because input is disabled

│ Error: Variables not allowed

│ on /home/tfc-agent/.tfc-agent/component/terraform/runs/run-uGHGZhRqc5VVoXhU/terraform.tfvars line 1:
│ 1: access_key = xxx

│ Variables may not be used here.

Operation failed: failed running terraform plan (exit 1)
```

Am I missing something?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.