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

Provider tries to incorrectly set `initial_group_config` after import of `google_cloud_identity_group` #13515

Open spkane opened 1 year ago

spkane commented 1 year ago

Community Note

Terraform Version

Terraform v1.3.1
on linux_amd64
+ provider registry.terraform.io/dnsimple/dnsimple v0.5.3
+ provider registry.terraform.io/dopplerhq/doppler v1.1.6
+ provider registry.terraform.io/hashicorp/aws v4.50.0
+ provider registry.terraform.io/hashicorp/external v2.2.3
+ provider registry.terraform.io/hashicorp/google v4.49.0
+ provider registry.terraform.io/hashicorp/googleworkspace v0.7.0
+ provider registry.terraform.io/hashicorp/local v2.2.3
+ provider registry.terraform.io/hashicorp/null v3.1.1
+ provider registry.terraform.io/hashicorp/random v3.4.3
+ provider registry.terraform.io/hashicorp/template v2.2.0
+ provider registry.terraform.io/integrations/github v5.3.0
+ provider registry.terraform.io/spacelift-io/spacelift v0.1.37

Affected Resource(s)

Terraform Configuration Files

resource "google_cloud_identity_group" "everyone" {
  description  = "employees + contractors"
  display_name = "everyone"

  parent               = "customers/${var.customer_id}"

  group_key {
    id = "everyone@${var.domain}"
  }

  labels = {
    "cloudidentity.googleapis.com/groups.discussion_forum" = ""
  }
}

Debug Output

Panic Output

N/A

Expected Behavior

$ terraform import google_cloud_identity_group.everyone groups/99omg42n3sillyf
...
Import successful!
$ terraform apply
...
No changes. Your infrastructure matches the configuration.

Actual Behavior

$ terraform import google_cloud_identity_group.everyone groups/99omg42n3sillyf
...
Import successful!
$ terraform apply
...
Terraform used the selected providers to generate the
following execution plan. Resource actions are indicated with
the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # google_cloud_identity_group.contractors will be updated in-place
  ~ resource "google_cloud_identity_group" "everyone" {
        id                   = "groups/99omg42n3sillyf"
      + initial_group_config = "EMPTY"
        name                 = "groups/99omg42n3sillyf"
        # (6 unchanged attributes hidden)

        # (2 unchanged blocks hidden)
    }

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

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

google_cloud_identity_group.contractors: Modifying... [id=groups/02pta16n3woggyf]
╷
│ Error: Error updating Group "groups/02pta16n3woggyf": googleapi: Error 400: Request contains an invalid argument.
│ 
│   with google_cloud_identity_group.contractors,
│   on groups.tf line 40, in resource "google_cloud_identity_group" "contractors":
│   40: resource "google_cloud_identity_group" "contractors" {
│ 
╵
Releasing state lock. This may take a few moments...
$ terraform apply
...
No changes. Your infrastructure matches the configuration.

Steps to Reproduce

  1. terraform import google_cloud_identity_group.everyone groups/99omg42n3sillyf
  2. terraform apply
  3. terraform apply

Important Factoids

N/A

References

N/A

edwardmedia commented 1 year ago

Likely initial_group_config needs to be set Computed

rileykarson commented 1 year ago

Sending an explicit "EMPTY" to the API on create calls is likely required. Rather than Computed, we could consider setting the value to "EMPTY" in the import function, or in Read when the value is empty ("") or nil. We'd want to state in the docs that imported resources must always specify a value of "EMPTY" in that case (which, given what the field does, feels reasonable).

github-actions[bot] commented 1 year ago

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.

roaks3 commented 2 months ago

Re-opening because we now have 2 users claiming that the fix did not stick: https://github.com/GoogleCloudPlatform/magic-modules/pull/7348#issuecomment-1819948732 and https://github.com/GoogleCloudPlatform/magic-modules/pull/7348#issuecomment-2093015603.

cc @dawnbreak @nathou you can add any further details here instead of the PR.