I am working on a automation flow which should accept the groups and service accounts and add them as members to a subnet in GCP. I am using the terraform resource "google_compute_subnetwork_iam_member" for this purpose.
According to its documentation (link below), terraform should preserve the previous members for the subnet when the configuration file is applied which contains only the new members. But when I apply the configuration, it destroys all the previous members and adds the new ones. Pls let me know if I am missing something
terraform resource name : google_compute_subnetwork_iam_member
Documentation link : https://www.terraform.io/docs/providers/google/r/compute_subnetwork_iam.html#google_compute_subnetwork_iam_member
**main.tf sample**
terraform {
backend "gcs" {
bucket = "bucketname"
project = "projectname"
prefix = "projectname/subnet_sharing/serviceprojectname"
}
}
provider "google" {
project = "projectname"
alias = "us-central1"
region = "us-central1"
}
resource "google_compute_subnetwork_iam_member" "gcp-group-name-manager-to-subnet-name" {
subnetwork = "subnetname"
role = "roles/compute.networkUser"
project = "project-name"
region = "us-central1"
member = "group:gcp-group-name-manager@domain.com"
}
Thanks
Sandeep