BucketObjectArgs

data class BucketObjectArgs(val acl: Output<String>? = null, val bucket: Output<String>? = null, val bucketKeyEnabled: Output<Boolean>? = null, val cacheControl: 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 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<BucketObjectArgs>

Provides an S3 object resource.

Example Usage

Encrypting with KMS Key

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.BucketAclV2;
import com.pulumi.aws.s3.BucketAclV2Args;
import com.pulumi.aws.s3.BucketObject;
import com.pulumi.aws.s3.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 examplekms = new Key("examplekms", KeyArgs.builder()
.description("KMS key 1")
.deletionWindowInDays(7)
.build());
var examplebucket = new BucketV2("examplebucket");
var exampleBucketAclV2 = new BucketAclV2("exampleBucketAclV2", BucketAclV2Args.builder()
.bucket(examplebucket.id())
.acl("private")
.build());
var exampleBucketObject = new BucketObject("exampleBucketObject", BucketObjectArgs.builder()
.key("someobject")
.bucket(examplebucket.id())
.source(new FileAsset("index.html"))
.kmsKeyId(examplekms.arn())
.build());
}
}

Server Side Encryption with S3 Default Master Key

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.BucketAclV2;
import com.pulumi.aws.s3.BucketAclV2Args;
import com.pulumi.aws.s3.BucketObject;
import com.pulumi.aws.s3.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 examplebucket = new BucketV2("examplebucket");
var exampleBucketAclV2 = new BucketAclV2("exampleBucketAclV2", BucketAclV2Args.builder()
.bucket(examplebucket.id())
.acl("private")
.build());
var exampleBucketObject = new BucketObject("exampleBucketObject", BucketObjectArgs.builder()
.key("someobject")
.bucket(examplebucket.id())
.source(new FileAsset("index.html"))
.serverSideEncryption("aws:kms")
.build());
}
}

Server Side Encryption with AWS-Managed Key

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.BucketAclV2;
import com.pulumi.aws.s3.BucketAclV2Args;
import com.pulumi.aws.s3.BucketObject;
import com.pulumi.aws.s3.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 examplebucket = new BucketV2("examplebucket");
var exampleBucketAclV2 = new BucketAclV2("exampleBucketAclV2", BucketAclV2Args.builder()
.bucket(examplebucket.id())
.acl("private")
.build());
var exampleBucketObject = new BucketObject("exampleBucketObject", BucketObjectArgs.builder()
.key("someobject")
.bucket(examplebucket.id())
.source(new FileAsset("index.html"))
.serverSideEncryption("AES256")
.build());
}
}

S3 Object Lock

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.BucketObject;
import com.pulumi.aws.s3.BucketObjectArgs;
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()
.objectLockEnabled(true)
.build());
var exampleBucketAclV2 = new BucketAclV2("exampleBucketAclV2", 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 BucketObject("exampleBucketObject", BucketObjectArgs.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());
}
}

Import

Objects can be imported using the id. The id is the bucket name and the key together e.g.,

$ pulumi import aws:s3/bucketObject:BucketObject object some-bucket-name/some/key.txt

Additionally, s3 url syntax can be used, e.g.,

$ pulumi import aws:s3/bucketObject:BucketObject object 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, 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, 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. Defaults to private.

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 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" (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
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.

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(): BucketObjectArgs