How to copy the content of an s3 bucket to another s3 bucket using Terraform

0 votes

Hi Guys,

I have created one s3 bucket and uploaded some files. Now I want to copy all the data to another bucket. But I am not able to find any provisioner in Terraform to do that. Can anyone help me?

Sep 11, 2020 in Terraform by akhtar
• 38,260 points
5,088 views

1 answer to this question.

0 votes

Hi@akhtar,

There is no resource that enables the copying of objects from one S3 bucket to another. If you want to include this in your Terraform setup then you would need to use a local-exec provisioner.

It would need to execute the command below, with the support of the AWS CLI to run aws s3 cp.

resource "null_resource" "s3_objects" {
  provisioner "local-exec" {
    command = "aws s3 cp s3://bucket1 s3://bucket2 --recursive"
  }
}
answered Sep 11, 2020 by MD
• 95,460 points

Related Questions In Terraform

0 votes
1 answer

How to create one S3 bucket in AWS using Terraform?

Hi@akhtar, You need to set aws provider name ...READ MORE

answered Jul 23, 2020 in Terraform by MD
• 95,460 points
1,402 views
0 votes
1 answer

How to create a folder inside S3 Bucket using Terraform code?

Hi@akhtar, You can create a folder at the ...READ MORE

answered Jul 23, 2020 in Terraform by MD
• 95,460 points
2,952 views
0 votes
1 answer

How to block public access to S3 bucket using Terraform?

Hi@akhtar, To control the access of the S3 ...READ MORE

answered Sep 9, 2020 in Terraform by MD
• 95,460 points
13,715 views
0 votes
1 answer

How to read the volume ID of the EC2 instance using Terraform?

Hi@akhtar, You won't be able to extract EBS ...READ MORE

answered Dec 4, 2020 in Terraform by MD
• 95,460 points
2,297 views
0 votes
1 answer

Error: Error putting object in S3 bucket (example11225588): AccessDenied: Access Denied

Hi@akhtar, To upload your file in the s3 ...READ MORE

answered Jun 11, 2020 in Terraform by MD
• 95,460 points
2,951 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to create a folder in S3 bucket using terraform?

Hi@akhtar, You can use aws_s3_bucket_object resource to create one ...READ MORE

answered Jun 11, 2020 in Terraform by MD
• 95,460 points
10,962 views
0 votes
1 answer

How to create one s3 bucket using terraform?

Hi@akhtar, You can use aws_s3_bucket resources to create ...READ MORE

answered Jun 12, 2020 in Terraform by MD
• 95,460 points
3,907 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP