Terraform-provider-google: Error with google_compute_address when an static IP already exists.

Created on 17 Jun 2017  ·  4Comments  ·  Source: hashicorp/terraform-provider-google

Terraform Version

Terraform v0.9.8

Affected Resource(s)

- google_compute_address

Expected Behavior

I already have an existent static IP on my networking with this name, which I want to refer in the instance resource.
I'm doing the following:

resource "google_compute_address" "vault-server-ip" { name = "vault-server-ip" }

and referencing on the instance:
access_config { // Static Vault Server IP nat_ip = "${google_compute_address.vault-server-ip.address}" }

Since I already have this Static IP on my network, it shoulds only referer this IP to the instance and keep the creation of the resources.

Actual Behavior

It tries to create an NEW ip with the same name which returns the following error:
`Error applying plan:
1 error(s) occurred:

  • google_compute_address.vault-server-ip: 1 error(s) occurred:
  • google_compute_address.vault-server-ip: Error creating address: googleapi: Error 409: The resource 'projects/dft-vault/regions/us-east1/addresses/vault-server-ip' already exists, alreadyExists
    `

Steps to Reproduce

  1. terraform apply

Important Factoids

Are there anything atypical about your accounts that we should know?
NO

References

NO

Most helpful comment

google_compute_address is an importable resource, so you can add an existing one to Terraform's state using the import command. It would look something like this for the configuration you posted:

terraform import google_compute_address.vault-server-ip vault-server-ip

In case you have other existing infrastructure in place - every importable resource is listed on the Importability page, and resources that require more than just a name to import have import instructions listed on their individual pages.

If a resource you'd like to import doesn't appear there, please file an issue so that we know that users want to import that type of resource!

All 4 comments

google_compute_address is an importable resource, so you can add an existing one to Terraform's state using the import command. It would look something like this for the configuration you posted:

terraform import google_compute_address.vault-server-ip vault-server-ip

In case you have other existing infrastructure in place - every importable resource is listed on the Importability page, and resources that require more than just a name to import have import instructions listed on their individual pages.

If a resource you'd like to import doesn't appear there, please file an issue so that we know that users want to import that type of resource!

Thanks @rileykarson !

Problem solved!

Glad to hear! :+1:

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!

Was this page helpful?
0 / 5 - 0 ratings