@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
180 lines • 7.56 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Rule = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
* A rule defines the deny or allow action of the operation it applies to and the conditions required for the rule to apply. You can set one rule for an entire repository and one rule for each package within.
*
* To get more information about Rule, see:
*
* * [API documentation](https://cloud.google.com/artifact-registry/docs/reference/rest/v1/projects.locations.repositories.rules)
* * How-to Guides
* * [Official Documentation](https://docs.cloud.google.com/sdk/gcloud/reference/artifacts/rules)
*
* ## Example Usage
*
* ### Artifact Registry Rule Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.artifactregistry.Repository("default", {
* location: "us-central1",
* repositoryId: "my-repository",
* description: "example docker repository",
* format: "DOCKER",
* });
* const my_rule = new gcp.artifactregistry.Rule("my-rule", {
* repositoryId: _default.repositoryId,
* location: _default.location,
* ruleId: "my-repo-rule-id",
* action: "DENY",
* operation: "DOWNLOAD",
* condition: {
* expression: "pkg.version.id < '2.0'",
* title: "Block legacy versions",
* description: "Prevents downloading images with version IDs less than 2.0",
* },
* });
* ```
* ### Artifact Registry Rule Full
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.artifactregistry.Repository("default", {
* location: "us-central1",
* repositoryId: "my-repository",
* description: "example docker repository",
* format: "DOCKER",
* });
* const my_rule = new gcp.artifactregistry.Rule("my-rule", {
* repositoryId: _default.repositoryId,
* location: _default.location,
* ruleId: "my-repo-rule-full-id",
* action: "DENY",
* operation: "DOWNLOAD",
* packageId: "foo",
* condition: {
* expression: "pkg.version.id < '2.0'",
* title: "Block legacy versions",
* description: "Prevents downloading images with version IDs less than 2.0",
* location: "artifact-registry-rules/policy.cel:1",
* },
* });
* ```
*
* ## Regional Endpoint Policies
*
* This resource supports Regional Endpoint Policies (REP). See the provider reference for more details on configuration.
*
* ## Import
*
* Rule can be imported using any of these accepted formats:
*
* * `projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}/rules/{{rule_id}}`
* * `{{project}}/{{location}}/{{repository_id}}/{{rule_id}}`
* * `{{location}}/{{repository_id}}/{{rule_id}}`
*
* When using the `pulumi import` command, Rule can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:artifactregistry/rule:Rule default projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}/rules/{{rule_id}}
* $ pulumi import gcp:artifactregistry/rule:Rule default {{project}}/{{location}}/{{repository_id}}/{{rule_id}}
* $ pulumi import gcp:artifactregistry/rule:Rule default {{location}}/{{repository_id}}/{{rule_id}}
* ```
*/
class Rule extends pulumi.CustomResource {
/**
* Get an existing Rule 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 Rule(name, state, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'gcp:artifactregistry/rule:Rule';
/**
* Returns true if the given object is an instance of Rule. 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'] === Rule.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["action"] = state?.action;
resourceInputs["condition"] = state?.condition;
resourceInputs["deletionPolicy"] = state?.deletionPolicy;
resourceInputs["location"] = state?.location;
resourceInputs["name"] = state?.name;
resourceInputs["operation"] = state?.operation;
resourceInputs["packageId"] = state?.packageId;
resourceInputs["project"] = state?.project;
resourceInputs["repositoryId"] = state?.repositoryId;
resourceInputs["ruleId"] = state?.ruleId;
}
else {
const args = argsOrState;
if (args?.repositoryId === undefined && !opts.urn) {
throw new Error("Missing required property 'repositoryId'");
}
if (args?.ruleId === undefined && !opts.urn) {
throw new Error("Missing required property 'ruleId'");
}
resourceInputs["action"] = args?.action;
resourceInputs["condition"] = args?.condition;
resourceInputs["deletionPolicy"] = args?.deletionPolicy;
resourceInputs["location"] = args?.location;
resourceInputs["operation"] = args?.operation;
resourceInputs["packageId"] = args?.packageId;
resourceInputs["project"] = args?.project;
resourceInputs["repositoryId"] = args?.repositoryId;
resourceInputs["ruleId"] = args?.ruleId;
resourceInputs["name"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Rule.__pulumiType, name, resourceInputs, opts);
}
}
exports.Rule = Rule;
//# sourceMappingURL=rule.js.map