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 crash with panic: runtime error: index out of range #4886

Closed
ghost opened this issue Nov 13, 2019 · 3 comments · Fixed by GoogleCloudPlatform/magic-modules#2672
Closed
Assignees

Comments

@ghost
Copy link

ghost commented Nov 13, 2019

This issue was originally opened by @albertomardomingo as hashicorp/terraform#23356. It was migrated here as a result of the provider split. The original body of the issue is below.


Hi!

I'm getting a crash while running terraform with a datasource from the Google provider. I'm not sure wether this is a terraform bug, or a google provider bug, but since the crash log instructed me to post here, so here I am.

I got the crash while setting the self_link attribute in the google_compute_subnetwork datasource to the value I get from the gcp console. If I use the value from the terraform state, it works as expected. The difference i can see is that the one from the tfstate includes "https://www.googleapis.com/compute/v1/ , whereas the one from the console does not.

Terraform Version

Terraform v0.12.13
+ provider.google v2.19.0
+ provider.google-beta v2.19.0
+ provider.null v2.1.2
+ provider.random v2.2.1

Terraform Configuration Files

/*
    Store the tfstate in google cloud
 */
terraform {
  backend "gcs" {
    bucket  = "<redacted>"
    prefix  = "<redacted>"
  }
}


/******************************************
  Provider configuration
 *****************************************/
provider "google" {
  version     = "~> 2.19"
}

provider "google-beta" {
  version     = "~> 2.19"
}

data "google_compute_network" "shared-vpc"{
  name    = "<redacted>"
  project = "<redacted>"
}

data "google_compute_subnetwork" "subnetwork" {
  #self_link = "https://www.googleapis.com/compute/v1/projects/<redacted>/regions/europe-west1/subnetworks/<redacted>"
  self_link = "projects/<redacted>/regions/europe-west1/subnetworks/<redacted>"
}

Debug Output

Uploaded encrypted with hashicorp's public key to
https://gist.github.com/albertomardomingo/7373272783116640add3a0735d0fa408

Crash Output

Uploaded encrypted with hashicorp's public key to
https://gist.github.com/albertomardomingo/7373272783116640add3a0735d0fa408

Expected Behavior

I would expect either an error about the self_link being mal formed, or it being smart enough to recognize the format.

Actual Behavior

Terraform crashed when not providing https://www.googleapis.com/compute/v1/projects/<redacted>/regions/europe-west1/subnetworks/<redacted>

Steps to Reproduce

This hcl crashed every time for me, without having to provide a valid project, running the plan:

provider "google" {
  version     = "~> 2.19"
}

data "google_compute_network" "shared-vpc"{
  name    = "some-network"
  project = "some-project"
}

data "google_compute_subnetwork" "subnetwork" {
  self_link = "projects/some-project/regions/europe-west1/subnetworks/subnetwork"
}

Running

terraform init
terraform plan

the plan crashes.

Additional Context

Replacing the self_link with the fqdn "https://www.googleapis.com/compute/v1/projects/some-project/regions/europe-west1/subnetworks/subnetwork" does not crash terraform.

References

None that I could find

@rileykarson
Copy link
Collaborator

We expect the full value (prefixed with https://) in that field. I'll make it stop crashing, at least.

@albertomardomingo
Copy link

And error instead of a panick would be great, thank you! :-)

@ghost
Copy link
Author

ghost commented Dec 19, 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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Dec 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants