1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. storage
  5. getBucketObjectContent
Google Cloud v8.23.0 published on Monday, Mar 24, 2025 by Pulumi

gcp.storage.getBucketObjectContent

Explore with Pulumi AI

Google Cloud v8.23.0 published on Monday, Mar 24, 2025 by Pulumi

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

Warning: The object content will be saved in the state, and visible to everyone who has access to the state file.

Example Usage

Example file object stored within a folder.

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

const key = gcp.storage.getBucketObjectContent({
    name: "encryptedkey",
    bucket: "keystore",
});
export const encrypted = key.then(key => key.content);
Copy
import pulumi
import pulumi_gcp as gcp

key = gcp.storage.get_bucket_object_content(name="encryptedkey",
    bucket="keystore")
pulumi.export("encrypted", key.content)
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 {
		key, err := storage.GetBucketObjectContent(ctx, &storage.GetBucketObjectContentArgs{
			Name:   "encryptedkey",
			Bucket: "keystore",
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("encrypted", key.Content)
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var key = Gcp.Storage.GetBucketObjectContent.Invoke(new()
    {
        Name = "encryptedkey",
        Bucket = "keystore",
    });

    return new Dictionary<string, object?>
    {
        ["encrypted"] = key.Apply(getBucketObjectContentResult => getBucketObjectContentResult.Content),
    };
});
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.GetBucketObjectContentArgs;
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 key = StorageFunctions.getBucketObjectContent(GetBucketObjectContentArgs.builder()
            .name("encryptedkey")
            .bucket("keystore")
            .build());

        ctx.export("encrypted", key.applyValue(getBucketObjectContentResult -> getBucketObjectContentResult.content()));
    }
}
Copy
variables:
  key:
    fn::invoke:
      function: gcp:storage:getBucketObjectContent
      arguments:
        name: encryptedkey
        bucket: keystore
outputs:
  encrypted: ${key.content}
Copy

Using getBucketObjectContent

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 getBucketObjectContent(args: GetBucketObjectContentArgs, opts?: InvokeOptions): Promise<GetBucketObjectContentResult>
function getBucketObjectContentOutput(args: GetBucketObjectContentOutputArgs, opts?: InvokeOptions): Output<GetBucketObjectContentResult>
Copy
def get_bucket_object_content(bucket: Optional[str] = None,
                              content: Optional[str] = None,
                              name: Optional[str] = None,
                              opts: Optional[InvokeOptions] = None) -> GetBucketObjectContentResult
def get_bucket_object_content_output(bucket: Optional[pulumi.Input[str]] = None,
                              content: Optional[pulumi.Input[str]] = None,
                              name: Optional[pulumi.Input[str]] = None,
                              opts: Optional[InvokeOptions] = None) -> Output[GetBucketObjectContentResult]
Copy
func GetBucketObjectContent(ctx *Context, args *GetBucketObjectContentArgs, opts ...InvokeOption) (*GetBucketObjectContentResult, error)
func GetBucketObjectContentOutput(ctx *Context, args *GetBucketObjectContentOutputArgs, opts ...InvokeOption) GetBucketObjectContentResultOutput
Copy

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

public static class GetBucketObjectContent 
{
    public static Task<GetBucketObjectContentResult> InvokeAsync(GetBucketObjectContentArgs args, InvokeOptions? opts = null)
    public static Output<GetBucketObjectContentResult> Invoke(GetBucketObjectContentInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetBucketObjectContentResult> getBucketObjectContent(GetBucketObjectContentArgs args, InvokeOptions options)
public static Output<GetBucketObjectContentResult> getBucketObjectContent(GetBucketObjectContentArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: gcp:storage/getBucketObjectContent:getBucketObjectContent
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Bucket This property is required. string
The name of the containing bucket.
Name This property is required. string
The name of the object.
Content string
(Computed) The content of the object.
Bucket This property is required. string
The name of the containing bucket.
Name This property is required. string
The name of the object.
Content string
(Computed) The content of the object.
bucket This property is required. String
The name of the containing bucket.
name This property is required. String
The name of the object.
content String
(Computed) The content of the object.
bucket This property is required. string
The name of the containing bucket.
name This property is required. string
The name of the object.
content string
(Computed) The content of the object.
bucket This property is required. str
The name of the containing bucket.
name This property is required. str
The name of the object.
content str
(Computed) The content of the object.
bucket This property is required. String
The name of the containing bucket.
name This property is required. String
The name of the object.
content String
(Computed) The content of the object.

getBucketObjectContent Result

The following output properties are available:

Bucket string
CacheControl string
Content string
(Computed) The content of the object.
ContentDisposition string
ContentEncoding string
ContentLanguage string
ContentType string
Crc32c string
CustomerEncryptions List<GetBucketObjectContentCustomerEncryption>
DetectMd5hash string
EventBasedHold bool
Generation int
Id string
The provider-assigned unique ID for this managed resource.
KmsKeyName string
Md5hash string
MediaLink string
Metadata Dictionary<string, string>
Name string
OutputName string
Retentions List<GetBucketObjectContentRetention>
SelfLink string
Source string
StorageClass string
TemporaryHold bool
Bucket string
CacheControl string
Content string
(Computed) The content of the object.
ContentDisposition string
ContentEncoding string
ContentLanguage string
ContentType string
Crc32c string
CustomerEncryptions []GetBucketObjectContentCustomerEncryption
DetectMd5hash string
EventBasedHold bool
Generation int
Id string
The provider-assigned unique ID for this managed resource.
KmsKeyName string
Md5hash string
MediaLink string
Metadata map[string]string
Name string
OutputName string
Retentions []GetBucketObjectContentRetention
SelfLink string
Source string
StorageClass string
TemporaryHold bool
bucket String
cacheControl String
content String
(Computed) The content of the object.
contentDisposition String
contentEncoding String
contentLanguage String
contentType String
crc32c String
customerEncryptions List<GetBucketObjectContentCustomerEncryption>
detectMd5hash String
eventBasedHold Boolean
generation Integer
id String
The provider-assigned unique ID for this managed resource.
kmsKeyName String
md5hash String
mediaLink String
metadata Map<String,String>
name String
outputName String
retentions List<GetBucketObjectContentRetention>
selfLink String
source String
storageClass String
temporaryHold Boolean
bucket string
cacheControl string
content string
(Computed) The content of the object.
contentDisposition string
contentEncoding string
contentLanguage string
contentType string
crc32c string
customerEncryptions GetBucketObjectContentCustomerEncryption[]
detectMd5hash string
eventBasedHold boolean
generation number
id string
The provider-assigned unique ID for this managed resource.
kmsKeyName string
md5hash string
mediaLink string
metadata {[key: string]: string}
name string
outputName string
retentions GetBucketObjectContentRetention[]
selfLink string
source string
storageClass string
temporaryHold boolean
bucket String
cacheControl String
content String
(Computed) The content of the object.
contentDisposition String
contentEncoding String
contentLanguage String
contentType String
crc32c String
customerEncryptions List<Property Map>
detectMd5hash String
eventBasedHold Boolean
generation Number
id String
The provider-assigned unique ID for this managed resource.
kmsKeyName String
md5hash String
mediaLink String
metadata Map<String>
name String
outputName String
retentions List<Property Map>
selfLink String
source String
storageClass String
temporaryHold Boolean

Supporting Types

GetBucketObjectContentCustomerEncryption

EncryptionAlgorithm This property is required. string
The encryption algorithm. Default: AES256
EncryptionKey This property is required. string
Base64 encoded customer supplied encryption key.
EncryptionAlgorithm This property is required. string
The encryption algorithm. Default: AES256
EncryptionKey This property is required. string
Base64 encoded customer supplied encryption key.
encryptionAlgorithm This property is required. String
The encryption algorithm. Default: AES256
encryptionKey This property is required. String
Base64 encoded customer supplied encryption key.
encryptionAlgorithm This property is required. string
The encryption algorithm. Default: AES256
encryptionKey This property is required. string
Base64 encoded customer supplied encryption key.
encryption_algorithm This property is required. str
The encryption algorithm. Default: AES256
encryption_key This property is required. str
Base64 encoded customer supplied encryption key.
encryptionAlgorithm This property is required. String
The encryption algorithm. Default: AES256
encryptionKey This property is required. String
Base64 encoded customer supplied encryption key.

GetBucketObjectContentRetention

Mode This property is required. string
The object retention mode. Supported values include: "Unlocked", "Locked".
RetainUntilTime This property is required. string
Time in RFC 3339 (e.g. 2030-01-01T02:03:04Z) until which object retention protects this object.
Mode This property is required. string
The object retention mode. Supported values include: "Unlocked", "Locked".
RetainUntilTime This property is required. string
Time in RFC 3339 (e.g. 2030-01-01T02:03:04Z) until which object retention protects this object.
mode This property is required. String
The object retention mode. Supported values include: "Unlocked", "Locked".
retainUntilTime This property is required. String
Time in RFC 3339 (e.g. 2030-01-01T02:03:04Z) until which object retention protects this object.
mode This property is required. string
The object retention mode. Supported values include: "Unlocked", "Locked".
retainUntilTime This property is required. string
Time in RFC 3339 (e.g. 2030-01-01T02:03:04Z) until which object retention protects this object.
mode This property is required. str
The object retention mode. Supported values include: "Unlocked", "Locked".
retain_until_time This property is required. str
Time in RFC 3339 (e.g. 2030-01-01T02:03:04Z) until which object retention protects this object.
mode This property is required. String
The object retention mode. Supported values include: "Unlocked", "Locked".
retainUntilTime This property is required. String
Time in RFC 3339 (e.g. 2030-01-01T02:03:04Z) until which object retention protects this 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.23.0 published on Monday, Mar 24, 2025 by Pulumi