BucketObjectv2Args

data class BucketObjectv2Args(val acl: Output<String>? = null, val bucket: Output<String>? = null, val bucketKeyEnabled: Output<Boolean>? = null, val cacheControl: Output<String>? = null, val checksumAlgorithm: Output<String>? = null, val content: Output<String>? = null, val contentBase64: Output<String>? = null, val contentDisposition: Output<String>? = null, val contentEncoding: Output<String>? = null, val contentLanguage: Output<String>? = null, val contentType: Output<String>? = null, val etag: Output<String>? = null, val forceDestroy: Output<Boolean>? = null, val key: Output<String>? = null, val kmsKeyId: Output<String>? = null, val metadata: Output<Map<String, String>>? = null, val objectLockLegalHoldStatus: Output<String>? = null, val objectLockMode: Output<String>? = null, val objectLockRetainUntilDate: Output<String>? = null, val overrideProvider: Output<BucketObjectv2OverrideProviderArgs>? = null, val serverSideEncryption: Output<String>? = null, val source: Output<AssetOrArchive>? = null, val sourceHash: Output<String>? = null, val storageClass: Output<String>? = null, val tags: Output<Map<String, String>>? = null, val websiteRedirect: Output<String>? = null) : ConvertibleToJava<BucketObjectv2Args>

Provides an S3 object resource.

Example Usage

Uploading a file to a bucket

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as std from "@pulumi/std";
const object = new aws.s3.BucketObjectv2("object", {
bucket: "your_bucket_name",
key: "new_object_key",
source: new pulumi.asset.FileAsset("path/to/file"),
etag: std.filemd5({
input: "path/to/file",
}).then(invoke => invoke.result),
});
import pulumi
import pulumi_aws as aws
import pulumi_std as std
object = aws.s3.BucketObjectv2("object",
bucket="your_bucket_name",
key="new_object_key",
source=pulumi.FileAsset("path/to/file"),
etag=std.filemd5(input="path/to/file").result)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
using Std = Pulumi.Std;
return await Deployment.RunAsync(() =>
{
var @object = new Aws.S3.BucketObjectv2("object", new()
{
Bucket = "your_bucket_name",
Key = "new_object_key",
Source = new FileAsset("path/to/file"),
Etag = Std.Filemd5.Invoke(new()
{
Input = "path/to/file",
}).Apply(invoke => invoke.Result),
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
"github.com/pulumi/pulumi-std/sdk/go/std"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
invokeFilemd5, err := std.Filemd5(ctx, &std.Filemd5Args{
Input: "path/to/file",
}, nil)
if err != nil {
return err
}
_, err = s3.NewBucketObjectv2(ctx, "object", &s3.BucketObjectv2Args{
Bucket: pulumi.Any("your_bucket_name"),
Key: pulumi.String("new_object_key"),
Source: pulumi.NewFileAsset("path/to/file"),
Etag: pulumi.String(invokeFilemd5.Result),
})
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.aws.s3.BucketObjectv2;
import com.pulumi.aws.s3.BucketObjectv2Args;
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 object = new BucketObjectv2("object", BucketObjectv2Args.builder()
.bucket("your_bucket_name")
.key("new_object_key")
.source(new FileAsset("path/to/file"))
.etag(StdFunctions.filemd5(Filemd5Args.builder()
.input("path/to/file")
.build()).result())
.build());
}
}
resources:
object:
type: aws:s3:BucketObjectv2
properties:
bucket: your_bucket_name
key: new_object_key
source:
fn::FileAsset: path/to/file
etag:
fn::invoke:
function: std:filemd5
arguments:
input: path/to/file
return: result

Encrypting with KMS Key

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const examplekms = new aws.kms.Key("examplekms", {
description: "KMS key 1",
deletionWindowInDays: 7,
});
const examplebucket = new aws.s3.BucketV2("examplebucket", {bucket: "examplebuckettftest"});
const example = new aws.s3.BucketAclV2("example", {
bucket: examplebucket.id,
acl: "private",
});
const exampleBucketObjectv2 = new aws.s3.BucketObjectv2("example", {
key: "someobject",
bucket: examplebucket.id,
source: new pulumi.asset.FileAsset("index.html"),
kmsKeyId: examplekms.arn,
});
import pulumi
import pulumi_aws as aws
examplekms = aws.kms.Key("examplekms",
description="KMS key 1",
deletion_window_in_days=7)
examplebucket = aws.s3.BucketV2("examplebucket", bucket="examplebuckettftest")
example = aws.s3.BucketAclV2("example",
bucket=examplebucket.id,
acl="private")
example_bucket_objectv2 = aws.s3.BucketObjectv2("example",
key="someobject",
bucket=examplebucket.id,
source=pulumi.FileAsset("index.html"),
kms_key_id=examplekms.arn)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var examplekms = new Aws.Kms.Key("examplekms", new()
{
Description = "KMS key 1",
DeletionWindowInDays = 7,
});
var examplebucket = new Aws.S3.BucketV2("examplebucket", new()
{
Bucket = "examplebuckettftest",
});
var example = new Aws.S3.BucketAclV2("example", new()
{
Bucket = examplebucket.Id,
Acl = "private",
});
var exampleBucketObjectv2 = new Aws.S3.BucketObjectv2("example", new()
{
Key = "someobject",
Bucket = examplebucket.Id,
Source = new FileAsset("index.html"),
KmsKeyId = examplekms.Arn,
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/kms"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
examplekms, err := kms.NewKey(ctx, "examplekms", &kms.KeyArgs{
Description: pulumi.String("KMS key 1"),
DeletionWindowInDays: pulumi.Int(7),
})
if err != nil {
return err
}
examplebucket, err := s3.NewBucketV2(ctx, "examplebucket", &s3.BucketV2Args{
Bucket: pulumi.String("examplebuckettftest"),
})
if err != nil {
return err
}
_, err = s3.NewBucketAclV2(ctx, "example", &s3.BucketAclV2Args{
Bucket: examplebucket.ID(),
Acl: pulumi.String("private"),
})
if err != nil {
return err
}
_, err = s3.NewBucketObjectv2(ctx, "example", &s3.BucketObjectv2Args{
Key: pulumi.String("someobject"),
Bucket: examplebucket.ID(),
Source: pulumi.NewFileAsset("index.html"),
KmsKeyId: examplekms.Arn,
})
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.aws.kms.Key;
import com.pulumi.aws.kms.KeyArgs;
import com.pulumi.aws.s3.BucketV2;
import com.pulumi.aws.s3.BucketV2Args;
import com.pulumi.aws.s3.BucketAclV2;
import com.pulumi.aws.s3.BucketAclV2Args;
import com.pulumi.aws.s3.BucketObjectv2;
import com.pulumi.aws.s3.BucketObjectv2Args;
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 examplekms = new Key("examplekms", KeyArgs.builder()
.description("KMS key 1")
.deletionWindowInDays(7)
.build());
var examplebucket = new BucketV2("examplebucket", BucketV2Args.builder()
.bucket("examplebuckettftest")
.build());
var example = new BucketAclV2("example", BucketAclV2Args.builder()
.bucket(examplebucket.id())
.acl("private")
.build());
var exampleBucketObjectv2 = new BucketObjectv2("exampleBucketObjectv2", BucketObjectv2Args.builder()
.key("someobject")
.bucket(examplebucket.id())
.source(new FileAsset("index.html"))
.kmsKeyId(examplekms.arn())
.build());
}
}
resources:
examplekms:
type: aws:kms:Key
properties:
description: KMS key 1
deletionWindowInDays: 7
examplebucket:
type: aws:s3:BucketV2
properties:
bucket: examplebuckettftest
example:
type: aws:s3:BucketAclV2
properties:
bucket: ${examplebucket.id}
acl: private
exampleBucketObjectv2:
type: aws:s3:BucketObjectv2
name: example
properties:
key: someobject
bucket: ${examplebucket.id}
source:
fn::FileAsset: index.html
kmsKeyId: ${examplekms.arn}

Server Side Encryption with S3 Default Master Key

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const examplebucket = new aws.s3.BucketV2("examplebucket", {bucket: "examplebuckettftest"});
const example = new aws.s3.BucketAclV2("example", {
bucket: examplebucket.id,
acl: "private",
});
const exampleBucketObjectv2 = new aws.s3.BucketObjectv2("example", {
key: "someobject",
bucket: examplebucket.id,
source: new pulumi.asset.FileAsset("index.html"),
serverSideEncryption: "aws:kms",
});
import pulumi
import pulumi_aws as aws
examplebucket = aws.s3.BucketV2("examplebucket", bucket="examplebuckettftest")
example = aws.s3.BucketAclV2("example",
bucket=examplebucket.id,
acl="private")
example_bucket_objectv2 = aws.s3.BucketObjectv2("example",
key="someobject",
bucket=examplebucket.id,
source=pulumi.FileAsset("index.html"),
server_side_encryption="aws:kms")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var examplebucket = new Aws.S3.BucketV2("examplebucket", new()
{
Bucket = "examplebuckettftest",
});
var example = new Aws.S3.BucketAclV2("example", new()
{
Bucket = examplebucket.Id,
Acl = "private",
});
var exampleBucketObjectv2 = new Aws.S3.BucketObjectv2("example", new()
{
Key = "someobject",
Bucket = examplebucket.Id,
Source = new FileAsset("index.html"),
ServerSideEncryption = "aws:kms",
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
examplebucket, err := s3.NewBucketV2(ctx, "examplebucket", &s3.BucketV2Args{
Bucket: pulumi.String("examplebuckettftest"),
})
if err != nil {
return err
}
_, err = s3.NewBucketAclV2(ctx, "example", &s3.BucketAclV2Args{
Bucket: examplebucket.ID(),
Acl: pulumi.String("private"),
})
if err != nil {
return err
}
_, err = s3.NewBucketObjectv2(ctx, "example", &s3.BucketObjectv2Args{
Key: pulumi.String("someobject"),
Bucket: examplebucket.ID(),
Source: pulumi.NewFileAsset("index.html"),
ServerSideEncryption: pulumi.String("aws:kms"),
})
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.aws.s3.BucketV2;
import com.pulumi.aws.s3.BucketV2Args;
import com.pulumi.aws.s3.BucketAclV2;
import com.pulumi.aws.s3.BucketAclV2Args;
import com.pulumi.aws.s3.BucketObjectv2;
import com.pulumi.aws.s3.BucketObjectv2Args;
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 examplebucket = new BucketV2("examplebucket", BucketV2Args.builder()
.bucket("examplebuckettftest")
.build());
var example = new BucketAclV2("example", BucketAclV2Args.builder()
.bucket(examplebucket.id())
.acl("private")
.build());
var exampleBucketObjectv2 = new BucketObjectv2("exampleBucketObjectv2", BucketObjectv2Args.builder()
.key("someobject")
.bucket(examplebucket.id())
.source(new FileAsset("index.html"))
.serverSideEncryption("aws:kms")
.build());
}
}
resources:
examplebucket:
type: aws:s3:BucketV2
properties:
bucket: examplebuckettftest
example:
type: aws:s3:BucketAclV2
properties:
bucket: ${examplebucket.id}
acl: private
exampleBucketObjectv2:
type: aws:s3:BucketObjectv2
name: example
properties:
key: someobject
bucket: ${examplebucket.id}
source:
fn::FileAsset: index.html
serverSideEncryption: aws:kms

Server Side Encryption with AWS-Managed Key

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const examplebucket = new aws.s3.BucketV2("examplebucket", {bucket: "examplebuckettftest"});
const example = new aws.s3.BucketAclV2("example", {
bucket: examplebucket.id,
acl: "private",
});
const exampleBucketObjectv2 = new aws.s3.BucketObjectv2("example", {
key: "someobject",
bucket: examplebucket.id,
source: new pulumi.asset.FileAsset("index.html"),
serverSideEncryption: "AES256",
});
import pulumi
import pulumi_aws as aws
examplebucket = aws.s3.BucketV2("examplebucket", bucket="examplebuckettftest")
example = aws.s3.BucketAclV2("example",
bucket=examplebucket.id,
acl="private")
example_bucket_objectv2 = aws.s3.BucketObjectv2("example",
key="someobject",
bucket=examplebucket.id,
source=pulumi.FileAsset("index.html"),
server_side_encryption="AES256")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var examplebucket = new Aws.S3.BucketV2("examplebucket", new()
{
Bucket = "examplebuckettftest",
});
var example = new Aws.S3.BucketAclV2("example", new()
{
Bucket = examplebucket.Id,
Acl = "private",
});
var exampleBucketObjectv2 = new Aws.S3.BucketObjectv2("example", new()
{
Key = "someobject",
Bucket = examplebucket.Id,
Source = new FileAsset("index.html"),
ServerSideEncryption = "AES256",
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
examplebucket, err := s3.NewBucketV2(ctx, "examplebucket", &s3.BucketV2Args{
Bucket: pulumi.String("examplebuckettftest"),
})
if err != nil {
return err
}
_, err = s3.NewBucketAclV2(ctx, "example", &s3.BucketAclV2Args{
Bucket: examplebucket.ID(),
Acl: pulumi.String("private"),
})
if err != nil {
return err
}
_, err = s3.NewBucketObjectv2(ctx, "example", &s3.BucketObjectv2Args{
Key: pulumi.String("someobject"),
Bucket: examplebucket.ID(),
Source: pulumi.NewFileAsset("index.html"),
ServerSideEncryption: pulumi.String("AES256"),
})
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.aws.s3.BucketV2;
import com.pulumi.aws.s3.BucketV2Args;
import com.pulumi.aws.s3.BucketAclV2;
import com.pulumi.aws.s3.BucketAclV2Args;
import com.pulumi.aws.s3.BucketObjectv2;
import com.pulumi.aws.s3.BucketObjectv2Args;
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 examplebucket = new BucketV2("examplebucket", BucketV2Args.builder()
.bucket("examplebuckettftest")
.build());
var example = new BucketAclV2("example", BucketAclV2Args.builder()
.bucket(examplebucket.id())
.acl("private")
.build());
var exampleBucketObjectv2 = new BucketObjectv2("exampleBucketObjectv2", BucketObjectv2Args.builder()
.key("someobject")
.bucket(examplebucket.id())
.source(new FileAsset("index.html"))
.serverSideEncryption("AES256")
.build());
}
}
resources:
examplebucket:
type: aws:s3:BucketV2
properties:
bucket: examplebuckettftest
example:
type: aws:s3:BucketAclV2
properties:
bucket: ${examplebucket.id}
acl: private
exampleBucketObjectv2:
type: aws:s3:BucketObjectv2
name: example
properties:
key: someobject
bucket: ${examplebucket.id}
source:
fn::FileAsset: index.html
serverSideEncryption: AES256

S3 Object Lock

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const examplebucket = new aws.s3.BucketV2("examplebucket", {
bucket: "examplebuckettftest",
objectLockEnabled: true,
});
const example = new aws.s3.BucketAclV2("example", {
bucket: examplebucket.id,
acl: "private",
});
const exampleBucketVersioningV2 = new aws.s3.BucketVersioningV2("example", {
bucket: examplebucket.id,
versioningConfiguration: {
status: "Enabled",
},
});
const examplebucketObject = new aws.s3.BucketObjectv2("examplebucket_object", {
key: "someobject",
bucket: examplebucket.id,
source: new pulumi.asset.FileAsset("important.txt"),
objectLockLegalHoldStatus: "ON",
objectLockMode: "GOVERNANCE",
objectLockRetainUntilDate: "2021-12-31T23:59:60Z",
forceDestroy: true,
}, {
dependsOn: [exampleBucketVersioningV2],
});
import pulumi
import pulumi_aws as aws
examplebucket = aws.s3.BucketV2("examplebucket",
bucket="examplebuckettftest",
object_lock_enabled=True)
example = aws.s3.BucketAclV2("example",
bucket=examplebucket.id,
acl="private")
example_bucket_versioning_v2 = aws.s3.BucketVersioningV2("example",
bucket=examplebucket.id,
versioning_configuration={
"status": "Enabled",
})
examplebucket_object = aws.s3.BucketObjectv2("examplebucket_object",
key="someobject",
bucket=examplebucket.id,
source=pulumi.FileAsset("important.txt"),
object_lock_legal_hold_status="ON",
object_lock_mode="GOVERNANCE",
object_lock_retain_until_date="2021-12-31T23:59:60Z",
force_destroy=True,
opts = pulumi.ResourceOptions(depends_on=[example_bucket_versioning_v2]))
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var examplebucket = new Aws.S3.BucketV2("examplebucket", new()
{
Bucket = "examplebuckettftest",
ObjectLockEnabled = true,
});
var example = new Aws.S3.BucketAclV2("example", new()
{
Bucket = examplebucket.Id,
Acl = "private",
});
var exampleBucketVersioningV2 = new Aws.S3.BucketVersioningV2("example", new()
{
Bucket = examplebucket.Id,
VersioningConfiguration = new Aws.S3.Inputs.BucketVersioningV2VersioningConfigurationArgs
{
Status = "Enabled",
},
});
var examplebucketObject = new Aws.S3.BucketObjectv2("examplebucket_object", new()
{
Key = "someobject",
Bucket = examplebucket.Id,
Source = new FileAsset("important.txt"),
ObjectLockLegalHoldStatus = "ON",
ObjectLockMode = "GOVERNANCE",
ObjectLockRetainUntilDate = "2021-12-31T23:59:60Z",
ForceDestroy = true,
}, new CustomResourceOptions
{
DependsOn =
{
exampleBucketVersioningV2,
},
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
examplebucket, err := s3.NewBucketV2(ctx, "examplebucket", &s3.BucketV2Args{
Bucket: pulumi.String("examplebuckettftest"),
ObjectLockEnabled: pulumi.Bool(true),
})
if err != nil {
return err
}
_, err = s3.NewBucketAclV2(ctx, "example", &s3.BucketAclV2Args{
Bucket: examplebucket.ID(),
Acl: pulumi.String("private"),
})
if err != nil {
return err
}
exampleBucketVersioningV2, err := s3.NewBucketVersioningV2(ctx, "example", &s3.BucketVersioningV2Args{
Bucket: examplebucket.ID(),
VersioningConfiguration: &s3.BucketVersioningV2VersioningConfigurationArgs{
Status: pulumi.String("Enabled"),
},
})
if err != nil {
return err
}
_, err = s3.NewBucketObjectv2(ctx, "examplebucket_object", &s3.BucketObjectv2Args{
Key: pulumi.String("someobject"),
Bucket: examplebucket.ID(),
Source: pulumi.NewFileAsset("important.txt"),
ObjectLockLegalHoldStatus: pulumi.String("ON"),
ObjectLockMode: pulumi.String("GOVERNANCE"),
ObjectLockRetainUntilDate: pulumi.String("2021-12-31T23:59:60Z"),
ForceDestroy: pulumi.Bool(true),
}, pulumi.DependsOn([]pulumi.Resource{
exampleBucketVersioningV2,
}))
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.aws.s3.BucketV2;
import com.pulumi.aws.s3.BucketV2Args;
import com.pulumi.aws.s3.BucketAclV2;
import com.pulumi.aws.s3.BucketAclV2Args;
import com.pulumi.aws.s3.BucketVersioningV2;
import com.pulumi.aws.s3.BucketVersioningV2Args;
import com.pulumi.aws.s3.inputs.BucketVersioningV2VersioningConfigurationArgs;
import com.pulumi.aws.s3.BucketObjectv2;
import com.pulumi.aws.s3.BucketObjectv2Args;
import com.pulumi.resources.CustomResourceOptions;
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 examplebucket = new BucketV2("examplebucket", BucketV2Args.builder()
.bucket("examplebuckettftest")
.objectLockEnabled(true)
.build());
var example = new BucketAclV2("example", BucketAclV2Args.builder()
.bucket(examplebucket.id())
.acl("private")
.build());
var exampleBucketVersioningV2 = new BucketVersioningV2("exampleBucketVersioningV2", BucketVersioningV2Args.builder()
.bucket(examplebucket.id())
.versioningConfiguration(BucketVersioningV2VersioningConfigurationArgs.builder()
.status("Enabled")
.build())
.build());
var examplebucketObject = new BucketObjectv2("examplebucketObject", BucketObjectv2Args.builder()
.key("someobject")
.bucket(examplebucket.id())
.source(new FileAsset("important.txt"))
.objectLockLegalHoldStatus("ON")
.objectLockMode("GOVERNANCE")
.objectLockRetainUntilDate("2021-12-31T23:59:60Z")
.forceDestroy(true)
.build(), CustomResourceOptions.builder()
.dependsOn(exampleBucketVersioningV2)
.build());
}
}
resources:
examplebucket:
type: aws:s3:BucketV2
properties:
bucket: examplebuckettftest
objectLockEnabled: true
example:
type: aws:s3:BucketAclV2
properties:
bucket: ${examplebucket.id}
acl: private
exampleBucketVersioningV2:
type: aws:s3:BucketVersioningV2
name: example
properties:
bucket: ${examplebucket.id}
versioningConfiguration:
status: Enabled
examplebucketObject:
type: aws:s3:BucketObjectv2
name: examplebucket_object
properties:
key: someobject
bucket: ${examplebucket.id}
source:
fn::FileAsset: important.txt
objectLockLegalHoldStatus: ON
objectLockMode: GOVERNANCE
objectLockRetainUntilDate: 2021-12-31T23:59:60Z
forceDestroy: true
options:
dependsOn:
- ${exampleBucketVersioningV2}

Ignoring Provider default_tags

S3 objects support a maximum of 10 tags. If the resource's own tags and the provider-level default_tags would together lead to more than 10 tags on an S3 object, use the override_provider configuration block to suppress any provider-level default_tags.

S3 objects stored in Amazon S3 Express directory buckets do not support tags, so any provider-level default_tags must be suppressed.

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const examplebucket = new aws.s3.BucketV2("examplebucket", {bucket: "examplebuckettftest"});
const examplebucketObject = new aws.s3.BucketObjectv2("examplebucket_object", {
key: "someobject",
bucket: examplebucket.id,
source: new pulumi.asset.FileAsset("important.txt"),
tags: {
Env: "test",
},
overrideProvider: {
defaultTags: {
tags: {},
},
},
});
import pulumi
import pulumi_aws as aws
examplebucket = aws.s3.BucketV2("examplebucket", bucket="examplebuckettftest")
examplebucket_object = aws.s3.BucketObjectv2("examplebucket_object",
key="someobject",
bucket=examplebucket.id,
source=pulumi.FileAsset("important.txt"),
tags={
"Env": "test",
},
override_provider={
"default_tags": {
"tags": {},
},
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var examplebucket = new Aws.S3.BucketV2("examplebucket", new()
{
Bucket = "examplebuckettftest",
});
var examplebucketObject = new Aws.S3.BucketObjectv2("examplebucket_object", new()
{
Key = "someobject",
Bucket = examplebucket.Id,
Source = new FileAsset("important.txt"),
Tags =
{
{ "Env", "test" },
},
OverrideProvider = new Aws.S3.Inputs.BucketObjectv2OverrideProviderArgs
{
DefaultTags = new Aws.S3.Inputs.BucketObjectv2OverrideProviderDefaultTagsArgs
{
Tags = null,
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
examplebucket, err := s3.NewBucketV2(ctx, "examplebucket", &s3.BucketV2Args{
Bucket: pulumi.String("examplebuckettftest"),
})
if err != nil {
return err
}
_, err = s3.NewBucketObjectv2(ctx, "examplebucket_object", &s3.BucketObjectv2Args{
Key: pulumi.String("someobject"),
Bucket: examplebucket.ID(),
Source: pulumi.NewFileAsset("important.txt"),
Tags: pulumi.StringMap{
"Env": pulumi.String("test"),
},
OverrideProvider: &s3.BucketObjectv2OverrideProviderArgs{
DefaultTags: &s3.BucketObjectv2OverrideProviderDefaultTagsArgs{
Tags: pulumi.StringMap{},
},
},
})
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.aws.s3.BucketV2;
import com.pulumi.aws.s3.BucketV2Args;
import com.pulumi.aws.s3.BucketObjectv2;
import com.pulumi.aws.s3.BucketObjectv2Args;
import com.pulumi.aws.s3.inputs.BucketObjectv2OverrideProviderArgs;
import com.pulumi.aws.s3.inputs.BucketObjectv2OverrideProviderDefaultTagsArgs;
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 examplebucket = new BucketV2("examplebucket", BucketV2Args.builder()
.bucket("examplebuckettftest")
.build());
var examplebucketObject = new BucketObjectv2("examplebucketObject", BucketObjectv2Args.builder()
.key("someobject")
.bucket(examplebucket.id())
.source(new FileAsset("important.txt"))
.tags(Map.of("Env", "test"))
.overrideProvider(BucketObjectv2OverrideProviderArgs.builder()
.defaultTags(BucketObjectv2OverrideProviderDefaultTagsArgs.builder()
.tags()
.build())
.build())
.build());
}
}
resources:
examplebucket:
type: aws:s3:BucketV2
properties:
bucket: examplebuckettftest
examplebucketObject:
type: aws:s3:BucketObjectv2
name: examplebucket_object
properties:
key: someobject
bucket: ${examplebucket.id}
source:
fn::FileAsset: important.txt
tags:
Env: test
overrideProvider:
defaultTags:
tags: {}

Import

Import using S3 URL syntax: Using pulumi import to import objects using the id or S3 URL. For example: Import using the id, which is the bucket name and the key together:

$ pulumi import aws:s3/bucketObjectv2:BucketObjectv2 example some-bucket-name/some/key.txt

Import using S3 URL syntax:

$ pulumi import aws:s3/bucketObjectv2:BucketObjectv2 example s3://some-bucket-name/some/key.txt

Constructors

Link copied to clipboard
constructor(acl: Output<String>? = null, bucket: Output<String>? = null, bucketKeyEnabled: Output<Boolean>? = null, cacheControl: Output<String>? = null, checksumAlgorithm: Output<String>? = null, content: Output<String>? = null, contentBase64: Output<String>? = null, contentDisposition: Output<String>? = null, contentEncoding: Output<String>? = null, contentLanguage: Output<String>? = null, contentType: Output<String>? = null, etag: Output<String>? = null, forceDestroy: Output<Boolean>? = null, key: Output<String>? = null, kmsKeyId: Output<String>? = null, metadata: Output<Map<String, String>>? = null, objectLockLegalHoldStatus: Output<String>? = null, objectLockMode: Output<String>? = null, objectLockRetainUntilDate: Output<String>? = null, overrideProvider: Output<BucketObjectv2OverrideProviderArgs>? = null, serverSideEncryption: Output<String>? = null, source: Output<AssetOrArchive>? = null, sourceHash: Output<String>? = null, storageClass: Output<String>? = null, tags: Output<Map<String, String>>? = null, websiteRedirect: Output<String>? = null)

Properties

Link copied to clipboard
val acl: Output<String>? = null

Canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control.

Link copied to clipboard
val bucket: Output<String>? = null

Name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified.

Link copied to clipboard
val bucketKeyEnabled: Output<Boolean>? = null

Whether or not to use Amazon S3 Bucket Keys for SSE-KMS.

Link copied to clipboard
val cacheControl: Output<String>? = null

Caching behavior along the request/reply chain Read w3c cache_control for further details.

Link copied to clipboard
val checksumAlgorithm: Output<String>? = null

Indicates the algorithm used to create the checksum for the object. If a value is specified and the object is encrypted with KMS, you must have permission to use the kms:Decrypt action. Valid values: CRC32, CRC32C, CRC64NVME, SHA1, SHA256.

Link copied to clipboard
val content: Output<String>? = null

Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text.

Link copied to clipboard
val contentBase64: Output<String>? = null

Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file.

Link copied to clipboard
val contentDisposition: Output<String>? = null

Presentational information for the object. Read w3c content_disposition for further information.

Link copied to clipboard
val contentEncoding: Output<String>? = null

Content encodings that have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field. Read w3c content encoding for further information.

Link copied to clipboard
val contentLanguage: Output<String>? = null

Language the content is in e.g., en-US or en-GB.

Link copied to clipboard
val contentType: Output<String>? = null

Standard MIME type describing the format of the object data, e.g., application/octet-stream. All Valid MIME Types are valid for this input.

Link copied to clipboard
val etag: Output<String>? = null

Triggers updates when the value changes. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = "aws:kms", also if an object is larger than 16 MB, the AWS Management Console will upload or copy that object as a Multipart Upload, and therefore the ETag will not be an MD5 digest (see source_hash instead).

Link copied to clipboard
val forceDestroy: Output<Boolean>? = null

Whether to allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled.

Link copied to clipboard
val key: Output<String>? = null

Name of the object once it is in the bucket. The following arguments are optional:

Link copied to clipboard
val kmsKeyId: Output<String>? = null

ARN of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws.kms.Key resource, use the arn attribute. If referencing the aws.kms.Alias data source or resource, use the target_key_arn attribute. The provider will only perform drift detection if a configuration value is provided.

Link copied to clipboard
val metadata: Output<Map<String, String>>? = null

Map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API).

Link copied to clipboard
val objectLockLegalHoldStatus: Output<String>? = null

Legal hold status that you want to apply to the specified object. Valid values are ON and OFF.

Link copied to clipboard
val objectLockMode: Output<String>? = null

Object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE.

Link copied to clipboard
val objectLockRetainUntilDate: Output<String>? = null

Date and time, in RFC3339 format, when this object's object lock will expire.

Link copied to clipboard

Override provider-level configuration options. See Override Provider below for more details.

Link copied to clipboard
val serverSideEncryption: Output<String>? = null

Server-side encryption of the object in S3. Valid values are "AES256" and "aws:kms".

Link copied to clipboard
val source: Output<AssetOrArchive>? = null

Path to a file that will be read and uploaded as raw bytes for the object content.

Link copied to clipboard
val sourceHash: Output<String>? = null

Triggers updates like etag but useful to address etag encryption limitations. (The value is only stored in state and not saved by AWS.)

Link copied to clipboard
val storageClass: Output<String>? = null

Storage Class for the object. Defaults to "STANDARD".

Link copied to clipboard
val tags: Output<Map<String, String>>? = null

Map of tags to assign to the object. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

Link copied to clipboard
val websiteRedirect: Output<String>? = null

Target URL for website redirect. If no content is provided through source, content or content_base64, then the object will be empty.

Functions

Link copied to clipboard
open override fun toJava(): BucketObjectv2Args