1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. storage
  5. getBuckets
Google Cloud v8.25.1 published on Wednesday, Apr 9, 2025 by Pulumi

gcp.storage.getBuckets

Explore with Pulumi AI

Google Cloud v8.25.1 published on Wednesday, Apr 9, 2025 by Pulumi

Gets a list of existing GCS buckets. See the official documentation and API.

Example Usage

Example GCS buckets.

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const example = gcp.storage.getBuckets({
    project: "example-project",
});
Copy
import pulumi
import pulumi_gcp as gcp

example = gcp.storage.get_buckets(project="example-project")
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := storage.GetBuckets(ctx, &storage.GetBucketsArgs{
			Project: pulumi.StringRef("example-project"),
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var example = Gcp.Storage.GetBuckets.Invoke(new()
    {
        Project = "example-project",
    });

});
Copy
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.GetBucketsArgs;
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 example = StorageFunctions.getBuckets(GetBucketsArgs.builder()
            .project("example-project")
            .build());

    }
}
Copy
variables:
  example:
    fn::invoke:
      function: gcp:storage:getBuckets
      arguments:
        project: example-project
Copy

Using getBuckets

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 getBuckets(args: GetBucketsArgs, opts?: InvokeOptions): Promise<GetBucketsResult>
function getBucketsOutput(args: GetBucketsOutputArgs, opts?: InvokeOptions): Output<GetBucketsResult>
Copy
def get_buckets(prefix: Optional[str] = None,
                project: Optional[str] = None,
                opts: Optional[InvokeOptions] = None) -> GetBucketsResult
def get_buckets_output(prefix: Optional[pulumi.Input[str]] = None,
                project: Optional[pulumi.Input[str]] = None,
                opts: Optional[InvokeOptions] = None) -> Output[GetBucketsResult]
Copy
func GetBuckets(ctx *Context, args *GetBucketsArgs, opts ...InvokeOption) (*GetBucketsResult, error)
func GetBucketsOutput(ctx *Context, args *GetBucketsOutputArgs, opts ...InvokeOption) GetBucketsResultOutput
Copy

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

public static class GetBuckets 
{
    public static Task<GetBucketsResult> InvokeAsync(GetBucketsArgs args, InvokeOptions? opts = null)
    public static Output<GetBucketsResult> Invoke(GetBucketsInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetBucketsResult> getBuckets(GetBucketsArgs args, InvokeOptions options)
public static Output<GetBucketsResult> getBuckets(GetBucketsArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: gcp:storage/getBuckets:getBuckets
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Prefix string
Filter results to buckets whose names begin with this prefix.
Project string
The ID of the project. If it is not provided, the provider project is used.
Prefix string
Filter results to buckets whose names begin with this prefix.
Project string
The ID of the project. If it is not provided, the provider project is used.
prefix String
Filter results to buckets whose names begin with this prefix.
project String
The ID of the project. If it is not provided, the provider project is used.
prefix string
Filter results to buckets whose names begin with this prefix.
project string
The ID of the project. If it is not provided, the provider project is used.
prefix str
Filter results to buckets whose names begin with this prefix.
project str
The ID of the project. If it is not provided, the provider project is used.
prefix String
Filter results to buckets whose names begin with this prefix.
project String
The ID of the project. If it is not provided, the provider project is used.

getBuckets Result

The following output properties are available:

Buckets List<GetBucketsBucket>
A list of all retrieved GCS buckets. Structure is defined below.
Id string
The provider-assigned unique ID for this managed resource.
Prefix string
Project string
Buckets []GetBucketsBucket
A list of all retrieved GCS buckets. Structure is defined below.
Id string
The provider-assigned unique ID for this managed resource.
Prefix string
Project string
buckets List<GetBucketsBucket>
A list of all retrieved GCS buckets. Structure is defined below.
id String
The provider-assigned unique ID for this managed resource.
prefix String
project String
buckets GetBucketsBucket[]
A list of all retrieved GCS buckets. Structure is defined below.
id string
The provider-assigned unique ID for this managed resource.
prefix string
project string
buckets Sequence[GetBucketsBucket]
A list of all retrieved GCS buckets. Structure is defined below.
id str
The provider-assigned unique ID for this managed resource.
prefix str
project str
buckets List<Property Map>
A list of all retrieved GCS buckets. Structure is defined below.
id String
The provider-assigned unique ID for this managed resource.
prefix String
project String

Supporting Types

GetBucketsBucket

Labels This property is required. Dictionary<string, string>
User-provided bucket labels, in key/value pairs.
Location This property is required. string
The location of the bucket.
Name This property is required. string
The name of the bucket.
SelfLink This property is required. string
A url reference to the bucket.
StorageClass This property is required. string
The StorageClass of the bucket.
Labels This property is required. map[string]string
User-provided bucket labels, in key/value pairs.
Location This property is required. string
The location of the bucket.
Name This property is required. string
The name of the bucket.
SelfLink This property is required. string
A url reference to the bucket.
StorageClass This property is required. string
The StorageClass of the bucket.
labels This property is required. Map<String,String>
User-provided bucket labels, in key/value pairs.
location This property is required. String
The location of the bucket.
name This property is required. String
The name of the bucket.
selfLink This property is required. String
A url reference to the bucket.
storageClass This property is required. String
The StorageClass of the bucket.
labels This property is required. {[key: string]: string}
User-provided bucket labels, in key/value pairs.
location This property is required. string
The location of the bucket.
name This property is required. string
The name of the bucket.
selfLink This property is required. string
A url reference to the bucket.
storageClass This property is required. string
The StorageClass of the bucket.
labels This property is required. Mapping[str, str]
User-provided bucket labels, in key/value pairs.
location This property is required. str
The location of the bucket.
name This property is required. str
The name of the bucket.
self_link This property is required. str
A url reference to the bucket.
storage_class This property is required. str
The StorageClass of the bucket.
labels This property is required. Map<String>
User-provided bucket labels, in key/value pairs.
location This property is required. String
The location of the bucket.
name This property is required. String
The name of the bucket.
selfLink This property is required. String
A url reference to the bucket.
storageClass This property is required. String
The StorageClass of the bucket.

Package Details

Repository
Google Cloud (GCP) Classic pulumi/pulumi-gcp
License
Apache-2.0
Notes
This Pulumi package is based on the google-beta Terraform Provider.
Google Cloud v8.25.1 published on Wednesday, Apr 9, 2025 by Pulumi