Show / Hide Table of Contents

Class Bucket

Creates a new bucket in Google cloud storage service (GCS). Once a bucket has been created, its location can't be changed. ACLs can be applied using the gcp.storage.BucketACL resource.

For more information see the official documentation and API.

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

using Pulumi;
using Gcp = Pulumi.Gcp;

class MyStack : Stack
{
public MyStack()
{
    var static_site = new Gcp.Storage.Bucket("static-site", new Gcp.Storage.BucketArgs
    {
        BucketPolicyOnly = true,
        Cors = 
        {
            new Gcp.Storage.Inputs.BucketCorArgs
            {
                MaxAgeSeconds = 3600,
                Method = 
                {
                    "GET",
                    "HEAD",
                    "PUT",
                    "POST",
                    "DELETE",
                },
                Origin = 
                {
                    "http://image-store.com",
                },
                ResponseHeader = 
                {
                    "*",
                },
            },
        },
        ForceDestroy = true,
        Location = "EU",
        Website = new Gcp.Storage.Inputs.BucketWebsiteArgs
        {
            MainPageSuffix = "index.html",
            NotFoundPage = "404.html",
        },
    });
}

}

Example Usage - Life cycle settings for storage bucket objects

using Pulumi;
using Gcp = Pulumi.Gcp;

class MyStack : Stack
{
public MyStack()
{
    var auto_expire = new Gcp.Storage.Bucket("auto-expire", new Gcp.Storage.BucketArgs
    {
        ForceDestroy = true,
        LifecycleRules = 
        {
            new Gcp.Storage.Inputs.BucketLifecycleRuleArgs
            {
                Action = new Gcp.Storage.Inputs.BucketLifecycleRuleActionArgs
                {
                    Type = "Delete",
                },
                Condition = new Gcp.Storage.Inputs.BucketLifecycleRuleConditionArgs
                {
                    Age = "3",
                },
            },
        },
        Location = "US",
    });
}

}
Inheritance
System.Object
Resource
CustomResource
Bucket
Inherited Members
CustomResource.Id
Resource.GetResourceType()
Resource.GetResourceName()
Resource.Urn
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.Gcp.Storage
Assembly: Pulumi.Gcp.dll
Syntax
public class Bucket : CustomResource

Constructors

View Source

Bucket(String, BucketArgs, CustomResourceOptions)

Create a Bucket resource with the given unique name, arguments, and options.

Declaration
public Bucket(string name, BucketArgs args = null, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resource

BucketArgs args

The arguments used to populate this resource's properties

CustomResourceOptions options

A bag of options that control this resource's behavior

Properties

View Source

BucketPolicyOnly

Enables Bucket Policy Only access to a bucket.

Declaration
public Output<bool> BucketPolicyOnly { get; }
Property Value
Type Description
Output<System.Boolean>
View Source

Cors

The bucket's Cross-Origin Resource Sharing (CORS) configuration. Multiple blocks of this type are permitted. Structure is documented below.

Declaration
public Output<ImmutableArray<BucketCor>> Cors { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<BucketCor>>
View Source

DefaultEventBasedHold

Declaration
public Output<bool?> DefaultEventBasedHold { get; }
Property Value
Type Description
Output<System.Nullable<System.Boolean>>
View Source

Encryption

The bucket's encryption configuration.

Declaration
public Output<BucketEncryption> Encryption { get; }
Property Value
Type Description
Output<BucketEncryption>
View Source

ForceDestroy

When deleting a bucket, this boolean option will delete all contained objects. If you try to delete a bucket that contains objects, the provider will fail that run.

Declaration
public Output<bool?> ForceDestroy { get; }
Property Value
Type Description
Output<System.Nullable<System.Boolean>>
View Source

Labels

A set of key/value label pairs to assign to the bucket.

Declaration
public Output<ImmutableDictionary<string, string>> Labels { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableDictionary<System.String, System.String>>
View Source

LifecycleRules

The bucket's Lifecycle Rules configuration. Multiple blocks of this type are permitted. Structure is documented below.

Declaration
public Output<ImmutableArray<BucketLifecycleRule>> LifecycleRules { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<BucketLifecycleRule>>
View Source

Location

The GCS location

Declaration
public Output<string> Location { get; }
Property Value
Type Description
Output<System.String>
View Source

Logging

The bucket's Access & Storage Logs configuration.

Declaration
public Output<BucketLogging> Logging { get; }
Property Value
Type Description
Output<BucketLogging>
View Source

Name

The name of the bucket.

Declaration
public Output<string> Name { get; }
Property Value
Type Description
Output<System.String>
View Source

Project

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Declaration
public Output<string> Project { get; }
Property Value
Type Description
Output<System.String>
View Source

RequesterPays

Enables Requester Pays on a storage bucket.

Declaration
public Output<bool?> RequesterPays { get; }
Property Value
Type Description
Output<System.Nullable<System.Boolean>>
View Source

RetentionPolicy

Configuration of the bucket's data retention policy for how long objects in the bucket should be retained. Structure is documented below.

Declaration
public Output<BucketRetentionPolicy> RetentionPolicy { get; }
Property Value
Type Description
Output<BucketRetentionPolicy>
View Source

SelfLink

The URI of the created resource.

Declaration
public Output<string> SelfLink { get; }
Property Value
Type Description
Output<System.String>
View Source

StorageClass

The target Storage Class of objects affected by this Lifecycle Rule. Supported values include: MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE.

Declaration
public Output<string> StorageClass { get; }
Property Value
Type Description
Output<System.String>
View Source

Url

The base URL of the bucket, in the format gs://&lt;bucket-name>.

Declaration
public Output<string> Url { get; }
Property Value
Type Description
Output<System.String>
View Source

Versioning

The bucket's Versioning configuration.

Declaration
public Output<BucketVersioning> Versioning { get; }
Property Value
Type Description
Output<BucketVersioning>
View Source

Website

Configuration if the bucket acts as a website. Structure is documented below.

Declaration
public Output<BucketWebsite> Website { get; }
Property Value
Type Description
Output<BucketWebsite>

Methods

View Source

Get(String, Input<String>, BucketState, CustomResourceOptions)

Get an existing Bucket resource's state with the given name, ID, and optional extra properties used to qualify the lookup.

Declaration
public static Bucket Get(string name, Input<string> id, BucketState state = null, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resulting resource.

Input<System.String> id

The unique provider ID of the resource to lookup.

BucketState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

Returns
Type Description
Bucket
  • View Source
Back to top Copyright 2016-2020, Pulumi Corporation.