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 Time Control #10974

Closed
ewbankkit opened this issue Nov 21, 2019 · 12 comments · Fixed by #21176
Closed

Amazon S3 Replication Time Control #10974

ewbankkit opened this issue Nov 21, 2019 · 12 comments · Fixed by #21176
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/s3 Issues and PRs that pertain to the s3 service.
Milestone

Comments

@ewbankkit
Copy link
Contributor

ewbankkit commented Nov 21, 2019

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 "me too" comments, 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 Time Control (S3 RTC) is a new feature of S3 Replication that provides a predictable replication time backed by a Service Level Agreement (SLA).

New or Affected Resource(s)

Potential Terraform Configuration

resource "aws_s3_bucket" "example" {
  replication_configuration {
  }
}

References

Announcement.
Blog post.
Developer guide.

Requires AWS SDK v1.25.39:

Related:

@ewbankkit ewbankkit added the enhancement Requests to existing resources that expand the functionality or scope. label Nov 21, 2019
@ghost ghost added the service/s3 Issues and PRs that pertain to the s3 service. label Nov 21, 2019
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Nov 21, 2019
@bflad bflad removed the needs-triage Waiting for first response or review from a maintainer. label Nov 21, 2019
@winem
Copy link

winem commented Dec 8, 2020

This would also allow to enable the replication monitoring. S3 RTC needs to be enabled for the replication metrics to be available. Otherwise you can enable them but it'll show no data. Would love to see this one merged.

@jonjohnston
Copy link

Please get this in. I have been waiting for almost 2 years for this feature!

@jonjohnston
Copy link

@YakDriver Please, can you include this in the v3.50.0 or v3.51.0 release.

@itadityachoudhari
Copy link

any alternatives?

@rambabugovind
Copy link

rambabugovind commented Aug 25, 2021

Not sure if this a "correct" way to do it but I am currently using local-exec provisioner as a workaround. You would have to add the below code in your .tf file

resource "null_resource" "s3_bucket" {
  depends_on = [
    # a resource, module, etc...
  ]
  triggers = {
    # below statement makes sure the local-exec provisioner is invoked on every run
    always_run = timestamp()
    encoded_replication_config = local.replication_config
  }
  provisioner "local-exec" {
    command = "aws s3api put-bucket-replication --bucket '${primary_bucket_name}' --replication-configuration '${self.triggers.encoded_replication_config}'"
  }
}

locals {
  replication_config = jsonencode({
    "Role" : role_arn,
    "Rules" : [
      {
        "ID": "replication-id"
        "Status" : "Enabled",
        "Priority" : 1,
        "DeleteMarkerReplication" : { "Status" : "Disabled" },
        "Filter" : { "Prefix" : "" },
        "Destination" : {
          "Bucket" : replica_bucket_arn,
          "ReplicationTime" : {
            "Status" : "Enabled",
            "Time" : {
              "Minutes" : 15
            }
          },
          "Metrics" : {
            "Status" : "Enabled",
            "EventThreshold" : {
              "Minutes" : 15
            }
          }
        }
      }
    ]
  })
}

You can modify the replication_config as per your needs. Please note, the replication config created using this approach would NOT be a part of Terraform's state. Hope this helps!
Refs:

  1. https://www.reddit.com/r/Terraform/comments/i9sx12/how_do_i_use_tf_variables_inside_a_localexec/
  2. https://blog.logrocket.com/dirty-terraform-hacks/

@tmccombs
Copy link
Contributor

Unfortunately, the local provisioner solution doesn't work if the aws provider is assuming a role (as is the case for me) because the temporary tokens are not available.

@github-actions
Copy link

github-actions bot commented Nov 4, 2021

This functionality has been released in v3.64.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@tcheksa62
Copy link

Hi,

Issue 17817 was closed but only one of asked feature are available. @ewbankkit
This feature enable usage of S3 RTC feature, but not "Replication metrics and notifications".
We can't enable "Replication metrics and notifications" with Terraform. And from this update, we have drift when we enable it from console :

- metrics {
   - minutes = 0 -> null
   - status = "Enabled" -> null
   }
}

We tried to config this param like terraform plan output, but metrics minutes value can't configured to 0.

Regards,
Tcheksa

@ewbankkit
Copy link
Contributor Author

@tcheksa62 Could you please open a new Issue?
Thanks.

@drmaciej
Copy link

@tcheksa62
I ran into the same problem. I found that using the replication_configuration block wasn't good enough - some fields were missing, and I couldn't hook up metrics either.
I followed the recommendation from https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket#using-replication-configuration and ended up using a separate aws_s3_bucket_replication_configuration resource - works without any issues.

@tcheksa62
Copy link

Hi @drmaciej,
Thank for the tip !
I will try this, I need to rewrite my module.

@github-actions
Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2022
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.
Projects
None yet
9 participants