@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
266 lines • 11.4 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.Bucket = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = 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,
* }],
* });
* ```
*
* ### 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 auto_expire = new gcp.storage.Bucket("auto-expire", {
* 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 auto_expire = new gcp.storage.Bucket("auto-expire", {
* name: "hns-enabled-bucket",
* location: "US",
* forceDestroy: true,
* hierarchicalNamespace: {
* enabled: true,
* },
* });
* ```
*
* ## 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}}
* ```
*
* ```sh
* $ pulumi import gcp:storage/bucket:Bucket default {{project_id}}/{{bucket}}
* ```
*
* `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, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* 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 ? state.autoclass : undefined;
resourceInputs["cors"] = state ? state.cors : undefined;
resourceInputs["customPlacementConfig"] = state ? state.customPlacementConfig : undefined;
resourceInputs["defaultEventBasedHold"] = state ? state.defaultEventBasedHold : undefined;
resourceInputs["effectiveLabels"] = state ? state.effectiveLabels : undefined;
resourceInputs["enableObjectRetention"] = state ? state.enableObjectRetention : undefined;
resourceInputs["encryption"] = state ? state.encryption : undefined;
resourceInputs["forceDestroy"] = state ? state.forceDestroy : undefined;
resourceInputs["hierarchicalNamespace"] = state ? state.hierarchicalNamespace : undefined;
resourceInputs["labels"] = state ? state.labels : undefined;
resourceInputs["lifecycleRules"] = state ? state.lifecycleRules : undefined;
resourceInputs["location"] = state ? state.location : undefined;
resourceInputs["logging"] = state ? state.logging : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["project"] = state ? state.project : undefined;
resourceInputs["projectNumber"] = state ? state.projectNumber : undefined;
resourceInputs["publicAccessPrevention"] = state ? state.publicAccessPrevention : undefined;
resourceInputs["pulumiLabels"] = state ? state.pulumiLabels : undefined;
resourceInputs["requesterPays"] = state ? state.requesterPays : undefined;
resourceInputs["retentionPolicy"] = state ? state.retentionPolicy : undefined;
resourceInputs["rpo"] = state ? state.rpo : undefined;
resourceInputs["selfLink"] = state ? state.selfLink : undefined;
resourceInputs["softDeletePolicy"] = state ? state.softDeletePolicy : undefined;
resourceInputs["storageClass"] = state ? state.storageClass : undefined;
resourceInputs["uniformBucketLevelAccess"] = state ? state.uniformBucketLevelAccess : undefined;
resourceInputs["url"] = state ? state.url : undefined;
resourceInputs["versioning"] = state ? state.versioning : undefined;
resourceInputs["website"] = state ? state.website : undefined;
}
else {
const args = argsOrState;
if ((!args || args.location === undefined) && !opts.urn) {
throw new Error("Missing required property 'location'");
}
resourceInputs["autoclass"] = args ? args.autoclass : undefined;
resourceInputs["cors"] = args ? args.cors : undefined;
resourceInputs["customPlacementConfig"] = args ? args.customPlacementConfig : undefined;
resourceInputs["defaultEventBasedHold"] = args ? args.defaultEventBasedHold : undefined;
resourceInputs["enableObjectRetention"] = args ? args.enableObjectRetention : undefined;
resourceInputs["encryption"] = args ? args.encryption : undefined;
resourceInputs["forceDestroy"] = args ? args.forceDestroy : undefined;
resourceInputs["hierarchicalNamespace"] = args ? args.hierarchicalNamespace : undefined;
resourceInputs["labels"] = args ? args.labels : undefined;
resourceInputs["lifecycleRules"] = args ? args.lifecycleRules : undefined;
resourceInputs["location"] = args ? args.location : undefined;
resourceInputs["logging"] = args ? args.logging : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["project"] = args ? args.project : undefined;
resourceInputs["publicAccessPrevention"] = args ? args.publicAccessPrevention : undefined;
resourceInputs["requesterPays"] = args ? args.requesterPays : undefined;
resourceInputs["retentionPolicy"] = args ? args.retentionPolicy : undefined;
resourceInputs["rpo"] = args ? args.rpo : undefined;
resourceInputs["softDeletePolicy"] = args ? args.softDeletePolicy : undefined;
resourceInputs["storageClass"] = args ? args.storageClass : undefined;
resourceInputs["uniformBucketLevelAccess"] = args ? args.uniformBucketLevelAccess : undefined;
resourceInputs["versioning"] = args ? args.versioning : undefined;
resourceInputs["website"] = args ? args.website : undefined;
resourceInputs["effectiveLabels"] = undefined /*out*/;
resourceInputs["projectNumber"] = undefined /*out*/;
resourceInputs["pulumiLabels"] = undefined /*out*/;
resourceInputs["selfLink"] = 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;
/** @internal */
Bucket.__pulumiType = 'gcp:storage/bucket:Bucket';
//# sourceMappingURL=bucket.js.map