Google Cloud (GCP) Classic

v6.43.0 published on Tuesday, Nov 15, 2022 by Pulumi

getBucket

Gets an existing bucket in Google Cloud Storage service (GCS). See the official documentation and API.

Example Usage

using System.Collections.Generic;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var my_bucket = Gcp.Storage.GetBucket.Invoke(new()
    {
        Name = "my-bucket",
    });

});
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/storage"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err = storage.LookupBucket(ctx, &storage.LookupBucketArgs{
			Name: "my-bucket",
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.storage.StorageFunctions;
import com.pulumi.gcp.storage.inputs.GetBucketArgs;
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) {
        final var my-bucket = StorageFunctions.getBucket(GetBucketArgs.builder()
            .name("my-bucket")
            .build());

    }
}
import pulumi
import pulumi_gcp as gcp

my_bucket = gcp.storage.get_bucket(name="my-bucket")
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const my_bucket = pulumi.output(gcp.storage.getBucket({
    name: "my-bucket",
}));
variables:
  my-bucket:
    fn::invoke:
      Function: gcp:storage:getBucket
      Arguments:
        name: my-bucket

Using getBucket

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getBucket(args: GetBucketArgs, opts?: InvokeOptions): Promise<GetBucketResult>
function getBucketOutput(args: GetBucketOutputArgs, opts?: InvokeOptions): Output<GetBucketResult>
def get_bucket(name: Optional[str] = None,
               opts: Optional[InvokeOptions] = None) -> GetBucketResult
def get_bucket_output(name: Optional[pulumi.Input[str]] = None,
               opts: Optional[InvokeOptions] = None) -> Output[GetBucketResult]
func LookupBucket(ctx *Context, args *LookupBucketArgs, opts ...InvokeOption) (*LookupBucketResult, error)
func LookupBucketOutput(ctx *Context, args *LookupBucketOutputArgs, opts ...InvokeOption) LookupBucketResultOutput

> Note: This function is named LookupBucket in the Go SDK.

public static class GetBucket 
{
    public static Task<GetBucketResult> InvokeAsync(GetBucketArgs args, InvokeOptions? opts = null)
    public static Output<GetBucketResult> Invoke(GetBucketInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetBucketResult> getBucket(GetBucketArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
  function: gcp:storage/getBucket:getBucket
  arguments:
    # arguments dictionary

The following arguments are supported:

Name string

The name of the bucket.

Name string

The name of the bucket.

name String

The name of the bucket.

name string

The name of the bucket.

name str

The name of the bucket.

name String

The name of the bucket.

getBucket Result

The following output properties are available:

Supporting Types

GetBucketCor

MaxAgeSeconds int
Methods List<string>
Origins List<string>
ResponseHeaders List<string>
MaxAgeSeconds int
Methods []string
Origins []string
ResponseHeaders []string
maxAgeSeconds Integer
methods List<String>
origins List<String>
responseHeaders List<String>
maxAgeSeconds number
methods string[]
origins string[]
responseHeaders string[]
max_age_seconds int
methods Sequence[str]
origins Sequence[str]
response_headers Sequence[str]
maxAgeSeconds Number
methods List<String>
origins List<String>
responseHeaders List<String>

GetBucketCustomPlacementConfig

DataLocations List<string>
DataLocations []string
dataLocations List<String>
dataLocations string[]
data_locations Sequence[str]
dataLocations List<String>

GetBucketEncryption

GetBucketLifecycleRule

GetBucketLifecycleRuleAction

StorageClass string
Type string
StorageClass string
Type string
storageClass String
type String
storageClass string
type string
storageClass String
type String

GetBucketLifecycleRuleCondition

GetBucketLogging

GetBucketRetentionPolicy

isLocked Boolean
retentionPeriod Integer

GetBucketVersioning

Enabled bool
Enabled bool
enabled Boolean
enabled boolean
enabled bool
enabled Boolean

GetBucketWebsite

Package Details

Repository
https://github.com/pulumi/pulumi-gcp
License
Apache-2.0
Notes

This Pulumi package is based on the google-beta Terraform Provider.