Hi
We have some S3 buckets with multiple rules, some added by our cloud operations team, others added specifically by ourselves.
Over time the rules are out of sync between out environments, so I’m trying to get terraform set up.
In PROD we have 3 rules on a bucket, r1 and r2 (ours) and OPS (the cloud op rule).
in NON-PROD we have 2 rules, r1 and OPS.
We want to leave the OPS rule alone, but add r2 to NON-PROD.
Currently I only seem to be able to ignore a rule based on index, but in PROD the OPS rule is index 2, and in NON-PROD it is index 1.
e.g.
resource "aws_s3_bucket_lifecycle_configuration" "bucket1" {
bucket = ...
rule {
id = "r1"
status = "Enabled"
...
}
rule {
id = "r2"
status = "Enabled"
...
}
rule {
id = "OP"
status = "Enabled"
}
lifecycle {
ignore_changes = [
rule[2]
]
}
In theory cloud ops might change the “OP” rule at any time, so I don’t want to store its definition in terraform. If I ran the above in NON-PROD it would overwrite the OP rule in index 1 with r2, and then maybe add a new blank rule “OP” at index 2 (or worse, not create that rule at all).
I could try to clean all this up manually, or add the existing OP rule in to terraform till its fixed, and then ignore as a separate step.
Any other options?
The following doesn’t work, which would be ideal, all rules are ignored if I put this:
ignore_changes = [ rule["OP"] ]