BatchOperationsJob class
Storage Batch Operations (SBO) is a Cloud Storage management feature that offers a seamless experience to perform single batch operations on millions of GCS objects in a serverless manner.
Example Usage
Storage Batch Operations
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const bucket = new gcp.storage.Bucket("bucket", {
name: "tf-sample-bucket",
location: "us-central1",
forceDestroy: true,
});
const tf_job = new gcp.storage.BatchOperationsJob("tf-job", {
jobId: "tf-job",
bucketList: {
buckets: {
bucket: bucket.name,
prefixList: {
includedObjectPrefixes: ["bkt"],
},
},
},
putMetadata: {
customMetadata: {
key: "value",
},
},
deleteProtection: false,
});
import pulumi
import pulumi_gcp as gcp
bucket = gcp.storage.Bucket("bucket",
name="tf-sample-bucket",
location="us-central1",
force_destroy=True)
tf_job = gcp.storage.BatchOperationsJob("tf-job",
job_id="tf-job",
bucket_list={
"buckets": {
"bucket": bucket.name,
"prefix_list": {
"included_object_prefixes": ["bkt"],
},
},
},
put_metadata={
"custom_metadata": {
"key": "value",
},
},
delete_protection=False)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var bucket = new Gcp.Storage.Bucket("bucket", new()
{
Name = "tf-sample-bucket",
Location = "us-central1",
ForceDestroy = true,
});
var tf_job = new Gcp.Storage.BatchOperationsJob("tf-job", new()
{
JobId = "tf-job",
BucketList = new Gcp.Storage.Inputs.BatchOperationsJobBucketListArgs
{
Buckets = new Gcp.Storage.Inputs.BatchOperationsJobBucketListBucketsArgs
{
Bucket = bucket.Name,
PrefixList = new Gcp.Storage.Inputs.BatchOperationsJobBucketListBucketsPrefixListArgs
{
IncludedObjectPrefixes = new[]
{
"bkt",
},
},
},
},
PutMetadata = new Gcp.Storage.Inputs.BatchOperationsJobPutMetadataArgs
{
CustomMetadata =
{
{ "key", "value" },
},
},
DeleteProtection = false,
});
});
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 {
bucket, err := storage.NewBucket(ctx, "bucket", &storage.BucketArgs{
Name: pulumi.String("tf-sample-bucket"),
Location: pulumi.String("us-central1"),
ForceDestroy: pulumi.Bool(true),
})
if err != nil {
return err
}
_, err = storage.NewBatchOperationsJob(ctx, "tf-job", &storage.BatchOperationsJobArgs{
JobId: pulumi.String("tf-job"),
BucketList: &storage.BatchOperationsJobBucketListArgs{
Buckets: &storage.BatchOperationsJobBucketListBucketsArgs{
Bucket: bucket.Name,
PrefixList: &storage.BatchOperationsJobBucketListBucketsPrefixListArgs{
IncludedObjectPrefixes: pulumi.StringArray{
pulumi.String("bkt"),
},
},
},
},
PutMetadata: &storage.BatchOperationsJobPutMetadataArgs{
CustomMetadata: pulumi.StringMap{
"key": pulumi.String("value"),
},
},
DeleteProtection: pulumi.Bool(false),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_storage_bucket" "bucket" {
name = "tf-sample-bucket"
location = "us-central1"
force_destroy = true
}
resource "gcp_storage_batchoperationsjob" "tf-job" {
job_id = "tf-job"
bucket_list = {
buckets = {
bucket = gcp_storage_bucket.bucket.name
prefix_list = {
included_object_prefixes = ["bkt"]
}
}
}
put_metadata = {
custom_metadata = {
"key" = "value"
}
}
delete_protection = false
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.storage.Bucket;
import com.pulumi.gcp.storage.BucketArgs;
import com.pulumi.gcp.storage.BatchOperationsJob;
import com.pulumi.gcp.storage.BatchOperationsJobArgs;
import com.pulumi.gcp.storage.inputs.BatchOperationsJobBucketListArgs;
import com.pulumi.gcp.storage.inputs.BatchOperationsJobBucketListBucketsArgs;
import com.pulumi.gcp.storage.inputs.BatchOperationsJobBucketListBucketsPrefixListArgs;
import com.pulumi.gcp.storage.inputs.BatchOperationsJobPutMetadataArgs;
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 bucket = new Bucket("bucket", BucketArgs.builder()
.name("tf-sample-bucket")
.location("us-central1")
.forceDestroy(true)
.build());
var tf_job = new BatchOperationsJob("tf-job", BatchOperationsJobArgs.builder()
.jobId("tf-job")
.bucketList(BatchOperationsJobBucketListArgs.builder()
.buckets(BatchOperationsJobBucketListBucketsArgs.builder()
.bucket(bucket.name())
.prefixList(BatchOperationsJobBucketListBucketsPrefixListArgs.builder()
.includedObjectPrefixes("bkt")
.build())
.build())
.build())
.putMetadata(BatchOperationsJobPutMetadataArgs.builder()
.customMetadata(Map.of("key", "value"))
.build())
.deleteProtection(false)
.build());
}
}
resources:
bucket:
type: gcp:storage:Bucket
properties:
name: tf-sample-bucket
location: us-central1
forceDestroy: true
tf-job:
type: gcp:storage:BatchOperationsJob
properties:
jobId: tf-job
bucketList:
buckets:
bucket: ${bucket.name}
prefixList:
includedObjectPrefixes:
- bkt
putMetadata:
customMetadata:
key: value
deleteProtection: false
Storage Batch Operations Description
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const bucket = new gcp.storage.Bucket("bucket", {
name: "tf-sample-bucket",
location: "us-central1",
forceDestroy: true,
});
const tf_job = new gcp.storage.BatchOperationsJob("tf-job", {
jobId: "tf-job",
description: "A sample job description",
bucketList: {
buckets: {
bucket: bucket.name,
prefixList: {
includedObjectPrefixes: ["bkt"],
},
},
},
putMetadata: {
customMetadata: {
key: "value",
},
},
deleteProtection: false,
});
import pulumi
import pulumi_gcp as gcp
bucket = gcp.storage.Bucket("bucket",
name="tf-sample-bucket",
location="us-central1",
force_destroy=True)
tf_job = gcp.storage.BatchOperationsJob("tf-job",
job_id="tf-job",
description="A sample job description",
bucket_list={
"buckets": {
"bucket": bucket.name,
"prefix_list": {
"included_object_prefixes": ["bkt"],
},
},
},
put_metadata={
"custom_metadata": {
"key": "value",
},
},
delete_protection=False)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var bucket = new Gcp.Storage.Bucket("bucket", new()
{
Name = "tf-sample-bucket",
Location = "us-central1",
ForceDestroy = true,
});
var tf_job = new Gcp.Storage.BatchOperationsJob("tf-job", new()
{
JobId = "tf-job",
Description = "A sample job description",
BucketList = new Gcp.Storage.Inputs.BatchOperationsJobBucketListArgs
{
Buckets = new Gcp.Storage.Inputs.BatchOperationsJobBucketListBucketsArgs
{
Bucket = bucket.Name,
PrefixList = new Gcp.Storage.Inputs.BatchOperationsJobBucketListBucketsPrefixListArgs
{
IncludedObjectPrefixes = new[]
{
"bkt",
},
},
},
},
PutMetadata = new Gcp.Storage.Inputs.BatchOperationsJobPutMetadataArgs
{
CustomMetadata =
{
{ "key", "value" },
},
},
DeleteProtection = false,
});
});
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 {
bucket, err := storage.NewBucket(ctx, "bucket", &storage.BucketArgs{
Name: pulumi.String("tf-sample-bucket"),
Location: pulumi.String("us-central1"),
ForceDestroy: pulumi.Bool(true),
})
if err != nil {
return err
}
_, err = storage.NewBatchOperationsJob(ctx, "tf-job", &storage.BatchOperationsJobArgs{
JobId: pulumi.String("tf-job"),
Description: pulumi.String("A sample job description"),
BucketList: &storage.BatchOperationsJobBucketListArgs{
Buckets: &storage.BatchOperationsJobBucketListBucketsArgs{
Bucket: bucket.Name,
PrefixList: &storage.BatchOperationsJobBucketListBucketsPrefixListArgs{
IncludedObjectPrefixes: pulumi.StringArray{
pulumi.String("bkt"),
},
},
},
},
PutMetadata: &storage.BatchOperationsJobPutMetadataArgs{
CustomMetadata: pulumi.StringMap{
"key": pulumi.String("value"),
},
},
DeleteProtection: pulumi.Bool(false),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_storage_bucket" "bucket" {
name = "tf-sample-bucket"
location = "us-central1"
force_destroy = true
}
resource "gcp_storage_batchoperationsjob" "tf-job" {
job_id = "tf-job"
description = "A sample job description"
bucket_list = {
buckets = {
bucket = gcp_storage_bucket.bucket.name
prefix_list = {
included_object_prefixes = ["bkt"]
}
}
}
put_metadata = {
custom_metadata = {
"key" = "value"
}
}
delete_protection = false
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.storage.Bucket;
import com.pulumi.gcp.storage.BucketArgs;
import com.pulumi.gcp.storage.BatchOperationsJob;
import com.pulumi.gcp.storage.BatchOperationsJobArgs;
import com.pulumi.gcp.storage.inputs.BatchOperationsJobBucketListArgs;
import com.pulumi.gcp.storage.inputs.BatchOperationsJobBucketListBucketsArgs;
import com.pulumi.gcp.storage.inputs.BatchOperationsJobBucketListBucketsPrefixListArgs;
import com.pulumi.gcp.storage.inputs.BatchOperationsJobPutMetadataArgs;
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 bucket = new Bucket("bucket", BucketArgs.builder()
.name("tf-sample-bucket")
.location("us-central1")
.forceDestroy(true)
.build());
var tf_job = new BatchOperationsJob("tf-job", BatchOperationsJobArgs.builder()
.jobId("tf-job")
.description("A sample job description")
.bucketList(BatchOperationsJobBucketListArgs.builder()
.buckets(BatchOperationsJobBucketListBucketsArgs.builder()
.bucket(bucket.name())
.prefixList(BatchOperationsJobBucketListBucketsPrefixListArgs.builder()
.includedObjectPrefixes("bkt")
.build())
.build())
.build())
.putMetadata(BatchOperationsJobPutMetadataArgs.builder()
.customMetadata(Map.of("key", "value"))
.build())
.deleteProtection(false)
.build());
}
}
resources:
bucket:
type: gcp:storage:Bucket
properties:
name: tf-sample-bucket
location: us-central1
forceDestroy: true
tf-job:
type: gcp:storage:BatchOperationsJob
properties:
jobId: tf-job
description: A sample job description
bucketList:
buckets:
bucket: ${bucket.name}
prefixList:
includedObjectPrefixes:
- bkt
putMetadata:
customMetadata:
key: value
deleteProtection: false
Import
Job can be imported using any of these accepted formats:
projects/{{project}}/locations/global/jobs/{{job_id}}{{project}}/{{job_id}}{{job_id}}
When using the pulumi import command, Job can be imported using one of the formats above. For example:
$ pulumi import gcp:storage/batchOperationsJob:BatchOperationsJob default projects/{{project}}/locations/global/jobs/{{job_id}}
$ pulumi import gcp:storage/batchOperationsJob:BatchOperationsJob default {{project}}/{{job_id}}
$ pulumi import gcp:storage/batchOperationsJob:BatchOperationsJob default {{job_id}}
Constructors
- BatchOperationsJob(String name, {BatchOperationsJobArgs? args, CustomResourceOptions? options})
-
Creates a new BatchOperationsJob.
nameThe Pulumi resource name.argsArguments used to configure this BatchOperationsJob. The set of arguments for BatchOperationsJob.optionsResource options controlling this resource's behavior. - BatchOperationsJob.reference(String urn)
- Creates a typed reference to an existing BatchOperationsJob resource.
Properties
-
bucketList
↔ Output<
BatchOperationsJobBucketList?> -
List of buckets and their objects to be transformed. Currently, only one bucket configuration is supported. If multiple buckets are specified, an error will be returned
Structure is documented below.
latefinal
-
childResources
→ Set<
Resource> -
finalinherited
-
completeTime
↔ Output<
String> -
The time that the job was completed.
latefinal
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
createTime
↔ Output<
String> -
The timestamp at which this storage batch operation was created.
latefinal
-
deleteObject
↔ Output<
BatchOperationsJobDeleteObject?> -
allows batch operations to delete objects in bucket
Structure is documented below.
latefinal
-
deleteProtection
↔ Output<
bool?> -
If set to
true, the storage batch operation job will not be deleted and new job will be created.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
-
description
↔ Output<
String?> -
A description provided by the user for the job. Its max length is 1024 bytes when Unicode-encoded.
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
-
jobId
↔ Output<
String?> -
The ID of the job.
latefinal
-
project
↔ Output<
String> -
The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
latefinal
-
putMetadata
↔ Output<
BatchOperationsJobPutMetadata?> -
allows batch operations to update metadata for objects in bucket
Structure is documented below.
latefinal
-
putObjectHold
↔ Output<
BatchOperationsJobPutObjectHold?> -
allows to update temporary hold or eventBased hold for objects in bucket.
Structure is documented below.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
-
rewriteObject
↔ Output<
BatchOperationsJobRewriteObject?> -
allows to update encryption key for objects in bucket.
Structure is documented below.
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
scheduleTime
↔ Output<
String> -
The time that the job was scheduled.
latefinal
-
state
↔ Output<
String> -
State of the job.
latefinal
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
updateTime
↔ Output<
String> -
The timestamp at which this storage batch operation was most recently updated.
latefinal
-
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, {BatchOperationsJobState? state, CustomResourceOptions? options}) → BatchOperationsJob -
Gets an existing BatchOperationsJob resource's state with the given
nameandid.