cloud-foundation-fabric/modules/data-catalog-tag-template
Ludovico Magnocavallo 6941313c7d
Factories refactor (#1843)
* factories refactor doc

* Adds file schema and filesystem organization

* Update 20231106-factories.md

* move factories out of blueprints and create new factories  README

* align factory in billing-account module

* align factory in dataplex-datascan module

* align factory in billing-account module

* align factory in net-firewall-policy module

* align factory in dns-response-policy module

* align factory in net-vpc-firewall module

* align factory in net-vpc module

* align factory variable names in FAST

* remove decentralized firewall blueprint

* bump terraform version

* bump module versions

* update top-level READMEs

* move project factory to modules

* fix variable names and tests

* tfdoc

* remove changelog link

* add project factory to top-level README

* fix cludrun eventarc diff

* fix README

* fix cludrun eventarc diff

---------

Co-authored-by: Simone Ruffilli <sruffilli@google.com>
2024-02-26 10:16:52 +00:00
..
README.md Fix tests in README (#2027) 2024-01-30 11:04:47 +00:00
iam.tf Add Tag Template module (#2013) 2024-01-27 12:30:21 +01:00
main.tf Add Tag Template module (#2013) 2024-01-27 12:30:21 +01:00
outputs.tf Add Tag Template module (#2013) 2024-01-27 12:30:21 +01:00
variables.tf Add Tag Template module (#2013) 2024-01-27 12:30:21 +01:00
versions.tf Factories refactor (#1843) 2024-02-26 10:16:52 +00:00

README.md

Google Cloud Data Catalog Tag Template Module

This module allows managing Data Catalog Tag Templates.

Examples

Simple Tag Template

module "data-catalog-tag-template" {
  source     = "./fabric/modules/data-catalog-tag-template"
  project_id = "my-project"
  tag_templates = {
    demo_var = {
      region       = "europe-west1"
      display_name = "Demo Tag Template"
      fields = {
        source = {
          display_name = "Source of data asset"
          type = {
            primitive_type = "STRING"
          }
          is_required = true
        }
      }
    }
  }
}
# tftest modules=1 resources=1

Tag Template with IAM

module "data-catalog-tag-template" {
  source     = "./fabric/modules/data-catalog-tag-template"
  project_id = "my-project"
  tag_templates = {
    demo_var = {
      region       = "europe-west1"
      display_name = "Demo Tag Template"
      fields = {
        source = {
          display_name = "Source of data asset"
          type = {
            primitive_type = "STRING"
          }
          is_required = true
        }
      }
    }
  }
  iam = {
    "roles/datacatalog.tagTemplateOwner" = ["group:data-governance@example.com"]
    "roles/datacatalog.tagTemplateUser"  = ["group:data-product-eng@example.com"]
  }
}
# tftest modules=1 resources=3
module "data-catalog-tag-template" {
  source     = "./fabric/modules/data-catalog-tag-template"
  project_id = var.project_id
  tag_templates = {
    demo_var = {
      region       = "europe-west1"
      display_name = "Demo Tag Template"
      fields = {
        source = {
          display_name = "Source of data asset"
          type = {
            primitive_type = "STRING"
          }
          is_required = true
        }
      }
    }
  }
  iam_bindings = {
    admin-with-delegated_roles = {
      role    = "roles/datacatalog.tagTemplateOwner"
      members = ["group:data-governance@example.com"]
      condition = {
        title = "delegated-role-grants"
        expression = format(
          "api.getAttribute('iam.googleapis.com/modifiedGrantsByRole', []).hasOnly([%s])",
          join(",", formatlist("'%s'",
            [
              "roles/datacatalog.tagTemplateOwner"
            ]
          ))
        )
      }
    }
  }
}
# tftest modules=1 resources=2
module "data-catalog-tag-template" {
  source     = "./fabric/modules/data-catalog-tag-template"
  project_id = var.project_id
  tag_templates = {
    demo_var = {
      region       = "europe-west1"
      display_name = "Demo Tag Template"
      fields = {
        source = {
          display_name = "Source of data asset"
          type = {
            primitive_type = "STRING"
          }
          is_required = true
        }
      }
    }
  }
  iam_bindings_additive = {
    admin-with-delegated_roles = {
      role   = "roles/datacatalog.tagTemplateOwner"
      member = "group:data-governance@example.com"
      condition = {
        title = "delegated-role-grants"
        expression = format(
          "api.getAttribute('iam.googleapis.com/modifiedGrantsByRole', []).hasOnly([%s])",
          join(",", formatlist("'%s'",
            [
              "roles/datacatalog.tagTemplateOwner"
            ]
          ))
        )
      }
    }
  }
}
# tftest modules=1 resources=2

Factory

Similarly to other modules, a rules factory (see Resource Factories) is also included here to allow tag template management via descriptive configuration files.

Factory configuration is via one optional attributes in the factory_config_path variable specifying the path where tag template files are stored.

Factory tag templates are merged with rules declared in code, with the latter taking precedence where both use the same key.

The name of the file will be used as tag_template_id field.

This is an example of a simple factory:

module "data-catalog-tag-template" {
  source     = "./fabric/modules/data-catalog-tag-template"
  project_id = "my-project"
  tag_templates = {
    demo_var = {
      region       = "europe-west1"
      display_name = "Demo Tag Template"
      fields = {
        source = {
          display_name = "Source of data asset"
          type = {
            primitive_type = "STRING"
          }
          is_required = true
        }
      }
    }
  }
  factories_config = {
    tag_templates = "data"
  }
}
# tftest modules=1 resources=2 files=demo_tag
# tftest-file id=demo_tag path=data/demo.yaml

region: europe-west2
display_name: Demo Tag Template
fields:
  source:
      display_name: Source of data asset
      type:
        primitive_type: STRING
      is_required: true
  pii_type:
      display_name: PII type
      type:
        enum_type:
          - EMAIL
          - SOCIAL SECURITY NUMBER
          - NONE

Variables

name description type required default
project_id Id of the project where Tag Templates will be created. string
factories_config Paths to data files and folders that enable factory functionality. object({…}) {}
iam IAM bindings in {ROLE => [MEMBERS]} format. map(list(string)) {}
iam_bindings Authoritative IAM bindings in {KEY => {role = ROLE, members = [], condition = {}}}. Keys are arbitrary. map(object({…})) {}
iam_bindings_additive Individual additive IAM bindings. Keys are arbitrary. map(object({…})) {}
tag_templates Tag templates definitions in the form {TAG_TEMPLATE_ID => TEMPLATE_DEFINITION}. map(object({…})) {}

Outputs

name description sensitive
data_catalog_tag_template_ids Data catalog tag template ids.
data_catalog_tag_templates Data catalog tag templates.