hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.25k stars 1.7k forks source link

`google_clouddomains_registration` is currently unusable on import #18124

Open jeremad opened 2 months ago

jeremad commented 2 months ago

Community Note

Terraform Version & Provider Version(s)

Terraform v1.8.3 on linux_amd64

Affected Resource(s)

google_clouddomains_registration

Terraform Configuration

resource "google_clouddomains_registration" "example" {
  domain_name = "xxx.yyy"
  location    = "global"
  yearly_price {}
  management_settings {
    transfer_lock_state = "LOCKED"
  }
  dns_settings {
    custom_dns {
      name_servers = [
        "...",
      ]
    }
  }
  contact_settings {
    privacy = "PRIVATE_CONTACT_DATA"
    registrant_contact {
      phone_number = "+000"
      email        = "zzz@xxx.yyy"
      postal_address {
        region_code   = "..."
        postal_code   = "..."
        locality      = "..."
        address_lines = ["..."]
        recipients    = ["..."]
      }
    }
    admin_contact {
      phone_number = "+000"
      email        = "zzz@xxx.yyy"
      postal_address {
        region_code   = "..."
        postal_code   = "..."
        locality      = "..."
        address_lines = ["..."]
        recipients    = ["..."]
      }
    }
    technical_contact {
      phone_number = "+000"
      email        = "zzz@xxx.yyy"
      postal_address {
        region_code   = "..."
        postal_code   = "..."
        locality      = "..."
        address_lines = ["..."]
        recipients    = ["..."]
      }
    }
  }
}

Debug Output

No response

Expected Behavior

When I import an existing resource terraform import google_clouddomains_registration.example global/xxx.yyy with a configuration copy/pasted directly from the GCP console, I can apply my configuration without a forces replacement.

yearly_price should absolutely not be a required argument, but rather an attribute.

resource "google_clouddomains_registration" "example" {
      ~ create_time             = "2023-02-08T08:12:39.881634216Z" -> (known after apply)
      ~ effective_labels        = {} -> (known after apply)
      ~ expire_time             = "2025-02-05T23:59:59Z" -> (known after apply)
      ~ id                      = "projects/.../locations/global/registrations/xxx.yyy" -> (known after apply)
      ~ issues                  = [] -> (known after apply)
      - labels                  = {} -> null
      ~ name                    = "projects/.../locations/global/registrations/xxx.yyy" -> (known after apply)
      + register_failure_reason = (known after apply)
      ~ state                   = "ACTIVE" -> (known after apply)
      ~ supported_privacy       = [
          - "PRIVATE_CONTACT_DATA",
          - "PUBLIC_CONTACT_DATA",
        ] -> (known after apply)
      ~ terraform_labels        = {} -> (known after apply)
        # (3 unchanged attributes hidden)

      ~ contact_settings {
            # (1 unchanged attribute hidden)

          ~ admin_contact {
              + phone_number = "+000" # forces replacement
                # (2 unchanged attributes hidden)

              + postal_address { # forces replacement
                  + address_lines = [ # forces replacement
                      + "...",
                    ]
                  + locality      = "..." # forces replacement
                  + postal_code   = "..." # forces replacement
                  + recipients    = [ # forces replacement
                      + "...",
                    ]
                  + region_code   = "..." # forces replacement
                }
            }

          ~ registrant_contact {
              + phone_number = "+000" # forces replacement
                # (2 unchanged attributes hidden)

              + postal_address { # forces replacement
                  + address_lines = [ # forces replacement
                      + "...",
                    ]
                  + locality      = "..." # forces replacement
                  + postal_code   = "..." # forces replacement
                  + recipients    = [ # forces replacement
                      + "...",
                    ]
                  + region_code   = "..." # forces replacement
                }
            }

          ~ technical_contact {
              + phone_number = "+000" # forces replacement
                # (2 unchanged attributes hidden)

              + postal_address { # forces replacement
                  + address_lines = [ # forces replacement
                      + "...",
                    ]
                  + locality      = "..." # forces replacement
                  + postal_code   = "..." # forces replacement
                  + recipients    = [ # forces replacement
                      + "...",
                    ]
                  + region_code   = "..." # forces replacement
                }
            }
        }

      ~ management_settings {
          + preferred_renewal_method = (known after apply)
          ~ renewal_method           = "AUTOMATIC_RENEWAL" -> (known after apply)
            # (1 unchanged attribute hidden)
        }

      + yearly_price {} # forces replacement

        # (1 unchanged block hidden)
    }

Plan: 1 to add, 0 to change, 1 to destroy.

Actual Behavior

No response

Steps to reproduce

  1. terraform import google_clouddomains_registration.example global/xxx.yyy
  2. terraform plan -target google_clouddomains_registration.example

Important Factoids

No response

References

No response

ggtisc commented 2 months ago

Hi @jeremad please share the output that you got after running the terraform import google_clouddomains_registration.example

Also confirm if you are using only the command terraform import google_clouddomains_registration.example or this other one terraform import google_clouddomains_registration.example xxx.yyy

jeremad commented 1 month ago

Here is the output:

...
google_clouddomains_registration.example: Import prepared!
  Prepared google_clouddomains_registration for import
...
Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.

Here is the command: terraform import google_clouddomains_registration.example global/xxx.yyy,

Indeed I miswrote that in the original issue, it's fixed!