BucketObject class
Creates a new object inside an existing bucket in Google cloud storage service (GCS).
ACLs can be applied using the gcp.storage.ObjectACL resource.
For more information see
the official documentation
and
API.
A datasource can be used to retrieve the data of the stored object:
gcp.storage.getBucketObjectContent: Retrieves the content within a specified bucket object in Google Cloud Storage Service (GCS)
Example Usage
Example creating a public object in an existing image-store bucket.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const picture = new gcp.storage.BucketObject("picture", {
name: "butterfly01",
source: new pulumi.asset.FileAsset("/images/nature/garden-tiger-moth.jpg"),
bucket: "image-store",
});
import pulumi
import pulumi_gcp as gcp
picture = gcp.storage.BucketObject("picture",
name="butterfly01",
source=pulumi.FileAsset("/images/nature/garden-tiger-moth.jpg"),
bucket="image-store")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var picture = new Gcp.Storage.BucketObject("picture", new()
{
Name = "butterfly01",
Source = new FileAsset("/images/nature/garden-tiger-moth.jpg"),
Bucket = "image-store",
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/storage"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := storage.NewBucketObject(ctx, "picture", &storage.BucketObjectArgs{
Name: pulumi.String("butterfly01"),
Source: pulumi.NewFileAsset("/images/nature/garden-tiger-moth.jpg"),
Bucket: pulumi.String("image-store"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_storage_bucketobject" "picture" {
name = "butterfly01"
source = fileAsset("/images/nature/garden-tiger-moth.jpg")
bucket = "image-store"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.storage.BucketObject;
import com.pulumi.gcp.storage.BucketObjectArgs;
import com.pulumi.asset.FileAsset;
import java.util.ArrayList;
import java.util.Arrays;
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 picture = new BucketObject("picture", BucketObjectArgs.builder()
.name("butterfly01")
.source(new FileAsset("/images/nature/garden-tiger-moth.jpg"))
.bucket("image-store")
.build());
}
}
resources:
picture:
type: gcp:storage:BucketObject
properties:
name: butterfly01
source:
fn::fileAsset: /images/nature/garden-tiger-moth.jpg
bucket: image-store
Example creating an empty folder in an existing image-store bucket.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const emptyFolder = new gcp.storage.BucketObject("empty_folder", {
name: "empty_folder/",
content: " ",
bucket: "image-store",
});
import pulumi
import pulumi_gcp as gcp
empty_folder = gcp.storage.BucketObject("empty_folder",
name="empty_folder/",
content=" ",
bucket="image-store")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var emptyFolder = new Gcp.Storage.BucketObject("empty_folder", new()
{
Name = "empty_folder/",
Content = " ",
Bucket = "image-store",
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/storage"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := storage.NewBucketObject(ctx, "empty_folder", &storage.BucketObjectArgs{
Name: pulumi.String("empty_folder/"),
Content: pulumi.String(" "),
Bucket: pulumi.String("image-store"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_storage_bucketobject" "empty_folder" {
name = "empty_folder/"
content = " "
bucket = "image-store"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.storage.BucketObject;
import com.pulumi.gcp.storage.BucketObjectArgs;
import java.util.ArrayList;
import java.util.Arrays;
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 emptyFolder = new BucketObject("emptyFolder", BucketObjectArgs.builder()
.name("empty_folder/")
.content(" ")
.bucket("image-store")
.build());
}
}
resources:
emptyFolder:
type: gcp:storage:BucketObject
name: empty_folder
properties:
name: empty_folder/
content: ' '
bucket: image-store
Example creating an contexts for an object.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const bucketObject = new gcp.storage.BucketObject("bucket_object", {
bucket: "test-bucket",
name: "test-object",
content: "test-content",
contexts: {
customs: [
{
key: "testKey",
value: "test",
},
{
key: "testKeyTwo",
value: "test",
},
],
},
});
import pulumi
import pulumi_gcp as gcp
bucket_object = gcp.storage.BucketObject("bucket_object",
bucket="test-bucket",
name="test-object",
content="test-content",
contexts={
"customs": [
{
"key": "testKey",
"value": "test",
},
{
"key": "testKeyTwo",
"value": "test",
},
],
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var bucketObject = new Gcp.Storage.BucketObject("bucket_object", new()
{
Bucket = "test-bucket",
Name = "test-object",
Content = "test-content",
Contexts = new Gcp.Storage.Inputs.BucketObjectContextsArgs
{
Customs = new[]
{
new Gcp.Storage.Inputs.BucketObjectContextsCustomArgs
{
Key = "testKey",
Value = "test",
},
new Gcp.Storage.Inputs.BucketObjectContextsCustomArgs
{
Key = "testKeyTwo",
Value = "test",
},
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/storage"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := storage.NewBucketObject(ctx, "bucket_object", &storage.BucketObjectArgs{
Bucket: pulumi.String("test-bucket"),
Name: pulumi.String("test-object"),
Content: pulumi.String("test-content"),
Contexts: &storage.BucketObjectContextsArgs{
Customs: storage.BucketObjectContextsCustomArray{
&storage.BucketObjectContextsCustomArgs{
Key: pulumi.String("testKey"),
Value: pulumi.String("test"),
},
&storage.BucketObjectContextsCustomArgs{
Key: pulumi.String("testKeyTwo"),
Value: pulumi.String("test"),
},
},
},
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_storage_bucketobject" "bucket_object" {
bucket = "test-bucket"
name = "test-object"
content = "test-content"
contexts = {
customs = [{
"key" = "testKey"
"value" = "test"
}, {
"key" = "testKeyTwo"
"value" = "test"
}]
}
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.storage.BucketObject;
import com.pulumi.gcp.storage.BucketObjectArgs;
import com.pulumi.gcp.storage.inputs.BucketObjectContextsArgs;
import com.pulumi.gcp.storage.inputs.BucketObjectContextsCustomArgs;
import java.util.ArrayList;
import java.util.Arrays;
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 bucketObject = new BucketObject("bucketObject", BucketObjectArgs.builder()
.bucket("test-bucket")
.name("test-object")
.content("test-content")
.contexts(BucketObjectContextsArgs.builder()
.customs(
BucketObjectContextsCustomArgs.builder()
.key("testKey")
.value("test")
.build(),
BucketObjectContextsCustomArgs.builder()
.key("testKeyTwo")
.value("test")
.build())
.build())
.build());
}
}
resources:
bucketObject:
type: gcp:storage:BucketObject
name: bucket_object
properties:
bucket: test-bucket
name: test-object
content: test-content
contexts:
customs:
- key: testKey
value: test
- key: testKeyTwo
value: test
Import
This resource does not support import.
Constructors
- BucketObject(String name, {BucketObjectArgs? args, CustomResourceOptions? options})
-
Creates a new BucketObject.
nameThe Pulumi resource name.argsArguments used to configure this BucketObject. The set of arguments for BucketObject.optionsResource options controlling this resource's behavior. - BucketObject.reference(String urn)
- Creates a typed reference to an existing BucketObject resource.
Properties
-
bucket
↔ Output<
String> -
The name of the containing bucket.
latefinal
-
cacheControl
↔ Output<
String?> -
Cache-Control
directive to specify caching behavior of object data. If omitted and object is accessible to all anonymous users, the default will be public, max-age=3600
latefinal
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
content
↔ Output<
String> -
Data as
stringto be uploaded. Must be defined ifsourceis not. Note: Thecontentfield is marked as sensitive.latefinal -
contentDisposition
↔ Output<
String?> -
Content-Disposition of the object data.
latefinal
-
contentEncoding
↔ Output<
String?> -
Content-Encoding of the object data.
latefinal
-
contentLanguage
↔ Output<
String?> -
Content-Language of the object data.
latefinal
-
contentType
↔ Output<
String> -
Content-Type of the object data. Defaults to "application/octet-stream" or "text/plain; charset=utf-8".
latefinal
-
contexts
↔ Output<
BucketObjectContexts?> -
Contexts attached to an object, in key-value pairs. For more information about object contexts, see Object contexts overview. Structure is documented below.
latefinal
-
crc32c
↔ Output<
String> -
(Computed) Base 64 CRC32 hash of the uploaded data.
latefinal
-
customerEncryption
↔ Output<
BucketObjectCustomerEncryption?> -
Enables object encryption with Customer-Supplied Encryption Key (CSEK). Google documentation about CSEK.
Structure is documented below.
latefinal
-
deletionPolicy
↔ Output<
String> -
Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE".
When a 'terraform destroy' or 'pulumi up' would delete the resource,
the command will fail if this field is set to "PREVENT" in Terraform state.
When set to "ABANDON", the command will remove the resource from Terraform
management without updating or deleting the resource in the API.
When set to "DELETE", deleting the resource is allowed.
latefinal
-
detectMd5hash
↔ Output<
String?> -
Detect changes to local file or changes made outside of Terraform to the file stored on the server. MD5 hash of the data, encoded using base64. This field is not present for composite objects. For more information about using the MD5 hash, see Hashes and ETags: Best Practices.
latefinal
-
eventBasedHold
↔ Output<
bool?> -
Whether an object is under event-based hold. Event-based hold is a way to retain objects until an event occurs, which is signified by the hold's release (i.e. this value is set to false). After being released (set to false), such objects will be subject to bucket-level retention (if any).
latefinal
-
forceEmptyContentType
↔ Output<
bool?> -
When set to true, it ensure the object's Content-Type is empty.
latefinal
-
generation
↔ Output<
int> -
(Computed) The content generation of this object. Used for object versioning and soft delete.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
kmsKeyName
↔ Output<
String> -
The resource name of the Cloud KMS key that will be used to encrypt the object.
latefinal
-
md5hash
↔ Output<
String> -
(Computed) Base 64 MD5 hash of the uploaded data.
latefinal
-
md5hexhash
↔ Output<
String> -
(Computed) Hex value of md5hash`
latefinal
-
mediaLink
↔ Output<
String> -
(Computed) A url reference to download this object.
latefinal
-
metadata
↔ Output<
Map< String, String> ?> -
User-provided metadata, in key/value pairs.
latefinal
-
name
↔ Output<
String> -
The name of the object. If you're interpolating the name of this object, see
outputNameinstead.latefinal -
outputName
↔ Output<
String> -
(Computed) The name of the object. Use this field in interpolations with
gcp.storage.ObjectACLto recreategcp.storage.ObjectACLresources when yourgcp.storage.BucketObjectis recreated.latefinal -
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
-
retention
↔ Output<
BucketObjectRetention?> -
The object retention settings for the object. The retention settings allow an object to be retained until a provided date. Structure is documented below.
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
selfLink
↔ Output<
String> -
(Computed) A url reference to this object.
latefinal
- source ↔ Output
-
A path to the data you want to upload. Must be defined
if
contentis not.latefinal -
sourceMd5hash
↔ Output<
String?> -
User-provided md5hash to trigger replacement of object in storage bucket, Must be Base 64 MD5 hash of the object data. The usual way to set this is filemd5("file.zip"), where "file.zip" is the local filename
latefinal
-
storageClass
↔ Output<
String> -
The StorageClass of the new bucket object.
Supported values include:
MULTI_REGIONAL,REGIONAL,NEARLINE,COLDLINE,ARCHIVE. If not provided, this defaults to the bucket's default storage class or to a standard class.latefinal -
temporaryHold
↔ Output<
bool?> -
Whether an object is under temporary hold. While this flag is set to true, the object is protected against deletion and overwrites.
latefinal
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {BucketObjectState? state, CustomResourceOptions? options}) → BucketObject -
Gets an existing BucketObject resource's state with the given
nameandid.