3

I’m working through this tutorial and managed to set everything up ok.

https://learn.hashicorp.com/tutorials/terraform/cloud-workspace-configure?in=terraform%2Fcloud-get-started

On queuing the plan i get the following errors back relating to variables and unable to get to the bottom of it.

Anyone any ideas on how to move forward with this? Thanks

Was hoping this was going to be a nice easy one to get up and running!

Configuring remote state backend...
Initializing Terraform configuration...

Warning: Value for undeclared variable

The root module does not declare a variable named "tag_user_name" but a value
was found in file "/terraform/terraform.tfvars". To use this value, add a
"variable" block to the configuration.

Using a variables file to set an undeclared variable is deprecated and will
become an error in a future release. If you wish to provide certain "global"
settings to all configurations in your organization, use TF_VAR_...
environment variables to set these instead.


Error: No value for required variable

  on variables.tf line 6:
   6: variable "aws_access_key_id" {

The root module input variable "aws_access_key_id" is not set, and has no
default value. Use a -var or -var-file command line argument to provide a
value for this variable.


Error: No value for required variable

  on variables.tf line 10:
  10: variable "aws_secret_access_key" {

The root module input variable "aws_secret_access_key" is not set, and has no
default value. Use a -var or -var-file command line argument to provide a
value for this variable.
tddmonkey
  • 20,798
  • 10
  • 58
  • 67
John Fox
  • 747
  • 1
  • 13
  • 28

2 Answers2

5

I'm following the steps described here and I have faced a similar issue: https://learn.hashicorp.com/tutorials/terraform/aws-remote?in=terraform/certification-associate-tutorials

The mentioned error is shown to me if I choose the option "Terraform variable" while creating the variables in Terraform Cloud.

I solved the issue by selecting "Environment variable" while creating the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY variables.

1

seems that you forget about step "Configure workspace variables", you need to set two Environment Variables (AWS_SECRET_ACCESS_KEY, AWS_ACCESS_KEY_ID) and after that, all should work as expected.

zombi_man
  • 1,804
  • 3
  • 16
  • 22
  • I think I found the issue - the issue was in the example code, and this commit should fix it: https://github.com/hashicorp/tfc-guide-example/pull/106 You could update your GitHub fork, and everything should works as expected. – zombi_man Aug 15 '20 at 21:37