@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
370 lines • 14.1 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.Bucket = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
* Creates a new bucket in Google cloud storage service (GCS).
* Once a bucket has been created, its location can't be changed.
*
* For more information see
* [the official documentation](https://cloud.google.com/storage/docs/overview)
* and
* [API](https://cloud.google.com/storage/docs/json_api/v1/buckets).
*
* **Note**: If the project id is not set on the resource or in the provider block it will be dynamically
* determined which will require enabling the compute api.
*
* ## Example Usage
*
* ### Creating A Private Bucket In Standard Storage, In The EU Region. Bucket Configured As Static Website And CORS Configurations
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const static_site = new gcp.storage.Bucket("static-site", {
* name: "image-store.com",
* location: "EU",
* forceDestroy: true,
* uniformBucketLevelAccess: true,
* website: {
* mainPageSuffix: "index.html",
* notFoundPage: "404.html",
* },
* cors: [
* {
* origins: ["http://image-store.com"],
* methods: [
* "GET",
* "HEAD",
* "PUT",
* "POST",
* "DELETE",
* ],
* responseHeaders: ["*"],
* maxAgeSeconds: 3600,
* },
* {
* origins: ["http://image-store.com"],
* methods: [
* "GET",
* "HEAD",
* "PUT",
* "POST",
* "DELETE",
* ],
* responseHeaders: ["*"],
* maxAgeSeconds: 0,
* },
* ],
* });
* ```
*
* ### Life Cycle Settings For Storage Bucket Objects
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const auto_expire = new gcp.storage.Bucket("auto-expire", {
* name: "auto-expiring-bucket",
* location: "US",
* forceDestroy: true,
* lifecycleRules: [
* {
* condition: {
* age: 3,
* },
* action: {
* type: "Delete",
* },
* },
* {
* condition: {
* age: 1,
* },
* action: {
* type: "AbortIncompleteMultipartUpload",
* },
* },
* ],
* });
* ```
*
* ### Life Cycle Settings For Storage Bucket Objects With `Send_age_if_zero` Disabled
* When creating a life cycle condition that does not also include an `age` field, a default `age` of 0 will be set. Set the `sendAgeIfZero` flag to `false` to prevent this and avoid any potentially unintended interactions.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const no_age_enabled = new gcp.storage.Bucket("no-age-enabled", {
* name: "no-age-enabled-bucket",
* location: "US",
* forceDestroy: true,
* lifecycleRules: [{
* action: {
* type: "Delete",
* },
* condition: {
* daysSinceNoncurrentTime: 3,
* sendAgeIfZero: false,
* },
* }],
* });
* ```
*
* ### Enabling Public Access Prevention
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const no_public_access = new gcp.storage.Bucket("no-public-access", {
* name: "no-public-access-bucket",
* location: "US",
* forceDestroy: true,
* publicAccessPrevention: "enforced",
* });
* ```
*
* ### Enabling Hierarchical Namespace
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const hns_enabled = new gcp.storage.Bucket("hns-enabled", {
* name: "hns-enabled-bucket",
* location: "US",
* forceDestroy: true,
* hierarchicalNamespace: {
* enabled: true,
* },
* });
* ```
*
* ### IP Filter Mode Enabled
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const hns_enabled = new gcp.storage.Bucket("hns-enabled", {
* name: "hns-enabled-bucket",
* location: "US",
* forceDestroy: true,
* ipFilter: {
* mode: "Enabled",
* publicNetworkSource: {
* allowedIpCidrRanges: [
* "0.0.0.0/0",
* "::/0",
* ],
* },
* },
* });
* ```
*
* ### IP Filter Mode Disabled
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const hns_enabled = new gcp.storage.Bucket("hns-enabled", {
* name: "hns-enabled-bucket",
* location: "US",
* forceDestroy: true,
* ipFilter: {
* mode: "Disabled",
* publicNetworkSource: {
* allowedIpCidrRanges: [
* "0.0.0.0/0",
* "::/0",
* ],
* },
* },
* });
* ```
* ### Enabling Encryption Enforcement Config
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const hns_enabled = new gcp.storage.Bucket("hns-enabled", {
* name: "hns-enabled-bucket",
* location: "US",
* forceDestroy: true,
* encryption: {
* googleManagedEncryptionEnforcementConfig: {
* restrictionMode: "FullyRestricted",
* },
* customerManagedEncryptionEnforcementConfig: {
* restrictionMode: "FullyRestricted",
* },
* customerSuppliedEncryptionEnforcementConfig: {
* restrictionMode: "NotRestricted",
* },
* },
* });
* ```
*
* ## Import
*
* Storage buckets can be imported using the `name` or `project/name`. If the project is not
* passed to the import command it will be inferred from the provider block or environment variables.
* If it cannot be inferred it will be queried from the Compute API (this will fail if the API is
* not enabled).
*
* * `{{project_id}}/{{bucket}}`
* * `{{bucket}}`
*
* When using the `pulumi import` command, Storage buckets can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:storage/bucket:Bucket default {{bucket}}
* $ pulumi import gcp:storage/bucket:Bucket default {{project_id}}/{{bucket}}
* ```
*
* > **Note:** Terraform will import this resource with `forceDestroy` set to
* `false` in state. If you've set it to `true` in config, run `pulumi up` to
* update the value set in state. If you delete this resource before updating the
* value, objects in the bucket will not be destroyed.
*/
class Bucket extends pulumi.CustomResource {
/**
* Get an existing Bucket 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 Bucket(name, state, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'gcp:storage/bucket:Bucket';
/**
* Returns true if the given object is an instance of Bucket. 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'] === Bucket.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["autoclass"] = state?.autoclass;
resourceInputs["cors"] = state?.cors;
resourceInputs["customPlacementConfig"] = state?.customPlacementConfig;
resourceInputs["defaultEventBasedHold"] = state?.defaultEventBasedHold;
resourceInputs["deletionPolicy"] = state?.deletionPolicy;
resourceInputs["effectiveLabels"] = state?.effectiveLabels;
resourceInputs["enableObjectRetention"] = state?.enableObjectRetention;
resourceInputs["encryption"] = state?.encryption;
resourceInputs["forceDestroy"] = state?.forceDestroy;
resourceInputs["hierarchicalNamespace"] = state?.hierarchicalNamespace;
resourceInputs["ipFilter"] = state?.ipFilter;
resourceInputs["labels"] = state?.labels;
resourceInputs["lifecycleRules"] = state?.lifecycleRules;
resourceInputs["location"] = state?.location;
resourceInputs["logging"] = state?.logging;
resourceInputs["name"] = state?.name;
resourceInputs["project"] = state?.project;
resourceInputs["projectNumber"] = state?.projectNumber;
resourceInputs["publicAccessPrevention"] = state?.publicAccessPrevention;
resourceInputs["pulumiLabels"] = state?.pulumiLabels;
resourceInputs["requesterPays"] = state?.requesterPays;
resourceInputs["retentionPolicy"] = state?.retentionPolicy;
resourceInputs["rpo"] = state?.rpo;
resourceInputs["selfLink"] = state?.selfLink;
resourceInputs["softDeletePolicy"] = state?.softDeletePolicy;
resourceInputs["storageClass"] = state?.storageClass;
resourceInputs["timeCreated"] = state?.timeCreated;
resourceInputs["uniformBucketLevelAccess"] = state?.uniformBucketLevelAccess;
resourceInputs["updated"] = state?.updated;
resourceInputs["url"] = state?.url;
resourceInputs["versioning"] = state?.versioning;
resourceInputs["website"] = state?.website;
}
else {
const args = argsOrState;
if (args?.location === undefined && !opts.urn) {
throw new Error("Missing required property 'location'");
}
resourceInputs["autoclass"] = args?.autoclass;
resourceInputs["cors"] = args?.cors;
resourceInputs["customPlacementConfig"] = args?.customPlacementConfig;
resourceInputs["defaultEventBasedHold"] = args?.defaultEventBasedHold;
resourceInputs["deletionPolicy"] = args?.deletionPolicy;
resourceInputs["enableObjectRetention"] = args?.enableObjectRetention;
resourceInputs["encryption"] = args?.encryption;
resourceInputs["forceDestroy"] = args?.forceDestroy;
resourceInputs["hierarchicalNamespace"] = args?.hierarchicalNamespace;
resourceInputs["ipFilter"] = args?.ipFilter;
resourceInputs["labels"] = args?.labels;
resourceInputs["lifecycleRules"] = args?.lifecycleRules;
resourceInputs["location"] = args?.location;
resourceInputs["logging"] = args?.logging;
resourceInputs["name"] = args?.name;
resourceInputs["project"] = args?.project;
resourceInputs["publicAccessPrevention"] = args?.publicAccessPrevention;
resourceInputs["requesterPays"] = args?.requesterPays;
resourceInputs["retentionPolicy"] = args?.retentionPolicy;
resourceInputs["rpo"] = args?.rpo;
resourceInputs["softDeletePolicy"] = args?.softDeletePolicy;
resourceInputs["storageClass"] = args?.storageClass;
resourceInputs["uniformBucketLevelAccess"] = args?.uniformBucketLevelAccess;
resourceInputs["versioning"] = args?.versioning;
resourceInputs["website"] = args?.website;
resourceInputs["effectiveLabels"] = undefined /*out*/;
resourceInputs["projectNumber"] = undefined /*out*/;
resourceInputs["pulumiLabels"] = undefined /*out*/;
resourceInputs["selfLink"] = undefined /*out*/;
resourceInputs["timeCreated"] = undefined /*out*/;
resourceInputs["updated"] = undefined /*out*/;
resourceInputs["url"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const secretOpts = { additionalSecretOutputs: ["effectiveLabels", "pulumiLabels"] };
opts = pulumi.mergeOptions(opts, secretOpts);
super(Bucket.__pulumiType, name, resourceInputs, opts);
}
}
exports.Bucket = Bucket;
//# sourceMappingURL=bucket.js.map