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",
});
}
}
Inherited Members
Namespace: Pulumi.Gcp.Storage
Assembly: Pulumi.Gcp.dll
Syntax
public class Bucket : CustomResource
Constructors
View SourceBucket(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 SourceBucketPolicyOnly
Enables Bucket Policy Only access to a bucket.
Declaration
public Output<bool> BucketPolicyOnly { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Boolean> |
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>> |
DefaultEventBasedHold
Declaration
public Output<bool?> DefaultEventBasedHold { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
Encryption
The bucket's encryption configuration.
Declaration
public Output<BucketEncryption> Encryption { get; }
Property Value
| Type | Description |
|---|---|
| Output<BucketEncryption> |
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>> |
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>> |
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>> |
Location
The GCS location
Declaration
public Output<string> Location { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Logging
The bucket's Access & Storage Logs configuration.
Declaration
public Output<BucketLogging> Logging { get; }
Property Value
| Type | Description |
|---|---|
| Output<BucketLogging> |
Name
The name of the bucket.
Declaration
public Output<string> Name { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
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> |
RequesterPays
Enables Requester Pays on a storage bucket.
Declaration
public Output<bool?> RequesterPays { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
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> |
SelfLink
The URI of the created resource.
Declaration
public Output<string> SelfLink { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
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> |
Url
The base URL of the bucket, in the format gs://<bucket-name>.
Declaration
public Output<string> Url { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Versioning
The bucket's Versioning configuration.
Declaration
public Output<BucketVersioning> Versioning { get; }
Property Value
| Type | Description |
|---|---|
| Output<BucketVersioning> |
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 SourceGet(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 |