-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
r/aws_s3_bucket: Support S3 Cross-Region Replication filtering based on S3 object tags #5940
Comments
Requires: |
Exciting to see this added to the API. I will see about getting #3577 merged since it will be in the same code neighborhood and looks okay at first glance. |
Proposed syntax:
resource "aws_s3_bucket" "bucket" {
bucket = "tf-test-bucket-12345"
replication_configuration {
rules {
id = "foobar"
priority = 123
prefix = "foo"
tags {
ReplicateMe = "Yes"
}
status = "Enabled"
destination {
bucket = "${aws_s3_bucket.destination.arn}"
storage_class = "STANDARD"
}
}
}
} |
I if I create 4 rules through the AWS console
$ aws s3api get-bucket-replication --bucket ewbankkit-us-east-1
{
"ReplicationConfiguration": {
"Rules": [
{
"Status": "Enabled",
"Filter": {
"And": {
"Prefix": "rule4-prefix",
"Tags": [
{
"Value": "VV",
"Key": "Rule4Tag_2"
},
{
"Value": "V",
"Key": "Rule4Tag_1"
}
]
}
},
"DeleteMarkerReplication": {
"Status": "Disabled"
},
"Destination": {
"Bucket": "arn:aws:s3:::ewbankkit-us-west-2"
},
"Priority": 4,
"ID": "rule4"
},
{
"Status": "Enabled",
"Filter": {
"Tag": {
"Value": "V",
"Key": "Rule3Tag"
}
},
"DeleteMarkerReplication": {
"Status": "Disabled"
},
"Destination": {
"Bucket": "arn:aws:s3:::ewbankkit-us-west-2"
},
"Priority": 3,
"ID": "rule3"
},
{
"Status": "Enabled",
"Filter": {
"Prefix": "rule2-prefix"
},
"DeleteMarkerReplication": {
"Status": "Disabled"
},
"Destination": {
"Bucket": "arn:aws:s3:::ewbankkit-us-west-2"
},
"Priority": 2,
"ID": "rule2"
},
{
"Status": "Enabled",
"Filter": {},
"DeleteMarkerReplication": {
"Status": "Disabled"
},
"Destination": {
"Bucket": "arn:aws:s3:::ewbankkit-us-west-2"
},
"Priority": 1,
"ID": "rule1"
}
],
"Role": "arn:aws:iam::000000000000:role/service-role/r"
}
} If I add the equivalent of rule2 with the current provider: resource "aws_s3_bucket" "e" {
bucket = "ewbankkit-us-east-1"
region = "us-east-1"
acl = "private"
force_destroy = false
replication_configuration {
role = "arn:aws:iam::000000000000:role/service-role/r"
rules {
id = "rule2"
status = "Enabled"
prefix = "rule2-prefix"
destination {
bucket = "arn:aws:s3:::ewbankkit-us-west-2"
}
}
}
} then $ aws s3api get-bucket-replication --bucket ewbankkit-us-east-1
{
"ReplicationConfiguration": {
"Rules": [
{
"Status": "Enabled",
"Prefix": "rule2-prefix",
"Destination": {
"Bucket": "arn:aws:s3:::ewbankkit-us-west-2"
},
"ID": "rule2"
}
],
"Role": "arn:aws:iam::000000000000:role/service-role/r"
}
}
so it looks like we have to deal with If I apply the TF configuration above and then go to add a new rule via the AWS console: More details: |
It also looks like we'll need to add support for the Delete Marker Replication functionality:
So we'll have an additional optional |
resource "aws_s3_bucket" "e" {
bucket = "ewbankkit-us-east-1"
region = "us-east-1"
acl = "private"
force_destroy = false
replication_configuration {
role = "arn:aws:iam::000000000000:role/service-role/r"
rules {
id = "rule1"
status = "Enabled"
prefix = "rule1-prefix"
destination {
bucket = "arn:aws:s3:::ewbankkit-us-west-2"
}
}
rules {
id = "rule2"
status = "Enabled"
prefix = "rule2-prefix"
destination {
bucket = "arn:aws:s3:::ewbankkit-us-west-2"
}
}
}
} before schema migration via the AWS console $ aws s3api get-bucket-replication --bucket ewbankkit-us-east-1
{
"ReplicationConfiguration": {
"Rules": [
{
"Status": "Enabled",
"Prefix": "rule1-prefix",
"Destination": {
"Bucket": "arn:aws:s3:::ewbankkit-us-west-2"
},
"ID": "rule1"
},
{
"Status": "Enabled",
"Prefix": "rule2-prefix",
"Destination": {
"Bucket": "arn:aws:s3:::ewbankkit-us-west-2"
},
"ID": "rule2"
}
],
"Role": "arn:aws:iam::000000000000:role/service-role/r"
}
} after schema migration via the AWS console: $ aws s3api get-bucket-replication --bucket ewbankkit-us-east-1
{
"ReplicationConfiguration": {
"Rules": [
{
"Status": "Enabled",
"Filter": {
"Prefix": "rule1-prefix"
},
"DeleteMarkerReplication": {
"Status": "Disabled"
},
"Destination": {
"Bucket": "arn:aws:s3:::ewbankkit-us-west-2"
},
"Priority": 1,
"ID": "rule1"
},
{
"Status": "Enabled",
"Filter": {
"Prefix": "rule2-prefix"
},
"DeleteMarkerReplication": {
"Status": "Disabled"
},
"Destination": {
"Bucket": "arn:aws:s3:::ewbankkit-us-west-2"
},
"Priority": 2,
"ID": "rule2"
}
],
"Role": "arn:aws:iam::000000000000:role/service-role/r"
}
} |
My approach is going to be introduce a new resource schema version and in the
so we should be OK. |
After some work with the approach described above (motivated by trying to make the change look a bit like #899) I have come to the conclusion that in order to maintain backwards compatibility we will need a new resource "aws_s3_bucket" "bucket" {
bucket = "tf-test-bucket-12345"
replication_configuration {
rules {
id = "foobar"
priority = 123
filter {
prefix = "foo"
tags {
ReplicateMe = "Yes"
}
}
status = "Enabled"
destination {
bucket = "${aws_s3_bucket.destination.arn}"
storage_class = "STANDARD"
}
}
}
}
|
I ended up with a simpler implementation:
|
This has been released in version 1.42.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
Hello I need to setup the delete marker in the rule. But I do not see this attribute in docs... Did I miss something? Nek |
@nekloth For schema V2 ( |
@ewaltman Ok, thanks. However, I had to explicitly mention the value of the DeleteMarkerReplication attribute in the tule to make it work .... but using the s3api.
|
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! |
Just announced S3 Cross-Region Replication filtering based on S3 object tags.
Add support to
aws_s3_bucket
resource'sreplication_configuration
attribute.The text was updated successfully, but these errors were encountered: