AWS Amazon S3 Object Copy
This page shows how to write Terraform and CloudFormation for Amazon S3 Object Copy and write them securely.
aws_s3_object_copy (Terraform)
The Object Copy in Amazon S3 can be configured in Terraform with the resource name aws_s3_object_copy. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
An example could not be found in GitHub.
Parameters
-
acloptional - string -
bucketrequired - string -
bucket_key_enabledoptional computed - bool -
cache_controloptional computed - string -
content_dispositionoptional computed - string -
content_encodingoptional computed - string -
content_languageoptional computed - string -
content_typeoptional computed - string -
copy_if_matchoptional - string -
copy_if_modified_sinceoptional - string -
copy_if_none_matchoptional - string -
copy_if_unmodified_sinceoptional - string -
customer_algorithmoptional computed - string -
customer_keyoptional - string -
customer_key_md5optional computed - string -
etagoptional computed - string -
expected_bucket_owneroptional - string -
expected_source_bucket_owneroptional - string -
expirationoptional computed - string -
expiresoptional - string -
force_destroyoptional - bool -
idoptional computed - string -
keyrequired - string -
kms_encryption_contextoptional computed - string -
kms_key_idoptional computed - string -
last_modifiedoptional computed - string -
metadataoptional computed - map from string to string -
metadata_directiveoptional - string -
object_lock_legal_hold_statusoptional computed - string -
object_lock_modeoptional computed - string -
object_lock_retain_until_dateoptional computed - string -
request_chargedoptional computed - bool -
request_payeroptional - string -
server_side_encryptionoptional computed - string -
sourcerequired - string -
source_customer_algorithmoptional - string -
source_customer_keyoptional - string -
source_customer_key_md5optional - string -
source_version_idoptional computed - string -
storage_classoptional computed - string -
tagging_directiveoptional - string -
tagsoptional - map from string to string -
version_idoptional computed - string -
website_redirectoptional computed - string -
grantset block-
emailoptional - string -
idoptional - string -
permissionsrequired - set of string -
typerequired - string -
urioptional - string
-
Explanation in Terraform Registry
Provides a resource for copying an S3 object.
Tips: Best Practices for The Other AWS Amazon S3 Resources
In addition to the aws_s3_bucket_public_access_block, AWS Amazon S3 has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
aws_s3_bucket_public_access_block
Ensure S3 bucket-level Public Access Block restricts public bucket policies
It is better to enable S3 bucket-level Public Access Block if you don't need public buckets.
aws_s3_bucket
Ensure S3 bucket access policy is well configured
It is better to configure the S3 bucket access policy properly to limit it unless explicitly required.
AWS::S3::Bucket (CloudFormation)
The Bucket in S3 can be configured in CloudFormation with the resource name AWS::S3::Bucket. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
Type: "AWS::S3::Bucket"
SourceBucket:
Properties:
BucketName: !Ref morflessSourceBucket
PublicAccessBlockConfiguration:
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref MugShotCodeBucketName
SubmissionMugShotBucket:
Type: AWS::S3::Bucket
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub '${Topic.TopicName}-bucket'
S3Bucket2:
Type: AWS::S3::Bucket
Type: AWS::S3::Bucket
Properties:
BucketName: cfd-shared-content
PublicAccessBlockConfiguration:
BlockPublicAcls: true
BlockPublicPolicy: true
Type: AWS::S3::Bucket
Properties:
BucketName: "at-hella-calibrations"
BuildAUBucket:
Type: AWS::S3::Bucket
Properties:
"Type" : "AWS::S3::Bucket",
"Properties" : {
"BucketName" : "fakebucketfakebucket"
}
},
"resourceType" : "AWS::S3::Bucket",
"properties" : [ {
"propertyName" : "AccessControl",
"propertyType" : "String",
"required" : false
}, {
"Type": "AWS::S3::Bucket",
"Properties": {
"BucketEncryption": {
"ServerSideEncryptionConfiguration": [
{
"ServerSideEncryptionByDefault": {
"Type": "AWS::S3::Bucket",
"Properties": {
"BucketEncryption": {
"ServerSideEncryptionConfiguration": [
{
"ServerSideEncryptionByDefault": {
"Type": "AWS::S3::Bucket"
},
"TransformLogGroup": {
"Type": "AWS::Logs::LogGroup",
"Properties": {
"LogGroupName": "/aws/lambda/thumbnail-creator-dev-transform"
Parameters
-
AccelerateConfigurationoptional - AccelerateConfiguration -
AccessControloptional - String -
AnalyticsConfigurationsoptional - List of AnalyticsConfiguration -
BucketEncryptionoptional - BucketEncryption -
BucketNameoptional - String -
CorsConfigurationoptional - CorsConfiguration -
IntelligentTieringConfigurationsoptional - List of IntelligentTieringConfiguration -
InventoryConfigurationsoptional - List of InventoryConfiguration -
LifecycleConfigurationoptional - LifecycleConfiguration -
LoggingConfigurationoptional - LoggingConfiguration -
MetricsConfigurationsoptional - List of MetricsConfiguration -
NotificationConfigurationoptional - NotificationConfiguration -
ObjectLockConfigurationoptional - ObjectLockConfiguration -
ObjectLockEnabledoptional - Boolean -
OwnershipControlsoptional - OwnershipControls -
PublicAccessBlockConfigurationoptional - PublicAccessBlockConfiguration -
ReplicationConfigurationoptional - ReplicationConfiguration -
Tagsoptional - List of Tag -
VersioningConfigurationoptional - VersioningConfiguration -
WebsiteConfigurationoptional - WebsiteConfiguration
Explanation in CloudFormation Registry
The
AWS::S3::Bucketresource creates an Amazon S3 bucket in the same AWS Region where you create the AWS CloudFormation stack.To control how AWS CloudFormation handles the bucket when the stack is deleted, you can set a deletion policy for your bucket. You can choose to retain the bucket or to delete the bucket. For more information, see DeletionPolicy Attribute.
Important You can only delete empty buckets. Deletion fails for buckets that have contents.
Frequently asked questions
What is AWS Amazon S3 Object Copy?
AWS Amazon S3 Object Copy is a resource for Amazon S3 of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS Amazon S3 Object Copy?
For CloudFormation, the MickyHCorbett/MorfLess, victorsalaun/mugshot-aws-serverless and org-formation/org-formation-cli source code examples are useful. See the CloudFormation Example section for further details.