Bucket Object Args
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/v8/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
})
}
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.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) {
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/v8/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
})
}
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.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) {
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
Import
This resource does not support import.
Constructors
Properties
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
Content-Disposition of the object data.
Content-Encoding of the object data.
Content-Language of the object data.
Content-Type of the object data. Defaults to "application/octet-stream" or "text/plain; charset=utf-8".
Enables object encryption with Customer-Supplied Encryption Key (CSEK). Google documentation about CSEK. Structure is documented below.
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).
The resource name of the Cloud KMS key that will be used to encrypt the object.
The object retention settings for the object. The retention settings allow an object to be retained until a provided date. Structure is documented below.
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.
Whether an object is under temporary hold. While this flag is set to true, the object is protected against deletion and overwrites.