@spacelift-io/pulumi-spacelift
Version:
A Pulumi package for creating and managing Spacelift resources.
86 lines • 3.85 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.PolicyAttachment = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* `spacelift.PolicyAttachment` represents a relationship between a policy (`spacelift.Policy`) and a stack (`spacelift.Stack`) or module (`spacelift.Module`). Each policy can only be attached to a stack/module once. `LOGIN` policies are the exception because they apply globally and not to individual stacks/modules. An attempt to attach one will fail.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as fs from "fs";
* import * as spacelift from "@spacelift-io/pulumi-spacelift";
*
* const no_weekend_deploysPolicy = new spacelift.Policy("no-weekend-deploysPolicy", {
* body: fs.readFileSync("policies/no-weekend-deploys.rego"),
* type: "PLAN",
* });
* const core_infra_production = new spacelift.Stack("core-infra-production", {
* branch: "master",
* repository: "core-infra",
* });
* const no_weekend_deploysPolicyAttachment = new spacelift.PolicyAttachment("no-weekend-deploysPolicyAttachment", {
* policyId: no_weekend_deploysPolicy.id,
* stackId: core_infra_production.id,
* });
* ```
*
* ## Import
*
* ```sh
* $ pulumi import spacelift:index/policyAttachment:PolicyAttachment no-weekend-deploys $POLICY_ID/$STACK_ID
* ```
*/
class PolicyAttachment extends pulumi.CustomResource {
/**
* Get an existing PolicyAttachment 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 PolicyAttachment(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of PolicyAttachment. 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'] === PolicyAttachment.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["moduleId"] = state ? state.moduleId : undefined;
resourceInputs["policyId"] = state ? state.policyId : undefined;
resourceInputs["stackId"] = state ? state.stackId : undefined;
}
else {
const args = argsOrState;
if ((!args || args.policyId === undefined) && !opts.urn) {
throw new Error("Missing required property 'policyId'");
}
resourceInputs["moduleId"] = args ? args.moduleId : undefined;
resourceInputs["policyId"] = args ? args.policyId : undefined;
resourceInputs["stackId"] = args ? args.stackId : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(PolicyAttachment.__pulumiType, name, resourceInputs, opts);
}
}
exports.PolicyAttachment = PolicyAttachment;
/** @internal */
PolicyAttachment.__pulumiType = 'spacelift:index/policyAttachment:PolicyAttachment';
//# sourceMappingURL=policyAttachment.js.map