google_data_catalog_tag

Tags are used to attach custom metadata to Data Catalog resources. Tags conform to the specifications within their tag template.

See Data Catalog IAM for information on the permissions needed to create or view tags.

To get more information about Tag, see:

Open in Cloud Shell

Example Usage - Data Catalog Entry Tag Basic

resource "google_data_catalog_entry" "entry" {
  entry_group = google_data_catalog_entry_group.entry_group.id
  entry_id = "my_entry"

  user_specified_type = "my_custom_type"
  user_specified_system = "SomethingExternal"
}

resource "google_data_catalog_entry_group" "entry_group" {
  entry_group_id = "my_entry_group"
}

resource "google_data_catalog_tag_template" "tag_template" {
  tag_template_id = "my_template"
  region = "us-central1"
  display_name = "Demo Tag Template"

  fields {
    field_id = "source"
    display_name = "Source of data asset"
    type {
      primitive_type = "STRING"
    }
    is_required = true
  }

  fields {
    field_id = "num_rows"
    display_name = "Number of rows in the data asset"
    type {
      primitive_type = "DOUBLE"
    }
  }

  fields {
    field_id = "pii_type"
    display_name = "PII type"
    type {
      enum_type {
        allowed_values {
          display_name = "EMAIL"
        }
        allowed_values {
          display_name = "SOCIAL SECURITY NUMBER"
        }
        allowed_values {
          display_name = "NONE"
        }
      }
    }
  }

  force_delete = "false"
}

resource "google_data_catalog_tag" "basic_tag" {
  parent   = google_data_catalog_entry.entry.id
  template = google_data_catalog_tag_template.tag_template.id

  fields {
    field_name   = "source"
    string_value = "my-string"
  }
}
Open in Cloud Shell

Example Usage - Data Catalog Entry Group Tag

resource "google_data_catalog_entry" "first_entry" {
  entry_group = google_data_catalog_entry_group.entry_group.id
  entry_id = "first_entry"

  user_specified_type = "my_custom_type"
  user_specified_system = "SomethingExternal"
}

resource "google_data_catalog_entry" "second_entry" {
  entry_group = google_data_catalog_entry_group.entry_group.id
  entry_id = "second_entry"

  user_specified_type = "another_custom_type"
  user_specified_system = "SomethingElseExternal"
}

resource "google_data_catalog_entry_group" "entry_group" {
  entry_group_id = "my_entry_group"
}

resource "google_data_catalog_tag_template" "tag_template" {
  tag_template_id = "my_template"
  region = "us-central1"
  display_name = "Demo Tag Template"

  fields {
    field_id = "source"
    display_name = "Source of data asset"
    type {
      primitive_type = "STRING"
    }
    is_required = true
  }

  fields {
    field_id = "num_rows"
    display_name = "Number of rows in the data asset"
    type {
      primitive_type = "DOUBLE"
    }
  }

  fields {
    field_id = "pii_type"
    display_name = "PII type"
    type {
      enum_type {
        allowed_values {
          display_name = "EMAIL"
        }
        allowed_values {
          display_name = "SOCIAL SECURITY NUMBER"
        }
        allowed_values {
          display_name = "NONE"
        }
      }
    }
  }

  force_delete = "false"
}

resource "google_data_catalog_tag" "entry_group_tag" {
  parent   = google_data_catalog_entry_group.entry_group.id
  template = google_data_catalog_tag_template.tag_template.id

  fields {
    field_name   = "source"
    string_value = "my-string"
  }
}
Open in Cloud Shell

Example Usage - Data Catalog Entry Tag Full

resource "google_data_catalog_entry" "entry" {
  entry_group = google_data_catalog_entry_group.entry_group.id
  entry_id = "my_entry"

  user_specified_type = "my_custom_type"
  user_specified_system = "SomethingExternal"

  schema = <<EOF
{
  "columns": [
    {
      "column": "first_name",
      "description": "First name",
      "mode": "REQUIRED",
      "type": "STRING"
    },
    {
      "column": "last_name",
      "description": "Last name",
      "mode": "REQUIRED",
      "type": "STRING"
    },
    {
      "column": "address",
      "description": "Address",
      "mode": "REPEATED",
      "subcolumns": [
        {
          "column": "city",
          "description": "City",
          "mode": "NULLABLE",
          "type": "STRING"
        },
        {
          "column": "state",
          "description": "State",
          "mode": "NULLABLE",
          "type": "STRING"
        }
      ],
      "type": "RECORD"
    }
  ]
}
EOF
}

resource "google_data_catalog_entry_group" "entry_group" {
  entry_group_id = "my_entry_group"
}

resource "google_data_catalog_tag_template" "tag_template" {
  tag_template_id = "my_template"
  region = "us-central1"
  display_name = "Demo Tag Template"

  fields {
    field_id = "source"
    display_name = "Source of data asset"
    type {
      primitive_type = "STRING"
    }
    is_required = true
  }

  fields {
    field_id = "num_rows"
    display_name = "Number of rows in the data asset"
    type {
      primitive_type = "DOUBLE"
    }
  }

  fields {
    field_id = "pii_type"
    display_name = "PII type"
    type {
      enum_type {
        allowed_values {
          display_name = "EMAIL"
        }
        allowed_values {
          display_name = "SOCIAL SECURITY NUMBER"
        }
        allowed_values {
          display_name = "NONE"
        }
      }
    }
  }

  force_delete = "false"
}

resource "google_data_catalog_tag" "basic_tag" {
  parent   = google_data_catalog_entry.entry.id
  template = google_data_catalog_tag_template.tag_template.id

  fields {
    field_name   = "source"
    string_value = "my-string"
  }

  fields {
    field_name   = "num_rows"
    double_value = 5
  }

  fields {
    field_name = "pii_type"
    enum_value = "EMAIL"
  }

  column = "address"
}

resource "google_data_catalog_tag" "second-tag" {
  parent   = google_data_catalog_entry.entry.id
  template = google_data_catalog_tag_template.tag_template.id

  fields {
    field_name   = "source"
    string_value = "my-string"
  }

  fields {
    field_name = "pii_type"
    enum_value = "NONE"
  }

  column = "first_name"
}

Argument Reference

The following arguments are supported:

The fields block supports:


Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

Timeouts

This resource provides the following Timeouts configuration options:

Import

Tag can be imported using any of these accepted formats:

In Terraform v1.5.0 and later, use an import block to import Tag using one of the formats above. For example:

import {
  id = "{{name}}"
  to = google_data_catalog_tag.default
}

When using the terraform import command, Tag can be imported using one of the formats above. For example:

$ terraform import google_data_catalog_tag.default {{name}}