diff --git a/.changelog/9760.txt b/.changelog/9760.txt new file mode 100644 index 00000000000..535c637544e --- /dev/null +++ b/.changelog/9760.txt @@ -0,0 +1,3 @@ +```release-note:new-resource +`google_network_security_address_group_iam_*` +``` diff --git a/google/provider/provider_mmv1_resources.go b/google/provider/provider_mmv1_resources.go index 3555469c190..b5e17d078c8 100644 --- a/google/provider/provider_mmv1_resources.go +++ b/google/provider/provider_mmv1_resources.go @@ -334,6 +334,7 @@ var generatedIAMDatasources = map[string]*schema.Resource{ "google_iap_web_region_backend_service_iam_policy": tpgiamresource.DataSourceIamPolicy(iap.IapWebRegionBackendServiceIamSchema, iap.IapWebRegionBackendServiceIamUpdaterProducer), "google_iap_web_type_app_engine_iam_policy": tpgiamresource.DataSourceIamPolicy(iap.IapWebTypeAppEngineIamSchema, iap.IapWebTypeAppEngineIamUpdaterProducer), "google_iap_web_type_compute_iam_policy": tpgiamresource.DataSourceIamPolicy(iap.IapWebTypeComputeIamSchema, iap.IapWebTypeComputeIamUpdaterProducer), + "google_network_security_address_group_iam_policy": tpgiamresource.DataSourceIamPolicy(networksecurity.NetworkSecurityProjectAddressGroupIamSchema, networksecurity.NetworkSecurityProjectAddressGroupIamUpdaterProducer), "google_notebooks_instance_iam_policy": tpgiamresource.DataSourceIamPolicy(notebooks.NotebooksInstanceIamSchema, notebooks.NotebooksInstanceIamUpdaterProducer), "google_notebooks_runtime_iam_policy": tpgiamresource.DataSourceIamPolicy(notebooks.NotebooksRuntimeIamSchema, notebooks.NotebooksRuntimeIamUpdaterProducer), "google_privateca_ca_pool_iam_policy": tpgiamresource.DataSourceIamPolicy(privateca.PrivatecaCaPoolIamSchema, privateca.PrivatecaCaPoolIamUpdaterProducer), @@ -379,8 +380,8 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{ // Resources // Generated resources: 367 -// Generated IAM resources: 219 -// Total generated resources: 586 +// Generated IAM resources: 222 +// Total generated resources: 589 var generatedResources = map[string]*schema.Resource{ "google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(), "google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(), @@ -830,6 +831,9 @@ var generatedResources = map[string]*schema.Resource{ "google_network_security_address_group": networksecurity.ResourceNetworkSecurityAddressGroup(), "google_network_security_gateway_security_policy": networksecurity.ResourceNetworkSecurityGatewaySecurityPolicy(), "google_network_security_gateway_security_policy_rule": networksecurity.ResourceNetworkSecurityGatewaySecurityPolicyRule(), + "google_network_security_address_group_iam_binding": tpgiamresource.ResourceIamBinding(networksecurity.NetworkSecurityProjectAddressGroupIamSchema, networksecurity.NetworkSecurityProjectAddressGroupIamUpdaterProducer, networksecurity.NetworkSecurityProjectAddressGroupIdParseFunc), + "google_network_security_address_group_iam_member": tpgiamresource.ResourceIamMember(networksecurity.NetworkSecurityProjectAddressGroupIamSchema, networksecurity.NetworkSecurityProjectAddressGroupIamUpdaterProducer, networksecurity.NetworkSecurityProjectAddressGroupIdParseFunc), + "google_network_security_address_group_iam_policy": tpgiamresource.ResourceIamPolicy(networksecurity.NetworkSecurityProjectAddressGroupIamSchema, networksecurity.NetworkSecurityProjectAddressGroupIamUpdaterProducer, networksecurity.NetworkSecurityProjectAddressGroupIdParseFunc), "google_network_security_url_lists": networksecurity.ResourceNetworkSecurityUrlLists(), "google_network_services_edge_cache_keyset": networkservices.ResourceNetworkServicesEdgeCacheKeyset(), "google_network_services_edge_cache_origin": networkservices.ResourceNetworkServicesEdgeCacheOrigin(), diff --git a/google/services/networksecurity/iam_network_security_address_group.go b/google/services/networksecurity/iam_network_security_address_group.go new file mode 100644 index 00000000000..6bde019aac0 --- /dev/null +++ b/google/services/networksecurity/iam_network_security_address_group.go @@ -0,0 +1,245 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** Type: MMv1 *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + +package networksecurity + +import ( + "fmt" + + "github.com/hashicorp/errwrap" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "google.golang.org/api/cloudresourcemanager/v1" + + "github.com/hashicorp/terraform-provider-google/google/tpgiamresource" + "github.com/hashicorp/terraform-provider-google/google/tpgresource" + transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" +) + +var NetworkSecurityProjectAddressGroupIamSchema = map[string]*schema.Schema{ + "project": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ForceNew: true, + }, + "location": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ForceNew: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, + }, +} + +type NetworkSecurityProjectAddressGroupIamUpdater struct { + project string + location string + name string + d tpgresource.TerraformResourceData + Config *transport_tpg.Config +} + +func NetworkSecurityProjectAddressGroupIamUpdaterProducer(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (tpgiamresource.ResourceIamUpdater, error) { + values := make(map[string]string) + + project, _ := tpgresource.GetProject(d, config) + if project != "" { + if err := d.Set("project", project); err != nil { + return nil, fmt.Errorf("Error setting project: %s", err) + } + } + values["project"] = project + location, _ := tpgresource.GetLocation(d, config) + if location != "" { + if err := d.Set("location", location); err != nil { + return nil, fmt.Errorf("Error setting location: %s", err) + } + } + values["location"] = location + if v, ok := d.GetOk("name"); ok { + values["name"] = v.(string) + } + + // We may have gotten either a long or short name, so attempt to parse long name if possible + m, err := tpgresource.GetImportIdQualifiers([]string{"projects/(?P[^/]+)/locations/(?P[^/]+)/addressGroups/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)"}, d, config, d.Get("name").(string)) + if err != nil { + return nil, err + } + + for k, v := range m { + values[k] = v + } + + u := &NetworkSecurityProjectAddressGroupIamUpdater{ + project: values["project"], + location: values["location"], + name: values["name"], + d: d, + Config: config, + } + + if err := d.Set("project", u.project); err != nil { + return nil, fmt.Errorf("Error setting project: %s", err) + } + if err := d.Set("location", u.location); err != nil { + return nil, fmt.Errorf("Error setting location: %s", err) + } + if err := d.Set("name", u.GetResourceId()); err != nil { + return nil, fmt.Errorf("Error setting name: %s", err) + } + + return u, nil +} + +func NetworkSecurityProjectAddressGroupIdParseFunc(d *schema.ResourceData, config *transport_tpg.Config) error { + values := make(map[string]string) + + project, _ := tpgresource.GetProject(d, config) + if project != "" { + values["project"] = project + } + + location, _ := tpgresource.GetLocation(d, config) + if location != "" { + values["location"] = location + } + + m, err := tpgresource.GetImportIdQualifiers([]string{"projects/(?P[^/]+)/locations/(?P[^/]+)/addressGroups/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)"}, d, config, d.Id()) + if err != nil { + return err + } + + for k, v := range m { + values[k] = v + } + + u := &NetworkSecurityProjectAddressGroupIamUpdater{ + project: values["project"], + location: values["location"], + name: values["name"], + d: d, + Config: config, + } + if err := d.Set("name", u.GetResourceId()); err != nil { + return fmt.Errorf("Error setting name: %s", err) + } + d.SetId(u.GetResourceId()) + return nil +} + +func (u *NetworkSecurityProjectAddressGroupIamUpdater) GetResourceIamPolicy() (*cloudresourcemanager.Policy, error) { + url, err := u.qualifyProjectAddressGroupUrl("getIamPolicy") + if err != nil { + return nil, err + } + + project, err := tpgresource.GetProject(u.d, u.Config) + if err != nil { + return nil, err + } + var obj map[string]interface{} + + userAgent, err := tpgresource.GenerateUserAgentString(u.d, u.Config.UserAgent) + if err != nil { + return nil, err + } + + policy, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: u.Config, + Method: "GET", + Project: project, + RawURL: url, + UserAgent: userAgent, + Body: obj, + }) + if err != nil { + return nil, errwrap.Wrapf(fmt.Sprintf("Error retrieving IAM policy for %s: {{err}}", u.DescribeResource()), err) + } + + out := &cloudresourcemanager.Policy{} + err = tpgresource.Convert(policy, out) + if err != nil { + return nil, errwrap.Wrapf("Cannot convert a policy to a resource manager policy: {{err}}", err) + } + + return out, nil +} + +func (u *NetworkSecurityProjectAddressGroupIamUpdater) SetResourceIamPolicy(policy *cloudresourcemanager.Policy) error { + json, err := tpgresource.ConvertToMap(policy) + if err != nil { + return err + } + + obj := make(map[string]interface{}) + obj["policy"] = json + + url, err := u.qualifyProjectAddressGroupUrl("setIamPolicy") + if err != nil { + return err + } + project, err := tpgresource.GetProject(u.d, u.Config) + if err != nil { + return err + } + + userAgent, err := tpgresource.GenerateUserAgentString(u.d, u.Config.UserAgent) + if err != nil { + return err + } + + _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: u.Config, + Method: "POST", + Project: project, + RawURL: url, + UserAgent: userAgent, + Body: obj, + Timeout: u.d.Timeout(schema.TimeoutCreate), + }) + if err != nil { + return errwrap.Wrapf(fmt.Sprintf("Error setting IAM policy for %s: {{err}}", u.DescribeResource()), err) + } + + return nil +} + +func (u *NetworkSecurityProjectAddressGroupIamUpdater) qualifyProjectAddressGroupUrl(methodIdentifier string) (string, error) { + urlTemplate := fmt.Sprintf("{{NetworkSecurityBasePath}}%s:%s", fmt.Sprintf("projects/%s/locations/%s/addressGroups/%s", u.project, u.location, u.name), methodIdentifier) + url, err := tpgresource.ReplaceVars(u.d, u.Config, urlTemplate) + if err != nil { + return "", err + } + return url, nil +} + +func (u *NetworkSecurityProjectAddressGroupIamUpdater) GetResourceId() string { + return fmt.Sprintf("projects/%s/locations/%s/addressGroups/%s", u.project, u.location, u.name) +} + +func (u *NetworkSecurityProjectAddressGroupIamUpdater) GetMutexKey() string { + return fmt.Sprintf("iam-networksecurity-projectaddressgroup-%s", u.GetResourceId()) +} + +func (u *NetworkSecurityProjectAddressGroupIamUpdater) DescribeResource() string { + return fmt.Sprintf("networksecurity projectaddressgroup %q", u.GetResourceId()) +} diff --git a/google/services/networksecurity/iam_network_security_address_group_generated_test.go b/google/services/networksecurity/iam_network_security_address_group_generated_test.go new file mode 100644 index 00000000000..cfe4dc4e21a --- /dev/null +++ b/google/services/networksecurity/iam_network_security_address_group_generated_test.go @@ -0,0 +1,218 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** Type: MMv1 *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + +package networksecurity_test + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + "github.com/hashicorp/terraform-provider-google/google/acctest" + "github.com/hashicorp/terraform-provider-google/google/envvar" +) + +func TestAccNetworkSecurityProjectAddressGroupIamBindingGenerated(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "random_suffix": acctest.RandString(t, 10), + "role": "roles/compute.networkAdmin", + "project": envvar.GetTestProjectFromEnv(), + } + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + Steps: []resource.TestStep{ + { + Config: testAccNetworkSecurityProjectAddressGroupIamBinding_basicGenerated(context), + }, + { + // Test Iam Binding update + Config: testAccNetworkSecurityProjectAddressGroupIamBinding_updateGenerated(context), + }, + }, + }) +} + +func TestAccNetworkSecurityProjectAddressGroupIamMemberGenerated(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "random_suffix": acctest.RandString(t, 10), + "role": "roles/compute.networkAdmin", + "project": envvar.GetTestProjectFromEnv(), + } + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + Steps: []resource.TestStep{ + { + // Test Iam Member creation (no update for member, no need to test) + Config: testAccNetworkSecurityProjectAddressGroupIamMember_basicGenerated(context), + }, + }, + }) +} + +func TestAccNetworkSecurityProjectAddressGroupIamPolicyGenerated(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "random_suffix": acctest.RandString(t, 10), + "role": "roles/compute.networkAdmin", + "project": envvar.GetTestProjectFromEnv(), + } + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + Steps: []resource.TestStep{ + { + Config: testAccNetworkSecurityProjectAddressGroupIamPolicy_basicGenerated(context), + Check: resource.TestCheckResourceAttrSet("data.google_network_security_address_group_iam_policy.foo", "policy_data"), + }, + { + Config: testAccNetworkSecurityProjectAddressGroupIamPolicy_emptyBinding(context), + }, + }, + }) +} + +func testAccNetworkSecurityProjectAddressGroupIamMember_basicGenerated(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_network_security_address_group" "default" { + name = "tf-test-my-project-address-group%{random_suffix}" + parent = "projects/%{project}" + location = "us-central1" + type = "IPV4" + capacity = "100" + items = ["208.80.154.224/32"] +} + +resource "google_network_security_address_group_iam_member" "foo" { +project = "%{project}" +location = google_network_security_address_group.default.location +name = google_network_security_address_group.default.name + role = "%{role}" + member = "user:admin@hashicorptest.com" +} +`, context) +} + +func testAccNetworkSecurityProjectAddressGroupIamPolicy_basicGenerated(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_network_security_address_group" "default" { + name = "tf-test-my-project-address-group%{random_suffix}" + parent = "projects/%{project}" + location = "us-central1" + type = "IPV4" + capacity = "100" + items = ["208.80.154.224/32"] +} + +data "google_iam_policy" "foo" { + binding { + role = "%{role}" + members = ["user:admin@hashicorptest.com"] + } +} + +resource "google_network_security_address_group_iam_policy" "foo" { +project = "%{project}" +location = google_network_security_address_group.default.location +name = google_network_security_address_group.default.name + policy_data = data.google_iam_policy.foo.policy_data +} + +data "google_network_security_address_group_iam_policy" "foo" { +project = "%{project}" +location = google_network_security_address_group.default.location +name = google_network_security_address_group.default.name + depends_on = [ + google_network_security_address_group_iam_policy.foo + ] +} +`, context) +} + +func testAccNetworkSecurityProjectAddressGroupIamPolicy_emptyBinding(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_network_security_address_group" "default" { + name = "tf-test-my-project-address-group%{random_suffix}" + parent = "projects/%{project}" + location = "us-central1" + type = "IPV4" + capacity = "100" + items = ["208.80.154.224/32"] +} + +data "google_iam_policy" "foo" { +} + +resource "google_network_security_address_group_iam_policy" "foo" { +project = "%{project}" +location = google_network_security_address_group.default.location +name = google_network_security_address_group.default.name + policy_data = data.google_iam_policy.foo.policy_data +} +`, context) +} + +func testAccNetworkSecurityProjectAddressGroupIamBinding_basicGenerated(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_network_security_address_group" "default" { + name = "tf-test-my-project-address-group%{random_suffix}" + parent = "projects/%{project}" + location = "us-central1" + type = "IPV4" + capacity = "100" + items = ["208.80.154.224/32"] +} + +resource "google_network_security_address_group_iam_binding" "foo" { +project = "%{project}" +location = google_network_security_address_group.default.location +name = google_network_security_address_group.default.name + role = "%{role}" + members = ["user:admin@hashicorptest.com"] +} +`, context) +} + +func testAccNetworkSecurityProjectAddressGroupIamBinding_updateGenerated(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_network_security_address_group" "default" { + name = "tf-test-my-project-address-group%{random_suffix}" + parent = "projects/%{project}" + location = "us-central1" + type = "IPV4" + capacity = "100" + items = ["208.80.154.224/32"] +} + +resource "google_network_security_address_group_iam_binding" "foo" { +project = "%{project}" +location = google_network_security_address_group.default.location +name = google_network_security_address_group.default.name + role = "%{role}" + members = ["user:admin@hashicorptest.com", "user:gterraformtest1@gmail.com"] +} +`, context) +} diff --git a/website/docs/d/network_security_address_group_iam_policy.html.markdown b/website/docs/d/network_security_address_group_iam_policy.html.markdown new file mode 100644 index 00000000000..388f37d81d3 --- /dev/null +++ b/website/docs/d/network_security_address_group_iam_policy.html.markdown @@ -0,0 +1,54 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file in +# .github/CONTRIBUTING.md. +# +# ---------------------------------------------------------------------------- +subcategory: "Network security" +description: |- + A datasource to retrieve the IAM policy state for Network security ProjectAddressGroup +--- + + +# `google_network_security_address_group_iam_policy` +Retrieves the current IAM policy data for projectaddressgroup + + + +## example + +```hcl +data "google_network_security_address_group_iam_policy" "policy" { +project = "%{project}" +location = google_network_security_address_group.default.location +name = google_network_security_address_group.default.name +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) Used to find the parent resource to bind the IAM policy to +* `location` - (Required) The location of the gateway security policy. + Used to find the parent resource to bind the IAM policy to + +* `project` - (Optional) The ID of the project in which the resource belongs. + If it is not provided, the project will be parsed from the identifier of the parent resource. If no project is provided in the parent identifier and no project is specified, the provider project is used. + +## Attributes Reference + +The attributes are exported: + +* `etag` - (Computed) The etag of the IAM policy. + +* `policy_data` - (Required only by `google_network_security_address_group_iam_policy`) The policy data generated by + a `google_iam_policy` data source. diff --git a/website/docs/r/network_security_address_group_iam.html.markdown b/website/docs/r/network_security_address_group_iam.html.markdown new file mode 100644 index 00000000000..0bbabb15b2c --- /dev/null +++ b/website/docs/r/network_security_address_group_iam.html.markdown @@ -0,0 +1,155 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file in +# .github/CONTRIBUTING.md. +# +# ---------------------------------------------------------------------------- +subcategory: "Network security" +description: |- + Collection of resources to manage IAM policy for Network security ProjectAddressGroup +--- + +# IAM policy for Network security ProjectAddressGroup +Three different resources help you manage your IAM policy for Network security ProjectAddressGroup. Each of these resources serves a different use case: + +* `google_network_security_address_group_iam_policy`: Authoritative. Sets the IAM policy for the projectaddressgroup and replaces any existing policy already attached. +* `google_network_security_address_group_iam_binding`: Authoritative for a given role. Updates the IAM policy to grant a role to a list of members. Other roles within the IAM policy for the projectaddressgroup are preserved. +* `google_network_security_address_group_iam_member`: Non-authoritative. Updates the IAM policy to grant a role to a new member. Other members for the role for the projectaddressgroup are preserved. + +A data source can be used to retrieve policy data in advent you do not need creation + +* `google_network_security_address_group_iam_policy`: Retrieves the IAM policy for the projectaddressgroup + +~> **Note:** `google_network_security_address_group_iam_policy` **cannot** be used in conjunction with `google_network_security_address_group_iam_binding` and `google_network_security_address_group_iam_member` or they will fight over what your policy should be. + +~> **Note:** `google_network_security_address_group_iam_binding` resources **can be** used in conjunction with `google_network_security_address_group_iam_member` resources **only if** they do not grant privilege to the same role. + + + + +## google\_network\_security\_address\_group\_iam\_policy + +```hcl +data "google_iam_policy" "admin" { + binding { + role = "roles/compute.networkAdmin" + members = [ + "user:jane@example.com", + ] + } +} + +resource "google_network_security_address_group_iam_policy" "policy" { +project = "%{project}" +location = google_network_security_address_group.default.location +name = google_network_security_address_group.default.name + policy_data = data.google_iam_policy.admin.policy_data +} +``` + +## google\_network\_security\_address\_group\_iam\_binding + +```hcl +resource "google_network_security_address_group_iam_binding" "binding" { +project = "%{project}" +location = google_network_security_address_group.default.location +name = google_network_security_address_group.default.name + role = "roles/compute.networkAdmin" + members = [ + "user:jane@example.com", + ] +} +``` + +## google\_network\_security\_address\_group\_iam\_member + +```hcl +resource "google_network_security_address_group_iam_member" "member" { +project = "%{project}" +location = google_network_security_address_group.default.location +name = google_network_security_address_group.default.name + role = "roles/compute.networkAdmin" + member = "user:jane@example.com" +} +``` + + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) Used to find the parent resource to bind the IAM policy to +* `location` - (Required) The location of the gateway security policy. + Used to find the parent resource to bind the IAM policy to + +* `project` - (Optional) The ID of the project in which the resource belongs. + If it is not provided, the project will be parsed from the identifier of the parent resource. If no project is provided in the parent identifier and no project is specified, the provider project is used. + +* `member/members` - (Required) Identities that will be granted the privilege in `role`. + Each entry can have one of the following values: + * **allUsers**: A special identifier that represents anyone who is on the internet; with or without a Google account. + * **allAuthenticatedUsers**: A special identifier that represents anyone who is authenticated with a Google account or a service account. + * **user:{emailid}**: An email address that represents a specific Google account. For example, alice@gmail.com or joe@example.com. + * **serviceAccount:{emailid}**: An email address that represents a service account. For example, my-other-app@appspot.gserviceaccount.com. + * **group:{emailid}**: An email address that represents a Google group. For example, admins@example.com. + * **domain:{domain}**: A G Suite domain (primary, instead of alias) name that represents all the users of that domain. For example, google.com or example.com. + * **projectOwner:projectid**: Owners of the given project. For example, "projectOwner:my-example-project" + * **projectEditor:projectid**: Editors of the given project. For example, "projectEditor:my-example-project" + * **projectViewer:projectid**: Viewers of the given project. For example, "projectViewer:my-example-project" + +* `role` - (Required) The role that should be applied. Only one + `google_network_security_address_group_iam_binding` can be used per role. Note that custom roles must be of the format + `[projects|organizations]/{parent-name}/roles/{role-name}`. + +* `policy_data` - (Required only by `google_network_security_address_group_iam_policy`) The policy data generated by + a `google_iam_policy` data source. + +## Attributes Reference + +In addition to the arguments listed above, the following computed attributes are +exported: + +* `etag` - (Computed) The etag of the IAM policy. + +## Import + +For all import syntaxes, the "resource in question" can take any of the following forms: + +* projects/{{project}}/locations/{{location}}/addressGroups/{{name}} +* {{project}}/{{location}}/{{name}} +* {{location}}/{{name}} +* {{name}} + +Any variables not passed in the import command will be taken from the provider configuration. + +Network security projectaddressgroup IAM resources can be imported using the resource identifiers, role, and member. + +IAM member imports use space-delimited identifiers: the resource in question, the role, and the member identity, e.g. +``` +$ terraform import google_network_security_address_group_iam_member.editor "projects/{{project}}/locations/{{location}}/addressGroups/{{project_address_group}} roles/compute.networkAdmin user:jane@example.com" +``` + +IAM binding imports use space-delimited identifiers: the resource in question and the role, e.g. +``` +$ terraform import google_network_security_address_group_iam_binding.editor "projects/{{project}}/locations/{{location}}/addressGroups/{{project_address_group}} roles/compute.networkAdmin" +``` + +IAM policy imports use the identifier of the resource in question, e.g. +``` +$ terraform import google_network_security_address_group_iam_policy.editor projects/{{project}}/locations/{{location}}/addressGroups/{{project_address_group}} +``` + +-> **Custom Roles**: If you're importing a IAM resource with a custom role, make sure to use the + full name of the custom role, e.g. `[projects/my-project|organizations/my-org]/roles/my-custom-role`. + +## User Project Overrides + +This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override).