BucketObjectv2

class BucketObjectv2 : KotlinCustomResource

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.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");
var exampleBucketAclV2 = new BucketAclV2("exampleBucketAclV2", 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());
}
}

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.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");
var exampleBucketAclV2 = new BucketAclV2("exampleBucketAclV2", 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());
}
}

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.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");
var exampleBucketAclV2 = new BucketAclV2("exampleBucketAclV2", 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());
}
}

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.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()
.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 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());
}
}

Import

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

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

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

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

Properties

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

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>

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

Link copied to clipboard

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

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

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

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

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>?

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

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

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

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>?

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

Link copied to clipboard
val contentType: Output<String>

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>

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>?

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 id: Output<String>
Link copied to clipboard
val key: Output<String>

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

Link copied to clipboard
val kmsKeyId: Output<String>

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>>?

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

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>?

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

Link copied to clipboard

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

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

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

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

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>?

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>

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

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

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 tagsAll: Output<Map<String, String>>

Map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val versionId: Output<String>

Unique version ID value for the object, if bucket versioning is enabled.

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

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