Files
hunfabric/modules/dataplex-aspect-types
Julio Castillo 9b9ad76ced Update gke-hub module to use new Policy Controller API (#3332)
* Update gke-hub to use new Policy Controller API

Fixes #3287

* Use same config format for servicemesh

* remove useless trys

* use ternaries as in the rest of the repo

* Update docs and fix tests

* Update variables

* Bump tofu version

* Bump terraform version 1.12
2025-10-13 09:47:39 +02:00
..
2025-05-03 21:21:38 +00:00
2025-04-22 13:06:40 +00:00
2025-05-03 21:21:38 +00:00
2025-05-03 21:21:38 +00:00

Dataplex Aspect Types Module

This module allows managing Dataplex Aspect Types and their associated IAM bindings via variables and YAML files defined via a resource factory.

The module manages Aspect Types for a single location in a single project. To manage them in different locations invoke the module multiple times, or use it with a for_each on locations/projects.

Simple example

This example mirrors the one in the google_dataplex_aspect_type resource documentation, but also shows how to manage IAM on the single aspect type. More types can of course be defined by just adding them to the aspect_types map.

module "aspect-types" {
  source     = "./fabric/modules/dataplex-aspect-types"
  project_id = "test-project"
  # var.location defaults to "global"
  # location   = "global"
  aspect_types = {
    tf-test-template = {
      display_name = "Test template."
      iam = {
        "roles/dataplex.aspectTypeOwner" = ["group:data-owners@example.com"]
      }
      iam_bindings_additive = {
        user = {
          role   = "roles/dataplex.aspectTypeUser"
          member = "serviceAccount:sa-0@test-project.iam.gserviceaccount.com"
        }
      }
      metadata_template = <<END
      {
        "name": "tf-test-template",
        "type": "record",
        "recordFields": [
          {
            "name": "type",
            "type": "enum",
            "annotations": {
              "displayName": "Type",
              "description": "Specifies the type of view represented by the entry."
            },
            "index": 1,
            "constraints": {
              "required": true
            },
            "enumValues": [
              {
                "name": "VIEW",
                "index": 1
              }
            ]
          }
        ]
      }
      END
    }
  }
}
# tftest modules=1 resources=3

Factory example

Aspect types can also be defined via a resource factory, where the file name will be used as the aspect type id. The resulting data is then internally combined with the aspect_types variable.

IAM attributes can leverage substitutions for principals, which need to be defined via the factories_configs.context.iam_principals variable as shown in the example below.

module "aspect-types" {
  source     = "./fabric/modules/dataplex-aspect-types"
  project_id = "test-project"
  factories_config = {
    aspect_types = "data/aspect-types"
    context = {
      iam_principals = {
        test-sa = "serviceAccount:sa-0@test-project.iam.gserviceaccount.com"
      }
    }
  }
}
# tftest modules=1 resources=4 files=aspect-0,aspect-1
display_name: "Test template 0."
iam:
  "roles/dataplex.aspectTypeOwner":
    - group:data-owners@example.com
metadata_template: |
  {
    "name": "tf-test-template-0",
    "type": "record",
    "recordFields": [
      {
        "name": "type",
        "type": "enum",
        "annotations": {
          "displayName": "Type",
          "description": "Specifies the type of view represented by the entry."
        },
        "index": 1,
        "constraints": {
          "required": true
        },
        "enumValues": [
          {
            "name": "VIEW",
            "index": 1
          }
        ]
      }
    ]
  }
# tftest-file id=aspect-0 path=data/aspect-types/aspect-0.yaml schema=aspect-type.schema.json
display_name: "Test template 1."
iam_bindings_additive:
  user:
    role: roles/dataplex.aspectTypeUser
    member: test-sa
metadata_template: |
  {
    "name": "tf-test-template-1",
    "type": "record",
    "recordFields": [
      {
        "name": "type",
        "type": "enum",
        "annotations": {
          "displayName": "Type",
          "description": "Specifies the type of view represented by the entry."
        },
        "index": 1,
        "constraints": {
          "required": true
        },
        "enumValues": [
          {
            "name": "VIEW",
            "index": 1
          }
        ]
      }
    ]
  }
# tftest-file id=aspect-1 path=data/aspect-types/aspect-1.yaml schema=aspect-type.schema.json

Variables

name description type required default
project_id Project id where resources will be created. string
aspect_types Aspect templates. Merged with those defined via the factory. map(object({…})) {}
factories_config Paths to folders for the optional factories. object({…}) {}
location Location for aspect types. string "global"

Outputs

name description sensitive
ids Aspect type IDs.
names Aspect type names.
timestamps Aspect type create and update timestamps.
uids Aspect type gobally unique IDs.