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

Remote terraforom plan reports missing input vars #23115

Closed
imranismail opened this issue Oct 18, 2019 · 5 comments · Fixed by #23122
Closed

Remote terraforom plan reports missing input vars #23115

imranismail opened this issue Oct 18, 2019 · 5 comments · Fixed by #23122
Labels
regression v0.12 Issues (primarily bugs) reported against v0.12 releases

Comments

@imranismail
Copy link

Hi,

I'm trying to run terraform plan on a remote backend (terraform cloud) with 0.12.11 however it always says variable not set. I suspect this is related to #21659

Terraform Version

Terraform v0.12.11
+ provider.aws v2.33.0

Terraform Configuration Files

terraform {
  backend "remote" {
    organization = "fave"

    workspaces {
      prefix = "data-pipeline_staging_main_v1_"
    }
  }
}

provider "aws" {
  version = "~> 2.0"

  region     = var.aws_region
  access_key = var.aws_access_key
  secret_key = var.aws_secret_key

  assume_role {
    role_arn = var.aws_role_arn
  }
}

resource "aws_s3_bucket" "target" {
  bucket_prefix = "my-bucket"
  force_destroy = true
}

Debug Output

Crash Output

Error: No value for required variable

  on variables.tf line 1:
   1: variable "spotinst_token" {

The root module input variable "spotinst_token" 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 5:
   5: variable "spotinst_account" {

The root module input variable "spotinst_account" 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 9:
   9: variable "aws_access_key" {

The root module input variable "aws_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.


Error: No value for required variable

  on variables.tf line 13:
  13: variable "aws_secret_key" {

The root module input variable "aws_secret_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.


Error: No value for required variable

  on variables.tf line 17:
  17: variable "aws_region" {

The root module input variable "aws_region" 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 21:
  21: variable "aws_role_arn" {

The root module input variable "aws_role_arn" 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 25:
  25: variable "admin_role_arn" {

The root module input variable "admin_role_arn" 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 29:
  29: variable "accepter_vpc_id" {

The root module input variable "accepter_vpc_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.

Expected Behavior

Remote terraform plan should be run in the cloud where all variables are already set

Actual Behavior

Terraform plan reports missing variables

Steps to Reproduce

  1. terraform init with backend set to terraform cloud
  2. terraform plan

References

@lae
Copy link

lae commented Oct 18, 2019

I'm running into this same issue and earlier opened a ticket with Hashicorp support about it.

This doesn't just happen on a CLI-initialized terraform plan but also on a VCS-triggered plan. I'm not sure, but I think Terraform does generate a valid plan, then does something else that breaks? For me, it showed what changes would happen, correct variables and all, then errors out saying it couldn't find the input variables.

Edit: I just tried 0.12.10 and it works as-expected. So regression, I guess.

@WillBeebe
Copy link

WillBeebe commented Oct 18, 2019

We ran into this too, but there's a cure! You have to set vars for every variable you use. It's a bit annoying that in what's technically a patch release there was a breaking change, but oh well. From an interface perspective this makes a lot of sense. If like us, you set variables in the backend that aren't declared in the repo, you just have to give them defaults.

variable "some_var" {
  default = "sane default"
}

# for vars that don't have sane defaults
variable "who_killed_the_muffin_man" {
  default = null
}

@pselle pselle added v0.12 Issues (primarily bugs) reported against v0.12 releases regression labels Oct 18, 2019
@pselle
Copy link
Contributor

pselle commented Oct 18, 2019

Thanks for the reports! We're looking into this, and have a suspected source (#23040) but will update as we progress on our investigation. Thank you for noting a workaround, @WillBeebe!

@apparentlymart
Copy link
Contributor

apparentlymart commented Oct 18, 2019

Hi all! Thanks again for reporting this and sharing workarounds.

The fix for this regression is in the v0.12.12 release, which is now available for selection on Terraform Cloud.

Because this bug is an interaction between Terraform CLI and Terraform Cloud, it's unfortunately important to upgrade both your local CLI executable and the version selected on the remote workspace. v0.12.11 is not functional either as a remote operations client or within the Terraform Cloud remote execution environment.

@ghost
Copy link

ghost commented Nov 18, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Nov 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
regression v0.12 Issues (primarily bugs) reported against v0.12 releases
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants