cycloidio / terracognita

Reads from existing public and private cloud providers (reverse Terraform) and generates your infrastructure as code on Terraform configuration
MIT License
2.17k stars 163 forks source link

google_compute_instance nat_ip #189

Open FredericHeem opened 3 years ago

FredericHeem commented 3 years ago

General information:

Describe the bug:

The generated code for google_compute_instance contains the extraneous field networkInterfaces[0].accessConfigs[0].natIP which causes an issue when deploying

Log message

Error: Error creating instance: googleapi: Error 400: Invalid value for field 'resource.networkInterfaces[0].accessConfigs[0].natIP': '34.91.94.74'. The specified external IP address '34.91.94.74' was not found in region 'europe-west4'., invalid

  on resources.tf line 25, in resource "google_compute_instance" "ZipaG":
  25: resource "google_compute_instance" "ZipaG" {

When this field is removed, terraform apply is successful.

xescugc commented 3 years ago

For what I can see this is "valid", you can set that value https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#nat_ip so it's not an issue that we are setting an Attribute(https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#attributes-reference). I was just checking and discarding things hehe.

The issue is that the value is "invalid" but that value was returned from the API so it was read from Google. IDK how we are reading a value that is "invalid", is it possible that something else is invalid/missing on the google_compute_instance so terraform apply cannot make the right link?