diff --git a/mmv1/products/dataplex/DataProduct.yaml b/mmv1/products/dataplex/DataProduct.yaml index 87ec8a14075a..98ee71219843 100644 --- a/mmv1/products/dataplex/DataProduct.yaml +++ b/mmv1/products/dataplex/DataProduct.yaml @@ -79,10 +79,23 @@ parameters: The ID of the data product. properties: + - name: 'name' + type: String + output: true + description: 'The relative resource name of the data product.' - name: 'uid' type: String output: true description: 'System generated unique ID.' + - name: 'accessApprovalConfig' + type: NestedObject + description: 'Configuration for access approval for the data product.' + properties: + - name: 'approverEmails' + type: Array + item_type: + type: String + description: 'Specifies the email addresses of users who are potential approvers.' - name: 'displayName' type: String required: true @@ -146,3 +159,11 @@ properties: - name: 'serviceAccount' type: String description: 'Specifies the email of the producer service account.' +iam_policy: + method_name_suffix: DataProduct + parent_resource_attribute: data_product_id + method_name_separator: ':' + exclude_import_test: true + import_format: + - 'projects/{{project}}/locations/{{location}}/dataProducts/{{data_product_id}}' + - '{{data_product_id}}' diff --git a/mmv1/templates/terraform/examples/dataplex_data_product_full.tf.tmpl b/mmv1/templates/terraform/examples/dataplex_data_product_full.tf.tmpl index e44363dcd6a4..b705ab91f40c 100644 --- a/mmv1/templates/terraform/examples/dataplex_data_product_full.tf.tmpl +++ b/mmv1/templates/terraform/examples/dataplex_data_product_full.tf.tmpl @@ -14,6 +14,10 @@ resource "google_dataplex_data_product" "{{$.PrimaryResourceId}}" { owner_emails = ["gterraformtestuser@gmail.com"] + access_approval_config { + approver_emails = ["gterraformtestuser@gmail.com"] + } + labels = { env = "manual-test" } diff --git a/mmv1/third_party/terraform/services/dataplex/iam_dataplex_data_product_test.go b/mmv1/third_party/terraform/services/dataplex/iam_dataplex_data_product_test.go new file mode 100644 index 000000000000..7510c9c2fe19 --- /dev/null +++ b/mmv1/third_party/terraform/services/dataplex/iam_dataplex_data_product_test.go @@ -0,0 +1,67 @@ +package dataplex_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/hashicorp/terraform-provider-google/google/acctest" +) + +func TestAccDataplexDataProductIamMember_basic(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "data_product_id": "tf-test-dp-" + acctest.RandString(t, 10), + "role": "roles/dataplex.dataProductsViewer", + "member": "user:okvidhi@google.com", + } + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + Steps: []resource.TestStep{ + { + Config: testAccDataplexDataProductIamMember_basic(context), + }, + { + ResourceName: "google_dataplex_data_product_iam_member.member", + ImportState: true, + ImportStateVerify: true, + // FIX: Added function to construct the space-separated import ID + ImportStateIdFunc: testAccDataplexDataProductIamMemberImportStateId("google_dataplex_data_product_iam_member.member"), + }, + }, + }) +} + +// Helper to build the "resource_name role member" string required for import +func testAccDataplexDataProductIamMemberImportStateId(resourceName string) func(*terraform.State) (string, error) { + return func(s *terraform.State) (string, error) { + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return "", fmt.Errorf("Not found: %s", resourceName) + } + + return fmt.Sprintf("%s %s %s", rs.Primary.Attributes["data_product_id"], rs.Primary.Attributes["role"], rs.Primary.Attributes["member"]), nil + } +} + +func testAccDataplexDataProductIamMember_basic(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_dataplex_data_product" "example" { + location = "us-central1" + data_product_id = "%{data_product_id}" + display_name = "iam test product" + owner_emails = ["terraform-test@google.com"] +} + +resource "google_dataplex_data_product_iam_member" "member" { + # Passes the parent's full .name attribute to satisfy Dataplex identity rules + data_product_id = google_dataplex_data_product.example.name + role = "%{role}" + member = "%{member}" +} +`, context) +}