BucketArgs

data class BucketArgs(val autoclass: Output<BucketAutoclassArgs>? = null, val cors: Output<List<BucketCorArgs>>? = null, val customPlacementConfig: Output<BucketCustomPlacementConfigArgs>? = null, val defaultEventBasedHold: Output<Boolean>? = null, val encryption: Output<BucketEncryptionArgs>? = null, val forceDestroy: Output<Boolean>? = null, val labels: Output<Map<String, String>>? = null, val lifecycleRules: Output<List<BucketLifecycleRuleArgs>>? = null, val location: Output<String>? = null, val logging: Output<BucketLoggingArgs>? = null, val name: Output<String>? = null, val project: Output<String>? = null, val publicAccessPrevention: Output<String>? = null, val requesterPays: Output<Boolean>? = null, val retentionPolicy: Output<BucketRetentionPolicyArgs>? = null, val storageClass: Output<String>? = null, val uniformBucketLevelAccess: Output<Boolean>? = null, val versioning: Output<BucketVersioningArgs>? = null, val website: Output<BucketWebsiteArgs>? = null) : ConvertibleToJava<BucketArgs>

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 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

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.storage.Bucket;
import com.pulumi.gcp.storage.BucketArgs;
import com.pulumi.gcp.storage.inputs.BucketCorArgs;
import com.pulumi.gcp.storage.inputs.BucketWebsiteArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var static_site = new Bucket("static-site", BucketArgs.builder()
.cors(BucketCorArgs.builder()
.maxAgeSeconds(3600)
.methods(
"GET",
"HEAD",
"PUT",
"POST",
"DELETE")
.origins("http://image-store.com")
.responseHeaders("*")
.build())
.forceDestroy(true)
.location("EU")
.uniformBucketLevelAccess(true)
.website(BucketWebsiteArgs.builder()
.mainPageSuffix("index.html")
.notFoundPage("404.html")
.build())
.build());
}
}

Life Cycle Settings For Storage Bucket Objects

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.storage.Bucket;
import com.pulumi.gcp.storage.BucketArgs;
import com.pulumi.gcp.storage.inputs.BucketLifecycleRuleArgs;
import com.pulumi.gcp.storage.inputs.BucketLifecycleRuleActionArgs;
import com.pulumi.gcp.storage.inputs.BucketLifecycleRuleConditionArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var auto_expire = new Bucket("auto-expire", BucketArgs.builder()
.forceDestroy(true)
.lifecycleRules(
BucketLifecycleRuleArgs.builder()
.action(BucketLifecycleRuleActionArgs.builder()
.type("Delete")
.build())
.condition(BucketLifecycleRuleConditionArgs.builder()
.age(3)
.build())
.build(),
BucketLifecycleRuleArgs.builder()
.action(BucketLifecycleRuleActionArgs.builder()
.type("AbortIncompleteMultipartUpload")
.build())
.condition(BucketLifecycleRuleConditionArgs.builder()
.age(1)
.build())
.build())
.location("US")
.build());
}
}

Enabling Public Access Prevention

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.storage.Bucket;
import com.pulumi.gcp.storage.BucketArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var auto_expire = new Bucket("auto-expire", BucketArgs.builder()
.forceDestroy(true)
.location("US")
.publicAccessPrevention("enforced")
.build());
}
}

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). e.g.

$ pulumi import gcp:storage/bucket:Bucket image-store image-store-bucket
$ pulumi import gcp:storage/bucket:Bucket image-store tf-test-project/image-store-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.

Constructors

Link copied to clipboard
constructor(autoclass: Output<BucketAutoclassArgs>? = null, cors: Output<List<BucketCorArgs>>? = null, customPlacementConfig: Output<BucketCustomPlacementConfigArgs>? = null, defaultEventBasedHold: Output<Boolean>? = null, encryption: Output<BucketEncryptionArgs>? = null, forceDestroy: Output<Boolean>? = null, labels: Output<Map<String, String>>? = null, lifecycleRules: Output<List<BucketLifecycleRuleArgs>>? = null, location: Output<String>? = null, logging: Output<BucketLoggingArgs>? = null, name: Output<String>? = null, project: Output<String>? = null, publicAccessPrevention: Output<String>? = null, requesterPays: Output<Boolean>? = null, retentionPolicy: Output<BucketRetentionPolicyArgs>? = null, storageClass: Output<String>? = null, uniformBucketLevelAccess: Output<Boolean>? = null, versioning: Output<BucketVersioningArgs>? = null, website: Output<BucketWebsiteArgs>? = null)

Properties

Link copied to clipboard
val autoclass: Output<BucketAutoclassArgs>? = null

The bucket's Autoclass configuration. Structure is documented below.

Link copied to clipboard
val cors: Output<List<BucketCorArgs>>? = null

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

Link copied to clipboard

The bucket's custom location configuration, which specifies the individual regions that comprise a dual-region bucket. If the bucket is designated a single or multi-region, the parameters are empty. Structure is documented below.

Link copied to clipboard
val defaultEventBasedHold: Output<Boolean>? = null

Whether or not to automatically apply an eventBasedHold to new objects added to the bucket.

Link copied to clipboard
val encryption: Output<BucketEncryptionArgs>? = null

The bucket's encryption configuration. Structure is documented below.

Link copied to clipboard
val forceDestroy: Output<Boolean>? = null

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.

Link copied to clipboard
val labels: Output<Map<String, String>>? = null

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

Link copied to clipboard

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

Link copied to clipboard
val location: Output<String>? = null
Link copied to clipboard
val logging: Output<BucketLoggingArgs>? = null

The bucket's Access & Storage Logs configuration. Structure is documented below.

Link copied to clipboard
val name: Output<String>? = null

The name of the bucket.

Link copied to clipboard
val project: Output<String>? = null

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

Link copied to clipboard
val publicAccessPrevention: Output<String>? = null

Prevents public access to a bucket. Acceptable values are "inherited" or "enforced". If "inherited", the bucket uses public access prevention. only if the bucket is subject to the public access prevention organization policy constraint. Defaults to "inherited".

Link copied to clipboard
val requesterPays: Output<Boolean>? = null

Enables Requester Pays on a storage bucket.

Link copied to clipboard

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

Link copied to clipboard
val storageClass: Output<String>? = null

The Storage Class of the new bucket. Supported values include: STANDARD, MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, ARCHIVE.

Link copied to clipboard
val uniformBucketLevelAccess: Output<Boolean>? = null

Enables Uniform bucket-level access access to a bucket.

Link copied to clipboard
val versioning: Output<BucketVersioningArgs>? = null

The bucket's Versioning configuration. Structure is documented below.

Link copied to clipboard
val website: Output<BucketWebsiteArgs>? = null

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

Functions

Link copied to clipboard
open override fun toJava(): BucketArgs