Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions mmv1/products/dataplex/DataProduct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Comment thread
okvidhi marked this conversation as resolved.
import_format:
- 'projects/{{project}}/locations/{{location}}/dataProducts/{{data_product_id}}'
- '{{data_product_id}}'
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Comment thread
okvidhi marked this conversation as resolved.
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)
}
Loading