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 10, 2020 in Terraform by akhtar
• 38,180 points
1,044 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 10, 2020 by MD
• 95,140 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,140 points
290 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,140 points
587 views
0 votes
1 answer
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,140 points
162 views
0 votes
1 answer
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,140 points
2,887 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,140 points
2,165 views