Skip to content

feat!: Deduplicate IAM for cloudservices service agent#1016

Open
gorge511 wants to merge 1 commit intoterraform-google-modules:mainfrom
gorge511:share_vpc_count_fix
Open

feat!: Deduplicate IAM for cloudservices service agent#1016
gorge511 wants to merge 1 commit intoterraform-google-modules:mainfrom
gorge511:share_vpc_count_fix

Conversation

@gorge511
Copy link
Contributor

@gorge511 gorge511 commented Nov 6, 2025

BREAKING CHANGE: Terraform will remove the IAM for cloudservices service agent and return it on the next run. Can be avoided with removing all the duplicated IAM resources from terraform state manually.

Previous code was creating duplicated IAM for cloudservices service agent. It doesn't matter when creating, but it matters when removing api from active apis list. Then it remove all the IAM for the cloudservices service agent and it gets fixed only with subsequent terraform apply.

See the plan below with two active apis. It creates two identical iam_member resources.

# module.shared_vpc_access.google_compute_subnetwork_iam_member.cloudservices_shared_vpc_subnet_users[0] will be created
+ resource "google_compute_subnetwork_iam_member" "cloudservices_shared_vpc_subnet_users" {
    + etag       = (known after apply)
    + id         = (known after apply)
    + member     = "serviceAccount:1234567890@cloudservices.gserviceaccount.com"
    + project    = "my-host-project-1234"
    + region     = "europe-west1"
    + role       = "roles/compute.networkUser"
    + subnetwork = "subnet1"
  }
# module.shared_vpc_access.google_compute_subnetwork_iam_member.cloudservices_shared_vpc_subnet_users[1] will be created
+ resource "google_compute_subnetwork_iam_member" "cloudservices_shared_vpc_subnet_users" {
    + etag       = (known after apply)
    + id         = (known after apply)
    + member     = "serviceAccount:1234567890@cloudservices.gserviceaccount.com"
    + project    = "my-host-project-1234"
    + region     = "europe-west1"
    + role       = "roles/compute.networkUser"
    + subnetwork = "subnet1"
  }

@gorge511 gorge511 requested review from a team and imrannayer as code owners November 6, 2025 21:12
@github-actions
Copy link

github-actions bot commented Jan 5, 2026

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Stale label Jan 5, 2026
@gorge511
Copy link
Contributor Author

gorge511 commented Jan 5, 2026

Hi @imrannayer, can you please check this PR?

@github-actions github-actions bot removed the Stale label Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant