Created
February 28, 2022 12:19
-
-
Save infraredgirl/60680d632597859e0fe5b652b920cfa4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[aws_s3_bucket_acceleration_status] | |
match=''' | |
resource "aws_s3_bucket" ":[resource_name]" { | |
:[other_config_above] | |
acceleration_status = :[acceleration_status_value] | |
:[other_config_below] | |
}''' | |
rewrite=''' | |
resource "aws_s3_bucket" ":[resource_name]" { | |
:[other_config_above] | |
:[other_config_below] | |
} | |
resource "aws_s3_bucket_accelerate_configuration" ":[resource_name]" { | |
count = var.create_resources && var.acceleration_status != null ? 1 : 0 | |
bucket = aws_s3_bucket.:[resource_name][0].id | |
status = :[acceleration_status_value] | |
}''' | |
[aws_s3_bucket_acl] | |
match=''' | |
resource "aws_s3_bucket" ":[resource_name]" { | |
:[other_config_above] | |
acl = :[acl_value] | |
:[other_config_below] | |
}''' | |
rewrite=''' | |
resource "aws_s3_bucket" ":[resource_name]" { | |
:[other_config_above] | |
:[other_config_below] | |
} | |
resource "aws_s3_bucket_acl" ":[resource_name]" { | |
count = var.create_resources && var.acl != null ? 1 : 0 | |
bucket = aws_s3_bucket.:[resource_name][0].id | |
acl = :[acl_value] | |
}''' | |
[aws_s3_bucket_cors_rule] | |
match=''' | |
resource "aws_s3_bucket" ":[resource_name]" { | |
:[other_config_above] | |
dynamic "cors_rule" { | |
:[cors_rule_value] | |
} | |
:[other_config_below] | |
}''' | |
rewrite=''' | |
resource "aws_s3_bucket" ":[resource_name]" { | |
:[other_config_above] | |
:[other_config_below] | |
} | |
resource "aws_s3_bucket_cors_configuration" ":[resource_name]" { | |
count = var.create_resources && length(var.cors_rules) > 0 ? 1 : 0 | |
bucket = aws_s3_bucket.:[resource_name][0].id | |
dynamic "cors_rule" { | |
:[cors_rule_value] | |
} | |
}''' | |
[aws_s3_bucket_lifecycle_rule_01] | |
match=''' | |
resource "aws_s3_bucket" ":[resource_name]" { | |
:[other_config_above] | |
dynamic "lifecycle_rule" { | |
:[lifecycle_rule_value] | |
} | |
:[other_config_below] | |
}''' | |
rewrite=''' | |
resource "aws_s3_bucket" ":[resource_name]" { | |
:[other_config_above] | |
:[other_config_below] | |
} | |
resource "aws_s3_bucket_lifecycle_configuration" ":[resource_name]" { | |
count = var.create_resources && length(var.lifecycle_rules) > 0 ? 1 : 0 | |
bucket = aws_s3_bucket.:[resource_name][0].id | |
dynamic "rule" { | |
:[lifecycle_rule_value] | |
} | |
}''' | |
[aws_s3_bucket_lifecycle_rule_02] | |
match=''' | |
lifecycle_rule.''' | |
rewrite=''' | |
rule.''' | |
[aws_s3_bucket_lifecycle_rule_03] | |
match=''' | |
resource "aws_s3_bucket_lifecycle_configuration" ":[resource_name]" { | |
:[other_config_above_1] | |
dynamic "rule" { | |
:[other_config_above_2] | |
content { | |
:[other_config_above_3] | |
enabled = ... | |
:[other_config_below] | |
} | |
} | |
}''' | |
rewrite=''' | |
resource "aws_s3_bucket_lifecycle_configuration" ":[resource_name]" { | |
:[other_config_above_1] | |
dynamic "rule" { | |
:[other_config_above_2] | |
content { | |
:[other_config_above_3] | |
status = lookup(rule.value, "enabled", null) == true ? "Enabled" : "Suspended" | |
:[other_config_below] | |
} | |
} | |
}''' | |
[aws_s3_bucket_lifecycle_rule_04] | |
match=''' | |
resource "aws_s3_bucket_lifecycle_configuration" ":[resource_name]" { | |
:[other_config_above_1] | |
dynamic "rule" { | |
:[other_config_above_2] | |
content { | |
:[other_config_above_3] | |
abort_incomplete_multipart_upload_days = ... | |
:[other_config_below] | |
} | |
} | |
}''' | |
rewrite=''' | |
resource "aws_s3_bucket_lifecycle_configuration" ":[resource_name]" { | |
:[other_config_above_1] | |
dynamic "rule" { | |
:[other_config_above_2] | |
content { | |
:[other_config_above_3] | |
dynamic "abort_incomplete_multipart_upload" { | |
for_each = lookup(rule.value, "abort_incomplete_multipart_upload_days", null) != null ? ["once"] : [] | |
content { | |
days_after_initiation = lookup(rule.value, "abort_incomplete_multipart_upload_days", null) | |
} | |
} | |
:[other_config_below] | |
} | |
} | |
}''' | |
[aws_s3_bucket_lifecycle_rule_05] | |
match=''' | |
resource "aws_s3_bucket_lifecycle_configuration" ":[resource_name]" { | |
:[other_config_above_1] | |
dynamic "rule" { | |
:[other_config_above_2] | |
content { | |
:[other_config_above_3] | |
prefix = ... | |
tags = ... | |
:[other_config_below] | |
} | |
} | |
}''' | |
rewrite=''' | |
resource "aws_s3_bucket_lifecycle_configuration" ":[resource_name]" { | |
:[other_config_above_1] | |
dynamic "rule" { | |
:[other_config_above_2] | |
content { | |
:[other_config_above_3] | |
# For 3.x backward compatibility: | |
# Create an and filter when tags are provided, even if prefix is not provided, to match the 3.x provider logic. | |
# See https://github.com/hashicorp/terraform-provider-aws/blob/v3.74.3/internal/service/s3/bucket.go#L2242-L2249 | |
dynamic "filter" { | |
for_each = lookup(rule.value, "tags", null) != null ? ["once"] : [] | |
content { | |
and { | |
prefix = lookup(rule.value, "prefix", null) | |
tags = lookup(rule.value, "tags", null) | |
} | |
} | |
} | |
# For 3.x backward compatibility: | |
# Create a prefix-only filter when tags are not provided, even if prefix is not provided, to match the 3.x | |
# provider logic. | |
# See https://github.com/hashicorp/terraform-provider-aws/blob/v3.74.3/internal/service/s3/bucket.go#L2242-L2249 | |
dynamic "filter" { | |
for_each = lookup(rule.value, "tags", null) == null ? ["once"] : [] | |
content { | |
prefix = lookup(rule.value, "prefix", null) | |
} | |
} | |
:[other_config_below] | |
} | |
} | |
}''' | |
[aws_s3_bucket_lifecycle_rule_06] | |
match=''' | |
dynamic "noncurrent_version_expiration" { | |
:[other_config_above] | |
content { | |
days = :[days_value] | |
} | |
}''' | |
rewrite=''' | |
dynamic "noncurrent_version_expiration" { | |
:[other_config_above] | |
content { | |
noncurrent_days = :[days_value] | |
} | |
}''' | |
[aws_s3_bucket_lifecycle_rule_07] | |
match=''' | |
dynamic "noncurrent_version_transition" { | |
:[other_config_above] | |
content { | |
days = :[days_value] | |
:[other_config_below] | |
} | |
}''' | |
rewrite=''' | |
dynamic "noncurrent_version_transition" { | |
:[other_config_above] | |
content { | |
noncurrent_days = :[days_value] | |
:[other_config_below] | |
} | |
}''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment