Expand description
Provides an S3 object resource.
§Example Usage
§Uploading a file to a bucket
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
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
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
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
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.
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
Structs§
- Use builder syntax to set the inputs and finish with
build_struct()
.
Functions§
- Registers a new resource with the given unique name and arguments