1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. storage
  5. getBucketObjects
Google Cloud v8.14.0 published on Wednesday, Jan 15, 2025 by Pulumi

gcp.storage.getBucketObjects

Explore with Pulumi AI

Google Cloud v8.14.0 published on Wednesday, Jan 15, 2025 by Pulumi

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

Example Usage

Example files stored within a bucket.

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

const files = gcp.storage.getBucketObjects({
    bucket: "file-store",
});
Copy
import pulumi
import pulumi_gcp as gcp

files = gcp.storage.get_bucket_objects(bucket="file-store")
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.GetBucketObjects(ctx, &storage.GetBucketObjectsArgs{
			Bucket: "file-store",
		}, 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 files = Gcp.Storage.GetBucketObjects.Invoke(new()
    {
        Bucket = "file-store",
    });

});
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.GetBucketObjectsArgs;
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 files = StorageFunctions.getBucketObjects(GetBucketObjectsArgs.builder()
            .bucket("file-store")
            .build());

    }
}
Copy
variables:
  files:
    fn::invoke:
      function: gcp:storage:getBucketObjects
      arguments:
        bucket: file-store
Copy

Using getBucketObjects

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 getBucketObjects(args: GetBucketObjectsArgs, opts?: InvokeOptions): Promise<GetBucketObjectsResult>
function getBucketObjectsOutput(args: GetBucketObjectsOutputArgs, opts?: InvokeOptions): Output<GetBucketObjectsResult>
Copy
def get_bucket_objects(bucket: Optional[str] = None,
                       match_glob: Optional[str] = None,
                       prefix: Optional[str] = None,
                       opts: Optional[InvokeOptions] = None) -> GetBucketObjectsResult
def get_bucket_objects_output(bucket: Optional[pulumi.Input[str]] = None,
                       match_glob: Optional[pulumi.Input[str]] = None,
                       prefix: Optional[pulumi.Input[str]] = None,
                       opts: Optional[InvokeOptions] = None) -> Output[GetBucketObjectsResult]
Copy
func GetBucketObjects(ctx *Context, args *GetBucketObjectsArgs, opts ...InvokeOption) (*GetBucketObjectsResult, error)
func GetBucketObjectsOutput(ctx *Context, args *GetBucketObjectsOutputArgs, opts ...InvokeOption) GetBucketObjectsResultOutput
Copy

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

public static class GetBucketObjects 
{
    public static Task<GetBucketObjectsResult> InvokeAsync(GetBucketObjectsArgs args, InvokeOptions? opts = null)
    public static Output<GetBucketObjectsResult> Invoke(GetBucketObjectsInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetBucketObjectsResult> getBucketObjects(GetBucketObjectsArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
Copy
fn::invoke:
  function: gcp:storage/getBucketObjects:getBucketObjects
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Bucket This property is required. string
The name of the containing bucket.
MatchGlob string
A glob pattern used to filter results (for example, foo*bar).
Prefix string
Filter results to include only objects whose names begin with this prefix.
Bucket This property is required. string
The name of the containing bucket.
MatchGlob string
A glob pattern used to filter results (for example, foo*bar).
Prefix string
Filter results to include only objects whose names begin with this prefix.
bucket This property is required. String
The name of the containing bucket.
matchGlob String
A glob pattern used to filter results (for example, foo*bar).
prefix String
Filter results to include only objects whose names begin with this prefix.
bucket This property is required. string
The name of the containing bucket.
matchGlob string
A glob pattern used to filter results (for example, foo*bar).
prefix string
Filter results to include only objects whose names begin with this prefix.
bucket This property is required. str
The name of the containing bucket.
match_glob str
A glob pattern used to filter results (for example, foo*bar).
prefix str
Filter results to include only objects whose names begin with this prefix.
bucket This property is required. String
The name of the containing bucket.
matchGlob String
A glob pattern used to filter results (for example, foo*bar).
prefix String
Filter results to include only objects whose names begin with this prefix.

getBucketObjects Result

The following output properties are available:

Bucket string
BucketObjects List<GetBucketObjectsBucketObject>
A list of retrieved objects contained in the provided GCS bucket. Structure is defined below.
Id string
The provider-assigned unique ID for this managed resource.
MatchGlob string
Prefix string
Bucket string
BucketObjects []GetBucketObjectsBucketObject
A list of retrieved objects contained in the provided GCS bucket. Structure is defined below.
Id string
The provider-assigned unique ID for this managed resource.
MatchGlob string
Prefix string
bucket String
bucketObjects List<GetBucketObjectsBucketObject>
A list of retrieved objects contained in the provided GCS bucket. Structure is defined below.
id String
The provider-assigned unique ID for this managed resource.
matchGlob String
prefix String
bucket string
bucketObjects GetBucketObjectsBucketObject[]
A list of retrieved objects contained in the provided GCS bucket. Structure is defined below.
id string
The provider-assigned unique ID for this managed resource.
matchGlob string
prefix string
bucket str
bucket_objects Sequence[GetBucketObjectsBucketObject]
A list of retrieved objects contained in the provided GCS bucket. Structure is defined below.
id str
The provider-assigned unique ID for this managed resource.
match_glob str
prefix str
bucket String
bucketObjects List<Property Map>
A list of retrieved objects contained in the provided GCS bucket. Structure is defined below.
id String
The provider-assigned unique ID for this managed resource.
matchGlob String
prefix String

Supporting Types

GetBucketObjectsBucketObject

ContentType This property is required. string
Content-Type of the object data.
MediaLink This property is required. string
A url reference to download this object.
Name This property is required. string
The name of the object.
SelfLink This property is required. string
A url reference to this object.
StorageClass This property is required. string
The StorageClass of the bucket object.
ContentType This property is required. string
Content-Type of the object data.
MediaLink This property is required. string
A url reference to download this object.
Name This property is required. string
The name of the object.
SelfLink This property is required. string
A url reference to this object.
StorageClass This property is required. string
The StorageClass of the bucket object.
contentType This property is required. String
Content-Type of the object data.
mediaLink This property is required. String
A url reference to download this object.
name This property is required. String
The name of the object.
selfLink This property is required. String
A url reference to this object.
storageClass This property is required. String
The StorageClass of the bucket object.
contentType This property is required. string
Content-Type of the object data.
mediaLink This property is required. string
A url reference to download this object.
name This property is required. string
The name of the object.
selfLink This property is required. string
A url reference to this object.
storageClass This property is required. string
The StorageClass of the bucket object.
content_type This property is required. str
Content-Type of the object data.
media_link This property is required. str
A url reference to download this object.
name This property is required. str
The name of the object.
self_link This property is required. str
A url reference to this object.
storage_class This property is required. str
The StorageClass of the bucket object.
contentType This property is required. String
Content-Type of the object data.
mediaLink This property is required. String
A url reference to download this object.
name This property is required. String
The name of the object.
selfLink This property is required. String
A url reference to this object.
storageClass This property is required. String
The StorageClass of the bucket object.

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.14.0 published on Wednesday, Jan 15, 2025 by Pulumi