Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amazon S3 Replication to multiple destinations #16546

Closed
ewbankkit opened this issue Dec 2, 2020 · 7 comments · Fixed by #16677
Closed

Amazon S3 Replication to multiple destinations #16546

ewbankkit opened this issue Dec 2, 2020 · 7 comments · Fixed by #16677
Assignees
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/s3 Issues and PRs that pertain to the s3 service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.

Comments

@ewbankkit
Copy link
Contributor

ewbankkit commented Dec 2, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Amazon S3 Replication now gives you the ability to replicate data from one source bucket to multiple destination buckets in the same, or different AWS Regions.

New or Affected Resource(s)

Potential Terraform Configuration

resource "aws_s3_bucket" "source" {
  bucket = "example"

  versioning {
    enabled = true
  }

  replication_configuration {
    role = aws_iam_role.replication.arn

    rules {
      id       = "rule1"
      priority = 1
      status   = "Enabled"

      filter {}

      destination {
        bucket        = aws_s3_bucket.destination1.arn
        storage_class = "STANDARD"
      }
    }

    rules {
      id       = "rule2"
      priority = 2
      status   = "Enabled"

      filter {
        prefix = "prefix2"
      }

      destination {
        bucket        = aws_s3_bucket.destination2.arn
        storage_class = "STANDARD_IA"
      }
    }
  }
}

References

Announcement.
Blog post.
Developer Guide.

@ewbankkit ewbankkit added the enhancement Requests to existing resources that expand the functionality or scope. label Dec 2, 2020
@ghost ghost added the service/s3 Issues and PRs that pertain to the s3 service. label Dec 2, 2020
@ewbankkit
Copy link
Contributor Author

It looks like this should be supported in the current code (there is no limitation on rules that would prevent this scenario).
We should add an explicit acceptance tests case for this.

@maratdr
Copy link

maratdr commented Dec 9, 2020

It looks like this should be supported in the current code (there is no limitation on rules that would prevent this scenario).
We should add an explicit acceptance tests case for this.

It seems to be limited by aws go sdk version of terraform aws provider (3.20.0). At moment, I am still getting below error

Error: Error putting S3 replication configuration: InvalidRequest: Number of distinct destination bucket ARNs cannot exceed 1
	status code: 400, request id: C0A5C4E04398B311, host id: vEVcHcwOS2lN6DRX9Twqt8gwBcF8tf9DM94PGKgtA0op6JmfgPvvBaA3Z8z1bL5oLOCOvnFcE8M=

it's been addressed in aws/aws-sdk-go#3668

@ewbankkit
Copy link
Contributor Author

ewbankkit commented Dec 9, 2020

Hmm, v3.20.0 built against AWS SDK v1.36.0: #16530.
I'll add a new acceptance test and try with the latest trunk code.

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSS3Bucket_Replication_MultipleDestinations'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSS3Bucket_Replication_MultipleDestinations -timeout 120m
=== RUN   TestAccAWSS3Bucket_Replication_MultipleDestinations
=== PAUSE TestAccAWSS3Bucket_Replication_MultipleDestinations
=== CONT  TestAccAWSS3Bucket_Replication_MultipleDestinations
    resource_aws_s3_bucket_test.go:1560: Step 1/2 error: Error running apply: 2020/12/09 10:01:38 [DEBUG] Using modified User-Agent: Terraform/0.12.26 HashiCorp-terraform-exec/0.10.0
        
        Error: Error putting S3 replication configuration: InvalidRequest: Number of distinct destination bucket ARNs cannot exceed 1
        	status code: 400, request id: A786AF26FAF89ABB, host id: Ek/dB+mcb4roTI+fTsL4jxFAMhR4RuoDNsa1bER6kK9VoKsoe0gWG/iDyxYGBPc23GovYJqebDo=
        
        
--- FAIL: TestAccAWSS3Bucket_Replication_MultipleDestinations (14.04s)
FAIL
FAIL	github.com/terraform-providers/terraform-provider-aws/aws	14.143s
FAIL
GNUmakefile:27: recipe for target 'testacc' failed
make: *** [testacc] Error 1

Investigating...

@ewbankkit ewbankkit self-assigned this Dec 9, 2020
@ewbankkit
Copy link
Contributor Author

ewbankkit commented Dec 9, 2020

Priority is used when multiple destinations are specified, so priority must be specified.
Currently we are only sending priority if a filter is also specified - that needs to be addressed for the example above to work.

@ewbankkit ewbankkit added the tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. label Dec 9, 2020
@geototti21
Copy link

👋 hey @ewbankkit, I come about on this error Number of distinct destination bucket ARNs cannot exceed 1 , and while I set priority to all rules I kept getting this error even on latest version of the provider (3.21).

The problem was that I was not specifying filter {} as I don't have any filters at all. The moment I specified this it worked, even as an empty object. Not sure what will be the best behavior here but just in case anyone else has the same problem.

Maybe we can update the docs?

@ewbankkit
Copy link
Contributor Author

@geototti21 Yes, I found that I had to add filter {} when adding the additional acceptance tests.
I will make sure that the documentation is updated.
Thanks.

@ghost
Copy link

ghost commented Mar 13, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Mar 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/s3 Issues and PRs that pertain to the s3 service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
3 participants