@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
177 lines • 7.33 kB
JavaScript
;
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataPolicy = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* A BigQuery Data Policy
*
* To get more information about DataPolicy, see:
*
* * [API documentation](https://cloud.google.com/bigquery/docs/reference/bigquerydatapolicy/rest/v1beta1/projects.locations.dataPolicies/create)
* * How-to Guides
* * [Official Documentation](https://cloud.google.com/bigquery/docs/column-data-masking-intro)
*
* ## Example Usage
*
* ### Bigquery Datapolicy Data Policy Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const taxonomy = new gcp.datacatalog.Taxonomy("taxonomy", {
* region: "us-central1",
* displayName: "taxonomy",
* description: "A collection of policy tags",
* activatedPolicyTypes: ["FINE_GRAINED_ACCESS_CONTROL"],
* });
* const policyTag = new gcp.datacatalog.PolicyTag("policy_tag", {
* taxonomy: taxonomy.id,
* displayName: "Low security",
* description: "A policy tag normally associated with low security items",
* });
* const dataPolicy = new gcp.bigquerydatapolicy.DataPolicy("data_policy", {
* location: "us-central1",
* dataPolicyId: "data_policy",
* policyTag: policyTag.name,
* dataPolicyType: "COLUMN_LEVEL_SECURITY_POLICY",
* });
* ```
* ### Bigquery Datapolicy Data Policy Routine
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const taxonomy = new gcp.datacatalog.Taxonomy("taxonomy", {
* region: "us-central1",
* displayName: "taxonomy",
* description: "A collection of policy tags",
* activatedPolicyTypes: ["FINE_GRAINED_ACCESS_CONTROL"],
* });
* const policyTag = new gcp.datacatalog.PolicyTag("policy_tag", {
* taxonomy: taxonomy.id,
* displayName: "Low security",
* description: "A policy tag normally associated with low security items",
* });
* const test = new gcp.bigquery.Dataset("test", {
* datasetId: "dataset_id",
* location: "us-central1",
* });
* const customMaskingRoutine = new gcp.bigquery.Routine("custom_masking_routine", {
* datasetId: test.datasetId,
* routineId: "custom_masking_routine",
* routineType: "SCALAR_FUNCTION",
* language: "SQL",
* dataGovernanceType: "DATA_MASKING",
* definitionBody: "SAFE.REGEXP_REPLACE(ssn, '[0-9]', 'X')",
* returnType: "{\"typeKind\" : \"STRING\"}",
* arguments: [{
* name: "ssn",
* dataType: "{\"typeKind\" : \"STRING\"}",
* }],
* });
* const dataPolicy = new gcp.bigquerydatapolicy.DataPolicy("data_policy", {
* location: "us-central1",
* dataPolicyId: "data_policy",
* policyTag: policyTag.name,
* dataPolicyType: "DATA_MASKING_POLICY",
* dataMaskingPolicy: {
* routine: customMaskingRoutine.id,
* },
* });
* ```
*
* ## Import
*
* DataPolicy can be imported using any of these accepted formats:
*
* * `projects/{{project}}/locations/{{location}}/dataPolicies/{{data_policy_id}}`
*
* * `{{project}}/{{location}}/{{data_policy_id}}`
*
* * `{{location}}/{{data_policy_id}}`
*
* When using the `pulumi import` command, DataPolicy can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:bigquerydatapolicy/dataPolicy:DataPolicy default projects/{{project}}/locations/{{location}}/dataPolicies/{{data_policy_id}}
* ```
*
* ```sh
* $ pulumi import gcp:bigquerydatapolicy/dataPolicy:DataPolicy default {{project}}/{{location}}/{{data_policy_id}}
* ```
*
* ```sh
* $ pulumi import gcp:bigquerydatapolicy/dataPolicy:DataPolicy default {{location}}/{{data_policy_id}}
* ```
*/
class DataPolicy extends pulumi.CustomResource {
/**
* Get an existing DataPolicy resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new DataPolicy(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of DataPolicy. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === DataPolicy.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["dataMaskingPolicy"] = state ? state.dataMaskingPolicy : undefined;
resourceInputs["dataPolicyId"] = state ? state.dataPolicyId : undefined;
resourceInputs["dataPolicyType"] = state ? state.dataPolicyType : undefined;
resourceInputs["location"] = state ? state.location : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["policyTag"] = state ? state.policyTag : undefined;
resourceInputs["project"] = state ? state.project : undefined;
}
else {
const args = argsOrState;
if ((!args || args.dataPolicyId === undefined) && !opts.urn) {
throw new Error("Missing required property 'dataPolicyId'");
}
if ((!args || args.dataPolicyType === undefined) && !opts.urn) {
throw new Error("Missing required property 'dataPolicyType'");
}
if ((!args || args.location === undefined) && !opts.urn) {
throw new Error("Missing required property 'location'");
}
if ((!args || args.policyTag === undefined) && !opts.urn) {
throw new Error("Missing required property 'policyTag'");
}
resourceInputs["dataMaskingPolicy"] = args ? args.dataMaskingPolicy : undefined;
resourceInputs["dataPolicyId"] = args ? args.dataPolicyId : undefined;
resourceInputs["dataPolicyType"] = args ? args.dataPolicyType : undefined;
resourceInputs["location"] = args ? args.location : undefined;
resourceInputs["policyTag"] = args ? args.policyTag : undefined;
resourceInputs["project"] = args ? args.project : undefined;
resourceInputs["name"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(DataPolicy.__pulumiType, name, resourceInputs, opts);
}
}
exports.DataPolicy = DataPolicy;
/** @internal */
DataPolicy.__pulumiType = 'gcp:bigquerydatapolicy/dataPolicy:DataPolicy';
//# sourceMappingURL=dataPolicy.js.map