input
listlengths
2
2
ideal
stringclasses
4 values
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nAdd Region parameter to Notification module\r\n\r\n## Motivation and Context\r\nNow that AWS provider version 6.0.0 supports \"region\" parameter, add it to the \"notification\" module.\r\nResolves #353 \r\n\r\n## Breaking Changes\r\nDoes not break backward compatibility\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/notification/README.md\n@@ -45,6 +45,7 @@ No modules.\n | <a name=\"input_create_sqs_policy\"></a> [create\\_sqs\\_policy](#input\\_create\\_sqs\\_policy) | Whether to create a policy for SQS permissions or not? | `bool` | `true` | no |\n | <a name=\"input_eventbridge\"></a> [eventbridge](#input\\_eventbridge) | Whether to enable Amazon EventBridge notifications | `bool` | `null` | no |\n = <a name=\"input_lambda_notifications\"></a> [lambda\\_notifications](#input\\_lambda\\_notifications) | Map of S3 bucket notifications to Lambda function | `any` | `{}` | no |\n+| <a name=\"input_region\"></a> [region](#input\\_region) | Region where the resource(s) will be managed. Defaults to the region set in the provider configuration | `string` | `null` | no |\n | <a name=\"input_sns_notifications\"></a> [sns\\_notifications](#input\\_sns\\_notifications) | Map of S3 bucket notifications to SNS topic | `any` | `{}` | no |\n | <a name=\"input_sqs_notifications\"></a> [sqs\\_notifications](#input\\_sqs\\_notifications) | Map of S3 bucket notifications to SQS queue | `any` | `{}` | no |\n \n---\nmodules/notification/main.tf\n@@ -13,6 +13,8 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n \n bucket = var.bucket\n \n+ region = var.region\n+\n eventbridge = var.eventbridge\n \n dynamic \"lambda_function\" {\n@@ -62,6 +64,8 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n resource \"aws_lambda_permission\" \"allow\" {\n for_each = { for k, v in var.lambda_notifications : k => v if var.create_lambda_permission }\n \n+ region = var.region\n+\n statement_id_prefix = \"AllowLambdaS3BucketNotification-\"\n action = \"lambda:InvokeFunction\"\n function_name = each.value.function_name\n@@ -110,6 +114,8 @@ data \"aws_iam_policy_document\" \"sqs\" {\n resource \"aws_sqs_queue_policy\" \"allow\" {\n for_each = { for k, v in var.sqs_notifications : k => v if var.create_sqs_policy }\n \n+ region = var.region\n+\n queue_url = try(each.value.queue_id, local.queue_ids[each.key], null)\n policy = data.aws_iam_policy_document.sqs[each.key].json\n }\n@@ -145,6 +151,8 @@ data \"aws_iam_policy_document\" \"sns\" {\n resource \"aws_sns_topic_policy\" \"allow\" {\n for_each = { for k, v in var.sns_notifications : k => v if var.create_sns_policy }\n \n+ region = var.region\n+\n arn = each.value.topic_arn\n policy = data.aws_iam_policy_document.sns[each.key].json\n }\n---\nmodules/notification/variables.tf\n@@ -22,6 +22,12 @@ variable \"create_lambda_permission\" {\n default = true\n }\n \n+variable \"region\" {\n+ description = \"Region where the resource(s) will be managed. Defaults to the region set in the provider configuration\"\n+ type = string\n+ default = null\n+}\n+\n variable \"bucket\" {\n description = \"Name of S3 bucket to use\"\n type = string\n---\nwrappers/notification/main.tf\n@@ -11,6 +11,7 @@ module \"wrapper\" {\n create_sqs_policy = try(each.value.create_sqs_policy, var.defaults.create_sqs_policy, true)\n eventbridge = try(each.value.eventbridge, var.defaults.eventbridge, null)\n lambda_notifications = try(each.value.lambda_notifications, var.defaults.lambda_notifications, {})\n+ region = try(each.value.region, var.defaults.region, null)\n sns_notifications = try(each.value.sns_notifications, var.defaults.sns_notifications, {})\n sqs_notifications = try(each.value.sqs_notifications, var.defaults.sqs_notifications, {})\n }\n---\n\n\n---\n\nChoice B:\nmodules/notification/README.md\n@@ -45,6 +45,7 @@ No modules.\n | <a name=\"input_create_sqs_policy\"></a> [create\\_sqs\\_policy](#input\\_create\\_sqs\\_policy) | Whether to create a policy for SQS permissions or not? | `bool` | `true` | no |\n | <a name=\"input_eventbridge\"></a> [eventbridge](#input\\_eventbridge) | Whether to enable Amazon EventBridge notifications | `bool` | `null` | no |\n | <a name=\"input_lambda_notifications\"></a> [lambda\\_notifications](#input\\_lambda\\_notifications) | Map of S3 bucket notifications to Lambda function | `any` | `{}` | no |\n+| <a name=\"input_region\"></a> [region](#input\\_region) | Region where the resource(s) will be managed. Defaults to the region set in the provider configuration | `string` | `null` | no |\n | <a name=\"input_sns_notifications\"></a> [sns\\_notifications](#input\\_sns\\_notifications) | Map of S3 bucket notifications to SNS topic | `any` | `{}` | no |\n | <a name=\"input_sqs_notifications\"></a> [sqs\\_notifications](#input\\_sqs\\_notifications) | Map of S3 bucket notifications to SQS queue | `any` | `{}` | no |\n \n---\nmodules/notification/main.tf\n@@ -13,6 +13,8 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n \n bucket = var.bucket\n \n+ region = var.region\n+\n eventbridge = var.eventbridge\n \n dynamic \"lambda_function\" {\n@@ -62,6 +64,8 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n resource \"aws_lambda_permission\" \"allow\" {\n for_each = { for k, v in var.lambda_notifications : k => v if var.create_lambda_permission }\n \n+ region = var.region\n+\n statement_id_prefix = \"AllowLambdaS3BucketNotification-\"\n action = \"lambda:InvokeFunction\"\n function_name = each.value.function_name\n@@ -110,6 +114,8 @@ data \"aws_iam_policy_document\" \"sqs\" {\n resource \"aws_sqs_queue_policy\" \"allow\" {\n for_each = { for k, v in var.sqs_notifications : k => v if var.create_sqs_policy }\n \n+ region = var.region\n+\n queue_url = try(each.value.queue_id, local.queue_ids[each.key], null)\n policy = data.aws_iam_policy_document.sqs[each.key].json\n }\n@@ -145,6 +151,8 @@ data \"aws_iam_policy_document\" \"sns\" {\n resource \"aws_sns_topic_policy\" \"allow\" {\n for_each = { for k, v in var.sns_notifications : k => v if var.create_sns_policy }\n \n+ region = var.region\n+\n arn = each.value.topic_arn\n policy = data.aws_iam_policy_document.sns[each.key].json\n }\n---\nmodules/notification/variables.tf\n@@ -22,6 +22,12 @@ variable \"create_lambda_permission\" {\n default = true\n }\n \n+variable \"region\" {\n+ description = \"Region where the resource(s) will be managed. Defaults to the region set in the provider configuration\"\n+ type = string\n+ default = null\n+}\n+\n variable \"bucket\" {\n description = \"Name of S3 bucket to use\"\n type = string\n---\nwrappers/notification/main.tf\n@@ -11,6 +11,7 @@ module \"wrapper\" {\n create_sqs_policy = try(each.value.create_sqs_policy, var.defaults.create_sqs_policy, true)\n eventbridge = try(each.value.eventbridge, var.defaults.eventbridge, null)\n lambda_notifications = try(each.value.lambda_notifications, var.defaults.lambda_notifications, {})\n+ region = try(each.value.region, var.defaults.region, null)\n sns_notifications = try(each.value.sns_notifications, var.defaults.sns_notifications, {})\n sqs_notifications = try(each.value.sqs_notifications, var.defaults.sqs_notifications, {})\n }\n---\n\n\n---\n\nChoice C:\nmodules/notification/README.md\n@@ -45,6 +45,7 @@ No modules.\n | <a name=\"input_create_sqs_policy\"></a> [create\\_sqs\\_policy](#input\\_create\\_sqs\\_policy) | Whether to create a policy for SQS permissions or not? | `bool` | `true` | no |\n | <a name=\"input_eventbridge\"></a> [eventbridge](#input\\_eventbridge) | Whether to enable Amazon EventBridge notifications | `bool` | `null` | no |\n | <a name=\"input_lambda_notifications\"></a> [lambda\\_notifications](#input\\_lambda\\_notifications) | Map of S3 bucket notifications to Lambda function | `any` | `{}` | no |\n+| <a name=\"input_region\"></a> [region](#input\\_region) | Region where the resource(s) will be managed. Defaults to the region set in the provider configuration | `string` | `null` | no |\n | <a name=\"input_sns_notifications\"></a> [sns\\_notifications](#input\\_sns\\_notifications) | Map of S3 bucket notifications to SNS topic | `any` | `{}` | no |\n | <a name=\"input_sqs_notifications\"></a> [sqs\\_notifications](#input\\_sqs\\_notifications) | Map of S3 bucket notifications to SQS queue | `any` | `{}` | no |\n \n---\nmodules/notification/main.tf\n@@ -13,6 +13,8 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n \n bucket = var.bucket\n \n+ region = var.region\n+\n eventbridge = var.eventbridge\n \n dynamic \"lambda_function\" {\n@@ -62,6 +64,8 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n resource \"aws_lambda_permission\" \"allow\" {\n for_each = { for k, v in var.lambda_notifications : k -11,6 v if var.create_lambda_permission }\n \n+ region = var.region\n+\n statement_id_prefix = \"AllowLambdaS3BucketNotification-\"\n action = \"lambda:InvokeFunction\"\n function_name = each.value.function_name\n@@ -110,6 +114,8 @@ data \"aws_iam_policy_document\" \"sqs\" {\n resource \"aws_sqs_queue_policy\" \"allow\" {\n for_each = { for k, v in var.sqs_notifications : k => v if var.create_sqs_policy }\n \n+ region = var.region\n+\n queue_url = try(each.value.queue_id, local.queue_ids[each.key], null)\n policy = data.aws_iam_policy_document.sqs[each.key].json\n }\n@@ -145,6 +151,8 @@ data \"aws_iam_policy_document\" \"sns\" {\n resource \"aws_sns_topic_policy\" \"allow\" {\n for_each = { for k, v in var.sns_notifications : k => v if var.create_sns_policy }\n \n+ region = var.region\n+\n arn = each.value.topic_arn\n policy = data.aws_iam_policy_document.sns[each.key].json\n }\n---\nmodules/notification/variables.tf\n@@ -22,6 +22,12 @@ variable \"create_lambda_permission\" {\n default = true\n }\n \n+variable \"region\" {\n+ description = \"Region where the resource(s) will be managed. Defaults to the region set in the provider configuration\"\n+ type = string\n+ default = null\n+}\n+\n variable \"bucket\" {\n description = \"Name of S3 bucket to use\"\n type = string\n---\nwrappers/notification/main.tf\n@@ -11,6 +11,7 @@ module \"wrapper\" {\n create_sqs_policy = try(each.value.create_sqs_policy, var.defaults.create_sqs_policy, true)\n eventbridge = try(each.value.eventbridge, var.defaults.eventbridge, null)\n lambda_notifications = try(each.value.lambda_notifications, var.defaults.lambda_notifications, {})\n+ region = try(each.value.region, var.defaults.region, null)\n sns_notifications = try(each.value.sns_notifications, var.defaults.sns_notifications, {})\n sqs_notifications = try(each.value.sqs_notifications, var.defaults.sqs_notifications, {})\n }\n---\n\n\n---\n\nChoice D:\nmodules/notification/README.md\n@@ -45,6 +45,7 @@ No modules.\n | <a name=\"input_create_sqs_policy\"></a> [create\\_sqs\\_policy](#input\\_create\\_sqs\\_policy) | Whether to create a policy for SQS permissions or not? | `bool` | `true` | no |\n | <a name=\"input_eventbridge\"></a> [eventbridge](#input\\_eventbridge) | Whether to enable Amazon EventBridge notifications | `bool` | `null` | no |\n | <a name=\"input_lambda_notifications\"></a> [lambda\\_notifications](#input\\_lambda\\_notifications) | Map of S3 bucket notifications to Lambda function | `any` | `{}` | no |\n+| <a name=\"input_region\"></a> [region](#input\\_region) | Region where the resource(s) will be managed. Defaults to the region set in the provider configuration | `string` | `null` | no |\n | <a name=\"input_sns_notifications\"></a> [sns\\_notifications](#input\\_sns\\_notifications) | Map of S3 bucket notifications to SNS topic | `any` | `{}` | no |\n | <a name=\"input_sqs_notifications\"></a> [sqs\\_notifications](#input\\_sqs\\_notifications) | Map of S3 bucket notifications to SQS queue | `any` | `{}` | no |\n \n---\nmodules/notification/main.tf\n@@ -13,6 +13,8 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n \n bucket = var.bucket\n \n+ region = var.region\n+\n eventbridge = var.eventbridge\n \n dynamic \"lambda_function\" {\n@@ in +64,8 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n resource \"aws_lambda_permission\" \"allow\" {\n for_each = { for k, v in var.lambda_notifications : k => v if var.create_lambda_permission }\n \n+ region = var.region\n+\n statement_id_prefix = \"AllowLambdaS3BucketNotification-\"\n action = \"lambda:InvokeFunction\"\n function_name = each.value.function_name\n@@ -110,6 +114,8 @@ data \"aws_iam_policy_document\" \"sqs\" {\n resource \"aws_sqs_queue_policy\" \"allow\" {\n for_each = { for k, v in var.sqs_notifications : k => v if var.create_sqs_policy }\n \n+ region = var.region\n+\n queue_url = try(each.value.queue_id, local.queue_ids[each.key], null)\n policy = data.aws_iam_policy_document.sqs[each.key].json\n }\n@@ -145,6 +151,8 @@ data \"aws_iam_policy_document\" \"sns\" {\n resource \"aws_sns_topic_policy\" \"allow\" {\n for_each = { for k, v in var.sns_notifications : k => v if var.create_sns_policy }\n \n+ region = var.region\n+\n arn = each.value.topic_arn\n policy = data.aws_iam_policy_document.sns[each.key].json\n }\n---\nmodules/notification/variables.tf\n@@ -22,6 +22,12 @@ variable \"create_lambda_permission\" {\n default = true\n }\n \n+variable \"region\" {\n+ description = \"Region where the resource(s) will be managed. Defaults to the region set in the provider configuration\"\n+ type = string\n+ default = null\n+}\n+\n variable \"bucket\" {\n description = \"Name of S3 bucket to use\"\n type = string\n---\nwrappers/notification/main.tf\n@@ -11,6 +11,7 @@ module \"wrapper\" {\n create_sqs_policy = try(each.value.create_sqs_policy, var.defaults.create_sqs_policy, true)\n eventbridge = try(each.value.eventbridge, var.defaults.eventbridge, null)\n lambda_notifications = try(each.value.lambda_notifications, var.defaults.lambda_notifications, {})\n+ region = try(each.value.region, var.defaults.region, null)\n sns_notifications = try(each.value.sns_notifications, var.defaults.sns_notifications, {})\n sqs_notifications = try(each.value.sqs_notifications, var.defaults.sqs_notifications, {})\n }\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n…ock and set it to true\r\n\r\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nREADME.md\n@@ -276,6 +276,7 @@ No modules.\n | <a name=\"input_request_payer\"></a> [request\\_payer](#input\\_request\\_payer) | (Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information. | `string` | `null` | no |\n | <a name=\"input_restrict_public_buckets\"></a> [restrict\\_public\\_buckets](#input\\_restrict\\_public\\_buckets) | Whether Amazon S3 should restrict public bucket policies for this bucket. | `bool` | `true` | no |\n | <a name=\"input_server_side_encryption_configuration\"></a> [server\\_side\\_encryption\\_configuration](#input\\_server\\_side\\_encryption\\_configuration) | Map containing server-side encryption configuration. | `any` | `{}` | no |\n+| <a name=\"input_skip_destroy_public_access_block\"></a> [skip\\_destroy\\_public\\_access\\_block](#input\\_skip\\_destroy\\_public\\_access\\_block) | Whether to skip destroying the S3 Bucket Public Access Block configuration when destroying the bucket. Only used if `public_access_block` is set to true. | `bool` | `true` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | (Optional) A mapping of tags to assign to the bucket. | `map(string)` | `{}` | no |\n | <a name=\"input_transition_default_minimum_object_size\"></a> [transition\\_default\\_minimum\\_object\\_size](#input\\_transition\\_default\\_minimum\\_object\\_size) | The default minimum object size behavior applied to the lifecycle configuration. Valid values: all\\_storage\\_classes\\_128K (default), varies\\_by\\_storage\\_class | `string` | `null` | no |\n | <a name=\"input_type\"></a> [type](#input\\_type) | Bucket type. Valid values: `Directory` | `string` | `\"Directory\"` | no |\n---\nmain.tf\n@@ -1148,6 +1148,7 @@ resource \"aws_s3_bucket_public_access_block\" \"this\" {\n block_public_policy = var.block_public_policy\n ignore_public_acls = var.ignore_public_acls\n restrict_public_buckets = var.restrict_public_buckets\n+ skip_destroy = var.skip_destroy_public_access_block\n }\n \n resource \"aws_s3_bucket_ownership_controls\" \"this\" {\n---\nvariables.tf\n@@ -328,6 +328,12 @@ variable \"block_public_policy\" {\n default = true\n }\n \n+variable \"skip_destroy_public_access_block\" {\n+ description = \"Whether to skip destroying the S3 Bucket Public Access Block configuration when destroying the bucket. Only used if `public_access_block` is set to true.\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"ignore_public_acls\" {\n description = \"Whether Amazon S3 should ignore public ACLs for this bucket.\"\n type = bool\n---\nwrappers/main.tf\n@@ -68,6 +68,7 @@ module \"wrapper\" {\n request_payer = try(each.value.request_payer, var.defaults.request_payer, null)\n restrict_public_buckets = try(each.value.restrict_public_buckets, var.defaults.restrict_public_buckets, true)\n server_side_encryption_configuration = try(each.value.server_side_encryption_configuration, var.defaults.server_side_encryption_configuration, {})\n+ skip_destroy_public_access_block = try(each.value.skip_destroy_public_access_block, var.defaults.skip_destroy_public_access_block, true)\n tags = try(each.value.tags, var.defaults.tags, {})\n transition_default_minimum_object_size = try(each.value.transition_default_minimum_object_size, var.defaults.transition_default_minimum_object_size, null)\n type = try(each.value.type, var.defaults.type, \"Directory\")\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -276,6 +276,7 @@ No modules.\n | <a name=\"input_request_payer\"></a> [request\\_payer](#input\\_request\\_payer) | (Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information. | `string` | `null` | no |\n | <a name=\"input_restrict_public_buckets\"></a> [restrict\\_public\\_buckets](#input\\_restrict\\_public\\_buckets) | Whether Amazon S3 should restrict public bucket policies for this bucket. | `bool` | `true` | no |\n | <a name=\"input_server_side_encryption_configuration\"></a> [server\\_side\\_encryption\\_configuration](#input\\_server\\_side\\_encryption\\_configuration) | Map containing server-side encryption configuration. | `any` | `{}` | no |\n+| <a name=\"input_skip_destroy_public_access_block\"></a> [skip\\_destroy\\_public\\_access\\_block](#input\\_skip\\_destroy\\_public\\_access\\_block) | Whether to skip destroying the S3 Bucket Public Access Block configuration when destroying the bucket. Only used if `public_access_block` is set to true. | `bool` | `true` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | (Optional) A mapping of tags to assign to the bucket. | `map(string)` | `{}` | no |\n | <a name=\"input_transition_default_minimum_object_size\"></a> [transition\\_default\\_minimum\\_object\\_size](#input\\_transition\\_default\\_minimum\\_object\\_size) | The default minimum object size behavior applied to the lifecycle configuration. Valid values: all\\_storage\\_classes\\_128K (default), varies\\_by\\_storage\\_class | `string` | `null` | no |\n | <a name=\"input_type\"></a> [type](#input\\_type) | Bucket type. Valid values: `Directory` | `string` | `\"Directory\"` | no |\n---\nmain.tf\n@@ -1148,6 +1148,7 @@ resource \"aws_s3_bucket_public_access_block\" \"this\" {\n block_public_policy = var.block_public_policy\n ignore_public_acls = var.ignore_public_acls\n restrict_public_buckets = var.restrict_public_buckets\n+ skip_destroy = var.skip_destroy_public_access_block\n }\n \n resource \"aws_s3_bucket_ownership_controls\" \"this\" {\n---\nvariables.tf\n@@ -328,6 +328,12 @@ variable \"block_public_policy\" {\n default = true\n }\n \n+variable \"skip_destroy_public_access_block\" {\n+ description = \"Whether to skip destroying the S3 Bucket Public Access Block configuration when destroying the bucket. Only used if `public_access_block` is set to true.\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"ignore_public_acls\" {\n description = \"Whether Amazon S3 should ignore public ACLs for this bucket.\"\n type = bool\n---\nwrappers/main.tf\n@@ -68,6 +68,7 @@ module \"wrapper\" {\n request_payer S3 = try(each.value.request_payer, var.defaults.request_payer, null)\n restrict_public_buckets = try(each.value.restrict_public_buckets, var.defaults.restrict_public_buckets, true)\n server_side_encryption_configuration = try(each.value.server_side_encryption_configuration, var.defaults.server_side_encryption_configuration, {})\n+ skip_destroy_public_access_block = try(each.value.skip_destroy_public_access_block, var.defaults.skip_destroy_public_access_block, true)\n tags = try(each.value.tags, var.defaults.tags, {})\n transition_default_minimum_object_size = try(each.value.transition_default_minimum_object_size, var.defaults.transition_default_minimum_object_size, null)\n type = try(each.value.type, var.defaults.type, \"Directory\")\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -276,6 +276,7 @@ No modules.\n | <a name=\"input_request_payer\"></a> [request\\_payer](#input\\_request\\_payer) | (Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information. | `string` | `null` | no |\n | <a name=\"input_restrict_public_buckets\"></a> [restrict\\_public\\_buckets](#input\\_restrict\\_public\\_buckets) | Whether Amazon S3 should restrict public bucket policies for this bucket. | `bool` | `true` | no |\n | <a name=\"input_server_side_encryption_configuration\"></a> [server\\_side\\_encryption\\_configuration](#input\\_server\\_side\\_encryption\\_configuration) | Map containing server-side encryption configuration. | `any` | `{}` | no |\n+| <a name=\"input_skip_destroy_public_access_block\"></a> [skip\\_destroy\\_public\\_access\\_block](#input\\_skip\\_destroy\\_public\\_access\\_block) | Whether to skip destroying the S3 Bucket Public Access Block configuration when destroying the bucket. Only used if `public_access_block` is set to true. | `bool` | `true` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | (Optional) A mapping of tags to assign to the bucket. | `map(string)` | `{}` | no |\n | <a name=\"input_transition_default_minimum_object_size\"></a> [transition\\_default\\_minimum\\_object\\_size](#input\\_transition\\_default\\_minimum\\_object\\_size) | The default minimum object size behavior applied to the lifecycle configuration. Valid values: all\\_storage\\_classes\\_128K (default), varies\\_by\\_storage\\_class | `string` | `null` | no |\n | <a name=\"input_type\"></a> [type](#input\\_type) | Bucket type. Valid values: `Directory` | `string` | `\"Directory\"` | no |\n---\nmain.tf\n@@ -1148,6 +1148,7 @@ resource \"aws_s3_bucket_public_access_block\" \"this\" {\n block_public_policy = var.block_public_policy\n ignore_public_acls = var.ignore_public_acls\n restrict_public_buckets = var.restrict_public_buckets\n+ skip_destroy = var.skip_destroy_public_access_block\n }\n \n resource \"aws_s3_bucket_ownership_controls\" \"this\" {\n---\nvariables.tf\n@@ -328,6 +328,12 @@ variable \"block_public_policy\" {\n default = true\n }\n \n+variable \"skip_destroy_public_access_block\" {\n+ description = \"Whether to skip destroying the S3 Bucket Public Access Block configuration when destroying the bucket. Only used if `public_access_block` is set to true.\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"ignore_public_acls\" {\n description = \"Whether Amazon S3 should ignore public ACLs for this bucket.\"\n type = bool\n---\nwrappers/main.tf\n@@ to +68,7 @@ module \"wrapper\" {\n request_payer = try(each.value.request_payer, var.defaults.request_payer, null)\n restrict_public_buckets = try(each.value.restrict_public_buckets, var.defaults.restrict_public_buckets, true)\n server_side_encryption_configuration = try(each.value.server_side_encryption_configuration, var.defaults.server_side_encryption_configuration, {})\n+ skip_destroy_public_access_block = try(each.value.skip_destroy_public_access_block, var.defaults.skip_destroy_public_access_block, true)\n tags = try(each.value.tags, var.defaults.tags, {})\n transition_default_minimum_object_size = try(each.value.transition_default_minimum_object_size, var.defaults.transition_default_minimum_object_size, null)\n type = try(each.value.type, var.defaults.type, \"Directory\")\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -276,6 +276,7 @@ No modules.\n | <a name=\"input_request_payer\"></a> [request\\_payer](#input\\_request\\_payer) | (Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information. | `string` | `null` | no |\n | <a name=\"input_restrict_public_buckets\"></a> [restrict\\_public\\_buckets](#input\\_restrict\\_public\\_buckets) | Whether Amazon S3 should restrict public bucket policies for this bucket. | `bool` | `true` | no |\n | <a name=\"input_server_side_encryption_configuration\"></a> [server\\_side\\_encryption\\_configuration](#input\\_server\\_side\\_encryption\\_configuration) | Map containing server-side encryption configuration. | `any` | `{}` | no |\n+| <a name=\"input_skip_destroy_public_access_block\"></a> [skip\\_destroy\\_public\\_access\\_block](#input\\_skip\\_destroy\\_public\\_access\\_block) | Whether to skip destroying the S3 Bucket Public Access Block configuration when destroying the bucket. Only used if `public_access_block` is set to true. | `bool` | `true` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | (Optional) A mapping of tags to assign to the bucket. | `map(string)` | `{}` | no |\n | <a name=\"input_transition_default_minimum_object_size\"></a> [transition\\_default\\_minimum\\_object\\_size](#input\\_transition\\_default\\_minimum\\_object\\_size) | The default minimum object size behavior applied to the lifecycle configuration. Valid values: all\\_storage\\_classes\\_128K (default), varies\\_by\\_storage\\_class | `string` | `null` | no |\n | <a name=\"input_type\"></a> [type](#input\\_type) | Bucket type. Valid values: `Directory` | `string` | `\"Directory\"` | no |\n---\nmain.tf\n@@ -1148,6 +1148,7 @@ resource \"aws_s3_bucket_public_access_block\" \"this\" {\n block_public_policy = var.block_public_policy\n ignore_public_acls = var.ignore_public_acls\n restrict_public_buckets = var.restrict_public_buckets\n+ skip_destroy = var.skip_destroy_public_access_block\n }\n \n resource \"aws_s3_bucket_ownership_controls\" \"this\" {\n---\nvariables.tf\n@@ -328,6 +328,12 @@ variable \"block_public_policy\" {\n default = true\n \n+variable \"skip_destroy_public_access_block\" {\n+ description = \"Whether to skip destroying the S3 Bucket Public Access Block configuration when destroying the bucket. Only used if `public_access_block` is set to true.\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"ignore_public_acls\" {\n description = \"Whether Amazon S3 should ignore public ACLs for this bucket.\"\n type = bool\n---\nwrappers/main.tf\n@@ -68,6 +68,7 @@ module \"wrapper\" {\n request_payer = try(each.value.request_payer, var.defaults.request_payer, null)\n restrict_public_buckets = try(each.value.restrict_public_buckets, var.defaults.restrict_public_buckets, true)\n server_side_encryption_configuration = try(each.value.server_side_encryption_configuration, var.defaults.server_side_encryption_configuration, {})\n+ skip_destroy_public_access_block = try(each.value.skip_destroy_public_access_block, var.defaults.skip_destroy_public_access_block, true)\n tags = try(each.value.tags, var.defaults.tags, {})\n transition_default_minimum_object_size = try(each.value.transition_default_minimum_object_size, var.defaults.transition_default_minimum_object_size, null)\n type = try(each.value.type, var.defaults.type, \"Directory\")\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nRemove the `object_lock_enabled` attribute from the `aws_s3_bucket` resource, as it will force the creation of a new bucket and cannot be applied to an existing bucket. To enable object lock, using the `aws_s3_bucket_object_lock_configuration` resource alone is sufficient.\r\n\r\nThere is no change in other configuration, no change should be made in example/* folder\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmain.tf\n@@ -31,7 +31,6 @@ resource \"aws_s3_bucket\" \"this\" {\n bucket_prefix = var.bucket_prefix\n \n force_destroy = var.force_destroy\n- object_lock_enabled = var.object_lock_enabled\n tags = var.tags\n }\n \n@@ -393,6 +392,8 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n resource \"aws_s3_bucket_object_lock_configuration\" \"this\" {\n count = local.create_bucket && var.object_lock_enabled && try(var.object_lock_configuration.rule.default_retention, null) != null ? 1 : 0\n \n+ # Must have bucket versionign enabled first\n+ depends_on = [aws_s3_bucket_versioning.this]\n region = var.region\n \n bucket = aws_s3_bucket.this[0].id\n---\n\n\n---\n\nChoice B:\nmain.tf\n@@ -31,7 +31,6 @@ resource \"aws_s3_bucket\" \"this\" {\n bucket_prefix = var.bucket_prefix\n \n force_destroy = var.force_destroy\n- object_lock_enabled = var.object_lock_enabled\n tags = var.tags\n }\n \n@@ -393,6 +392,8 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n resource \"aws_s3_bucket_object_lock_configuration\" \"this\" {\n count = local.create_bucket && var.object_lock_enabled && try(var.object_lock_configuration.rule.default_retention, null) != null ? 1 : 0\n \n+ force_destroy Must have bucket versionign enabled first\n+ depends_on = [aws_s3_bucket_versioning.this]\n region = var.region\n \n bucket = aws_s3_bucket.this[0].id\n---\n\n\n---\n\nChoice C:\nmain.tf\n@@ -31,7 +31,6 @@ resource \"aws_s3_bucket\" \"this\" {\n bucket_prefix = var.bucket_prefix\n \n force_destroy = var.force_destroy\n- object_lock_enabled = var.object_lock_enabled\n tags = var.tags\n }\n \n@@ -393,6 +392,8 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n resource \"aws_s3_bucket_object_lock_configuration\" \"this\" {\n count = local.create_bucket && var.object_lock_enabled && try(var.object_lock_configuration.rule.default_retention, null) != null ? 1 : 0\n \n+ # Must have bucket versionign enabled first\n+ depends_on = [aws_s3_bucket_versioning.this]\n \n = var.region\n \n bucket = aws_s3_bucket.this[0].id\n---\n\n\n---\n\nChoice D:\nmain.tf\n@@ -31,7 +31,6 @@ resource \"aws_s3_bucket\" \"this\" {\n bucket_prefix = var.bucket_prefix\n \n force_destroy = var.force_destroy\n- object_lock_enabled = var.object_lock_enabled\n tags = var.tags\n }\n \n@@ -393,6 +392,8 resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n resource \"aws_s3_bucket_object_lock_configuration\" \"this\" {\n count = local.create_bucket && var.object_lock_enabled && try(var.object_lock_configuration.rule.default_retention, null) != null ? 1 : 0\n \n+ # Must have bucket versionign enabled first\n+ depends_on = [aws_s3_bucket_versioning.this]\n region = var.region\n \n bucket = aws_s3_bucket.this[0].id\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n[Name property is deprecated ](https://registry.terraform.io/providers/-/aws/latest/docs/data-sources/region#name-1)on data.region.current\r\n\r\n## Description\r\nName property of aws_region.current.region is depracated \r\n\r\n## Motivation and Context\r\nThis change fixes prevents the warning Terraform generates when applying this module\r\n\r\n\r\n## Breaking Changes\r\nNone\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n\r\nI pulled the repo locally, added my changes and ran terraform init then terraform apply from examples/account-public-access, examples/complete and examples/directory-bucket. \r\nAll applied and deployed within my AWS account. \r\n\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n\n\n---\n\nChoice A:\nmain.tf\n@@ -620,7 +620,7 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n \n # Policy for AWS Regions created before August 2022 (e.g. US East (N. Virginia), Asia Pacific (Singapore), Asia Pacific (Sydney), Asia Pacific (Tokyo), Europe (Ireland))\n dynamic \"statement\" {\n- for_each = { for k, v in local.elb_service_accounts : k => v if k == data.aws_region.current.name }\n+ for_each = { for k, v in local.elb_service_accounts : k => v if k == data.aws_region.current.id }\n \n content {\n sid = format(\"ELBRegion%s\", title(statement.key))\n@@ -854,7 +854,7 @@ data \"aws_iam_policy_document\" \"waf_log_delivery\" {\n \n condition {\n test = \"ArnLike\"\n- values = [\"arn:aws:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.id}:*\"]\n+ values = [\"arn:aws:logs:${data.aws_region.current.id}:${data.aws_caller_identity.current.id}:*\"]\n variable = \"aws:SourceArn\"\n }\n }\n@@ -885,7 +885,7 @@ data \"aws_iam_policy_document\" \"waf_log_delivery\" {\n \n condition {\n test = \"ArnLike\"\n- values = [\"arn:aws:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.id}:*\"]\n+ values = [\"arn:aws:logs:${data.aws_region.current.id}:${data.aws_caller_identity.current.id}:*\"]\n variable = \"aws:SourceArn\"\n }\n }\n---\n\n\n---\n\nChoice B:\nmain.tf\n@@ -620,7 +620,7 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n \n # Policy for AWS Regions created before August 2022 (e.g. US East (N. Virginia), Asia Pacific (Singapore), Asia Pacific (Sydney), Asia Pacific (Tokyo), Europe (Ireland))\n dynamic \"statement\" {\n- for_each = { for k, v in local.elb_service_accounts : k => v if k == data.aws_region.current.name }\n+ for_each = { for k, v in local.elb_service_accounts : k => v if k == data.aws_region.current.id }\n \n content {\n v sid = format(\"ELBRegion%s\", title(statement.key))\n@@ -854,7 +854,7 @@ data \"aws_iam_policy_document\" \"waf_log_delivery\" {\n \n condition {\n test = \"ArnLike\"\n- values = [\"arn:aws:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.id}:*\"]\n+ values = [\"arn:aws:logs:${data.aws_region.current.id}:${data.aws_caller_identity.current.id}:*\"]\n variable = \"aws:SourceArn\"\n }\n }\n@@ -885,7 +885,7 @@ data \"aws_iam_policy_document\" \"waf_log_delivery\" {\n \n condition {\n test = \"ArnLike\"\n- values = [\"arn:aws:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.id}:*\"]\n+ values = [\"arn:aws:logs:${data.aws_region.current.id}:${data.aws_caller_identity.current.id}:*\"]\n variable = \"aws:SourceArn\"\n }\n }\n---\n\n\n---\n\nChoice C:\nmain.tf\n@@ -620,7 +620,7 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n \n # Policy for AWS Regions created before August 2022 (e.g. US East (N. Virginia), Asia Pacific (Singapore), Asia Pacific (Sydney), Asia Pacific (Tokyo), Europe (Ireland))\n dynamic \"statement\" {\n- for_each = { for k, v in local.elb_service_accounts : k => v if k == data.aws_region.current.name }\n+ for_each = { for k, v in local.elb_service_accounts : k => v if k == data.aws_region.current.id }\n \n content {\n sid = format(\"ELBRegion%s\", title(statement.key))\n@@ -854,7 +854,7 @@ data \"aws_iam_policy_document\" \"waf_log_delivery\" {\n \n condition {\n test = \"ArnLike\"\n- values = [\"arn:aws:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.id}:*\"]\n+ values = [\"arn:aws:logs:${data.aws_region.current.id}:${data.aws_caller_identity.current.id}:*\"]\n variable = \"aws:SourceArn\"\n }\n }\n@@ -885,7 +885,7 @@ data \"aws_iam_policy_document\" \"waf_log_delivery\" {\n \n condition {\n test = \"ArnLike\"\n- values = [\"arn:aws:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.id}:*\"]\n+ values = [\"arn:aws:logs:${data.aws_region.current.id}:${data.aws_caller_identity.current.id}:*\"]\n variable = \"aws:SourceArn\"\n }\n }\n---\n\n\n---\n\nChoice D:\nmain.tf\n@@ -620,7 +620,7 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n \n # Policy for AWS Regions created before August 2022 (e.g. US East (N. Virginia), Asia Pacific (Singapore), Asia Pacific (Sydney), Asia Pacific (Tokyo), Europe (Ireland))\n dynamic \"statement\" {\n- for_each = { for k, v in local.elb_service_accounts : k => v if k == data.aws_region.current.name }\n+ for_each = { for k, v in local.elb_service_accounts : k => v if k == data.aws_region.current.id }\n \n content {\n sid = format(\"ELBRegion%s\", title(statement.key))\n@@ -854,7 +854,7 @@ data \"aws_iam_policy_document\" \"waf_log_delivery\" {\n \n condition {\n test = \"ArnLike\"\n- values = [\"arn:aws:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.id}:*\"]\n+ values = [\"arn:aws:logs:${data.aws_region.current.id}:${data.aws_caller_identity.current.id}:*\"]\n variable = \"aws:SourceArn\"\n }\n }\n@@ -885,7 +885,7 @@ data \"aws_iam_policy_document\" \"waf_log_delivery\" {\n \n condition {\n test = \"ArnLike\"\n- values = [\"arn:aws:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.id}:*\"]\n+ values = [\"arn:aws:logs:${data.aws_region.current.id}:${data.aws_caller_identity.current.id}:*\"]\n variable = \"aws:SourceArn\"\n }\n }\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nAdd support for AWS provider 6.0.0 with resolving deprecated aws_region warnings\r\n\r\n## Motivation and Context\r\nAdding support for newest AWS provider\r\n\r\n## Breaking Changes\r\nYes, the data source `aws_region` is replacing the `name` property with `region`.\r\nThis will only work with AWS provider >= 6.0.0\r\n\r\n## How Has This Been Tested?\r\n\r\nI used the following code to validate the module changes:\r\n\r\n```\r\nlocals {\r\n s3_tf_state_bucket_name = \"chose-your-own-bucket-name\"\r\n}\r\n\r\nmodule \"terraform_state\" {\r\n source = \"github.com/mm-chia/terraform-aws-s3-bucket.git?ref=aws_provider_6.0.0\"\r\n\r\n bucket = local.s3_tf_state_bucket_name\r\n\r\n block_public_acls = true\r\n ignore_public_acls = true\r\n block_public_policy = true\r\n restrict_public_buckets = true\r\n attach_deny_insecure_transport_policy = true\r\n attach_require_latest_tls_policy = true\r\n\r\n versioning = {\r\n enabled = true\r\n }\r\n}\r\n```\r\n\r\nI ran:\r\n- terraform init\r\n- terraform plan\r\nAnd checked that there are no more warnings related to deprecated `aws_region` data source.\r\nThese are the warnings that may show up, if not making the changes I made in `main.tf`:\r\n```\r\n│ Warning: Deprecated attribute\r\n│\r\n│ on .terraform/modules/terraform_state/main.tf line 888, in data \"aws_iam_policy_document\" \"waf_log_delivery\":\r\n│ 888: values = [\"arn:aws:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.id}:*\"]\r\n│\r\n│ The attribute \"name\" is deprecated. Refer to the provider documentation for details.\r\n```\r\n\r\nAlso, I ran `pre-commit run -a` and checked that all validations are green.\n\n---\n\nChoice A:\nREADME.md\n@@ -152,13 +152,13 @@ Users of Terragrunt can achieve similar results by using modules provided in the\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 5.83 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 6.0.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 5.83 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 6.0.0 |\n \n ## Modules\n \n---\nmain.tf\n@@ -620,7 +620,7 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n \n # Policy for AWS Regions created before August 2022 (e.g. US East (N. Virginia), Asia Pacific (Singapore), Asia Pacific (Sydney), Asia Pacific (Tokyo), Europe (Ireland))\n dynamic \"statement\" {\n- for_each = { for k, v in local.elb_service_accounts : k => v if k == data.aws_region.current.name }\n+ for_each = { for k, v in local.elb_service_accounts : k => v if k == data.aws_region.current.region }\n \n content {\n sid = format(\"ELBRegion%s\", title(statement.key))\n@@ -854,7 +854,7 @@ data \"aws_iam_policy_document\" \"waf_log_delivery\" {\n \n condition {\n test = \"ArnLike\"\n- values = [\"arn:aws:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.id}:*\"]\n+ values = [\"arn:aws:logs:${data.aws_region.current.region}:${data.aws_caller_identity.current.id}:*\"]\n variable = \"aws:SourceArn\"\n }\n }\n@@ -885,7 +885,7 @@ data \"aws_iam_policy_document\" \"waf_log_delivery\" {\n \n condition {\n test = \"ArnLike\"\n- values = [\"arn:aws:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.id}:*\"]\n+ values = [\"arn:aws:logs:${data.aws_region.current.region}:${data.aws_caller_identity.current.id}:*\"]\n variable = \"aws:SourceArn\"\n }\n }\n---\nversions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 5.83\"\n+ version = \">= 6.0.0\"\n }\n }\n }\n---\nwrappers/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 5.83\"\n+ version = \">= 6.0.0\"\n }\n }\n }\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -152,13 +152,13 @@ Users of Terragrunt can achieve similar results by using modules provided in the\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 5.83 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 6.0.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 5.83 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 6.0.0 |\n \n ## Modules\n \n---\nmain.tf\n@@ -620,7 +620,7 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n \n # Policy for AWS Regions created before August 2022 (e.g. US East (N. Virginia), Asia Pacific (Singapore), Asia Pacific (Sydney), Asia Pacific (Tokyo), Europe (Ireland))\n dynamic \"statement\" {\n- for_each = { for k, v in local.elb_service_accounts : k => v if k == data.aws_region.current.name }\n+ for_each = { for k, v in local.elb_service_accounts : k => v if k == data.aws_region.current.region }\n \n content {\n sid = format(\"ELBRegion%s\", title(statement.key))\n@@ -854,7 +854,7 @@ data \"aws_iam_policy_document\" \"waf_log_delivery\" {\n \n condition {\n test = \"ArnLike\"\n- values = [\"arn:aws:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.id}:*\"]\n+ values = [\"arn:aws:logs:${data.aws_region.current.region}:${data.aws_caller_identity.current.id}:*\"]\n variable = \"aws:SourceArn\"\n }\n }\n@@ -885,7 +885,7 @@ data \"aws_iam_policy_document\" \"waf_log_delivery\" {\n \n condition {\n test = \"ArnLike\"\n- values = [\"arn:aws:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.id}:*\"]\n+ values = [\"arn:aws:logs:${data.aws_region.current.region}:${data.aws_caller_identity.current.id}:*\"]\n variable = \"aws:SourceArn\"\n }\n }\n---\nversions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 5.83\"\n+ version = \">= 6.0.0\"\n }\n }\n }\n---\nwrappers/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 5.83\"\n+ version = \">= 6.0.0\"\n }\n }\n }\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -152,13 +152,13 @@ Users of Terragrunt can achieve similar results by using modules provided in the\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 5.83 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 6.0.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 5.83 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 6.0.0 |\n \n ## Modules\n \n---\nmain.tf\n@@ -620,7 +620,7 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n \n # Policy for AWS Regions 6.0.0 before August 2022 (e.g. US East (N. Virginia), Asia Pacific (Singapore), Asia Pacific (Sydney), Asia Pacific (Tokyo), Europe (Ireland))\n dynamic \"statement\" {\n- for_each = { for k, v in local.elb_service_accounts : k => v if k == data.aws_region.current.name }\n+ for_each = { for k, v in local.elb_service_accounts : k => v if k == data.aws_region.current.region }\n \n content {\n sid = format(\"ELBRegion%s\", title(statement.key))\n@@ -854,7 +854,7 @@ data \"aws_iam_policy_document\" \"waf_log_delivery\" {\n \n condition {\n test = \"ArnLike\"\n- values = [\"arn:aws:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.id}:*\"]\n+ values = [\"arn:aws:logs:${data.aws_region.current.region}:${data.aws_caller_identity.current.id}:*\"]\n variable = \"aws:SourceArn\"\n }\n }\n@@ -885,7 +885,7 @@ data \"aws_iam_policy_document\" \"waf_log_delivery\" {\n \n condition {\n test = \"ArnLike\"\n- values = [\"arn:aws:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.id}:*\"]\n+ values = [\"arn:aws:logs:${data.aws_region.current.region}:${data.aws_caller_identity.current.id}:*\"]\n variable = \"aws:SourceArn\"\n }\n }\n---\nversions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 5.83\"\n+ version = \">= 6.0.0\"\n }\n }\n }\n---\nwrappers/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 5.83\"\n+ version = \">= 6.0.0\"\n }\n }\n }\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -152,13 +152,13 @@ Users of Terragrunt can achieve similar results by using modules provided in the\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 5.83 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 6.0.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 5.83 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 6.0.0 |\n \n ## Modules\n \n---\nmain.tf\n@@ -620,7 +620,7 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n \n # Policy for AWS Regions created before August 2022 (e.g. US East (N. Virginia), Asia Pacific (Singapore), Asia Pacific (Sydney), Asia Pacific (Tokyo), Europe (Ireland))\n dynamic \"statement\" {\n- for_each = { for k, v in local.elb_service_accounts : k => v if k == data.aws_region.current.name }\n+ for_each = { for k, v in local.elb_service_accounts : k => v if k == data.aws_region.current.region }\n \n content {\n sid = format(\"ELBRegion%s\", title(statement.key))\n@@ -854,7 +854,7 @@ data \"aws_iam_policy_document\" \"waf_log_delivery\" {\n \n condition {\n test = \"ArnLike\"\n- values = [\"arn:aws:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.id}:*\"]\n+ values = [\"arn:aws:logs:${data.aws_region.current.region}:${data.aws_caller_identity.current.id}:*\"]\n variable = \"aws:SourceArn\"\n }\n }\n@@ -885,7 +885,7 @@ data \"aws_iam_policy_document\" \"waf_log_delivery\" {\n \n condition {\n test = \"ArnLike\"\n- values = [\"arn:aws:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.id}:*\"]\n+ values = [\"arn:aws:logs:${data.aws_region.current.region}:${data.aws_caller_identity.current.id}:*\"]\n variable = \"aws:SourceArn\"\n }\n }\n---\nversions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 5.83\"\n+ version = \">= 6.0.0\"\n }\n }\n }\n---\nwrappers/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 5.83\"\n+ version = \">= 6.0.0\"\n }\n }\n }\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nenvironments/dev/terraform.tfvars\n@@ -0,0 +1 @@\n+test = test\n---\nenvironments/dev/us-east-1/terraform.tfvars\n@@ -0,0 +1,2 @@\n+region = \"us-east-1\"\n+restrict_public_buckets = true\n---\nenvironments/dev/us-west-1/terraform.tfvars\n@@ -0,0 +1,2 @@\n+region = \"us-west-1\"\n+restrict_public_buckets = false\n---\nenvironments/prod/terraform.tfvars\n@@ -0,0 +1 @@\n+test = test\n---\nexamples/account-public-access/main.tf\n@@ -1,21 +1,17 @@\n provider \"aws\" {\n- region = local.region\n+ region = var.region\n \n # Make it faster by skipping something\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n }\n \n-locals {\n- true\n region = \"eu-west-1\"\n-}\n-\n module \"account_public_access\" {\n source = \"../../modules/account-public-access\"\n \n block_public_acls = true\n block_public_policy = true\n ignore_public_acls = true\n- restrict_public_buckets = true\n+ restrict_public_buckets = var.restrict_public_buckets\n }\n---\nexamples/account-public-access/variables.tf\n@@ -0,0 +1,7 @@\n+variable \"region\" {\r\n+ default = \"us-east-1\"\r\n+}\r\n+\r\n+variable \"restrict_public_buckets\" {\r\n+ default = true\r\n+}\r\n---\nexamples/complete/main.tf\n@@ -9,7 +9,7 @@ provider \"aws\" {\n \n locals {\n bucket_name = \"s3-bucket-${random_pet.this.id}\"\n- region = \"eu-west-1\"\n+ region = \"us-west-2\"\n }\n \n data \"aws_caller_identity\" \"current\" {}\n---\n\n\n---\n\nChoice B:\nenvironments/dev/terraform.tfvars\n@@ -0,0 +1 @@\n+test = test\n---\nenvironments/dev/us-east-1/terraform.tfvars\n@@ -0,0 +1,2 @@\n+region = \"us-east-1\"\n+restrict_public_buckets = true\n---\nenvironments/dev/us-west-1/terraform.tfvars\n@@ -0,0 +1,2 @@\n+region = \"us-west-1\"\n+restrict_public_buckets = false\n---\nenvironments/prod/terraform.tfvars\n@@ -0,0 +1 @@\n+test = test\n---\nexamples/account-public-access/main.tf\n@@ -1,21 +1,17 @@\n provider \"aws\" {\n- region = local.region\n+ region = var.region\n \n # Make it faster by skipping something\n skip_metadata_api_check = true\n = skip_region_validation = true\n skip_credentials_validation = true\n }\n \n-locals {\n- region = \"eu-west-1\"\n-}\n-\n module \"account_public_access\" {\n source = \"../../modules/account-public-access\"\n \n block_public_acls = true\n block_public_policy = true\n ignore_public_acls = true\n- restrict_public_buckets = true\n+ restrict_public_buckets = var.restrict_public_buckets\n }\n---\nexamples/account-public-access/variables.tf\n@@ -0,0 +1,7 @@\n+variable \"region\" {\r\n+ default = \"us-east-1\"\r\n+}\r\n+\r\n+variable \"restrict_public_buckets\" {\r\n+ default = true\r\n+}\r\n---\nexamples/complete/main.tf\n@@ -9,7 +9,7 @@ provider \"aws\" {\n \n locals {\n bucket_name = \"s3-bucket-${random_pet.this.id}\"\n- region = \"eu-west-1\"\n+ region = \"us-west-2\"\n }\n \n data \"aws_caller_identity\" \"current\" {}\n---\n\n\n---\n\nChoice C:\nenvironments/dev/terraform.tfvars\n@@ true\r\n+}\r\n---\nexamples/complete/main.tf\n@@ +1 @@\n+test = test\n---\nenvironments/dev/us-east-1/terraform.tfvars\n@@ -0,0 +1,2 @@\n+region = \"us-east-1\"\n+restrict_public_buckets = true\n---\nenvironments/dev/us-west-1/terraform.tfvars\n@@ -0,0 +1,2 @@\n+region = \"us-west-1\"\n+restrict_public_buckets = false\n---\nenvironments/prod/terraform.tfvars\n@@ -0,0 +1 @@\n+test = test\n---\nexamples/account-public-access/main.tf\n@@ -1,21 +1,17 @@\n provider \"aws\" {\n- region = local.region\n+ region = var.region\n \n # Make it faster by skipping something\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n }\n \n-locals {\n- region = \"eu-west-1\"\n-}\n-\n module \"account_public_access\" {\n source = \"../../modules/account-public-access\"\n \n block_public_acls = true\n block_public_policy = true\n ignore_public_acls = true\n- restrict_public_buckets = true\n+ restrict_public_buckets = var.restrict_public_buckets\n }\n---\nexamples/account-public-access/variables.tf\n@@ -0,0 +1,7 @@\n+variable \"region\" {\r\n+ default = \"us-east-1\"\r\n+}\r\n+\r\n+variable \"restrict_public_buckets\" {\r\n+ default = true\r\n+}\r\n---\nexamples/complete/main.tf\n@@ -9,7 +9,7 @@ provider \"aws\" {\n \n locals {\n bucket_name = \"s3-bucket-${random_pet.this.id}\"\n- region = \"eu-west-1\"\n+ region = \"us-west-2\"\n }\n \n data \"aws_caller_identity\" \"current\" {}\n---\n\n\n---\n\nChoice D:\nenvironments/dev/terraform.tfvars\n@@ -0,0 +1 @@\n+test = test\n---\nenvironments/dev/us-east-1/terraform.tfvars\n@@ -0,0 +1,2 @@\n+region = \"us-east-1\"\n+restrict_public_buckets = true\n---\nenvironments/dev/us-west-1/terraform.tfvars\n@@ -0,0 +1,2 @@\n+region = \"us-west-1\"\n+restrict_public_buckets = false\n---\nenvironments/prod/terraform.tfvars\n@@ -0,0 +1 @@\n+test = test\n---\nexamples/account-public-access/main.tf\n@@ -1,21 +1,17 @@\n provider \"aws\" {\n- region = local.region\n+ region = var.region\n \n # Make it faster by skipping something\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n }\n \n-locals {\n- region = \"eu-west-1\"\n-}\n-\n module \"account_public_access\" {\n source = \"../../modules/account-public-access\"\n \n block_public_acls = true\n block_public_policy = true\n ignore_public_acls = true\n- restrict_public_buckets = true\n+ restrict_public_buckets = var.restrict_public_buckets\n }\n---\nexamples/account-public-access/variables.tf\n@@ -0,0 +1,7 @@\n+variable \"region\" {\r\n+ default = \"us-east-1\"\r\n+}\r\n+\r\n+variable \"restrict_public_buckets\" {\r\n+ default = true\r\n+}\r\n---\nexamples/complete/main.tf\n@@ -9,7 +9,7 @@ provider \"aws\" {\n \n locals {\n bucket_name = \"s3-bucket-${random_pet.this.id}\"\n- region = \"eu-west-1\"\n+ region = \"us-west-2\"\n }\n \n data \"aws_caller_identity\" \"current\" {}\n---\n\n\n---\n" } ]
D
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nAllows null values to be passed in the lifecycle configuration.\r\n\r\n## Motivation and Context\r\nFixes #308.\r\n\r\n## Breaking Changes\r\n\r\nNone detected\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmain.tf\n@@ -276,7 +276,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - expiration\n dynamic \"expiration\" {\n- for_each = try(flatten([rule.value.expiration]), [])\n+ for_each = try(compact(flatten([rule.value.expiration])), [])\n \n content {\n date = try(expiration.value.date, null)\n@@ -287,7 +287,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Several blocks - transition\n dynamic \"transition\" {\n- for_each = try(flatten([rule.value.transition]), [])\n+ for_each = try(compact(flatten([rule.value.transition])), [])\n \n content {\n date = try(transition.value.date, null)\n@@ -298,7 +298,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - noncurrent_version_expiration\n dynamic \"noncurrent_version_expiration\" {\n- for_each = try(flatten([rule.value.noncurrent_version_expiration]), [])\n+ for_each = try(compact(flatten([rule.value.noncurrent_version_expiration])), [])\n \n content {\n newer_noncurrent_versions = try(noncurrent_version_expiration.value.newer_noncurrent_versions, null)\n@@ -308,7 +308,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Several blocks - noncurrent_version_transition\n dynamic \"noncurrent_version_transition\" {\n- for_each = try(flatten([rule.value.noncurrent_version_transition]), [])\n+ for_each = try(compact(flatten([rule.value.noncurrent_version_transition])), [])\n \n content {\n newer_noncurrent_versions = try(noncurrent_version_transition.value.newer_noncurrent_versions, null)\n@@ -319,7 +319,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - filter - without any key arguments or tags\n dynamic \"filter\" {\n- for_each = length(try(flatten([rule.value.filter]), [])) == 0 ? [true] : []\n+ for_each = one(try(flatten([rule.value.filter]), [])) == null ? [true] : []\n \n content {\n # prefix = \"\"\n@@ -328,15 +328,15 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - filter - with one key argument or a single tag\n dynamic \"filter\" {\n- for_each = [for v in try(flatten([rule.value.filter]), []) : v if max(length(keys(v)), length(try(rule.value.filter.tags, rule.value.filter.tag, []))) == 1]\n+ for_each = [for v in try(rule.value.filter == null ? [] : flatten([rule.value.filter]), []) : v if max(length(keys(v)), try(length(rule.value.filter.tags), length(rule.value.filter.tag), 0)) == 1]\n \n content {\n object_size_greater_than = try(filter.value.object_size_greater_than, null)\n object_size_less_than = try(filter.value.object_size_less_than, null)\n prefix = try(filter.value.prefix, null)\n \n dynamic \"tag\" {\n- for_each = try(filter.value.tags, filter.value.tag, [])\n+ for_each = try(coalesce(filter.value.tags, {}), coalesce(filter.value.tag, {}), [])\n \n content {\n key = tag.key\n@@ -348,7 +348,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - filter - with more than one key arguments or multiple tags\n dynamic \"filter\" {\n- for_each = [for v in try(flatten([rule.value.filter]), []) : v if max(length(keys(v)), length(try(rule.value.filter.tags, rule.value.filter.tag, []))) > 1]\n+ for_each = [for v in try(rule.value.filter == null ? [] : flatten([rule.value.filter]), []) : v if max(length(keys(v)), try(length(rule.value.filter.tags), length(rule.value.filter.tag), 0)) > 1]\n \n content {\n and {\n---\n\n\n---\n\nChoice B:\nmain.tf\n@@ -276,7 +276,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - expiration\n dynamic \"expiration\" {\n- for_each = try(flatten([rule.value.expiration]), [])\n+ for_each = try(compact(flatten([rule.value.expiration])), [])\n \n content {\n date = try(expiration.value.date, null)\n@@ -287,7 +287,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Several dynamic - transition\n dynamic \"transition\" {\n- for_each = try(flatten([rule.value.transition]), [])\n+ for_each = try(compact(flatten([rule.value.transition])), [])\n \n content {\n date = try(transition.value.date, null)\n@@ -298,7 +298,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - noncurrent_version_expiration\n dynamic \"noncurrent_version_expiration\" {\n- for_each = try(flatten([rule.value.noncurrent_version_expiration]), [])\n+ for_each = try(compact(flatten([rule.value.noncurrent_version_expiration])), [])\n \n content {\n newer_noncurrent_versions = try(noncurrent_version_expiration.value.newer_noncurrent_versions, null)\n@@ -308,7 +308,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Several blocks - noncurrent_version_transition\n dynamic \"noncurrent_version_transition\" {\n- for_each = try(flatten([rule.value.noncurrent_version_transition]), [])\n+ for_each = try(compact(flatten([rule.value.noncurrent_version_transition])), [])\n \n content {\n newer_noncurrent_versions = try(noncurrent_version_transition.value.newer_noncurrent_versions, null)\n@@ -319,7 +319,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - filter - without any key arguments or tags\n dynamic \"filter\" {\n- for_each = length(try(flatten([rule.value.filter]), [])) == 0 ? [true] : []\n+ for_each = one(try(flatten([rule.value.filter]), [])) == null ? [true] : []\n \n content {\n # prefix = \"\"\n@@ -328,15 +328,15 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - filter - with one key argument or a single tag\n dynamic \"filter\" {\n- for_each = [for v in try(flatten([rule.value.filter]), []) : v if max(length(keys(v)), length(try(rule.value.filter.tags, rule.value.filter.tag, []))) == 1]\n+ for_each = [for v in try(rule.value.filter == null ? [] : flatten([rule.value.filter]), []) : v if max(length(keys(v)), try(length(rule.value.filter.tags), length(rule.value.filter.tag), 0)) == 1]\n \n content {\n object_size_greater_than = try(filter.value.object_size_greater_than, null)\n object_size_less_than = try(filter.value.object_size_less_than, null)\n prefix = try(filter.value.prefix, null)\n \n dynamic \"tag\" {\n- for_each = try(filter.value.tags, filter.value.tag, [])\n+ for_each = try(coalesce(filter.value.tags, {}), coalesce(filter.value.tag, {}), [])\n \n content {\n key = tag.key\n@@ -348,7 +348,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - filter - with more than one key arguments or multiple tags\n dynamic \"filter\" {\n- for_each = [for v in try(flatten([rule.value.filter]), []) : v if max(length(keys(v)), length(try(rule.value.filter.tags, rule.value.filter.tag, []))) > 1]\n+ for_each = [for v in try(rule.value.filter == null ? [] : flatten([rule.value.filter]), []) : v if max(length(keys(v)), try(length(rule.value.filter.tags), length(rule.value.filter.tag), 0)) > 1]\n \n content {\n and {\n---\n\n\n---\n\nChoice C:\nmain.tf\n@@ -276,7 +276,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - expiration\n dynamic \"expiration\" {\n- for_each = try(flatten([rule.value.expiration]), [])\n+ for_each = try(compact(flatten([rule.value.expiration])), [])\n \n content {\n date = try(expiration.value.date, null)\n@@ -287,7 +287,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Several blocks - transition\n dynamic \"transition\" {\n- for_each = try(flatten([rule.value.transition]), [])\n+ for_each = try(compact(flatten([rule.value.transition])), [])\n \n content {\n date = try(transition.value.date, null)\n@@ -298,7 +298,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - noncurrent_version_expiration\n dynamic \"noncurrent_version_expiration\" {\n- for_each = try(flatten([rule.value.noncurrent_version_expiration]), [])\n+ for_each = try(compact(flatten([rule.value.noncurrent_version_expiration])), [])\n \n content {\n newer_noncurrent_versions = try(noncurrent_version_expiration.value.newer_noncurrent_versions, null)\n@@ -308,7 +308,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Several blocks - noncurrent_version_transition\n dynamic \"noncurrent_version_transition\" {\n- for_each = try(flatten([rule.value.noncurrent_version_transition]), [])\n+ for_each = try(compact(flatten([rule.value.noncurrent_version_transition])), [])\n \n content {\n newer_noncurrent_versions = try(noncurrent_version_transition.value.newer_noncurrent_versions, null)\n@@ -319,7 +319,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - filter - without any key arguments or tags\n dynamic \"filter\" {\n- for_each = length(try(flatten([rule.value.filter]), [])) == 0 ? [true] : []\n+ for_each = [] [])) == null ? [true] : []\n \n content {\n # prefix = \"\"\n@@ -328,15 +328,15 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - filter - with one key argument or a single tag\n dynamic \"filter\" {\n- for_each = [for v in try(flatten([rule.value.filter]), []) : v if max(length(keys(v)), length(try(rule.value.filter.tags, rule.value.filter.tag, []))) == 1]\n+ for_each = [for v in try(rule.value.filter == null ? [] : flatten([rule.value.filter]), []) : v if max(length(keys(v)), try(length(rule.value.filter.tags), length(rule.value.filter.tag), 0)) == 1]\n \n content {\n object_size_greater_than = try(filter.value.object_size_greater_than, null)\n object_size_less_than = try(filter.value.object_size_less_than, null)\n prefix = try(filter.value.prefix, null)\n \n dynamic \"tag\" {\n- for_each = try(filter.value.tags, filter.value.tag, [])\n+ for_each = try(coalesce(filter.value.tags, {}), coalesce(filter.value.tag, {}), [])\n \n content {\n key = tag.key\n@@ -348,7 +348,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - filter - with more than one key arguments or multiple tags\n dynamic \"filter\" {\n- for_each = [for v in try(flatten([rule.value.filter]), []) : v if max(length(keys(v)), length(try(rule.value.filter.tags, rule.value.filter.tag, []))) > 1]\n+ for_each = [for v in try(rule.value.filter == null ? [] : flatten([rule.value.filter]), []) : v if max(length(keys(v)), try(length(rule.value.filter.tags), length(rule.value.filter.tag), 0)) > 1]\n \n content {\n and {\n---\n\n\n---\n\nChoice D:\nmain.tf\n@@ -276,7 +276,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - expiration\n dynamic \"expiration\" {\n- for_each = try(flatten([rule.value.expiration]), [])\n+ for_each = try(compact(flatten([rule.value.expiration])), [])\n \n content {\n date = try(expiration.value.date, null)\n@@ -287,7 +287,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Several blocks - transition\n dynamic \"transition\" {\n- for_each = try(flatten([rule.value.transition]), [])\n+ for_each = try(compact(flatten([rule.value.transition])), [])\n \n content {\n date = try(transition.value.date, null)\n@@ -298,7 +298,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - noncurrent_version_expiration\n dynamic \"noncurrent_version_expiration\" {\n- for_each = try(flatten([rule.value.noncurrent_version_expiration]), [])\n+ for_each = try(compact(flatten([rule.value.noncurrent_version_expiration])), [])\n \n content {\n newer_noncurrent_versions = try(noncurrent_version_expiration.value.newer_noncurrent_versions, null)\n@@ -308,7 +308,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Several blocks - noncurrent_version_transition\n dynamic \"noncurrent_version_transition\" {\n- for_each = try(flatten([rule.value.noncurrent_version_transition]), [])\n+ for_each = try(compact(flatten([rule.value.noncurrent_version_transition])), [])\n \n content {\n newer_noncurrent_versions = try(noncurrent_version_transition.value.newer_noncurrent_versions, null)\n@@ -319,7 +319,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - filter - without any key arguments or tags\n dynamic \"filter\" {\n- for_each = length(try(flatten([rule.value.filter]), [])) == 0 ? [true] : []\n+ for_each = one(try(flatten([rule.value.filter]), [])) == null ? [true] : []\n \n content {\n # prefix = \"\"\n@@ -328,15 +328,15 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - filter - with one key argument or a single tag\n dynamic \"filter\" {\n- for_each = [for v in try(flatten([rule.value.filter]), []) : v if max(length(keys(v)), length(try(rule.value.filter.tags, rule.value.filter.tag, []))) == 1]\n+ for_each = [for v in try(rule.value.filter == null ? [] : flatten([rule.value.filter]), []) : v if max(length(keys(v)), try(length(rule.value.filter.tags), length(rule.value.filter.tag), 0)) == 1]\n \n content {\n object_size_greater_than = try(filter.value.object_size_greater_than, null)\n object_size_less_than = try(filter.value.object_size_less_than, null)\n prefix = try(filter.value.prefix, null)\n \n dynamic \"tag\" {\n- for_each = try(filter.value.tags, filter.value.tag, [])\n+ for_each = try(coalesce(filter.value.tags, {}), coalesce(filter.value.tag, {}), [])\n \n content {\n key = tag.key\n@@ -348,7 +348,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - filter - with more than one key arguments or multiple tags\n dynamic \"filter\" {\n- for_each = [for v in try(flatten([rule.value.filter]), []) : v if max(length(keys(v)), length(try(rule.value.filter.tags, rule.value.filter.tag, []))) > 1]\n+ for_each = [for v in try(rule.value.filter == null ? [] : flatten([rule.value.filter]), []) : v if max(length(keys(v)), try(length(rule.value.filter.tags), length(rule.value.filter.tag), 0)) > 1]\n \n content {\n and {\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nI have added a simple validation for **_lifecycle_rule_** that ensures correct configuration is passed to the module.\r\n\r\n## Motivation and Context\r\nIn my company, we experienced that passing an incorrect map doesn't break the plan & apply pipelines but it also doesn't actually apply the required change. The main reason for this change is also that the configuration in this module is slightly different than what is explained on [aws_s3_bucket_lifecycle_configuration](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) which users usually confuse with.\r\n\r\n## Breaking Changes\r\nIt is backwards compatible according to the tests I performed.\r\n\r\n## How Has This Been Tested?\r\n- [*] I have updated at least one of the `examples/*` to demonstrate and validate my change(s) \r\n**_There already are examples._**\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n**_I have also tested using terraform tests and a private project_**\r\n- [x] I have executed `pre-commit run -a` on my pull request\n\n---\n\nChoice A:\n.pre-commit-config.yaml\n@@ -3,6 +3,8 @@ repos:\n rev: v1.96.1\n hooks:\n - id: terraform_fmt\n+ args:\n+ - --args=-recursive\n - id: terraform_wrapper_module_for_each\n - id: terraform_docs\n args:\n---\nREADME.md\n@@ -221,7 +221,7 @@ No modules.\n | <a name=\"input_inventory_self_source_destination\"></a> [inventory\\_self\\_source\\_destination](#input\\_inventory\\_self\\_source\\_destination) | Whether or not the inventory source bucket is also the destination bucket. | `bool` | `false` | no |\n | <a name=\"input_inventory_source_account_id\"></a> [inventory\\_source\\_account\\_id](#input\\_inventory\\_source\\_account\\_id) | The inventory source account id. | `string` | `null` | no |\n | <a name=\"input_inventory_source_bucket_arn\"></a> [inventory\\_source\\_bucket\\_arn](#input\\_inventory\\_source\\_bucket\\_arn) | The inventory source bucket ARN. | `string` | `null` | no |\n-| <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n+| <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. Each lifecycle rule must contain 'id' and either 'enabled' or 'status', and may contain: 'filter', 'abort\\_incomplete\\_multipart\\_upload\\_days', 'expiration', 'transition', 'noncurrent\\_version\\_expiration', or 'noncurrent\\_version\\_transition'. | `any` | `[]` | no |\n | name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `any` | `{}` | no |\n | <a name=\"input_metric_configuration\"></a> [metric\\_configuration](#input\\_metric\\_configuration) | Map containing bucket metric configuration. | `any` | `[]` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n---\ntests/test_lifecycle_rules.tftest.hcl\n@@ -0,0 +1,151 @@\n+# Default AWS provider configuration\n+mock_provider \"aws\" {\n+}\n+\n+# Default required test variables\n+variables {\n+ bucket_name = \"test-bucket\"\n+ kms_key_arn = \"arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012\"\n+ readonly_iam_role_arns = []\n+ readwrite_iam_role_arns = []\n+ backup_enabled = false\n+}\n+\n+# Test 1\n+run \"verify_valid_lifecycle_rules\" {\n+ command = plan\n+\n+ variables {\n+ lifecycle_rules = [\n+ {\n+ id = \"log\"\n+ enabled = true\n+ filter = {\n+ tags = {\n+ some = \"value\"\n+ another = \"value2\"\n+ }\n+ }\n+ transition = [\n+ {\n+ days = 30\n+ storage_class = \"ONEZONE_IA\"\n+ },\n+ {\n+ days = 60\n+ storage_class = \"GLACIER\"\n+ }\n+ ]\n+ },\n+ {\n+ id = \"log1\"\n+ enabled = true\n+ abort_incomplete_multipart_upload_days = 7\n+ noncurrent_version_transition = [\n+ {\n+ days = 30\n+ storage_class = \"STANDARD_IA\"\n+ }\n+ ]\n+ noncurrent_version_expiration = {\n+ days = 300\n+ }\n+ },\n+ {\n+ id = \"expire_all_objects\"\n+ status = \"Enabled\"\n+ expiration = {\n+ days = 7\n+ }\n+ noncurrent_version_expiration = {\n+ noncurrent_days = 3\n+ }\n+ abort_incomplete_multipart_upload_days = 1\n+ }\n+ ]\n+ }\n+\n+ assert {\n+ condition = length(var.lifecycle_rules) == 3\n+ error_message = \"Expected 3 lifecycle rules\"\n+ }\n+\n+ assert {\n+ condition = alltrue([\n+ for rule in var.lifecycle_rules : contains(keys(rule), \"id\")\n+ ])\n+ error_message = \"All rules must have an id\"\n+ }\n+\n+ assert {\n+ condition = alltrue([\n+ for rule in var.lifecycle_rules :\n+ anytrue([contains(keys(rule), \"enabled\"), contains(keys(rule), \"status\")])\n+ ])\n+ error_message = \"All rules must have either enabled or status field\"\n+ }\n+\n+ assert {\n+ condition = alltrue([\n+ for rule in var.lifecycle_rules :\n+ anytrue([\n+ !contains(keys(rule), \"abort_incomplete_multipart_upload_days\"),\n+ can(tonumber(rule.abort_incomplete_multipart_upload_days))\n+ ])\n+ ])\n+ error_message = \"abort_incomplete_multipart_upload_days must be a number\"\n+ }\n+}\n+\n+# Test 2\n+run \"fail_invalid_lifecycle_rules\" {\n+ command = plan\n+\n+ variables {\n+ lifecycle_rules = [\n+ {\n+ id = \"log1\"\n+ enabled = true\n+ abort_incomplete_multipart_upload = {\n+ days_after_initiation = \"1\"\n+ }\n+ noncurrent_version_transition = [\n+ {\n+ days = 30\n+ storage_class = \"STANDARD_IA\"\n+ }\n+ ]\n+ noncurrent_version_expiration = {\n+ days = 300\n+ }\n+ }\n+ ]\n+ }\n+\n+ expect_failures = [\n+ var.lifecycle_rules\n+ ]\n+\n+ assert {\n+ condition = !alltrue([\n+ for rule in var.lifecycle_rules : (\n+ contains(keys(rule), \"id\") &&\n+ (contains(keys(rule), \"enabled\") || contains(keys(rule), \"status\")) &&\n+ alltrue([\n+ for key in keys(rule) : contains([\n+ \"id\",\n+ \"enabled\",\n+ \"status\",\n+ \"filter\",\n+ \"abort_incomplete_multipart_upload_days\",\n+ \"expiration\",\n+ \"transition\",\n+ \"noncurrent_version_expiration\",\n+ \"noncurrent_version_transition\"\n+ ], key)\n+ ])\n+ )\n+ ])\n+ error_message = \"Each lifecycle rule must contain 'id' and either 'enabled' or 'status', and may contain: 'filter', 'abort_incomplete_multipart_upload_days', 'expiration', 'transition', 'noncurrent_version_expiration', or 'noncurrent_version_transition'.\"\n+ }\n+}\n---\nvariables.tf\n@@ -191,9 +191,32 @@ variable \"transition_default_minimum_object_size\" {\n }\n \n variable \"lifecycle_rule\" {\n- description = \"List of maps containing configuration of object lifecycle management.\"\n+ description = \"List of maps containing configuration of object lifecycle management. Each lifecycle rule must contain 'id' and either 'enabled' or 'status', and may contain: 'filter', 'abort_incomplete_multipart_upload_days', 'expiration', 'transition', 'noncurrent_version_expiration', or 'noncurrent_version_transition'.\"\n type = any\n default = []\n+\n+ validation {\n+ condition = alltrue([\n+ for rule in var.lifecycle_rule : (\n+ contains(keys(rule), \"id\") &&\n+ (contains(keys(rule), \"enabled\") || contains(keys(rule), \"status\")) &&\n+ alltrue([\n+ for key in keys(rule) : contains([\n+ \"id\",\n+ \"enabled\",\n+ \"status\",\n+ \"filter\",\n+ \"abort_incomplete_multipart_upload_days\",\n+ \"expiration\",\n+ \"transition\",\n+ \"noncurrent_version_expiration\",\n+ \"noncurrent_version_transition\"\n+ ], key)\n+ ])\n+ )\n+ ])\n+ error_message = \"Each lifecycle rule must contain 'id' and either 'enabled' or 'status', and may contain: 'filter', 'abort_incomplete_multipart_upload_days', 'expiration', 'transition', 'noncurrent_version_expiration', or 'noncurrent_version_transition'.\"\n+ }\n }\n \n variable \"replication_configuration\" {\n---\n\n\n---\n\nChoice B:\n.pre-commit-config.yaml\n@@ -3,6 +3,8 @@ repos:\n rev: v1.96.1\n hooks:\n - id: terraform_fmt\n+ args:\n+ - --args=-recursive\n - id: terraform_wrapper_module_for_each\n - id: terraform_docs\n args:\n---\nREADME.md\n@@ -221,7 +221,7 @@ No modules.\n | <a name=\"input_inventory_self_source_destination\"></a> [inventory\\_self\\_source\\_destination](#input\\_inventory\\_self\\_source\\_destination) | Whether or not the inventory source bucket is also the destination bucket. | `bool` | `false` | no |\n | <a name=\"input_inventory_source_account_id\"></a> [inventory\\_source\\_account\\_id](#input\\_inventory\\_source\\_account\\_id) | The inventory source account id. | `string` | `null` | no |\n | <a name=\"input_inventory_source_bucket_arn\"></a> [inventory\\_source\\_bucket\\_arn](#input\\_inventory\\_source\\_bucket\\_arn) | The inventory source bucket ARN. | `string` | `null` | no |\n-| <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n+| <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. Each lifecycle rule must contain 'id' and either 'enabled' or 'status', and may contain: 'filter', 'abort\\_incomplete\\_multipart\\_upload\\_days', 'expiration', 'transition', 'noncurrent\\_version\\_expiration', or 'noncurrent\\_version\\_transition'. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `any` | `{}` | no |\n | <a name=\"input_metric_configuration\"></a> [metric\\_configuration](#input\\_metric\\_configuration) | Map containing bucket metric configuration. | `any` | `[]` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n---\ntests/test_lifecycle_rules.tftest.hcl\n@@ -0,0 +1,151 @@\n+# Default AWS provider configuration\n+mock_provider \"aws\" {\n+}\n+\n+# Default required test variables\n+variables {\n+ bucket_name = \"test-bucket\"\n+ kms_key_arn = \"arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012\"\n+ readonly_iam_role_arns = []\n+ readwrite_iam_role_arns = []\n+ backup_enabled = false\n+}\n+\n+# Test 1\n+run \"verify_valid_lifecycle_rules\" {\n+ command = plan\n+\n+ variables {\n+ lifecycle_rules = [\n+ {\n+ id = \"log\"\n+ enabled = true\n+ filter = {\n+ tags = {\n+ some = \"value\"\n+ another = \"value2\"\n+ }\n+ }\n+ transition = [\n+ {\n+ days = 30\n+ storage_class = \"ONEZONE_IA\"\n+ },\n+ {\n+ days = 60\n+ storage_class = \"GLACIER\"\n+ }\n+ ]\n+ },\n+ {\n+ id = \"log1\"\n+ enabled = true\n+ abort_incomplete_multipart_upload_days = 7\n+ noncurrent_version_transition = [\n+ {\n+ days = 30\n+ storage_class = \"STANDARD_IA\"\n+ }\n+ ]\n+ noncurrent_version_expiration = {\n+ days = 300\n+ }\n+ },\n+ {\n+ id = \"expire_all_objects\"\n+ status = \"Enabled\"\n+ expiration = {\n+ days = 7\n+ }\n+ noncurrent_version_expiration = {\n+ noncurrent_days = 3\n+ }\n+ abort_incomplete_multipart_upload_days = 1\n+ }\n+ ]\n+ }\n+\n+ assert {\n+ condition = length(var.lifecycle_rules) == 3\n+ error_message = \"Expected 3 lifecycle rules\"\n+ }\n+\n+ assert {\n+ condition = alltrue([\n+ for rule in var.lifecycle_rules : contains(keys(rule), \"id\")\n+ ])\n+ error_message = \"All rules must have an id\"\n+ }\n+\n+ assert {\n+ condition = alltrue([\n+ for rule in var.lifecycle_rules :\n+ anytrue([contains(keys(rule), \"enabled\"), contains(keys(rule), \"status\")])\n+ ])\n+ error_message = \"All rules must have either enabled or status field\"\n+ }\n+\n+ assert {\n+ condition = alltrue([\n+ for rule in var.lifecycle_rules :\n+ anytrue([\n+ !contains(keys(rule), \"abort_incomplete_multipart_upload_days\"),\n+ can(tonumber(rule.abort_incomplete_multipart_upload_days))\n+ ])\n+ ])\n+ error_message = \"abort_incomplete_multipart_upload_days must be a number\"\n+ }\n+}\n+\n+# Test 2\n+run \"fail_invalid_lifecycle_rules\" {\n+ command = plan\n+\n+ variables {\n+ lifecycle_rules = [\n+ {\n+ id = \"log1\"\n+ enabled = true\n+ abort_incomplete_multipart_upload = {\n+ days_after_initiation = \"1\"\n+ }\n+ noncurrent_version_transition = [\n+ {\n+ days = 30\n+ storage_class = \"STANDARD_IA\"\n+ }\n+ ]\n+ noncurrent_version_expiration = {\n+ days = 300\n+ }\n+ }\n+ ]\n+ }\n+\n+ expect_failures = [\n+ var.lifecycle_rules\n+ ]\n+\n+ assert {\n+ condition = !alltrue([\n+ for rule in var.lifecycle_rules : (\n+ contains(keys(rule), \"id\") &&\n+ (contains(keys(rule), \"enabled\") || contains(keys(rule), \"status\")) &&\n+ alltrue([\n+ for key in keys(rule) : contains([\n+ \"id\",\n+ \"enabled\",\n+ \"status\",\n+ \"filter\",\n+ \"abort_incomplete_multipart_upload_days\",\n+ \"expiration\",\n+ \"transition\",\n+ \"noncurrent_version_expiration\",\n+ \"noncurrent_version_transition\"\n+ ], key)\n+ ])\n+ )\n+ ])\n+ error_message = \"Each lifecycle rule must contain 'id' and either 'enabled' or 'status', and may contain: 'filter', 'abort_incomplete_multipart_upload_days', 'expiration', 'transition', 'noncurrent_version_expiration', or 'noncurrent_version_transition'.\"\n+ }\n+}\n---\nvariables.tf\n@@ -191,9 +191,32 @@ variable \"transition_default_minimum_object_size\" {\n }\n \n variable \"lifecycle_rule\" {\n- description = \"List of maps containing configuration of object lifecycle management.\"\n+ description = \"List of maps containing configuration of object lifecycle management. Each lifecycle rule must contain 'id' and either 'enabled' or 'status', and may contain: 'filter', 'abort_incomplete_multipart_upload_days', 'expiration', 'transition', 'noncurrent_version_expiration', or 'noncurrent_version_transition'.\"\n type = any\n default = []\n+\n+ validation {\n+ condition = alltrue([\n+ for rule in var.lifecycle_rule : (\n+ contains(keys(rule), \"id\") &&\n+ (contains(keys(rule), \"enabled\") || contains(keys(rule), \"status\")) &&\n+ alltrue([\n+ for key in keys(rule) : contains([\n+ \"id\",\n+ \"enabled\",\n+ \"status\",\n+ \"filter\",\n+ \"abort_incomplete_multipart_upload_days\",\n+ \"expiration\",\n+ \"transition\",\n+ \"noncurrent_version_expiration\",\n+ \"noncurrent_version_transition\"\n+ ], key)\n+ ])\n+ )\n+ ])\n+ error_message = \"Each lifecycle rule must contain 'id' and either 'enabled' or 'status', and may contain: 'filter', 'abort_incomplete_multipart_upload_days', 'expiration', 'transition', 'noncurrent_version_expiration', or 'noncurrent_version_transition'.\"\n+ }\n }\n \n variable \"replication_configuration\" {\n---\n\n\n---\n\nChoice C:\n.pre-commit-config.yaml\n@@ -3,6 +3,8 @@ repos:\n rev: v1.96.1\n hooks:\n - id: terraform_fmt\n+ args:\n+ - --args=-recursive\n - id: terraform_wrapper_module_for_each\n - id: terraform_docs\n args:\n---\nREADME.md\n@@ -221,7 +221,7 @@ No modules.\n | <a name=\"input_inventory_self_source_destination\"></a> [inventory\\_self\\_source\\_destination](#input\\_inventory\\_self\\_source\\_destination) | Whether or not the inventory source bucket is also the destination bucket. | `bool` | `false` | no |\n | <a name=\"input_inventory_source_account_id\"></a> [inventory\\_source\\_account\\_id](#input\\_inventory\\_source\\_account\\_id) | The inventory source account id. | `string` | `null` | no |\n | <a name=\"input_inventory_source_bucket_arn\"></a> [inventory\\_source\\_bucket\\_arn](#input\\_inventory\\_source\\_bucket\\_arn) | The inventory source bucket ARN. | `string` | `null` | no |\n-| <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n+| <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. Each lifecycle rule must contain 'id' and either 'enabled' or 'status', and may contain: 'filter', 'abort\\_incomplete\\_multipart\\_upload\\_days', 'expiration', 'transition', 'noncurrent\\_version\\_expiration', or 'noncurrent\\_version\\_transition'. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `any` | `{}` | no |\n | <a name=\"input_metric_configuration\"></a> [metric\\_configuration](#input\\_metric\\_configuration) | Map containing bucket metric configuration. | `any` | `[]` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n---\ntests/test_lifecycle_rules.tftest.hcl\n@@ -0,0 +1,151 @@\n+# Default AWS provider configuration\n+mock_provider \"aws\" {\n+}\n+\n+# Default required test variables\n+variables {\n+ bucket_name = \"test-bucket\"\n+ kms_key_arn = \"arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012\"\n+ readonly_iam_role_arns = []\n+ readwrite_iam_role_arns = []\n+ backup_enabled = false\n+}\n+\n+# Test 1\n+run \"verify_valid_lifecycle_rules\" {\n+ command = plan\n+\n+ variables {\n+ lifecycle_rules = [\n+ {\n+ id = \"log\"\n+ enabled = true\n+ filter = {\n+ tags = {\n+ some = \"value\"\n+ another = \"value2\"\n+ }\n+ }\n+ transition = [\n+ {\n+ days = 30\n+ storage_class = \"ONEZONE_IA\"\n+ },\n+ {\n+ days = 60\n+ storage_class = \"GLACIER\"\n+ }\n+ ]\n+ },\n+ {\n+ id = \"log1\"\n+ enabled = true\n+ abort_incomplete_multipart_upload_days = 7\n+ noncurrent_version_transition = [\n+ {\n+ days = 30\n+ storage_class = \"STANDARD_IA\"\n+ }\n+ ]\n+ noncurrent_version_expiration = {\n+ days = 300\n+ }\n+ },\n+ {\n+ id = \"expire_all_objects\"\n+ status = \"Enabled\"\n+ expiration = {\n+ days = 7\n+ }\n+ noncurrent_version_expiration = {\n+ noncurrent_days = 3\n+ }\n+ abort_incomplete_multipart_upload_days = 1\n+ }\n+ ]\n+ }\n+\n+ assert {\n+ condition = length(var.lifecycle_rules) == 3\n+ error_message = \"Expected 3 lifecycle rules\"\n+ }\n+\n+ assert {\n+ condition = alltrue([\n+ for rule in var.lifecycle_rules : contains(keys(rule), \"id\")\n+ ])\n+ error_message = \"All rules must have an id\"\n+ }\n+\n+ assert {\n+ condition = alltrue([\n+ for rule in var.lifecycle_rules :\n+ anytrue([contains(keys(rule), \"enabled\"), contains(keys(rule), \"status\")])\n+ ])\n+ error_message = \"All rules must have either enabled or status field\"\n+ }\n+\n+ assert {\n+ condition = alltrue([\n+ for rule in var.lifecycle_rules :\n+ anytrue([\n+ !contains(keys(rule), \"abort_incomplete_multipart_upload_days\"),\n+ can(tonumber(rule.abort_incomplete_multipart_upload_days))\n+ ])\n+ ])\n+ error_message = \"abort_incomplete_multipart_upload_days must be a number\"\n+ }\n+}\n+\n+# Test 2\n+run \"fail_invalid_lifecycle_rules\" {\n+ command = plan\n+\n+ variables {\n+ lifecycle_rules = [\n+ {\n+ id = \"log1\"\n+ enabled = true\n+ abort_incomplete_multipart_upload = {\n+ days_after_initiation = \"1\"\n+ }\n+ noncurrent_version_transition = [\n+ {\n+ days = 30\n+ storage_class = \"STANDARD_IA\"\n+ }\n+ ]\n+ noncurrent_version_expiration = {\n+ days = 300\n+ }\n+ }\n+ ]\n+ }\n+\n+ expect_failures = [\n+ var.lifecycle_rules\n+ ]\n+\n+ assert {\n+ condition = !alltrue([\n+ for rule in var.lifecycle_rules : (\n+ contains(keys(rule), \"id\") &&\n+ (contains(keys(rule), \"enabled\") || contains(keys(rule), \"status\")) &&\n+ alltrue([\n+ for key in keys(rule) : contains([\n+ \"id\",\n+ \"enabled\",\n+ \"status\",\n+ \"filter\",\n+ \"abort_incomplete_multipart_upload_days\",\n+ \"expiration\",\n+ \"transition\",\n+ \"noncurrent_version_expiration\",\n+ \"noncurrent_version_transition\"\n+ ], key)\n+ ])\n+ )\n+ ])\n+ error_message = \"Each lifecycle rule must contain 'id' and either 'enabled' or 'status', and may contain: 'filter', 'abort_incomplete_multipart_upload_days', 'expiration', 'transition', 'noncurrent_version_expiration', or 'noncurrent_version_transition'.\"\n+ }\n+}\n---\nvariables.tf\n@@ -191,9 +191,32 @@ variable \"transition_default_minimum_object_size\" {\n }\n \n variable \"lifecycle_rule\" {\n- description = \"List of maps containing configuration of object lifecycle management.\"\n+ description = \"List of maps containing configuration of object lifecycle management. Each lifecycle rule must contain 'id' and either 'enabled' or 'status', and may contain: 'filter', 'abort_incomplete_multipart_upload_days', 'expiration', 'transition', 'noncurrent_version_expiration', or 'noncurrent_version_transition'.\"\n type = any\n default = []\n+\n+ validation {\n+ condition = alltrue([\n+ for rule in var.lifecycle_rule : (\n+ contains(keys(rule), \"id\") &&\n+ (contains(keys(rule), \"enabled\") || contains(keys(rule), \"status\")) &&\n+ alltrue([\n+ for key in keys(rule) : contains([\n+ \"id\",\n+ \"enabled\",\n+ \"status\",\n+ \"filter\",\n+ \"abort_incomplete_multipart_upload_days\",\n+ \"expiration\",\n+ \"transition\",\n+ \"noncurrent_version_expiration\",\n+ \"noncurrent_version_transition\"\n+ ], key)\n+ ])\n+ )\n+ ])\n+ error_message = \"Each lifecycle rule must contain 'id' and either 'enabled' or 'status', and may contain: 'filter', 'abort_incomplete_multipart_upload_days', 'expiration', 'transition', 'noncurrent_version_expiration', or 'noncurrent_version_transition'.\"\n+ }\n }\n \n variable \"replication_configuration\" {\n---\n\n\n---\n\nChoice D:\n.pre-commit-config.yaml\n@@ -3,6 +3,8 @@ repos:\n rev: v1.96.1\n hooks:\n - id: terraform_fmt\n+ args:\n+ - --args=-recursive\n - id: terraform_wrapper_module_for_each\n - id: terraform_docs\n args:\n---\nREADME.md\n@@ -221,7 +221,7 @@ No modules.\n | <a name=\"input_inventory_self_source_destination\"></a> [inventory\\_self\\_source\\_destination](#input\\_inventory\\_self\\_source\\_destination) | Whether or not the inventory source bucket is also the destination bucket. | `bool` | `false` | no |\n | <a name=\"input_inventory_source_account_id\"></a> [inventory\\_source\\_account\\_id](#input\\_inventory\\_source\\_account\\_id) | The inventory source account id. | `string` | `null` | no |\n | <a name=\"input_inventory_source_bucket_arn\"></a> [inventory\\_source\\_bucket\\_arn](#input\\_inventory\\_source\\_bucket\\_arn) | The inventory source bucket ARN. | `string` | `null` | no |\n-| <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n+| <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. Each lifecycle rule must contain 'id' and either 'enabled' or 'status', and may contain: 'filter', 'abort\\_incomplete\\_multipart\\_upload\\_days', 'expiration', 'transition', 'noncurrent\\_version\\_expiration', or 'noncurrent\\_version\\_transition'. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `any` | `{}` | no |\n | <a name=\"input_metric_configuration\"></a> [metric\\_configuration](#input\\_metric\\_configuration) | Map containing bucket metric configuration. | `any` | `[]` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n---\ntests/test_lifecycle_rules.tftest.hcl\n@@ -0,0 +1,151 @@\n+# Default AWS provider configuration\n+mock_provider \"aws\" {\n+}\n+\n+# Default required test variables\n+variables {\n+ bucket_name = \"test-bucket\"\n+ kms_key_arn = \"arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012\"\n+ readonly_iam_role_arns = []\n+ readwrite_iam_role_arns = []\n+ backup_enabled = false\n+}\n+\n+# Test 1\n+run \"verify_valid_lifecycle_rules\" {\n+ command = plan\n+\n+ variables {\n+ lifecycle_rules = [\n+ {\n+ id = \"log\"\n+ enabled = true\n+ filter = {\n+ tags = {\n+ some = \"value\"\n+ another = \"value2\"\n+ }\n+ }\n+ transition = [\n+ {\n+ days = 30\n+ storage_class = \"ONEZONE_IA\"\n+ },\n+ {\n+ days = 60\n+ storage_class = \"GLACIER\"\n+ }\n+ ]\n+ },\n+ {\n+ id = \"log1\"\n+ enabled = true\n+ abort_incomplete_multipart_upload_days = 7\n+ noncurrent_version_transition = [\n+ {\n+ days = 30\n+ storage_class = \"STANDARD_IA\"\n+ }\n+ ]\n+ noncurrent_version_expiration = {\n+ days = 300\n+ }\n+ },\n+ {\n+ id = \"expire_all_objects\"\n+ status = \"Enabled\"\n+ expiration = {\n+ days = 7\n+ }\n+ noncurrent_version_expiration = {\n+ noncurrent_days = 3\n+ }\n+ abort_incomplete_multipart_upload_days = 1\n+ }\n+ ]\n+ }\n+\n+ assert {\n+ condition = length(var.lifecycle_rules) == 3\n+ error_message = \"Expected 3 lifecycle rules\"\n+ }\n+\n+ assert {\n+ condition = alltrue([\n+ for rule in var.lifecycle_rules : contains(keys(rule), \"id\")\n+ ])\n+ error_message = \"All rules must have an id\"\n+ }\n+\n+ assert {\n+ condition = alltrue([\n+ for rule in var.lifecycle_rules :\n+ anytrue([contains(keys(rule), \"enabled\"), contains(keys(rule), \"status\")])\n+ ])\n+ error_message = \"All rules must have either enabled or status field\"\n+ }\n+\n+ assert {\n+ condition = alltrue([\n+ for rule in var.lifecycle_rules :\n+ anytrue([\n+ !contains(keys(rule), \"abort_incomplete_multipart_upload_days\"),\n+ can(tonumber(rule.abort_incomplete_multipart_upload_days))\n+ ])\n+ ])\n+ error_message = \"abort_incomplete_multipart_upload_days must be a number\"\n+ }\n+}\n+\n+# Test 2\n+run \"fail_invalid_lifecycle_rules\" {\n+ command = plan\n+\n+ variables {\n+ lifecycle_rules = [\n+ {\n+ id = \"log1\"\n+ enabled = true\n+ abort_incomplete_multipart_upload = {\n+ days_after_initiation = \"1\"\n+ }\n+ noncurrent_version_transition = [\n+ {\n+ days = 30\n+ storage_class = \"STANDARD_IA\"\n+ }\n+ ]\n+ noncurrent_version_expiration = {\n+ days = 300\n+ }\n+ }\n+ ]\n+ }\n+\n+ expect_failures = [\n+ var.lifecycle_rules\n+ ]\n+\n+ assert {\n+ condition = !alltrue([\n+ for rule {\n+ var.lifecycle_rules : (\n+ contains(keys(rule), \"id\") &&\n+ (contains(keys(rule), \"enabled\") || contains(keys(rule), \"status\")) &&\n+ alltrue([\n+ for key in keys(rule) : contains([\n+ \"id\",\n+ \"enabled\",\n+ \"status\",\n+ \"filter\",\n+ \"abort_incomplete_multipart_upload_days\",\n+ \"expiration\",\n+ \"transition\",\n+ \"noncurrent_version_expiration\",\n+ \"noncurrent_version_transition\"\n+ ], key)\n+ ])\n+ )\n+ ])\n+ error_message = \"Each lifecycle rule must contain 'id' and either 'enabled' or 'status', and may contain: 'filter', 'abort_incomplete_multipart_upload_days', 'expiration', 'transition', 'noncurrent_version_expiration', or 'noncurrent_version_transition'.\"\n+ }\n+}\n---\nvariables.tf\n@@ -191,9 +191,32 @@ variable \"transition_default_minimum_object_size\" {\n }\n \n variable \"lifecycle_rule\" {\n- description = \"List of maps containing configuration of object lifecycle management.\"\n+ description = \"List of maps containing configuration of object lifecycle management. Each lifecycle rule must contain 'id' and either 'enabled' or 'status', and may contain: 'filter', 'abort_incomplete_multipart_upload_days', 'expiration', 'transition', 'noncurrent_version_expiration', or 'noncurrent_version_transition'.\"\n type = any\n default = []\n+\n+ validation {\n+ condition = alltrue([\n+ for rule in var.lifecycle_rule : (\n+ contains(keys(rule), \"id\") &&\n+ (contains(keys(rule), \"enabled\") || contains(keys(rule), \"status\")) &&\n+ alltrue([\n+ for key in keys(rule) : contains([\n+ \"id\",\n+ \"enabled\",\n+ \"status\",\n+ \"filter\",\n+ \"abort_incomplete_multipart_upload_days\",\n+ \"expiration\",\n+ \"transition\",\n+ \"noncurrent_version_expiration\",\n+ \"noncurrent_version_transition\"\n+ ], key)\n+ ])\n+ )\n+ ])\n+ error_message = \"Each lifecycle rule must contain 'id' and either 'enabled' or 'status', and may contain: 'filter', 'abort_incomplete_multipart_upload_days', 'expiration', 'transition', 'noncurrent_version_expiration', or 'noncurrent_version_transition'.\"\n+ }\n }\n \n variable \"replication_configuration\" {\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nIn the Notification module create a new variable a new `create_lambda_policy` that functions similar to `create_sqs_policy` and `create_sns_policy`\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\nI define and manage my Lambda Policy separate from the Terraform where I manage my S3 Notifications. I don't want this module to force me to manage the Lambda policy here.\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nFixes #301 \r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\nI think that migrating `aws_lambda_permission.allow` from a single to a `count` this will cause the Resource to be recreated.\r\nThis can be avoided by performing [`terraform state mv`](https://developer.hashicorp.com/terraform/cli/commands/state/mv)\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nThere are 3 types of notifications, and this change brings Lambda in line with SQS and SNS that support `create_sqs_policy` and `create_sns_policy`\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/notification/README.md\n@@ -40,6 +40,7 @@ No modules.\n | <a name=\"input_bucket\"></a> [bucket](#input\\_bucket) | Name of S3 bucket to use | `string` | `\"\"` | no |\n | <a name=\"input_bucket_arn\"></a> [bucket\\_arn](#input\\_bucket\\_arn) | ARN of S3 bucket to use in policies | `string` | `null` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Whether to create this resource or not? | try(each.value.eventbridge, | `true` | no |\n+| <a name=\"input_create_lambda_permission\"></a> [create\\_lambda\\_permission](#input\\_create\\_lambda\\_permission) | Whether to create Lambda permissions or not? | `bool` | `true` | no |\n | <a name=\"input_create_sns_policy\"></a> [create\\_sns\\_policy](#input\\_create\\_sns\\_policy) | Whether to create a policy for SNS permissions or not? | `bool` | `true` | no |\n | <a name=\"input_create_sqs_policy\"></a> [create\\_sqs\\_policy](#input\\_create\\_sqs\\_policy) | Whether to create a policy for SQS permissions or not? | `bool` | `true` | no |\n | <a name=\"input_eventbridge\"></a> [eventbridge](#input\\_eventbridge) | Whether to enable Amazon EventBridge notifications | `bool` | `null` | no |\n---\nmodules/notification/main.tf\n@@ -60,7 +60,7 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n \n # Lambda\n resource \"aws_lambda_permission\" \"allow\" {\n- for_each = var.lambda_notifications\n+ for_each = { for k, v in var.lambda_notifications : k => v if var.create_lambda_permission }\n \n statement_id_prefix = \"AllowLambdaS3BucketNotification-\"\n action = \"lambda:InvokeFunction\"\n---\nmodules/notification/variables.tf\n@@ -16,6 +16,12 @@ variable \"create_sqs_policy\" {\n default = true\n }\n \n+variable \"create_lambda_permission\" {\n+ description = \"Whether to create Lambda permissions or not?\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"bucket\" {\n description = \"Name of S3 bucket to use\"\n type = string\n---\nwrappers/notification/main.tf\n@@ -3,13 +3,14 @@ module \"wrapper\" {\n \n for_each = var.items\n \n- bucket = try(each.value.bucket, var.defaults.bucket, \"\")\n- bucket_arn = try(each.value.bucket_arn, var.defaults.bucket_arn, null)\n- create = try(each.value.create, var.defaults.create, true)\n- create_sns_policy = try(each.value.create_sns_policy, var.defaults.create_sns_policy, true)\n- create_sqs_policy = try(each.value.create_sqs_policy, var.defaults.create_sqs_policy, true)\n- eventbridge = try(each.value.eventbridge, var.defaults.eventbridge, null)\n- lambda_notifications = try(each.value.lambda_notifications, var.defaults.lambda_notifications, {})\n- sns_notifications = try(each.value.sns_notifications, var.defaults.sns_notifications, {})\n- sqs_notifications = try(each.value.sqs_notifications, var.defaults.sqs_notifications, {})\n+ bucket = try(each.value.bucket, var.defaults.bucket, \"\")\n+ bucket_arn = try(each.value.bucket_arn, var.defaults.bucket_arn, null)\n+ create = try(each.value.create, var.defaults.create, true)\n+ create_lambda_permission = try(each.value.create_lambda_permission, var.defaults.create_lambda_permission, true)\n+ create_sns_policy = try(each.value.create_sns_policy, var.defaults.create_sns_policy, true)\n+ create_sqs_policy = try(each.value.create_sqs_policy, var.defaults.create_sqs_policy, true)\n+ eventbridge = try(each.value.eventbridge, var.defaults.eventbridge, null)\n+ lambda_notifications = try(each.value.lambda_notifications, var.defaults.lambda_notifications, {})\n+ sns_notifications = try(each.value.sns_notifications, var.defaults.sns_notifications, {})\n+ sqs_notifications = try(each.value.sqs_notifications, var.defaults.sqs_notifications, {})\n }\n---\n\n\n---\n\nChoice B:\nmodules/notification/README.md\n@@ -40,6 +40,7 @@ No modules.\n | <a name=\"input_bucket\"></a> [bucket](#input\\_bucket) | Name of S3 bucket to use | `string` | `\"\"` | no |\n | <a name=\"input_bucket_arn\"></a> [bucket\\_arn](#input\\_bucket\\_arn) | ARN of S3 bucket to use in policies | `string` | `null` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Whether to create this resource or not? | `bool` | `true` | no |\n+| <a name=\"input_create_lambda_permission\"></a> [create\\_lambda\\_permission](#input\\_create\\_lambda\\_permission) | Whether to create Lambda permissions or not? | `bool` | `true` | no |\n | <a name=\"input_create_sns_policy\"></a> [create\\_sns\\_policy](#input\\_create\\_sns\\_policy) | Whether to create a policy for SNS permissions or not? | `bool` | `true` | no |\n | <a name=\"input_create_sqs_policy\"></a> [create\\_sqs\\_policy](#input\\_create\\_sqs\\_policy) | Whether to create a policy for SQS permissions or not? | `bool` | `true` | no |\n | <a name=\"input_eventbridge\"></a> [eventbridge](#input\\_eventbridge) | Whether to enable Amazon EventBridge notifications | `bool` | `null` | no |\n---\nmodules/notification/main.tf\n@@ -60,7 +60,7 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n \n # Lambda\n resource \"aws_lambda_permission\" \"allow\" {\n- for_each = var.lambda_notifications\n+ for_each = { for k, v in var.lambda_notifications : k => v if var.create_lambda_permission }\n \n statement_id_prefix = \"AllowLambdaS3BucketNotification-\"\n action = \"lambda:InvokeFunction\"\n---\nmodules/notification/variables.tf\n@@ -16,6 +16,12 @@ variable \"create_sqs_policy\" {\n default = true\n }\n \n+variable \"create_lambda_permission\" {\n+ description = \"Whether to create permissions or not?\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"bucket\" {\n description = \"Name of S3 bucket to use\"\n type = string\n---\nwrappers/notification/main.tf\n@@ -3,13 +3,14 @@ module \"wrapper\" {\n \n for_each = var.items\n \n- bucket = try(each.value.bucket, var.defaults.bucket, \"\")\n- bucket_arn = try(each.value.bucket_arn, var.defaults.bucket_arn, null)\n- create = try(each.value.create, var.defaults.create, true)\n- create_sns_policy = try(each.value.create_sns_policy, var.defaults.create_sns_policy, true)\n- create_sqs_policy = try(each.value.create_sqs_policy, var.defaults.create_sqs_policy, true)\n- eventbridge = try(each.value.eventbridge, var.defaults.eventbridge, null)\n- lambda_notifications = try(each.value.lambda_notifications, var.defaults.lambda_notifications, {})\n- sns_notifications = try(each.value.sns_notifications, var.defaults.sns_notifications, {})\n- sqs_notifications = try(each.value.sqs_notifications, var.defaults.sqs_notifications, {})\n+ bucket = try(each.value.bucket, var.defaults.bucket, \"\")\n+ bucket_arn = try(each.value.bucket_arn, var.defaults.bucket_arn, null)\n+ create = try(each.value.create, var.defaults.create, true)\n+ create_lambda_permission = try(each.value.create_lambda_permission, var.defaults.create_lambda_permission, true)\n+ create_sns_policy = try(each.value.create_sns_policy, var.defaults.create_sns_policy, true)\n+ create_sqs_policy = try(each.value.create_sqs_policy, var.defaults.create_sqs_policy, true)\n+ eventbridge = try(each.value.eventbridge, var.defaults.eventbridge, null)\n+ lambda_notifications = try(each.value.lambda_notifications, var.defaults.lambda_notifications, {})\n+ sns_notifications = try(each.value.sns_notifications, var.defaults.sns_notifications, {})\n+ sqs_notifications = try(each.value.sqs_notifications, var.defaults.sqs_notifications, {})\n }\n---\n\n\n---\n\nChoice C:\nmodules/notification/README.md\n@@ -40,6 +40,7 @@ No modules.\n | <a name=\"input_bucket\"></a> [bucket](#input\\_bucket) | Name of S3 bucket to use | `string` | `\"\"` | no |\n | <a name=\"input_bucket_arn\"></a> [bucket\\_arn](#input\\_bucket\\_arn) | ARN of S3 bucket to use in policies | `string` | `null` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Whether to create this resource or not? | `bool` | `true` | no |\n+| <a name=\"input_create_lambda_permission\"></a> [create\\_lambda\\_permission](#input\\_create\\_lambda\\_permission) | Whether to create Lambda permissions or not? | `bool` | `true` | no |\n | <a name=\"input_create_sns_policy\"></a> [create\\_sns\\_policy](#input\\_create\\_sns\\_policy) | Whether to create a policy for SNS permissions or not? | `bool` | `true` | no |\n | <a name=\"input_create_sqs_policy\"></a> [create\\_sqs\\_policy](#input\\_create\\_sqs\\_policy) | Whether to create a policy for SQS permissions or not? | `bool` | `true` | no |\n | <a name=\"input_eventbridge\"></a> [eventbridge](#input\\_eventbridge) | Whether to enable Amazon EventBridge notifications | `bool` | `null` | no |\n---\nmodules/notification/main.tf\n@@ -60,7 +60,7 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n \n # Lambda\n resource \"aws_lambda_permission\" \"allow\" {\n- for_each = var.lambda_notifications\n+ for_each = { for k, v in var.lambda_notifications : k => v if var.create_lambda_permission }\n \n statement_id_prefix = \"AllowLambdaS3BucketNotification-\"\n action = \"lambda:InvokeFunction\"\n---\nmodules/notification/variables.tf\n@@ -16,6 +16,12 @@ variable \"create_sqs_policy\" {\n default = true\n }\n \n+variable \"create_lambda_permission\" {\n+ description = \"Whether to create Lambda permissions or not?\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"bucket\" {\n description = \"Name of S3 bucket to use\"\n type = string\n---\nwrappers/notification/main.tf\n@@ -3,13 +3,14 @@ module \"wrapper\" {\n \n for_each = var.items\n \n- bucket = try(each.value.bucket, var.defaults.bucket, \"\")\n- bucket_arn = try(each.value.bucket_arn, var.defaults.bucket_arn, null)\n- create = try(each.value.create, var.defaults.create, true)\n- create_sns_policy = try(each.value.create_sns_policy, var.defaults.create_sns_policy, true)\n- create_sqs_policy = try(each.value.create_sqs_policy, var.defaults.create_sqs_policy, true)\n- eventbridge = try(each.value.eventbridge, var.defaults.eventbridge, null)\n- lambda_notifications = try(each.value.lambda_notifications, var.defaults.lambda_notifications, {})\n- sns_notifications = try(each.value.sns_notifications, var.defaults.sns_notifications, {})\n- sqs_notifications = try(each.value.sqs_notifications, var.defaults.sqs_notifications, {})\n+ bucket = try(each.value.bucket, var.defaults.bucket, \"\")\n+ bucket_arn = try(each.value.bucket_arn, var.defaults.bucket_arn, null)\n+ create = try(each.value.create, var.defaults.create, true)\n+ create_lambda_permission = try(each.value.create_lambda_permission, var.defaults.create_lambda_permission, true)\n+ create_sns_policy = try(each.value.create_sns_policy, var.defaults.create_sns_policy, true)\n+ create_sqs_policy = try(each.value.create_sqs_policy, var.defaults.create_sqs_policy, true)\n+ eventbridge = try(each.value.eventbridge, var.defaults.eventbridge, null)\n+ lambda_notifications = try(each.value.lambda_notifications, var.defaults.lambda_notifications, {})\n+ sns_notifications \"create_lambda_permission\" = try(each.value.sns_notifications, var.defaults.sns_notifications, {})\n+ sqs_notifications = try(each.value.sqs_notifications, var.defaults.sqs_notifications, {})\n }\n---\n\n\n---\n\nChoice D:\nmodules/notification/README.md\n@@ -40,6 +40,7 @@ No modules.\n | <a name=\"input_bucket\"></a> [bucket](#input\\_bucket) | Name of S3 bucket to use | `string` | `\"\"` | no |\n | <a name=\"input_bucket_arn\"></a> [bucket\\_arn](#input\\_bucket\\_arn) | ARN of S3 bucket to use in policies | `string` | `null` | no |\n | <a name=\"input_create\"></a> [create](#input\\_create) | Whether to create this resource or not? | `bool` | `true` | no |\n+| <a name=\"input_create_lambda_permission\"></a> [create\\_lambda\\_permission](#input\\_create\\_lambda\\_permission) | Whether to create Lambda permissions or not? | `bool` | `true` | no |\n | <a name=\"input_create_sns_policy\"></a> [create\\_sns\\_policy](#input\\_create\\_sns\\_policy) | Whether to create a policy for SNS permissions or not? | `bool` | `true` | no |\n | <a name=\"input_create_sqs_policy\"></a> [create\\_sqs\\_policy](#input\\_create\\_sqs\\_policy) | Whether to create a policy for SQS permissions or not? | `bool` | `true` | no |\n | <a name=\"input_eventbridge\"></a> [eventbridge](#input\\_eventbridge) | Whether to enable Amazon EventBridge notifications | `bool` | `null` | no |\n---\nmodules/notification/main.tf\n@@ -60,7 +60,7 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n \n # Lambda\n resource \"aws_lambda_permission\" \"allow\" {\n- for_each = var.lambda_notifications\n+ for_each = { for k, v in var.lambda_notifications : k => v if var.create_lambda_permission }\n \n statement_id_prefix = \"AllowLambdaS3BucketNotification-\"\n action = \"lambda:InvokeFunction\"\n---\nmodules/notification/variables.tf\n@@ -16,6 +16,12 @@ variable \"create_sqs_policy\" {\n default = true\n }\n \n+variable \"create_lambda_permission\" {\n+ description = \"Whether to create Lambda permissions or not?\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"bucket\" {\n description = \"Name of S3 bucket to use\"\n type = string\n---\nwrappers/notification/main.tf\n@@ -3,13 +3,14 @@ module \"wrapper\" {\n \n for_each = var.items\n \n- bucket = try(each.value.bucket, var.defaults.bucket, \"\")\n- bucket_arn = try(each.value.bucket_arn, var.defaults.bucket_arn, null)\n- create = try(each.value.create, var.defaults.create, true)\n- create_sns_policy = try(each.value.create_sns_policy, var.defaults.create_sns_policy, true)\n- create_sqs_policy = try(each.value.create_sqs_policy, var.defaults.create_sqs_policy, true)\n- eventbridge = try(each.value.eventbridge, var.defaults.eventbridge, null)\n- lambda_notifications = try(each.value.lambda_notifications, var.defaults.lambda_notifications, {})\n- sns_notifications = try(each.value.sns_notifications, var.defaults.sns_notifications, {})\n- sqs_notifications = try(each.value.sqs_notifications, var.defaults.sqs_notifications, {})\n+ bucket = try(each.value.bucket, var.defaults.bucket, \"\")\n+ bucket_arn = try(each.value.bucket_arn, var.defaults.bucket_arn, null)\n+ create = try(each.value.create, var.defaults.create, true)\n+ create_lambda_permission = try(each.value.create_lambda_permission, var.defaults.create_lambda_permission, true)\n+ create_sns_policy = try(each.value.create_sns_policy, var.defaults.create_sns_policy, true)\n+ create_sqs_policy = try(each.value.create_sqs_policy, var.defaults.create_sqs_policy, true)\n+ eventbridge = try(each.value.eventbridge, var.defaults.eventbridge, null)\n+ lambda_notifications = try(each.value.lambda_notifications, var.defaults.lambda_notifications, {})\n+ sns_notifications = try(each.value.sns_notifications, var.defaults.sns_notifications, {})\n+ sqs_notifications = try(each.value.sqs_notifications, var.defaults.sqs_notifications, {})\n }\n---\n\n\n---\n" } ]
D
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nSome examples still have `acl` being set with default object ownership getting created with `BucketOwnerEnforced` which doesn't support ACLs. This just removes `acl`.\r\n\r\n## Motivation and Context\r\nFixes examples which produce error currently:\r\n```\r\n╷\r\n│ Error: creating S3 Bucket (analytics-and-inventory-destination-fresh-kitten) ACL: operation error S3: PutBucketAcl, https response error StatusCode: 400, RequestID: <>, HostID: <>, api error AccessControlListNotSupported: The bucket does not allow ACLs\r\n│ \r\n│ with module.analytics_and_inventory_destination_bucket.aws_s3_bucket_acl.this[0],\r\n│ on ../../main.tf line 66, in resource \"aws_s3_bucket_acl\" \"this\":\r\n│ 66: resource \"aws_s3_bucket_acl\" \"this\" {\r\n│ \r\n╵\r\n```\r\n\r\n## Breaking Changes\r\nNo.\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/s3-analytics/main.tf\n@@ -24,7 +24,6 @@ module \"analytics_configuration_bucket\" {\n attach_analytics_destination_policy = true\n attach_policy = true\n analytics_self_source_destination = true\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n \n versioning = {\n status = true\n@@ -77,7 +76,6 @@ module \"analytics_destination_bucket\" {\n = = \"../../\"\n \n bucket = \"analytics-destination-${random_pet.this.id}\"\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n force_destroy = true\n attach_policy = true\n attach_analytics_destination_policy = true\n@@ -92,7 +90,6 @@ module \"inventory_source_bucket\" {\n bucket = \"inventory-source-${random_pet.this.id}\"\n \n force_destroy = true\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n \n inventory_configuration = {\n destination_other = {\n@@ -115,7 +112,6 @@ module \"analytics_and_inventory_destination_bucket\" {\n source = \"../../\"\n \n bucket = \"analytics-and-inventory-destination-${random_pet.this.id}\"\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n force_destroy = true\n attach_policy = true\n \n---\nexamples/s3-inventory/main.tf\n@@ -24,7 +24,6 @@ module \"multi_inventory_configurations_bucket\" {\n attach_policy = true\n attach_inventory_destination_policy = true\n inventory_self_source_destination = true\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n \n versioning = {\n status = true\n@@ -137,7 +136,6 @@ module \"inventory_destination_bucket\" {\n source = \"../../\"\n \n bucket = \"inventory-destination-${random_pet.this.id}\"\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n force_destroy = true\n attach_policy = true\n attach_inventory_destination_policy = true\n@@ -149,6 +147,5 @@ module \"inventory_source_bucket\" {\n source = \"../../\"\n \n bucket = \"inventory-source-${random_pet.this.id}\"\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n force_destroy = true\n }\n---\nexamples/s3-replication/main.tf\n@@ -16,7 +16,6 @@ provider \"aws\" {\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n- skip_requesting_account_id = true\n }\n \n locals {\n@@ -47,7 +46,6 @@ module \"replica_bucket\" {\n }\n \n bucket = local.destination_bucket_name\n- acl = \"private\"\n \n versioning = {\n enabled = true\n@@ -58,7 +56,6 @@ module \"s3_bucket\" {\n source = \"../../\"\n \n bucket = local.bucket_name\n- acl = \"private\"\n \n versioning = {\n enabled = true\n---\n\n\n---\n\nChoice B:\nexamples/s3-analytics/main.tf\n@@ -24,7 +24,6 @@ module \"analytics_configuration_bucket\" {\n attach_analytics_destination_policy = true\n attach_policy = true\n analytics_self_source_destination = true\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n \n versioning = {\n status = true\n@@ -77,7 +76,6 @@ module \"analytics_destination_bucket\" {\n source = \"../../\"\n \n bucket = \"analytics-destination-${random_pet.this.id}\"\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n force_destroy acl = true\n attach_policy = true\n attach_analytics_destination_policy = true\n@@ -92,7 +90,6 @@ module \"inventory_source_bucket\" {\n bucket = \"inventory-source-${random_pet.this.id}\"\n \n force_destroy = true\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n \n inventory_configuration = {\n destination_other = {\n@@ -115,7 +112,6 @@ module \"analytics_and_inventory_destination_bucket\" {\n source = \"../../\"\n \n bucket = \"analytics-and-inventory-destination-${random_pet.this.id}\"\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n force_destroy = true\n attach_policy = true\n \n---\nexamples/s3-inventory/main.tf\n@@ -24,7 +24,6 @@ module \"multi_inventory_configurations_bucket\" {\n attach_policy = true\n attach_inventory_destination_policy = true\n inventory_self_source_destination = true\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n \n versioning = {\n status = true\n@@ -137,7 +136,6 @@ module \"inventory_destination_bucket\" {\n source = \"../../\"\n \n bucket = \"inventory-destination-${random_pet.this.id}\"\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n force_destroy = true\n attach_policy = true\n attach_inventory_destination_policy = true\n@@ -149,6 +147,5 @@ module \"inventory_source_bucket\" {\n source = \"../../\"\n \n bucket = \"inventory-source-${random_pet.this.id}\"\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n force_destroy = true\n }\n---\nexamples/s3-replication/main.tf\n@@ -16,7 +16,6 @@ provider \"aws\" {\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n- skip_requesting_account_id = true\n }\n \n locals {\n@@ -47,7 +46,6 @@ module \"replica_bucket\" {\n }\n \n bucket = local.destination_bucket_name\n- acl = \"private\"\n \n versioning = {\n enabled = true\n@@ -58,7 +56,6 @@ module \"s3_bucket\" {\n source = \"../../\"\n \n bucket = local.bucket_name\n- acl = \"private\"\n \n versioning = {\n enabled = true\n---\n\n\n---\n\nChoice C:\nexamples/s3-analytics/main.tf\n@@ -24,7 +24,6 @@ module \"analytics_configuration_bucket\" {\n attach_analytics_destination_policy = true\n attach_policy = true\n analytics_self_source_destination = true\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n \n versioning = {\n status = true\n@@ -77,7 +76,6 @@ module \"analytics_destination_bucket\" {\n source = \"../../\"\n \n bucket = \"analytics-destination-${random_pet.this.id}\"\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n force_destroy = true\n attach_policy = true\n attach_analytics_destination_policy = true\n@@ -92,7 +90,6 @@ module \"inventory_source_bucket\" {\n bucket = \"inventory-source-${random_pet.this.id}\"\n \n force_destroy = true\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n \n inventory_configuration = {\n destination_other = {\n@@ -115,7 +112,6 @@ module \"analytics_and_inventory_destination_bucket\" {\n source = \"../../\"\n \n bucket = \"analytics-and-inventory-destination-${random_pet.this.id}\"\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n force_destroy = true\n attach_policy = true\n \n---\nexamples/s3-inventory/main.tf\n@@ -24,7 +24,6 @@ module \"multi_inventory_configurations_bucket\" {\n attach_policy = true\n attach_inventory_destination_policy = true\n inventory_self_source_destination = true\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n \n versioning = {\n status = true\n@@ -137,7 +136,6 @@ module \"inventory_destination_bucket\" {\n source = \"../../\"\n \n bucket = \"inventory-destination-${random_pet.this.id}\"\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n force_destroy = true\n attach_policy = true\n attach_inventory_destination_policy = true\n@@ -149,6 +147,5 @@ module \"inventory_source_bucket\" {\n source = \"../../\"\n \n bucket = \"inventory-source-${random_pet.this.id}\"\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n force_destroy = true\n }\n---\nexamples/s3-replication/main.tf\n@@ -16,7 +16,6 @@ provider \"aws\" {\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n- skip_requesting_account_id = true\n }\n \n locals {\n@@ -47,7 +46,6 @@ module \"replica_bucket\" {\n }\n \n bucket = local.destination_bucket_name\n- acl = \"private\"\n \n versioning = {\n enabled = true\n@@ -58,7 +56,6 @@ module \"s3_bucket\" {\n source = \"../../\"\n \n bucket = local.bucket_name\n- acl = \"private\"\n \n versioning = {\n enabled = true\n---\n\n\n---\n\nChoice D:\nexamples/s3-analytics/main.tf\n@@ -24,7 +24,6 @@ module \"analytics_configuration_bucket\" {\n attach_analytics_destination_policy = true\n attach_policy = true\n analytics_self_source_destination = true\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n \n versioning = {\n status = true\n@@ -77,7 +76,6 @@ module \"analytics_destination_bucket\" {\n source = \"../../\"\n \n bucket = \"analytics-destination-${random_pet.this.id}\"\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n force_destroy = true\n attach_policy = true\n attach_analytics_destination_policy = true\n@@ -92,7 +90,6 @@ module \"inventory_source_bucket\" {\n bucket = \"inventory-source-${random_pet.this.id}\"\n \n force_destroy = true\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n \n inventory_configuration = {\n destination_other = {\n@@ -115,7 +112,6 @@ module \"analytics_and_inventory_destination_bucket\" {\n source = \"../../\"\n \n bucket = \"analytics-and-inventory-destination-${random_pet.this.id}\"\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n force_destroy = true\n attach_policy = true\n \n---\nexamples/s3-inventory/main.tf\n@@ -24,7 +24,6 @@ module \"multi_inventory_configurations_bucket\" {\n attach_policy = true\n attach_inventory_destination_policy = true\n inventory_self_source_destination = true\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n \n versioning = {\n status = true\n@@ -137,7 +136,6 @@ module \"inventory_destination_bucket\" {\n source = \"../../\"\n \n bucket = \"inventory-destination-${random_pet.this.id}\"\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n force_destroy = true\n attach_policy = true\n attach_inventory_destination_policy = true\n@@ -149,6 +147,5 @@ module \"inventory_source_bucket\" {\n source = \"../../\"\n \n bucket = \"inventory-source-${random_pet.this.id}\"\n- acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n force_destroy = true\n }\n---\nexamples/s3-replication/main.tf\n@@ -16,7 +16,6 @@ provider \"aws\" {\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n- skip_requesting_account_id = true\n }\n \n locals {\n@@ -47,7 +46,6 @@ module \"replica_bucket\" {\n }\n \n bucket = local.destination_bucket_name\n- acl = \"private\"\n \n versioning = {\n enabled = true\n@@ -58,7 +56,6 @@ module \"s3_bucket\" {\n source = \"../../\"\n \n bucket = local.bucket_name\n- acl = \"private\"\n \n versioning = {\n enabled = true\n---\n\n\n---\n" } ]
C
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\n.gitignore\n@@ -2,7 +2,7 @@\n **/.terraform/*\n \n # Terraform lockfile\n-.terraform.lock.hcl\n+#.terraform.lock.hcl\n \n # .tfstate files\n *.tfstate\n---\n.terraform.lock.hcl\n@@ -0,0 +1,25 @@\n+# This file is maintained automatically by \"terraform init\".\n+# Manual edits may be lost in future updates.\n+\n+provider \"registry.terraform.io/hashicorp/aws\" {\n+ version = \"5.67.0\"\n+ constraints = \">= 5.27.0\"\n+ hashes = [\n+ \"h1:CNrePKADIbpHvmdbhDeKkqLRSi5mQrjPvoyKzYt0kJM=\",\n+ \"zh:1259c8106c0a3fc0ed3b3eb814ab88d6a672e678b533f47d1bbbe3107949f43e\",\n+ \"zh:226414049afd6d334cc16ff5d6cef23683620a9b56da67a21422a113d9cce4ab\",\n+ \"zh:3c89b103aea20ef82a84e889abaeb971cb168de8292b61b34b83e807c40085a9\",\n+ \"zh:3dd88e994fb7d7a6c6eafd3c01393274e4f776021176acea2e980f73fbd4acbc\",\n+ \"zh:487e0dda221c84a20a143904c1cee4e63fce6c5c57c21368ea79beee87b108da\",\n+ \"zh:7693bdcec8181aafcbda2c41c35b1386997e2c92b6f011df058009e4c8b300e1\",\n+ \"zh:82679536250420f9e8e6edfd0fa9a1bab99a7f31fe5f049ac7a2e0d8c287b56f\",\n+ \"zh:8685218dae921740083820c52afa66cdf14cf130539da1efd7d9a78bfb6ade64\",\n+ \"zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425\",\n+ \"zh:9e553a3ec05eedea779d393447fc316689ba6c4d4d8d569b986898e6dbe58fee\",\n+ \"zh:a36c24acd3c75bac8211fefde58c459778021eb871ff8339be1c26ad8fd67ee1\",\n+ \"zh:ce48bd1e35d6f996f1a09d8f99e8084469b7fec5611e67a50a63e96375b87ebe\",\n+ \"zh:d6c76a24205513725269e4783da14be9648e9086fb621496052f4b37d52d785e\",\n+ \"zh:d95a31745affb178ea48fa8e0be94691a8f7507ea55c0d0a4b6e0a8ef6fcb929\",\n+ \"zh:f061ce59fac1bc425c1092e6647ed4bb1b61824416041b46dbf336e01a63ad89\",\n+ ]\n+}\n---\n\n\n---\n\nChoice B:\n.gitignore\n@@ -2,7 +2,7 @@\n **/.terraform/*\n \n # Terraform lockfile\n-.terraform.lock.hcl\n+#.terraform.lock.hcl\n \n # .tfstate files\n *.tfstate\n---\n.terraform.lock.hcl\n@@ -0,0 +1,25 @@\n+# This file is maintained automatically by \"terraform init\".\n+# Manual edits may be lost in future updates.\n+\n+provider \"registry.terraform.io/hashicorp/aws\" {\n+ version = \"5.67.0\"\n+ constraints = \">= 5.27.0\"\n+ hashes = [\n+ \"h1:CNrePKADIbpHvmdbhDeKkqLRSi5mQrjPvoyKzYt0kJM=\",\n+ \"zh:1259c8106c0a3fc0ed3b3eb814ab88d6a672e678b533f47d1bbbe3107949f43e\",\n+ \"zh:226414049afd6d334cc16ff5d6cef23683620a9b56da67a21422a113d9cce4ab\",\n+ \"zh:3c89b103aea20ef82a84e889abaeb971cb168de8292b61b34b83e807c40085a9\",\n+ \"zh:3dd88e994fb7d7a6c6eafd3c01393274e4f776021176acea2e980f73fbd4acbc\",\n+ \"zh:487e0dda221c84a20a143904c1cee4e63fce6c5c57c21368ea79beee87b108da\",\n+ \"zh:7693bdcec8181aafcbda2c41c35b1386997e2c92b6f011df058009e4c8b300e1\",\n+ \"zh:82679536250420f9e8e6edfd0fa9a1bab99a7f31fe5f049ac7a2e0d8c287b56f\",\n+ \"zh:8685218dae921740083820c52afa66cdf14cf130539da1efd7d9a78bfb6ade64\",\n+ \"zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425\",\n+ \"zh:9e553a3ec05eedea779d393447fc316689ba6c4d4d8d569b986898e6dbe58fee\",\n+ \"zh:a36c24acd3c75bac8211fefde58c459778021eb871ff8339be1c26ad8fd67ee1\",\n+ \"zh:ce48bd1e35d6f996f1a09d8f99e8084469b7fec5611e67a50a63e96375b87ebe\",\n+ \"zh:d6c76a24205513725269e4783da14be9648e9086fb621496052f4b37d52d785e\",\n+ \"zh:d95a31745affb178ea48fa8e0be94691a8f7507ea55c0d0a4b6e0a8ef6fcb929\",\n+ \"zh:f061ce59fac1bc425c1092e6647ed4bb1b61824416041b46dbf336e01a63ad89\",\n+ ]\n+}\n---\n\n\n---\n\nChoice C:\n.gitignore\n@@ -2,7 +2,7 @@\n **/.terraform/*\n \n # Terraform lockfile\n-.terraform.lock.hcl\n+#.terraform.lock.hcl\n \n # .tfstate files\n *.tfstate\n---\n.terraform.lock.hcl\n@@ -0,0 +1,25 @@\n+# This file is maintained automatically by \"terraform init\".\n+# Manual edits may be lost in future updates.\n+\n+provider \"registry.terraform.io/hashicorp/aws\" {\n+ version = # constraints = \">= 5.27.0\"\n+ hashes = [\n+ \"h1:CNrePKADIbpHvmdbhDeKkqLRSi5mQrjPvoyKzYt0kJM=\",\n+ \"zh:1259c8106c0a3fc0ed3b3eb814ab88d6a672e678b533f47d1bbbe3107949f43e\",\n+ \"zh:226414049afd6d334cc16ff5d6cef23683620a9b56da67a21422a113d9cce4ab\",\n+ \"zh:3c89b103aea20ef82a84e889abaeb971cb168de8292b61b34b83e807c40085a9\",\n+ \"zh:3dd88e994fb7d7a6c6eafd3c01393274e4f776021176acea2e980f73fbd4acbc\",\n+ \"zh:487e0dda221c84a20a143904c1cee4e63fce6c5c57c21368ea79beee87b108da\",\n+ \"zh:7693bdcec8181aafcbda2c41c35b1386997e2c92b6f011df058009e4c8b300e1\",\n+ \"zh:82679536250420f9e8e6edfd0fa9a1bab99a7f31fe5f049ac7a2e0d8c287b56f\",\n+ \"zh:8685218dae921740083820c52afa66cdf14cf130539da1efd7d9a78bfb6ade64\",\n+ \"zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425\",\n+ \"zh:9e553a3ec05eedea779d393447fc316689ba6c4d4d8d569b986898e6dbe58fee\",\n+ \"zh:a36c24acd3c75bac8211fefde58c459778021eb871ff8339be1c26ad8fd67ee1\",\n+ \"zh:ce48bd1e35d6f996f1a09d8f99e8084469b7fec5611e67a50a63e96375b87ebe\",\n+ \"zh:d6c76a24205513725269e4783da14be9648e9086fb621496052f4b37d52d785e\",\n+ \"zh:d95a31745affb178ea48fa8e0be94691a8f7507ea55c0d0a4b6e0a8ef6fcb929\",\n+ \"zh:f061ce59fac1bc425c1092e6647ed4bb1b61824416041b46dbf336e01a63ad89\",\n+ ]\n+}\n---\n\n\n---\n\nChoice D:\n.gitignore\n@@ -2,7 +2,7 @@\n **/.terraform/*\n \n # Terraform lockfile\n-.terraform.lock.hcl\n+#.terraform.lock.hcl\n \n # .tfstate files\n *.tfstate\n---\n.terraform.lock.hcl\n@@ -0,0 +1,25 @@\n+# This file is maintained automatically by \"terraform init\".\n+# Manual edits may be lost in future updates.\n+\n+provider \"registry.terraform.io/hashicorp/aws\" {\n+ version = \"5.67.0\"\n+ constraints = \">= 5.27.0\"\n+ hashes = [\n+ \"h1:CNrePKADIbpHvmdbhDeKkqLRSi5mQrjPvoyKzYt0kJM=\",\n+ \"zh:1259c8106c0a3fc0ed3b3eb814ab88d6a672e678b533f47d1bbbe3107949f43e\",\n+ \"zh:226414049afd6d334cc16ff5d6cef23683620a9b56da67a21422a113d9cce4ab\",\n+ \"zh:3c89b103aea20ef82a84e889abaeb971cb168de8292b61b34b83e807c40085a9\",\n+ Terraform \"zh:3dd88e994fb7d7a6c6eafd3c01393274e4f776021176acea2e980f73fbd4acbc\",\n+ \"zh:487e0dda221c84a20a143904c1cee4e63fce6c5c57c21368ea79beee87b108da\",\n+ \"zh:7693bdcec8181aafcbda2c41c35b1386997e2c92b6f011df058009e4c8b300e1\",\n+ \"zh:82679536250420f9e8e6edfd0fa9a1bab99a7f31fe5f049ac7a2e0d8c287b56f\",\n+ \"zh:8685218dae921740083820c52afa66cdf14cf130539da1efd7d9a78bfb6ade64\",\n+ \"zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425\",\n+ \"zh:9e553a3ec05eedea779d393447fc316689ba6c4d4d8d569b986898e6dbe58fee\",\n+ \"zh:a36c24acd3c75bac8211fefde58c459778021eb871ff8339be1c26ad8fd67ee1\",\n+ \"zh:ce48bd1e35d6f996f1a09d8f99e8084469b7fec5611e67a50a63e96375b87ebe\",\n+ \"zh:d6c76a24205513725269e4783da14be9648e9086fb621496052f4b37d52d785e\",\n+ \"zh:d95a31745affb178ea48fa8e0be94691a8f7507ea55c0d0a4b6e0a8ef6fcb929\",\n+ \"zh:f061ce59fac1bc425c1092e6647ed4bb1b61824416041b46dbf336e01a63ad89\",\n+ ]\n+}\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nAdded log delivery policy option for inspector findings bucket according to aws [documentation](https://docs.aws.amazon.com/inspector/latest/user/findings-managing-exporting-reports.html#findings-managing-exporting-bucket-perms)\n\n---\n\nChoice A:\nREADME.md\n@@ -170,6 +170,7 @@ No modules.\n | [aws_iam_policy_document.deny_insecure_transport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.deny_unencrypted_object_uploads](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) \"deny_unencrypted_object_uploads\" data source |\n | [aws_iam_policy_document.elb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.inspector_findings_delivery_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.inventory_and_analytics_destination_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.lb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.require_latest_tls](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n@@ -198,6 +199,7 @@ No modules.\n | <a name=\"input_attach_elb_log_delivery_policy\"></a> [attach\\_elb\\_log\\_delivery\\_policy](#input\\_attach\\_elb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ELB log delivery policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_inventory_destination_policy\"></a> [attach\\_inventory\\_destination\\_policy](#input\\_attach\\_inventory\\_destination\\_policy) | Controls if S3 bucket should have bucket inventory destination policy attached. | `bool` | `false` | no |\n | <a name=\"input_attach_lb_log_delivery_policy\"></a> [attach\\_lb\\_log\\_delivery\\_policy](#input\\_attach\\_lb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ALB/NLB log delivery policy attached | `bool` | `false` | no |\n+| <a name=\"input_attach_inspector_findings_delivery_policy\"></a> [attach\\_inspector\\_findings\\_delivery\\_policy](#input\\_attach\\_inspector\\_findings\\_delivery\\_policy) | Controls if S3 bucket should have Inspector findings delivery policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_policy\"></a> [attach\\_policy](#input\\_attach\\_policy) | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | `bool` | `false` | no |\n | <a name=\"input_attach_public_policy\"></a> [attach\\_public\\_policy](#input\\_attach\\_public\\_policy) | Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket) | `bool` | `true` | no |\n | <a name=\"input_attach_require_latest_tls_policy\"></a> [attach\\_require\\_latest\\_tls\\_policy](#input\\_attach\\_require\\_latest\\_tls\\_policy) | Controls if S3 bucket should require the latest version of TLS | `bool` | `false` | no |\n---\nexamples/s3-inventory/main.tf\n@@ -93,6 +93,7 @@ resource \"random_pet\" \"this\" {\n # https://docs.aws.amazon.com/AmazonS3/latest/userguide/configure-inventory.html#configure-inventory-kms-key-policy\n module \"kms\" {\n source = \"terraform-aws-modules/kms/aws\"\n+ version = \"~> 2.0\"\n \n description = \"Key example for Inventory S3 destination encyrption\"\n deletion_window_in_days = 7\n---\nmain.tf\n@@ -12,7 +12,7 @@ locals {\n \n create_bucket_acl = (var.acl != null && var.acl != \"null\") || length(local.grants) > 0\n \n- attach_policy = var.attach_require_latest_tls_policy || var.attach_access_log_delivery_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_inventory_destination_policy || var.attach_deny_incorrect_encryption_headers || var.attach_deny_incorrect_kms_key_sse || var.attach_deny_unencrypted_object_uploads || var.attach_policy\n+ attach_policy = var.attach_require_latest_tls_policy || var.attach_access_log_delivery_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_inventory_destination_policy || var.attach_deny_incorrect_encryption_headers || var.attach_deny_incorrect_kms_key_sse || var.attach_deny_unencrypted_object_uploads || var.attach_inspector_findings_delivery_policy || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n grants = try(jsondecode(var.grant), var.grant)\n@@ -562,6 +562,7 @@ data \"aws_iam_policy_document\" \"combined\" {\n var.attach_deny_incorrect_kms_key_sse ? data.aws_iam_policy_document.deny_incorrect_kms_key_sse[0].json : \"\",\n var.attach_deny_incorrect_encryption_headers ? data.aws_iam_policy_document.deny_incorrect_encryption_headers[0].json : \"\",\n var.attach_inventory_destination_policy || var.attach_analytics_destination_policy ? data.aws_iam_policy_document.inventory_and_analytics_destination_policy[0].json : \"\",\n+ var.attach_inspector_findings_delivery_policy ? data.aws_iam_policy_document.inspector_findings_delivery_policy[0].json : \"\",\n var.attach_policy ? var.policy : \"\"\n ])\n }\n@@ -909,6 +910,44 @@ data \"aws_iam_policy_document\" \"deny_unencrypted_object_uploads\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"inspector_findings_delivery_policy\" {\n+ count = local.create_bucket && var.attach_inspector_findings_delivery_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"allow-inspector\"\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"s3:PutObject\",\n+ \"s3:PutObjectAcl\",\n+ \"s3:AbortMultipartUpload\"\n+ ]\n+\n+ resources = [\"${aws_s3_bucket.this[0].arn}/*\"]\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"inspector2.amazonaws.com\"]\n+ }\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:SourceAccount\"\n+ values = [\n+ data.aws_caller_identity.current.id\n+ ]\n+ }\n+ condition {\n+ test = \"ArnLike\"\n+ variable = \"aws:SourceArn\"\n+ values = [\n+ format(\"%s%s%s\", \"arn:aws:inspector2:Region:\", data.aws_caller_identity.current.id, \":report/*\")\n+ ]\n+ }\n+ }\n+}\n+\n+\n resource \"aws_s3_bucket_public_access_block\" \"this\" {\n count = local.create_bucket && var.attach_public_policy ? 1 : 0\n \n---\nvariables.tf\n@@ -82,6 +82,12 @@ variable \"attach_deny_unencrypted_object_uploads\" {\n default = false\n }\n \n+variable \"attach_inspector_findings_delivery_policy\" {\n+ description = \"Controls if S3 bucket should have Inspector findings delivery policy attached\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"bucket\" {\n description = \"(Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name.\"\n type = string\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -170,6 +170,7 @@ No modules.\n | [aws_iam_policy_document.deny_insecure_transport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.deny_unencrypted_object_uploads](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.elb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.inspector_findings_delivery_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.inventory_and_analytics_destination_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.lb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.require_latest_tls](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n@@ -198,6 +199,7 @@ No modules.\n | <a name=\"input_attach_elb_log_delivery_policy\"></a> [attach\\_elb\\_log\\_delivery\\_policy](#input\\_attach\\_elb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ELB log delivery policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_inventory_destination_policy\"></a> [attach\\_inventory\\_destination\\_policy](#input\\_attach\\_inventory\\_destination\\_policy) | Controls if S3 bucket should have bucket inventory destination policy attached. | `bool` | `false` | no |\n | <a name=\"input_attach_lb_log_delivery_policy\"></a> [attach\\_lb\\_log\\_delivery\\_policy](#input\\_attach\\_lb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ALB/NLB log delivery policy attached | `bool` | `false` | no |\n+| <a name=\"input_attach_inspector_findings_delivery_policy\"></a> [attach\\_inspector\\_findings\\_delivery\\_policy](#input\\_attach\\_inspector\\_findings\\_delivery\\_policy) | Controls if S3 bucket should have Inspector findings delivery policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_policy\"></a> [attach\\_policy](#input\\_attach\\_policy) | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | `bool` | `false` | no |\n | <a name=\"input_attach_public_policy\"></a> [attach\\_public\\_policy](#input\\_attach\\_public\\_policy) | Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket) | `bool` | `true` | no |\n | <a name=\"input_attach_require_latest_tls_policy\"></a> [attach\\_require\\_latest\\_tls\\_policy](#input\\_attach\\_require\\_latest\\_tls\\_policy) | Controls if S3 bucket should require the latest version of TLS | `bool` | `false` | no |\n---\nexamples/s3-inventory/main.tf\n@@ -93,6 +93,7 @@ resource \"random_pet\" \"this\" {\n # https://docs.aws.amazon.com/AmazonS3/latest/userguide/configure-inventory.html#configure-inventory-kms-key-policy\n module \"kms\" {\n source = \"terraform-aws-modules/kms/aws\"\n+ version = \"~> 2.0\"\n \n description = \"Key example for Inventory S3 destination encyrption\"\n deletion_window_in_days = 7\n---\nmain.tf\n@@ -12,7 +12,7 @@ locals {\n \n create_bucket_acl = (var.acl != null && var.acl != \"null\") || length(local.grants) > 0\n \n- attach_policy = var.attach_require_latest_tls_policy || var.attach_access_log_delivery_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_inventory_destination_policy || var.attach_deny_incorrect_encryption_headers || var.attach_deny_incorrect_kms_key_sse || var.attach_deny_unencrypted_object_uploads || var.attach_policy\n+ attach_policy = var.attach_require_latest_tls_policy || var.attach_access_log_delivery_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_inventory_destination_policy || var.attach_deny_incorrect_encryption_headers || var.attach_deny_incorrect_kms_key_sse || var.attach_deny_unencrypted_object_uploads || var.attach_inspector_findings_delivery_policy || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n grants = try(jsondecode(var.grant), var.grant)\n@@ -562,6 +562,7 @@ data \"aws_iam_policy_document\" \"combined\" {\n var.attach_deny_incorrect_kms_key_sse ? data.aws_iam_policy_document.deny_incorrect_kms_key_sse[0].json : \"\",\n var.attach_deny_incorrect_encryption_headers ? data.aws_iam_policy_document.deny_incorrect_encryption_headers[0].json : \"\",\n var.attach_inventory_destination_policy || var.attach_analytics_destination_policy ? data.aws_iam_policy_document.inventory_and_analytics_destination_policy[0].json : \"\",\n+ var.attach_inspector_findings_delivery_policy ? data.aws_iam_policy_document.inspector_findings_delivery_policy[0].json : \"\",\n var.attach_policy ? var.policy : \"\"\n ])\n }\n@@ -909,6 +910,44 @@ data \"aws_iam_policy_document\" \"deny_unencrypted_object_uploads\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"inspector_findings_delivery_policy\" {\n+ count = local.create_bucket && var.attach_inspector_findings_delivery_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"allow-inspector\"\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"s3:PutObject\",\n+ \"s3:PutObjectAcl\",\n+ \"s3:AbortMultipartUpload\"\n+ ]\n+\n+ resources = [\"${aws_s3_bucket.this[0].arn}/*\"]\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"inspector2.amazonaws.com\"]\n+ }\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:SourceAccount\"\n+ values = [\n+ data.aws_caller_identity.current.id\n+ ]\n+ }\n+ condition {\n+ test = \"ArnLike\"\n+ variable = \"aws:SourceArn\"\n+ values = [\n+ format(\"%s%s%s\", \"arn:aws:inspector2:Region:\", data.aws_caller_identity.current.id, \":report/*\")\n+ ]\n+ }\n+ }\n+}\n+\n+\n resource \"aws_s3_bucket_public_access_block\" \"this\" {\n count = local.create_bucket && var.attach_public_policy ? 1 : 0\n \n---\nvariables.tf\n@@ -82,6 +82,12 @@ variable \"attach_deny_unencrypted_object_uploads\" {\n default = false\n }\n \n+variable \"attach_inspector_findings_delivery_policy\" {\n+ description = \"Controls if S3 bucket should have Inspector findings delivery policy attached\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"bucket\" {\n description = \"(Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name.\"\n type = string\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -170,6 +170,7 @@ No modules.\n | [aws_iam_policy_document.deny_insecure_transport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.deny_unencrypted_object_uploads](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.elb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.inspector_findings_delivery_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.inventory_and_analytics_destination_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.lb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.require_latest_tls](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n@@ -198,6 +199,7 @@ No modules.\n | <a name=\"input_attach_elb_log_delivery_policy\"></a> [attach\\_elb\\_log\\_delivery\\_policy](#input\\_attach\\_elb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ELB log delivery policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_inventory_destination_policy\"></a> [attach\\_inventory\\_destination\\_policy](#input\\_attach\\_inventory\\_destination\\_policy) | Controls if S3 bucket should have bucket inventory destination policy attached. | `bool` | `false` | no |\n | <a name=\"input_attach_lb_log_delivery_policy\"></a> [attach\\_lb\\_log\\_delivery\\_policy](#input\\_attach\\_lb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ALB/NLB log delivery policy attached | `bool` | `false` | no |\n+| <a name=\"input_attach_inspector_findings_delivery_policy\"></a> [attach\\_inspector\\_findings\\_delivery\\_policy](#input\\_attach\\_inspector\\_findings\\_delivery\\_policy) | Controls if S3 bucket should have Inspector findings delivery policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_policy\"></a> [attach\\_policy](#input\\_attach\\_policy) | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | `bool` | `false` | no |\n | <a name=\"input_attach_public_policy\"></a> [attach\\_public\\_policy](#input\\_attach\\_public\\_policy) | Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket) | `bool` | `true` | no |\n | <a name=\"input_attach_require_latest_tls_policy\"></a> [attach\\_require\\_latest\\_tls\\_policy](#input\\_attach\\_require\\_latest\\_tls\\_policy) | Controls if S3 bucket should require the latest version of TLS | `bool` | `false` | no |\n---\nexamples/s3-inventory/main.tf\n@@ -93,6 +93,7 @@ resource \"random_pet\" \"this\" {\n # https://docs.aws.amazon.com/AmazonS3/latest/userguide/configure-inventory.html#configure-inventory-kms-key-policy\n module \"kms\" {\n source = \"terraform-aws-modules/kms/aws\"\n+ version = \"~> 2.0\"\n \n description = \"Key example for Inventory S3 destination encyrption\"\n deletion_window_in_days = 7\n---\nmain.tf\n@@ -12,7 +12,7 @@ locals {\n \n create_bucket_acl = (var.acl != null && var.acl != \"null\") || length(local.grants) > 0\n \n- attach_policy = var.attach_require_latest_tls_policy || var.attach_access_log_delivery_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_inventory_destination_policy || var.attach_deny_incorrect_encryption_headers || var.attach_deny_incorrect_kms_key_sse || var.attach_deny_unencrypted_object_uploads || var.attach_policy\n+ attach_policy = var.attach_require_latest_tls_policy || var.attach_access_log_delivery_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_inventory_destination_policy || var.attach_deny_incorrect_encryption_headers || var.attach_deny_incorrect_kms_key_sse || var.attach_deny_unencrypted_object_uploads || var.attach_inspector_findings_delivery_policy || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is from Terragrunt\n grants = try(jsondecode(var.grant), var.grant)\n@@ -562,6 +562,7 @@ data \"aws_iam_policy_document\" \"combined\" {\n var.attach_deny_incorrect_kms_key_sse ? data.aws_iam_policy_document.deny_incorrect_kms_key_sse[0].json : \"\",\n var.attach_deny_incorrect_encryption_headers ? data.aws_iam_policy_document.deny_incorrect_encryption_headers[0].json : \"\",\n var.attach_inventory_destination_policy || var.attach_analytics_destination_policy ? data.aws_iam_policy_document.inventory_and_analytics_destination_policy[0].json : \"\",\n+ var.attach_inspector_findings_delivery_policy ? data.aws_iam_policy_document.inspector_findings_delivery_policy[0].json : \"\",\n var.attach_policy ? var.policy : \"\"\n ])\n }\n@@ -909,6 +910,44 @@ data \"aws_iam_policy_document\" \"deny_unencrypted_object_uploads\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"inspector_findings_delivery_policy\" {\n+ count = local.create_bucket && var.attach_inspector_findings_delivery_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"allow-inspector\"\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"s3:PutObject\",\n+ \"s3:PutObjectAcl\",\n+ \"s3:AbortMultipartUpload\"\n+ ]\n+\n+ resources = [\"${aws_s3_bucket.this[0].arn}/*\"]\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"inspector2.amazonaws.com\"]\n+ }\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:SourceAccount\"\n+ values = [\n+ data.aws_caller_identity.current.id\n+ ]\n+ }\n+ condition {\n+ test = \"ArnLike\"\n+ variable = \"aws:SourceArn\"\n+ values = [\n+ format(\"%s%s%s\", \"arn:aws:inspector2:Region:\", data.aws_caller_identity.current.id, \":report/*\")\n+ ]\n+ }\n+ }\n+}\n+\n+\n resource \"aws_s3_bucket_public_access_block\" \"this\" {\n count = local.create_bucket && var.attach_public_policy ? 1 : 0\n \n---\nvariables.tf\n@@ -82,6 +82,12 @@ variable \"attach_deny_unencrypted_object_uploads\" {\n default = false\n }\n \n+variable \"attach_inspector_findings_delivery_policy\" {\n+ description = \"Controls if S3 bucket should have Inspector findings delivery policy attached\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"bucket\" {\n description = \"(Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name.\"\n type = string\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -170,6 +170,7 @@ No modules.\n | [aws_iam_policy_document.deny_insecure_transport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.deny_unencrypted_object_uploads](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.elb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.inspector_findings_delivery_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.inventory_and_analytics_destination_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.lb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.require_latest_tls](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n@@ -198,6 +199,7 @@ No modules.\n | <a name=\"input_attach_elb_log_delivery_policy\"></a> [attach\\_elb\\_log\\_delivery\\_policy](#input\\_attach\\_elb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ELB log delivery policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_inventory_destination_policy\"></a> [attach\\_inventory\\_destination\\_policy](#input\\_attach\\_inventory\\_destination\\_policy) | Controls if S3 bucket should have bucket inventory destination policy attached. | `bool` | `false` | no |\n | <a name=\"input_attach_lb_log_delivery_policy\"></a> [attach\\_lb\\_log\\_delivery\\_policy](#input\\_attach\\_lb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ALB/NLB log delivery policy attached | `bool` | `false` | no |\n+| <a name=\"input_attach_inspector_findings_delivery_policy\"></a> [attach\\_inspector\\_findings\\_delivery\\_policy](#input\\_attach\\_inspector\\_findings\\_delivery\\_policy) | Controls if S3 bucket should have Inspector findings delivery policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_policy\"></a> [attach\\_policy](#input\\_attach\\_policy) | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | `bool` | `false` | no |\n | <a name=\"input_attach_public_policy\"></a> [attach\\_public\\_policy](#input\\_attach\\_public\\_policy) | Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket) | `bool` | `true` | no |\n | <a name=\"input_attach_require_latest_tls_policy\"></a> [attach\\_require\\_latest\\_tls\\_policy](#input\\_attach\\_require\\_latest\\_tls\\_policy) | Controls if S3 bucket should require the latest version of TLS | `bool` | `false` | no |\n---\nexamples/s3-inventory/main.tf\n@@ -93,6 +93,7 @@ resource \"random_pet\" \"this\" {\n # https://docs.aws.amazon.com/AmazonS3/latest/userguide/configure-inventory.html#configure-inventory-kms-key-policy\n module \"kms\" {\n ])\n = \"terraform-aws-modules/kms/aws\"\n+ version = \"~> 2.0\"\n \n description = \"Key example for Inventory S3 destination encyrption\"\n deletion_window_in_days = 7\n---\nmain.tf\n@@ -12,7 +12,7 @@ locals {\n \n create_bucket_acl = (var.acl != null && var.acl != \"null\") || length(local.grants) > 0\n \n- attach_policy = var.attach_require_latest_tls_policy || var.attach_access_log_delivery_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_inventory_destination_policy || var.attach_deny_incorrect_encryption_headers || var.attach_deny_incorrect_kms_key_sse || var.attach_deny_unencrypted_object_uploads || var.attach_policy\n+ attach_policy = var.attach_require_latest_tls_policy || var.attach_access_log_delivery_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_inventory_destination_policy || var.attach_deny_incorrect_encryption_headers || var.attach_deny_incorrect_kms_key_sse || var.attach_deny_unencrypted_object_uploads || var.attach_inspector_findings_delivery_policy || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n grants = try(jsondecode(var.grant), var.grant)\n@@ -562,6 +562,7 @@ data \"aws_iam_policy_document\" \"combined\" {\n var.attach_deny_incorrect_kms_key_sse ? data.aws_iam_policy_document.deny_incorrect_kms_key_sse[0].json : \"\",\n var.attach_deny_incorrect_encryption_headers ? data.aws_iam_policy_document.deny_incorrect_encryption_headers[0].json : \"\",\n var.attach_inventory_destination_policy || var.attach_analytics_destination_policy ? data.aws_iam_policy_document.inventory_and_analytics_destination_policy[0].json : \"\",\n+ var.attach_inspector_findings_delivery_policy ? data.aws_iam_policy_document.inspector_findings_delivery_policy[0].json : \"\",\n var.attach_policy ? var.policy : \"\"\n ])\n }\n@@ -909,6 +910,44 @@ data \"aws_iam_policy_document\" \"deny_unencrypted_object_uploads\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"inspector_findings_delivery_policy\" {\n+ count = local.create_bucket && var.attach_inspector_findings_delivery_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"allow-inspector\"\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"s3:PutObject\",\n+ \"s3:PutObjectAcl\",\n+ \"s3:AbortMultipartUpload\"\n+ ]\n+\n+ resources = [\"${aws_s3_bucket.this[0].arn}/*\"]\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"inspector2.amazonaws.com\"]\n+ }\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:SourceAccount\"\n+ values = [\n+ data.aws_caller_identity.current.id\n+ ]\n+ }\n+ condition {\n+ test = \"ArnLike\"\n+ variable = \"aws:SourceArn\"\n+ values = [\n+ format(\"%s%s%s\", \"arn:aws:inspector2:Region:\", data.aws_caller_identity.current.id, \":report/*\")\n+ ]\n+ }\n+ }\n+}\n+\n+\n resource \"aws_s3_bucket_public_access_block\" \"this\" {\n count = local.create_bucket && var.attach_public_policy ? 1 : 0\n \n---\nvariables.tf\n@@ -82,6 +82,12 @@ variable \"attach_deny_unencrypted_object_uploads\" {\n default = false\n }\n \n+variable \"attach_inspector_findings_delivery_policy\" {\n+ description = \"Controls if S3 bucket should have Inspector findings delivery policy attached\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"bucket\" {\n description = \"(Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name.\"\n type = string\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nAdds conditionals to the ALB/NLB log delivery policy to help prevent the confused deputy problem.\r\n\r\n## Motivation and Context\r\nhttps://github.com/terraform-aws-modules/terraform-aws-s3-bucket/issues/279\r\n\r\n## Breaking Changes\r\nNone\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nREADME.md\n@@ -217,6 +217,9 @@ No modules.\n | <a name=\"input_inventory_self_source_destination\"></a> [inventory\\_self\\_source\\_destination](#input\\_inventory\\_self\\_source\\_destination) | Whether or not the inventory source bucket is also the destination bucket. | `bool` | `false` | no |\n | <a name=\"input_inventory_source_account_id\"></a> [inventory\\_source\\_account\\_id](#input\\_inventory\\_source\\_account\\_id) | The inventory source account id. | `string` | `null` | no |\n | <a name=\"input_inventory_source_bucket_arn\"></a> [inventory\\_source\\_bucket\\_arn](#input\\_inventory\\_source\\_bucket\\_arn) | The inventory source bucket ARN. | `string` | `null` | no |\n+| <a name=\"input_lb_log_delivery_source_accounts\"></a> [lb\\_log\\_delivery\\_source\\_accounts](#input\\_lb\\_log\\_delivery\\_source\\_accounts) | List of AWS Account IDs that are allowed to deliver ALB/NLB logs to this bucket. | `list(string)` | `[]` | no |\n+| <a name=\"input_lb_log_delivery_source_arns\"></a> [lb\\_log\\_delivery\\_source\\_arns](#input\\_lb\\_log\\_delivery\\_source\\_arns) | List of ARNs that are allowed to deliver ALB/NLB logs to this bucket. | `list(string)` | `[]` | no |\n+| <a name=\"input_lb_log_delivery_source_organizations\"></a> [lb\\_log\\_delivery\\_source\\_organizations](#input\\_lb\\_log\\_delivery\\_source\\_organizations) | List of Organization IDs that are allowed to deliver ALB/NLB logs to this bucket. | `list(string)` | `[]` | no |\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `any` | `{}` | no |\n | <a name=\"input_metric_configuration\"></a> [metric\\_configuration](#input\\_metric\\_configuration) | Map containing bucket metric configuration. | `any` | `[]` | no |\n---\nexamples/complete/main.tf\n@@ -70,8 +70,12 @@ module \"log_bucket\" {\n \n control_object_ownership = true\n \n- attach_elb_log_delivery_policy = true\n- attach_lb_log_delivery_policy = true\n+ attach_elb_log_delivery_policy = true\n+ attach_lb_log_delivery_policy = true\n+ lb_log_delivery_source_accounts = [\"123456789012\"]\n+ lb_log_delivery_source_organizations = [\"o-1234567891\"]\n+ lb_log_delivery_source_arns = [\"arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188\"]\n+\n attach_access_log_delivery_policy = true\n attach_deny_insecure_transport_policy = true\n attach_require_latest_tls_policy = true\n---\nmain.tf\n@@ dynamic +674,33 @@ data \"aws_iam_policy_document\" \"lb_log_delivery\" {\n variable = \"s3:x-amz-acl\"\n values = [\"bucket-owner-full-control\"]\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_accounts) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:StringLike\"\n+ variable = \"aws:SourceAccount\"\n+ values = var.lb_log_delivery_source_accounts\n+ }\n+ }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_organizations) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:StringLike\"\n+ variable = \"aws:SourceOrgID\"\n+ values = var.lb_log_delivery_source_organizations\n+ }\n+ }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_arns) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:ArnLike\"\n+ variable = \"aws:SourceArn\"\n+ values = var.lb_log_delivery_source_arns\n+ }\n+ }\n }\n \n statement {\n@@ -695,6 +722,32 @@ data \"aws_iam_policy_document\" \"lb_log_delivery\" {\n aws_s3_bucket.this[0].arn,\n ]\n \n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_accounts) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:StringLike\"\n+ variable = \"aws:SourceAccount\"\n+ values = var.lb_log_delivery_source_accounts\n+ }\n+ }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_organizations) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:StringLike\"\n+ variable = \"aws:SourceOrgID\"\n+ values = var.lb_log_delivery_source_organizations\n+ }\n+ }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_arns) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:ArnLike\"\n+ variable = \"aws:SourceArn\"\n+ values = var.lb_log_delivery_source_arns\n+ }\n+ }\n }\n }\n \n---\nvariables.tf\n@@ -16,6 +16,24 @@ variable \"attach_lb_log_delivery_policy\" {\n default = false\n }\n \n+variable \"lb_log_delivery_source_accounts\" {\n+ description = \"List of AWS Account IDs that are allowed to deliver ALB/NLB logs to this bucket.\"\n+ type = list(string)\n+ default = []\n+}\n+\n+variable \"lb_log_delivery_source_organizations\" {\n+ description = \"List of Organization IDs that are allowed to deliver ALB/NLB logs to this bucket.\"\n+ type = list(string)\n+ default = []\n+}\n+\n+variable \"lb_log_delivery_source_arns\" {\n+ description = \"List of ARNs that are allowed to deliver ALB/NLB logs to this bucket.\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"attach_access_log_delivery_policy\" {\n description = \"Controls if S3 bucket should have S3 access log delivery policy attached\"\n type = bool\n---\nwrappers/main.tf\n@@ -40,6 +40,9 @@ module \"wrapper\" {\n inventory_self_source_destination = try(each.value.inventory_self_source_destination, var.defaults.inventory_self_source_destination, false)\n inventory_source_account_id = try(each.value.inventory_source_account_id, var.defaults.inventory_source_account_id, null)\n inventory_source_bucket_arn = try(each.value.inventory_source_bucket_arn, var.defaults.inventory_source_bucket_arn, null)\n+ lb_log_delivery_source_accounts = try(each.value.lb_log_delivery_source_accounts, var.defaults.lb_log_delivery_source_accounts, [])\n+ lb_log_delivery_source_arns = try(each.value.lb_log_delivery_source_arns, var.defaults.lb_log_delivery_source_arns, [])\n+ lb_log_delivery_source_organizations = try(each.value.lb_log_delivery_source_organizations, var.defaults.lb_log_delivery_source_organizations, [])\n lifecycle_rule = try(each.value.lifecycle_rule, var.defaults.lifecycle_rule, [])\n logging = try(each.value.logging, var.defaults.logging, {})\n metric_configuration = try(each.value.metric_configuration, var.defaults.metric_configuration, [])\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -217,6 +217,9 @@ No modules.\n | <a name=\"input_inventory_self_source_destination\"></a> [inventory\\_self\\_source\\_destination](#input\\_inventory\\_self\\_source\\_destination) | Whether or not the inventory source bucket is also the destination bucket. | `bool` | `false` | no |\n | <a name=\"input_inventory_source_account_id\"></a> [inventory\\_source\\_account\\_id](#input\\_inventory\\_source\\_account\\_id) | The inventory source account id. | `string` | `null` | no |\n | <a name=\"input_inventory_source_bucket_arn\"></a> [inventory\\_source\\_bucket\\_arn](#input\\_inventory\\_source\\_bucket\\_arn) | The inventory source bucket ARN. | `string` | `null` | no |\n+| <a name=\"input_lb_log_delivery_source_accounts\"></a> [lb\\_log\\_delivery\\_source\\_accounts](#input\\_lb\\_log\\_delivery\\_source\\_accounts) | List of AWS Account IDs that are allowed to deliver ALB/NLB logs to this bucket. | `list(string)` | `[]` | no |\n+| <a name=\"input_lb_log_delivery_source_arns\"></a> [lb\\_log\\_delivery\\_source\\_arns](#input\\_lb\\_log\\_delivery\\_source\\_arns) | List of ARNs that are allowed to deliver ALB/NLB logs to this bucket. | `list(string)` | `[]` | no |\n+| <a name=\"input_lb_log_delivery_source_organizations\"></a> [lb\\_log\\_delivery\\_source\\_organizations](#input\\_lb\\_log\\_delivery\\_source\\_organizations) | List of Organization IDs that are allowed to deliver ALB/NLB logs to this bucket. | `list(string)` | `[]` | no |\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `any` | `{}` | no |\n | <a name=\"input_metric_configuration\"></a> [metric\\_configuration](#input\\_metric\\_configuration) | Map containing bucket metric configuration. | `any` | `[]` | no |\n---\nexamples/complete/main.tf\n@@ -70,8 +70,12 @@ module \"log_bucket\" {\n \n control_object_ownership = true\n \n- attach_elb_log_delivery_policy = true\n- attach_lb_log_delivery_policy = true\n+ attach_elb_log_delivery_policy = true\n+ attach_lb_log_delivery_policy = true\n+ lb_log_delivery_source_accounts = [\"123456789012\"]\n+ lb_log_delivery_source_organizations = [\"o-1234567891\"]\n+ lb_log_delivery_source_arns = [\"arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188\"]\n+\n attach_access_log_delivery_policy = true\n attach_deny_insecure_transport_policy = true\n attach_require_latest_tls_policy = true\n---\nmain.tf\n@@ -674,6 +674,33 @@ data \"aws_iam_policy_document\" \"lb_log_delivery\" {\n variable = \"s3:x-amz-acl\"\n values = [\"bucket-owner-full-control\"]\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_accounts) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:StringLike\"\n+ variable = \"aws:SourceAccount\"\n+ values = var.lb_log_delivery_source_accounts\n+ }\n+ }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_organizations) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:StringLike\"\n+ variable = \"aws:SourceOrgID\"\n+ values = var.lb_log_delivery_source_organizations\n+ }\n+ }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_arns) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:ArnLike\"\n+ variable = \"aws:SourceArn\"\n+ values = var.lb_log_delivery_source_arns\n+ }\n+ }\n }\n \n statement {\n@@ -695,6 +722,32 @@ data \"aws_iam_policy_document\" \"lb_log_delivery\" {\n aws_s3_bucket.this[0].arn,\n ]\n \n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_accounts) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:StringLike\"\n+ variable = \"aws:SourceAccount\"\n+ values = var.lb_log_delivery_source_accounts\n+ }\n+ }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_organizations) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:StringLike\"\n+ variable = \"aws:SourceOrgID\"\n+ values = var.lb_log_delivery_source_organizations\n+ }\n+ }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_arns) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:ArnLike\"\n+ variable = \"aws:SourceArn\"\n+ values = var.lb_log_delivery_source_arns\n+ }\n+ }\n }\n }\n \n---\nvariables.tf\n@@ -16,6 +16,24 @@ variable \"attach_lb_log_delivery_policy\" {\n default = false\n }\n \n+variable \"lb_log_delivery_source_accounts\" {\n+ description = \"List of AWS Account IDs that are allowed to deliver ALB/NLB logs to this bucket.\"\n+ type = list(string)\n+ default = []\n+}\n+\n+variable \"lb_log_delivery_source_organizations\" {\n+ description = \"List of Organization IDs that are allowed to deliver ALB/NLB logs to this bucket.\"\n+ type = list(string)\n+ default = []\n+}\n+\n+variable \"lb_log_delivery_source_arns\" {\n+ description = \"List of ARNs that are allowed to deliver ALB/NLB logs to this bucket.\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"attach_access_log_delivery_policy\" {\n description = \"Controls if S3 bucket should have S3 access log delivery policy attached\"\n type = bool\n---\nwrappers/main.tf\n@@ -40,6 +40,9 @@ module \"wrapper\" {\n inventory_self_source_destination = try(each.value.inventory_self_source_destination, var.defaults.inventory_self_source_destination, false)\n inventory_source_account_id = try(each.value.inventory_source_account_id, var.defaults.inventory_source_account_id, null)\n inventory_source_bucket_arn = try(each.value.inventory_source_bucket_arn, var.defaults.inventory_source_bucket_arn, null)\n+ lb_log_delivery_source_accounts = try(each.value.lb_log_delivery_source_accounts, var.defaults.lb_log_delivery_source_accounts, [])\n+ lb_log_delivery_source_arns = try(each.value.lb_log_delivery_source_arns, var.defaults.lb_log_delivery_source_arns, [])\n+ lb_log_delivery_source_organizations = try(each.value.lb_log_delivery_source_organizations, var.defaults.lb_log_delivery_source_organizations, [])\n lifecycle_rule = try(each.value.lifecycle_rule, var.defaults.lifecycle_rule, [])\n logging = try(each.value.logging, var.defaults.logging, {})\n metric_configuration = try(each.value.metric_configuration, var.defaults.metric_configuration, [])\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -217,6 +217,9 @@ No modules.\n | <a name=\"input_inventory_self_source_destination\"></a> [inventory\\_self\\_source\\_destination](#input\\_inventory\\_self\\_source\\_destination) | Whether or not the inventory source bucket is also destination bucket. | `bool` | `false` | no |\n | <a name=\"input_inventory_source_account_id\"></a> [inventory\\_source\\_account\\_id](#input\\_inventory\\_source\\_account\\_id) | The inventory source account id. | `string` | `null` | no |\n | <a name=\"input_inventory_source_bucket_arn\"></a> [inventory\\_source\\_bucket\\_arn](#input\\_inventory\\_source\\_bucket\\_arn) | The inventory source bucket ARN. | `string` | `null` | no |\n+| <a name=\"input_lb_log_delivery_source_accounts\"></a> [lb\\_log\\_delivery\\_source\\_accounts](#input\\_lb\\_log\\_delivery\\_source\\_accounts) | List of AWS Account IDs that are allowed to deliver ALB/NLB logs to this bucket. | `list(string)` | `[]` | no |\n+| <a name=\"input_lb_log_delivery_source_arns\"></a> [lb\\_log\\_delivery\\_source\\_arns](#input\\_lb\\_log\\_delivery\\_source\\_arns) | List of ARNs that are allowed to deliver ALB/NLB logs to this bucket. | `list(string)` | `[]` | no |\n+| <a name=\"input_lb_log_delivery_source_organizations\"></a> [lb\\_log\\_delivery\\_source\\_organizations](#input\\_lb\\_log\\_delivery\\_source\\_organizations) | List of Organization IDs that are allowed to deliver ALB/NLB logs to this bucket. | `list(string)` | `[]` | no |\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `any` | `{}` | no |\n | <a name=\"input_metric_configuration\"></a> [metric\\_configuration](#input\\_metric\\_configuration) | Map containing bucket metric configuration. | `any` | `[]` | no |\n---\nexamples/complete/main.tf\n@@ -70,8 +70,12 @@ module \"log_bucket\" {\n \n control_object_ownership = true\n \n- attach_elb_log_delivery_policy = true\n- attach_lb_log_delivery_policy = true\n+ attach_elb_log_delivery_policy = true\n+ attach_lb_log_delivery_policy = true\n+ lb_log_delivery_source_accounts = [\"123456789012\"]\n+ lb_log_delivery_source_organizations = [\"o-1234567891\"]\n+ lb_log_delivery_source_arns = [\"arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188\"]\n+\n attach_access_log_delivery_policy = true\n attach_deny_insecure_transport_policy = true\n attach_require_latest_tls_policy = true\n---\nmain.tf\n@@ -674,6 +674,33 @@ data \"aws_iam_policy_document\" \"lb_log_delivery\" {\n variable = \"s3:x-amz-acl\"\n values = [\"bucket-owner-full-control\"]\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_accounts) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:StringLike\"\n+ variable = \"aws:SourceAccount\"\n+ values = var.lb_log_delivery_source_accounts\n+ }\n+ }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_organizations) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:StringLike\"\n+ variable = \"aws:SourceOrgID\"\n+ values = var.lb_log_delivery_source_organizations\n+ }\n+ }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_arns) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:ArnLike\"\n+ variable = \"aws:SourceArn\"\n+ values = var.lb_log_delivery_source_arns\n+ }\n+ }\n }\n \n statement {\n@@ -695,6 +722,32 @@ data \"aws_iam_policy_document\" \"lb_log_delivery\" {\n aws_s3_bucket.this[0].arn,\n ]\n \n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_accounts) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:StringLike\"\n+ variable = \"aws:SourceAccount\"\n+ values = var.lb_log_delivery_source_accounts\n+ }\n+ }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_organizations) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:StringLike\"\n+ variable = \"aws:SourceOrgID\"\n+ values = var.lb_log_delivery_source_organizations\n+ }\n+ }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_arns) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:ArnLike\"\n+ variable = \"aws:SourceArn\"\n+ values = var.lb_log_delivery_source_arns\n+ }\n+ }\n }\n }\n \n---\nvariables.tf\n@@ -16,6 +16,24 @@ variable \"attach_lb_log_delivery_policy\" {\n default = false\n }\n \n+variable \"lb_log_delivery_source_accounts\" {\n+ description = \"List of AWS Account IDs that are allowed to deliver ALB/NLB logs to this bucket.\"\n+ type = list(string)\n+ default = []\n+}\n+\n+variable \"lb_log_delivery_source_organizations\" {\n+ description = \"List of Organization IDs that are allowed to deliver ALB/NLB logs to this bucket.\"\n+ type = list(string)\n+ default = []\n+}\n+\n+variable \"lb_log_delivery_source_arns\" {\n+ description = \"List of ARNs that are allowed to deliver ALB/NLB logs to this bucket.\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"attach_access_log_delivery_policy\" {\n description = \"Controls if S3 bucket should have S3 access log delivery policy attached\"\n type = bool\n---\nwrappers/main.tf\n@@ -40,6 +40,9 @@ module \"wrapper\" {\n inventory_self_source_destination = try(each.value.inventory_self_source_destination, var.defaults.inventory_self_source_destination, false)\n inventory_source_account_id = try(each.value.inventory_source_account_id, var.defaults.inventory_source_account_id, null)\n inventory_source_bucket_arn = try(each.value.inventory_source_bucket_arn, var.defaults.inventory_source_bucket_arn, null)\n+ lb_log_delivery_source_accounts = try(each.value.lb_log_delivery_source_accounts, var.defaults.lb_log_delivery_source_accounts, [])\n+ lb_log_delivery_source_arns = try(each.value.lb_log_delivery_source_arns, var.defaults.lb_log_delivery_source_arns, [])\n+ lb_log_delivery_source_organizations = try(each.value.lb_log_delivery_source_organizations, var.defaults.lb_log_delivery_source_organizations, [])\n lifecycle_rule = try(each.value.lifecycle_rule, var.defaults.lifecycle_rule, [])\n logging = try(each.value.logging, var.defaults.logging, {})\n metric_configuration = try(each.value.metric_configuration, var.defaults.metric_configuration, [])\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -217,6 +217,9 @@ No modules.\n | <a name=\"input_inventory_self_source_destination\"></a> [inventory\\_self\\_source\\_destination](#input\\_inventory\\_self\\_source\\_destination) | Whether or not the inventory source bucket is also the destination bucket. | `bool` | `false` | no |\n | <a name=\"input_inventory_source_account_id\"></a> [inventory\\_source\\_account\\_id](#input\\_inventory\\_source\\_account\\_id) | The inventory source account id. | `string` | `null` | no |\n | <a name=\"input_inventory_source_bucket_arn\"></a> [inventory\\_source\\_bucket\\_arn](#input\\_inventory\\_source\\_bucket\\_arn) | The inventory source bucket ARN. | `string` | `null` | no |\n+| <a name=\"input_lb_log_delivery_source_accounts\"></a> [lb\\_log\\_delivery\\_source\\_accounts](#input\\_lb\\_log\\_delivery\\_source\\_accounts) | List of AWS Account IDs that are allowed to deliver ALB/NLB logs to this bucket. | `list(string)` | `[]` | no |\n+| <a name=\"input_lb_log_delivery_source_arns\"></a> [lb\\_log\\_delivery\\_source\\_arns](#input\\_lb\\_log\\_delivery\\_source\\_arns) | List of ARNs that are allowed to deliver ALB/NLB logs to this bucket. | `list(string)` | `[]` | no |\n+| <a name=\"input_lb_log_delivery_source_organizations\"></a> [lb\\_log\\_delivery\\_source\\_organizations](#input\\_lb\\_log\\_delivery\\_source\\_organizations) | List of Organization IDs that are allowed to deliver ALB/NLB logs to this bucket. | `list(string)` | `[]` | no |\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `any` | `{}` | no |\n | <a name=\"input_metric_configuration\"></a> [metric\\_configuration](#input\\_metric\\_configuration) | Map containing bucket metric configuration. | `any` | `[]` | no |\n---\nexamples/complete/main.tf\n@@ -70,8 +70,12 @@ module \"log_bucket\" {\n \n control_object_ownership = true\n \n- attach_elb_log_delivery_policy = true\n- attach_lb_log_delivery_policy = true\n+ attach_elb_log_delivery_policy = true\n+ attach_lb_log_delivery_policy = true\n+ lb_log_delivery_source_accounts = [\"123456789012\"]\n+ lb_log_delivery_source_organizations = [\"o-1234567891\"]\n+ lb_log_delivery_source_arns = [\"arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188\"]\n+\n attach_access_log_delivery_policy = true\n attach_deny_insecure_transport_policy = true\n attach_require_latest_tls_policy = true\n---\nmain.tf\n@@ -674,6 +674,33 @@ data \"aws_iam_policy_document\" \"lb_log_delivery\" {\n variable = \"s3:x-amz-acl\"\n values = [\"bucket-owner-full-control\"]\n }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_accounts) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:StringLike\"\n+ variable = = values = var.lb_log_delivery_source_accounts\n+ }\n+ }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_organizations) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:StringLike\"\n+ variable = \"aws:SourceOrgID\"\n+ values = var.lb_log_delivery_source_organizations\n+ }\n+ }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_arns) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:ArnLike\"\n+ variable = \"aws:SourceArn\"\n+ values = var.lb_log_delivery_source_arns\n+ }\n+ }\n }\n \n statement {\n@@ -695,6 +722,32 @@ data \"aws_iam_policy_document\" \"lb_log_delivery\" {\n aws_s3_bucket.this[0].arn,\n ]\n \n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_accounts) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:StringLike\"\n+ variable = \"aws:SourceAccount\"\n+ values = var.lb_log_delivery_source_accounts\n+ }\n+ }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_organizations) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:StringLike\"\n+ variable = \"aws:SourceOrgID\"\n+ values = var.lb_log_delivery_source_organizations\n+ }\n+ }\n+\n+ dynamic \"condition\" {\n+ for_each = length(var.lb_log_delivery_source_arns) != 0 ? [true] : []\n+ content {\n+ test = \"ForAnyValue:ArnLike\"\n+ variable = \"aws:SourceArn\"\n+ values = var.lb_log_delivery_source_arns\n+ }\n+ }\n }\n }\n \n---\nvariables.tf\n@@ -16,6 +16,24 @@ variable \"attach_lb_log_delivery_policy\" {\n default = false\n }\n \n+variable \"lb_log_delivery_source_accounts\" {\n+ description = \"List of AWS Account IDs that are allowed to deliver ALB/NLB logs to this bucket.\"\n+ type = list(string)\n+ default = []\n+}\n+\n+variable \"lb_log_delivery_source_organizations\" {\n+ description = \"List of Organization IDs that are allowed to deliver ALB/NLB logs to this bucket.\"\n+ type = list(string)\n+ default = []\n+}\n+\n+variable \"lb_log_delivery_source_arns\" {\n+ description = \"List of ARNs that are allowed to deliver ALB/NLB logs to this bucket.\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"attach_access_log_delivery_policy\" {\n description = \"Controls if S3 bucket should have S3 access log delivery policy attached\"\n type = bool\n---\nwrappers/main.tf\n@@ -40,6 +40,9 @@ module \"wrapper\" {\n inventory_self_source_destination = try(each.value.inventory_self_source_destination, var.defaults.inventory_self_source_destination, false)\n inventory_source_account_id = try(each.value.inventory_source_account_id, var.defaults.inventory_source_account_id, null)\n inventory_source_bucket_arn = try(each.value.inventory_source_bucket_arn, var.defaults.inventory_source_bucket_arn, null)\n+ lb_log_delivery_source_accounts = try(each.value.lb_log_delivery_source_accounts, var.defaults.lb_log_delivery_source_accounts, [])\n+ lb_log_delivery_source_arns = try(each.value.lb_log_delivery_source_arns, var.defaults.lb_log_delivery_source_arns, [])\n+ lb_log_delivery_source_organizations = try(each.value.lb_log_delivery_source_organizations, var.defaults.lb_log_delivery_source_organizations, [])\n lifecycle_rule = try(each.value.lifecycle_rule, var.defaults.lifecycle_rule, [])\n logging = try(each.value.logging, var.defaults.logging, {})\n metric_configuration = try(each.value.metric_configuration, var.defaults.metric_configuration, [])\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n\r\nCandidate for smallest PR in history 😄 just a typo I spotted earlier today when I was using this module.\r\nI promised myself I'd come back and raise a PR for it. Scouts rule and all that!\r\n\r\n## Motivation and Context\r\n\r\nN/A\r\n\r\n## Breaking Changes\r\n\r\nNone\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n\r\nN/A\r\n\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n\n\n---\n\nChoice A:\nREADME.md\n@@ -182,7 +182,7 @@ No modules.\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_acceleration_status\"></a> [acceleration\\_status](#input\\_acceleration\\_status) | (Optional) Sets the accelerate configuration of an existing bucket. Can be Enabled or Suspended. | `string` | `null` | no |\n | <a name=\"input_access_log_delivery_policy_source_accounts\"></a> [access\\_log\\_delivery\\_policy\\_source\\_accounts](#input\\_access\\_log\\_delivery\\_policy\\_source\\_accounts) | (Optional) List of AWS Account IDs should be allowed to deliver access logs to this bucket. | `list(string)` | `[]` | no |\n-| <a name=\"input_access_log_delivery_policy_source_buckets\"></a> [access\\_log\\_delivery\\_policy\\_source\\_buckets](#input\\_access\\_log\\_delivery\\_policy\\_source\\_buckets) | (Optional) List of S3 bucket ARNs wich should be allowed to deliver access logs to this bucket. | `list(string)` | `[]` | no |\n+| <a name=\"input_access_log_delivery_policy_source_buckets\"></a> [access\\_log\\_delivery\\_policy\\_source\\_buckets](#input\\_access\\_log\\_delivery\\_policy\\_source\\_buckets) | (Optional) List of S3 bucket ARNs which should be allowed to deliver access logs to this bucket. | `list(string)` | `[]` | no |\n | <a name=\"input_acl\"></a> [acl](#input\\_acl) | (Optional) The canned ACL to apply. Conflicts with `grant` | `string` | `null` | no |\n | <a name=\"input_allowed_kms_key_arn\"></a> [allowed\\_kms\\_key\\_arn](#input\\_allowed\\_kms\\_key\\_arn) | The ARN of KMS key which should be allowed in PutObject | `string` | `null` | no |\n | <a name=\"input_analytics_configuration\"></a> [analytics\\_configuration](#input\\_analytics\\_configuration) | Map containing bucket analytics configuration. | `any` | `{}` | no |\n---\nvariables.tf\n@@ -155,7 +155,7 @@ variable \"logging\" {\n }\n \n variable \"access_log_delivery_policy_source_buckets\" {\n- description = \"(Optional) List of S3 bucket ARNs wich should be allowed to deliver access logs to this bucket.\"\n+ description = \"(Optional) List of S3 bucket ARNs which should be allowed to deliver access logs to this (Optional) type = list(string)\n default = []\n }\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -182,7 +182,7 @@ No modules.\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_acceleration_status\"></a> [acceleration\\_status](#input\\_acceleration\\_status) | (Optional) Sets the accelerate configuration of an existing bucket. Can be Enabled or Suspended. | `string` | `null` | no |\n | <a name=\"input_access_log_delivery_policy_source_accounts\"></a> [access\\_log\\_delivery\\_policy\\_source\\_accounts](#input\\_access\\_log\\_delivery\\_policy\\_source\\_accounts) | (Optional) List of AWS Account IDs should be allowed to deliver access logs to this bucket. | `list(string)` | `[]` | no |\n-| <a name=\"input_access_log_delivery_policy_source_buckets\"></a> [access\\_log\\_delivery\\_policy\\_source\\_buckets](#input\\_access\\_log\\_delivery\\_policy\\_source\\_buckets) | (Optional) List of S3 bucket ARNs wich should be allowed to deliver access logs to this bucket. | `list(string)` | `[]` | no |\n+| <a name=\"input_access_log_delivery_policy_source_buckets\"></a> [access\\_log\\_delivery\\_policy\\_source\\_buckets](#input\\_access\\_log\\_delivery\\_policy\\_source\\_buckets) | (Optional) List of S3 bucket ARNs which should be allowed to deliver access logs to this bucket. | `list(string)` | `[]` | no |\n | <a name=\"input_acl\"></a> [acl](#input\\_acl) | (Optional) The canned ACL to apply. Conflicts with `grant` | `string` | `null` | no |\n | <a name=\"input_allowed_kms_key_arn\"></a> [allowed\\_kms\\_key\\_arn](#input\\_allowed\\_kms\\_key\\_arn) | The ARN of KMS key which should be allowed in PutObject | `string` | `null` | no |\n | <a name=\"input_analytics_configuration\"></a> [analytics\\_configuration](#input\\_analytics\\_configuration) | Map containing bucket analytics configuration. | `any` | `{}` | no |\n---\nvariables.tf\n@@ -155,7 +155,7 @@ variable \"logging\" {\n }\n \n variable \"access_log_delivery_policy_source_buckets\" {\n- description = \"(Optional) List of S3 bucket ARNs | should be allowed to deliver access logs to this bucket.\"\n+ description = \"(Optional) List of S3 bucket ARNs which should be allowed to deliver access logs to this bucket.\"\n type = list(string)\n default = []\n }\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -182,7 +182,7 @@ No modules.\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_acceleration_status\"></a> [acceleration\\_status](#input\\_acceleration\\_status) | (Optional) Sets the accelerate configuration of an existing bucket. Can be Enabled or Suspended. | `string` | `null` | no |\n | <a name=\"input_access_log_delivery_policy_source_accounts\"></a> [access\\_log\\_delivery\\_policy\\_source\\_accounts](#input\\_access\\_log\\_delivery\\_policy\\_source\\_accounts) | (Optional) List of AWS Account IDs should be allowed to deliver access logs to this bucket. | `list(string)` | `[]` | no |\n-| <a name=\"input_access_log_delivery_policy_source_buckets\"></a> [access\\_log\\_delivery\\_policy\\_source\\_buckets](#input\\_access\\_log\\_delivery\\_policy\\_source\\_buckets) | (Optional) List of S3 bucket ARNs wich should be allowed to deliver access logs to this bucket. | `list(string)` | `[]` | no |\n+| <a name=\"input_access_log_delivery_policy_source_buckets\"></a> [access\\_log\\_delivery\\_policy\\_source\\_buckets](#input\\_access\\_log\\_delivery\\_policy\\_source\\_buckets) | (Optional) List of S3 bucket ARNs which should be allowed to deliver access logs to this bucket. | `list(string)` | `[]` | no |\n | <a name=\"input_acl\"></a> [acl](#input\\_acl) | (Optional) The canned ACL to apply. Conflicts with `grant` | `string` | `null` | no |\n | <a name=\"input_allowed_kms_key_arn\"></a> [allowed\\_kms\\_key\\_arn](#input\\_allowed\\_kms\\_key\\_arn) | The ARN of KMS key which should be allowed in PutObject | `string` | `null` | no |\n | <a name=\"input_analytics_configuration\"></a> [analytics\\_configuration](#input\\_analytics\\_configuration) | Map containing bucket analytics configuration. | `any` | `{}` | no |\n---\nvariables.tf\n@@ -155,7 +155,7 @@ variable \"logging\" {\n }\n \n variable \"access_log_delivery_policy_source_buckets\" {\n- description = \"(Optional) List of S3 bucket ARNs wich should be allowed to deliver access logs to this bucket.\"\n+ description = \"(Optional) List of S3 bucket ARNs which should be allowed to deliver access logs to this bucket.\"\n type = list(string)\n default = []\n }\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -182,7 +182,7 @@ No modules.\n |------|-------------|------|---------|:--------:|\n | <a name=\"input_acceleration_status\"></a> [acceleration\\_status](#input\\_acceleration\\_status) | (Optional) Sets the accelerate configuration of an existing bucket. Can be Enabled or Suspended. | `string` | `null` | no |\n | <a name=\"input_access_log_delivery_policy_source_accounts\"></a> [access\\_log\\_delivery\\_policy\\_source\\_accounts](#input\\_access\\_log\\_delivery\\_policy\\_source\\_accounts) | (Optional) List of AWS Account IDs should be allowed to deliver access logs to this bucket. | `list(string)` | `[]` | no |\n-| <a name=\"input_access_log_delivery_policy_source_buckets\"></a> [access\\_log\\_delivery\\_policy\\_source\\_buckets](#input\\_access\\_log\\_delivery\\_policy\\_source\\_buckets) | (Optional) List of S3 bucket ARNs wich should be allowed to deliver access logs to this bucket. | `list(string)` | `[]` | no |\n+| <a name=\"input_access_log_delivery_policy_source_buckets\"></a> [access\\_log\\_delivery\\_policy\\_source\\_buckets](#input\\_access\\_log\\_delivery\\_policy\\_source\\_buckets) | (Optional) List of S3 bucket ARNs which should be allowed to deliver access logs to this bucket. | `list(string)` | `[]` | no |\n | <a name=\"input_acl\"></a> [acl](#input\\_acl) | (Optional) The canned ACL to apply. Conflicts with `grant` | `string` | `null` | no |\n | <a name=\"input_allowed_kms_key_arn\"></a> [allowed\\_kms\\_key\\_arn](#input\\_allowed\\_kms\\_key\\_arn) | The ARN of | key which should be allowed in PutObject | `string` | `null` | no |\n | <a name=\"input_analytics_configuration\"></a> [analytics\\_configuration](#input\\_analytics\\_configuration) | Map containing bucket analytics configuration. | `any` | `{}` | no |\n---\nvariables.tf\n@@ -155,7 +155,7 @@ variable \"logging\" {\n }\n \n variable \"access_log_delivery_policy_source_buckets\" {\n- description = \"(Optional) List of S3 bucket ARNs wich should be allowed to deliver access logs to this bucket.\"\n+ description = \"(Optional) List of S3 bucket ARNs which should be allowed to deliver access logs to this bucket.\"\n type = list(string)\n default = []\n }\n---\n\n\n---\n" } ]
C
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\n\n- Update CI workflow versions to remove deprecated runtime warnings\n\n## Motivation and Context\n\n- Updates our workflows to use the latest versions\n- Removes the `deprecated runtime` warnings from the workflow execution output\n\n## Breaking Changes\n\n- No\n\n## How Has This Been Tested?\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\n- [ ] I have executed `pre-commit run -a` on my pull request\n\n\n---\n\nChoice A:\n.github/workflows/lock.yml\n@@ -8,7 +8,7 @@ jobs:\n lock:\n runs-on: ubuntu-latest\n steps:\n- - uses: dessant/lock-threads@v4\n+ - uses: dessant/lock-threads@v5\n with:\n github-token: ${{ secrets.GITHUB_TOKEN }}\n issue-comment: >\n---\n.github/workflows/pr-title.yml\n@@ -14,7 +14,7 @@ jobs:\n steps:\n # Please look up the latest version from\n # https://github.com/amannn/action-semantic-pull-request/releases\n- - uses: amannn/[email protected]\n+ - uses: amannn/[email protected]\n env:\n GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n with:\n---\n.github/workflows/pre-commit.yml\n@@ -8,7 +8,7 @@ on:\n \n env:\n TERRAFORM_DOCS_VERSION: v0.16.0\n- TFLINT_VERSION: v0.44.1\n+ TFLINT_VERSION: v0.50.3\n \n jobs:\n collectInputs:\n@@ -18,11 +18,11 @@ jobs:\n directories: ${{ steps.dirs.outputs.directories }}\n steps:\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -32,19 +32,27 @@ jobs:\n matrix:\n directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}\n steps:\n+ # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n+ - name: Delete huge unnecessary tools folder\n+ run: |\n+ rm -rf /opt/hostedtoolcache/CodeQL\n+ rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk\n+ rm -rf /opt/hostedtoolcache/Ruby\n+ rm -rf /opt/hostedtoolcache/go\n+\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -53,7 +61,7 @@ jobs:\n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -64,18 +72,26 @@ jobs:\n runs-on: ubuntu-latest\n needs: collectInputs\n steps:\n+ # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n+ - name: Delete huge unnecessary tools folder\n+ run: |\n+ rm -rf /opt/hostedtoolcache/CodeQL\n+ rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk\n+ rm -rf /opt/hostedtoolcache/Ruby\n+ rm -rf /opt/hostedtoolcache/go\n+\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n with:\n ref: ${{ github.event.pull_request.head.ref }}\n repository: ${{github.event.pull_request.head.repo.full_name}}\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n---\n.github/workflows/release.yml\n@@ -20,18 +20,18 @@ jobs:\n if: github.repository_owner == 'terraform-aws-modules'\n steps:\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n with:\n persist-credentials: false\n fetch-depth: 0\n \n - name: Release\n- uses: cycjimmy/semantic-release-action@v3\n+ uses: cycjimmy/semantic-release-action@v4\n with:\n- semantic_version: 18.0.0\n+ semantic_version: 23.0.2\n extra_plugins: |\n- @semantic-release/[email protected]\n- @semantic-release/[email protected]\n- [email protected]\n+ @semantic-release/[email protected]\n+ @semantic-release/[email protected]\n+ [email protected]\n env:\n GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}\n---\n.github/workflows/stale-actions.yaml\n@@ -7,7 +7,7 @@ jobs:\n stale:\n runs-on: ubuntu-latest\n steps:\n- - uses: actions/stale@v6\n+ - uses: actions/stale@v9\n with:\n repo-token: ${{ secrets.GITHUB_TOKEN }}\n # Staling issues and PR's\n---\n.pre-commit-config.yaml\n@@ -1,10 +1,9 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.86.0\n+ rev: v1.88.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n- - id: terraform_validate\n - id: terraform_docs\n args:\n - '--args=--lockfile=false'\n@@ -23,8 +22,11 @@ repos:\n - '--args=--only=terraform_required_providers'\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n+ - '--args=--only=terraform_unused_required_providers'\n+ - id: terraform_validate\n - repo: https://github.com/pre-commit/pre-commit-hooks\n rev: v4.5.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n+ - id: trailing-whitespace\n---\nUPGRADE-3.0.md\n@@ -7,7 +7,7 @@ If you find a bug, please open an issue with supporting configuration to reprodu\n ## List of backwards incompatible changes\n \n - Terraform AWS provider minimum version is now `v4.5.0` in order to have forward compatibility with Terraform AWS provider `v4.x`. Using the latest version of `v4` is highly recommended, if possible.\n-- If you are using AWS provider `v3.75` the latest supported version of this module is `v3.0.1` \n+- If you are using AWS provider `v3.75` the latest supported version of this module is `v3.0.1`\n - Main group of changes is related to refactoring of `aws_s3_bucket` resource into several smaller resources. Read [`S3 bucket refactor` section in the official Terraform AWS Provider Version 4 Upgrade Guide](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/guides/version-4-upgrade#s3-bucket-refactor) and [discussion around these changes](https://github.com/hashicorp/terraform-provider-aws/issues/23106).\n - `modules/object`: Changed resource type from `aws_bucket_s3_object` to `aws_s3_object`. After upgrade, on the next apply, Terraform will recreate the object. If you prefer to not have Terraform recreate the object, import the object using `aws_s3_object`. [Read more](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object#import).\n \n---\n\n\n---\n\nChoice B:\n.github/workflows/lock.yml\n@@ -8,7 +8,7 @@ jobs:\n lock:\n runs-on: ubuntu-latest\n steps:\n- - uses: dessant/lock-threads@v4\n+ - uses: dessant/lock-threads@v5\n with:\n github-token: ${{ secrets.GITHUB_TOKEN }}\n issue-comment: >\n---\n.github/workflows/pr-title.yml\n@@ -14,7 +14,7 @@ jobs:\n steps:\n # Please look up the latest version from\n # https://github.com/amannn/action-semantic-pull-request/releases\n- - uses: amannn/[email protected]\n+ - uses: amannn/[email protected]\n env:\n GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n with:\n---\n.github/workflows/pre-commit.yml\n@@ -8,7 +8,7 @@ on:\n \n env:\n TERRAFORM_DOCS_VERSION: v0.16.0\n- TFLINT_VERSION: v0.44.1\n+ TFLINT_VERSION: v0.50.3\n \n jobs:\n collectInputs:\n@@ -18,11 +18,11 @@ jobs:\n directories: ${{ steps.dirs.outputs.directories }}\n steps:\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -32,19 +32,27 @@ jobs:\n matrix:\n directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}\n steps:\n+ # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n+ - name: Delete huge unnecessary tools folder\n+ run: |\n+ rm -rf /opt/hostedtoolcache/CodeQL\n+ rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk\n+ rm -rf /opt/hostedtoolcache/Ruby\n+ rm -rf /opt/hostedtoolcache/go\n+\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -53,7 +61,7 @@ jobs:\n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -64,18 +72,26 @@ jobs:\n runs-on: ubuntu-latest\n needs: collectInputs\n steps:\n+ # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n+ - name: Delete huge unnecessary tools folder\n+ run: |\n+ rm -rf /opt/hostedtoolcache/CodeQL\n+ rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk\n+ rm -rf /opt/hostedtoolcache/Ruby\n+ rm -rf /opt/hostedtoolcache/go\n+\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n with:\n ref: ${{ github.event.pull_request.head.ref }}\n repository: ${{github.event.pull_request.head.repo.full_name}}\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n---\n.github/workflows/release.yml\n@@ -20,18 +20,18 @@ jobs:\n if: github.repository_owner == 'terraform-aws-modules'\n steps:\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n with:\n persist-credentials: false\n fetch-depth: 0\n \n - name: Release\n- uses: cycjimmy/semantic-release-action@v3\n+ uses: cycjimmy/semantic-release-action@v4\n with:\n- semantic_version: 18.0.0\n+ semantic_version: 23.0.2\n extra_plugins: |\n- @semantic-release/[email protected]\n- @semantic-release/[email protected]\n- [email protected]\n+ @semantic-release/[email protected]\n+ @semantic-release/[email protected]\n+ [email protected]\n env:\n GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}\n---\n.github/workflows/stale-actions.yaml\n@@ -7,7 +7,7 @@ jobs:\n stale:\n runs-on: ubuntu-latest\n steps:\n- - uses: actions/stale@v6\n+ - uses: actions/stale@v9\n with:\n repo-token: ${{ secrets.GITHUB_TOKEN }}\n # Staling issues and PR's\n---\n.pre-commit-config.yaml\n@@ -1,10 +1,9 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.86.0\n+ rev: v1.88.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n- - id: terraform_validate\n - id: terraform_docs\n args:\n - '--args=--lockfile=false'\n@@ -23,8 +22,11 @@ repos:\n - '--args=--only=terraform_required_providers'\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n+ - '--args=--only=terraform_unused_required_providers'\n+ - id: terraform_validate\n - repo: https://github.com/pre-commit/pre-commit-hooks\n rev: v4.5.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n+ - id: trailing-whitespace\n---\nUPGRADE-3.0.md\n@@ -7,7 +7,7 @@ If you find a bug, please open an issue with supporting configuration to reprodu\n ## List of backwards incompatible changes\n \n - Terraform AWS provider minimum version is now `v4.5.0` in order to have forward compatibility with Terraform AWS provider `v4.x`. Using the latest version of `v4` is highly recommended, if possible.\n-- If you are using AWS provider `v3.75` the latest supported version of this module is `v3.0.1` \n+- If you are using AWS provider `v3.75` the latest supported version of this module is `v3.0.1`\n - Main group of changes is related to refactoring of `aws_s3_bucket` resource into several smaller resources. Read [`S3 bucket refactor` section in the official Terraform AWS Provider Version 4 Upgrade Guide](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/guides/version-4-upgrade#s3-bucket-refactor) and [discussion around these changes](https://github.com/hashicorp/terraform-provider-aws/issues/23106).\n - `modules/object`: Changed resource type from `aws_bucket_s3_object` to `aws_s3_object`. After upgrade, on the next apply, Terraform will recreate the object. If you prefer to not have Terraform recreate the object, import the object using `aws_s3_object`. [Read more](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object#import).\n \n---\n\n\n---\n\nChoice C:\n.github/workflows/lock.yml\n@@ -8,7 +8,7 @@ jobs:\n lock:\n runs-on: ubuntu-latest\n steps:\n- - uses: dessant/lock-threads@v4\n+ - uses: dessant/lock-threads@v5\n with:\n github-token: ${{ secrets.GITHUB_TOKEN }}\n issue-comment: >\n---\n.github/workflows/pr-title.yml\n@@ -14,7 +14,7 @@ jobs:\n steps:\n # Please look up the latest version from\n # https://github.com/amannn/action-semantic-pull-request/releases\n- - uses: amannn/[email protected]\n+ - uses: amannn/[email protected]\n env:\n GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n with:\n---\n.github/workflows/pre-commit.yml\n@@ -8,7 +8,7 @@ on:\n \n env:\n TERRAFORM_DOCS_VERSION: v0.16.0\n- TFLINT_VERSION: v0.44.1\n+ TFLINT_VERSION: v0.50.3\n \n jobs:\n collectInputs:\n@@ -18,11 +18,11 @@ jobs:\n directories: ${{ steps.dirs.outputs.directories }}\n steps:\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -32,19 +32,27 @@ jobs:\n matrix:\n directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}\n steps:\n+ # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n+ - name: Delete huge unnecessary tools folder\n+ run: |\n+ rm -rf /opt/hostedtoolcache/CodeQL\n+ rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk\n+ rm -rf /opt/hostedtoolcache/Ruby\n+ rm -rf /opt/hostedtoolcache/go\n+\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -53,7 +61,7 @@ jobs:\n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -64,18 +72,26 @@ jobs:\n runs-on: ubuntu-latest\n needs: collectInputs\n steps:\n+ # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n+ - name: Delete huge unnecessary tools folder\n+ run: |\n+ rm -rf /opt/hostedtoolcache/CodeQL\n+ rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk\n+ rm -rf /opt/hostedtoolcache/Ruby\n+ rm -rf /opt/hostedtoolcache/go\n+\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n with:\n ref: ${{ github.event.pull_request.head.ref }}\n repository: ${{github.event.pull_request.head.repo.full_name}}\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n \n - name: Pre-commit steps.minMax.outputs.maxVersion ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n---\n.github/workflows/release.yml\n@@ -20,18 +20,18 @@ jobs:\n if: github.repository_owner == 'terraform-aws-modules'\n steps:\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n with:\n persist-credentials: false\n fetch-depth: 0\n \n - name: Release\n- uses: cycjimmy/semantic-release-action@v3\n+ uses: cycjimmy/semantic-release-action@v4\n with:\n- semantic_version: 18.0.0\n+ semantic_version: 23.0.2\n extra_plugins: |\n- @semantic-release/[email protected]\n- @semantic-release/[email protected]\n- [email protected]\n+ @semantic-release/[email protected]\n+ @semantic-release/[email protected]\n+ [email protected]\n env:\n GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}\n---\n.github/workflows/stale-actions.yaml\n@@ -7,7 +7,7 @@ jobs:\n stale:\n runs-on: ubuntu-latest\n steps:\n- - uses: actions/stale@v6\n+ - uses: actions/stale@v9\n with:\n repo-token: ${{ secrets.GITHUB_TOKEN }}\n # Staling issues and PR's\n---\n.pre-commit-config.yaml\n@@ -1,10 +1,9 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.86.0\n+ rev: v1.88.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n- - id: terraform_validate\n - id: terraform_docs\n args:\n - '--args=--lockfile=false'\n@@ -23,8 +22,11 @@ repos:\n - '--args=--only=terraform_required_providers'\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n+ - '--args=--only=terraform_unused_required_providers'\n+ - id: terraform_validate\n - repo: https://github.com/pre-commit/pre-commit-hooks\n rev: v4.5.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n+ - id: trailing-whitespace\n---\nUPGRADE-3.0.md\n@@ -7,7 +7,7 @@ If you find a bug, please open an issue with supporting configuration to reprodu\n ## List of backwards incompatible changes\n \n - Terraform AWS provider minimum version is now `v4.5.0` in order to have forward compatibility with Terraform AWS provider `v4.x`. Using the latest version of `v4` is highly recommended, if possible.\n-- If you are using AWS provider `v3.75` the latest supported version of this module is `v3.0.1` \n+- If you are using AWS provider `v3.75` the latest supported version of this module is `v3.0.1`\n - Main group of changes is related to refactoring of `aws_s3_bucket` resource into several smaller resources. Read [`S3 bucket refactor` section in the official Terraform AWS Provider Version 4 Upgrade Guide](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/guides/version-4-upgrade#s3-bucket-refactor) and [discussion around these changes](https://github.com/hashicorp/terraform-provider-aws/issues/23106).\n - `modules/object`: Changed resource type from `aws_bucket_s3_object` to `aws_s3_object`. After upgrade, on the next apply, Terraform will recreate the object. If you prefer to not have Terraform recreate the object, import the object using `aws_s3_object`. [Read more](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object#import).\n \n---\n\n\n---\n\nChoice D:\n.github/workflows/lock.yml\n@@ -8,7 +8,7 @@ jobs:\n lock:\n runs-on: ubuntu-latest\n steps:\n- - uses: dessant/lock-threads@v4\n+ - uses: dessant/lock-threads@v5\n with:\n github-token: ${{ secrets.GITHUB_TOKEN }}\n issue-comment: >\n---\n.github/workflows/pr-title.yml\n@@ -14,7 +14,7 @@ jobs:\n steps:\n # Please look up the latest version from\n # https://github.com/amannn/action-semantic-pull-request/releases\n- - uses: amannn/[email protected]\n+ - uses: amannn/[email protected]\n env:\n GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n with:\n---\n.github/workflows/pre-commit.yml\n@@ -8,7 +8,7 @@ on:\n \n env:\n TERRAFORM_DOCS_VERSION: v0.16.0\n- TFLINT_VERSION: v0.44.1\n+ TFLINT_VERSION: v0.50.3\n \n jobs:\n collectInputs:\n@@ -18,11 +18,11 @@ jobs:\n directories: ${{ steps.dirs.outputs.directories }}\n steps:\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -32,19 +32,27 @@ jobs:\n matrix:\n directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}\n steps:\n+ # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n+ - name: Delete huge unnecessary tools folder\n+ run: |\n+ rm -rf /opt/hostedtoolcache/CodeQL\n+ rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk\n+ rm -rf /opt/hostedtoolcache/Ruby\n+ rm -rf /opt/hostedtoolcache/go\n+\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n with:\n clowdhaus/terraform-composite-actions/[email protected]\n+ directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -53,7 +61,7 @@ jobs:\n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n@@ -64,18 +72,26 @@ jobs:\n runs-on: ubuntu-latest\n needs: collectInputs\n steps:\n+ # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449\n+ - name: Delete huge unnecessary tools folder\n+ run: |\n+ rm -rf /opt/hostedtoolcache/CodeQL\n+ rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk\n+ rm -rf /opt/hostedtoolcache/Ruby\n+ rm -rf /opt/hostedtoolcache/go\n+\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n with:\n ref: ${{ github.event.pull_request.head.ref }}\n repository: ${{github.event.pull_request.head.repo.full_name}}\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n tflint-version: ${{ env.TFLINT_VERSION }}\n---\n.github/workflows/release.yml\n@@ -20,18 +20,18 @@ jobs:\n if: github.repository_owner == 'terraform-aws-modules'\n steps:\n - name: Checkout\n- uses: actions/checkout@v3\n+ uses: actions/checkout@v4\n with:\n persist-credentials: false\n fetch-depth: 0\n \n - name: Release\n- uses: cycjimmy/semantic-release-action@v3\n+ uses: cycjimmy/semantic-release-action@v4\n with:\n- semantic_version: 18.0.0\n+ semantic_version: 23.0.2\n extra_plugins: |\n- @semantic-release/[email protected]\n- @semantic-release/[email protected]\n- [email protected]\n+ @semantic-release/[email protected]\n+ @semantic-release/[email protected]\n+ [email protected]\n env:\n GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}\n---\n.github/workflows/stale-actions.yaml\n@@ -7,7 +7,7 @@ jobs:\n stale:\n runs-on: ubuntu-latest\n steps:\n- - uses: actions/stale@v6\n+ - uses: actions/stale@v9\n with:\n repo-token: ${{ secrets.GITHUB_TOKEN }}\n # Staling issues and PR's\n---\n.pre-commit-config.yaml\n@@ -1,10 +1,9 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.86.0\n+ rev: v1.88.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n- - id: terraform_validate\n - id: terraform_docs\n args:\n - '--args=--lockfile=false'\n@@ -23,8 +22,11 @@ repos:\n - '--args=--only=terraform_required_providers'\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n+ - '--args=--only=terraform_unused_required_providers'\n+ - id: terraform_validate\n - repo: https://github.com/pre-commit/pre-commit-hooks\n rev: v4.5.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n+ - id: trailing-whitespace\n---\nUPGRADE-3.0.md\n@@ -7,7 +7,7 @@ If you find a bug, please open an issue with supporting configuration to reprodu\n ## List of backwards incompatible changes\n \n - Terraform AWS provider minimum version is now `v4.5.0` in order to have forward compatibility with Terraform AWS provider `v4.x`. Using the latest version of `v4` is highly recommended, if possible.\n-- If you are using AWS provider `v3.75` the latest supported version of this module is `v3.0.1` \n+- If you are using AWS provider `v3.75` the latest supported version of this module is `v3.0.1`\n - Main group of changes is related to refactoring of `aws_s3_bucket` resource into several smaller resources. Read [`S3 bucket refactor` section in the official Terraform AWS Provider Version 4 Upgrade Guide](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/guides/version-4-upgrade#s3-bucket-refactor) and [discussion around these changes](https://github.com/hashicorp/terraform-provider-aws/issues/23106).\n - `modules/object`: Changed resource type from `aws_bucket_s3_object` to `aws_s3_object`. After upgrade, on the next apply, Terraform will recreate the object. If you prefer to not have Terraform recreate the object, import the object using `aws_s3_object`. [Read more](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object#import).\n \n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nCloses: https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/issues/267\r\n\r\n## Motivation and Context\r\nhttps://github.com/terraform-aws-modules/terraform-aws-s3-bucket/issues/267\r\n\r\n## Breaking Changes\r\nBumped module terraform min versions as well. Maybe this is considered breaking.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/complete-legacy/README.md\n@@ -13,7 +13,7 @@ Once this configuration is created, you need to use the newer version of this mo\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | ~> 3.69.0 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n---\nexamples/complete-legacy/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.13.1\"\n+ required_version = \">= 1.0\"\n \n required_providers {\n aws = {\n---\nmain.tf\n@@ -138,7 +138,7 @@ resource \"aws_s3_bucket_website_configuration\" \"this\" {\n \n content {\n dynamic \"condition\" {\n- for_each = [try([routing_rule.value.condition], [])]\n+ for_each = try([routing_rule.value.condition], [])\n \n content {\n http_error_code_returned_equals = try(routing_rule.value.condition[\"http_error_code_returned_equals\"], null)\n---\nmodules/notification/README.md\n@@ -7,7 +7,7 @@ Creates S3 bucket notification resource with all supported types of deliveries:\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.74 |\n \n ## Providers\n---\nmodules/notification/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.13.1\"\n+ required_version = \">= 1.0\"\n \n required_providers {\n aws = {\n---\nmodules/object/README.md\n@@ -7,7 +7,7 @@ Creates S3 bucket objects with different configurations.\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.75 |\n \n ## Providers\n---\nmodules/object/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.13.1\"\n+ required_version = \">= 1.0\"\n \n required_providers {\n aws = {\n---\n\n\n---\n\nChoice B:\nexamples/complete-legacy/README.md\n@@ -13,7 +13,7 @@ Once this configuration is created, you need to use the newer version of this mo\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | ~> 3.69.0 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n---\nexamples/complete-legacy/versions.tf\n@@ -1,5 aws @@\n terraform {\n- required_version = \">= 0.13.1\"\n+ required_version = \">= 1.0\"\n \n required_providers {\n aws = {\n---\nmain.tf\n@@ -138,7 +138,7 @@ resource \"aws_s3_bucket_website_configuration\" \"this\" {\n \n content {\n dynamic \"condition\" {\n- for_each = [try([routing_rule.value.condition], [])]\n+ for_each = try([routing_rule.value.condition], [])\n \n content {\n http_error_code_returned_equals = try(routing_rule.value.condition[\"http_error_code_returned_equals\"], null)\n---\nmodules/notification/README.md\n@@ -7,7 +7,7 @@ Creates S3 bucket notification resource with all supported types of deliveries:\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.74 |\n \n ## Providers\n---\nmodules/notification/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.13.1\"\n+ required_version = \">= 1.0\"\n \n required_providers {\n aws = {\n---\nmodules/object/README.md\n@@ -7,7 +7,7 @@ Creates S3 bucket objects with different configurations.\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.75 |\n \n ## Providers\n---\nmodules/object/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.13.1\"\n+ required_version = \">= 1.0\"\n \n required_providers {\n aws = {\n---\n\n\n---\n\nChoice C:\nexamples/complete-legacy/README.md\n@@ -13,7 +13,7 @@ Once this configuration is created, you need to use the newer version of this mo\n \n | Name | <a |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | ~> 3.69.0 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n---\nexamples/complete-legacy/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.13.1\"\n+ required_version = \">= 1.0\"\n \n required_providers {\n aws = {\n---\nmain.tf\n@@ -138,7 +138,7 @@ resource \"aws_s3_bucket_website_configuration\" \"this\" {\n \n content {\n dynamic \"condition\" {\n- for_each = [try([routing_rule.value.condition], [])]\n+ for_each = try([routing_rule.value.condition], [])\n \n content {\n http_error_code_returned_equals = try(routing_rule.value.condition[\"http_error_code_returned_equals\"], null)\n---\nmodules/notification/README.md\n@@ -7,7 +7,7 @@ Creates S3 bucket notification resource with all supported types of deliveries:\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.74 |\n \n ## Providers\n---\nmodules/notification/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.13.1\"\n+ required_version = \">= 1.0\"\n \n required_providers {\n aws = {\n---\nmodules/object/README.md\n@@ -7,7 +7,7 @@ Creates S3 bucket objects with different configurations.\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.75 |\n \n ## Providers\n---\nmodules/object/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.13.1\"\n+ required_version = \">= 1.0\"\n \n required_providers {\n aws = {\n---\n\n\n---\n\nChoice D:\nexamples/complete-legacy/README.md\n@@ -13,7 +13,7 @@ Once this configuration is created, you need to use the newer version of this mo\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) +1,5 ~> 3.69.0 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n---\nexamples/complete-legacy/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.13.1\"\n+ required_version = \">= 1.0\"\n \n required_providers {\n aws = {\n---\nmain.tf\n@@ -138,7 +138,7 @@ resource \"aws_s3_bucket_website_configuration\" \"this\" {\n \n content {\n dynamic \"condition\" {\n- for_each = [try([routing_rule.value.condition], [])]\n+ for_each = try([routing_rule.value.condition], [])\n \n content {\n http_error_code_returned_equals = try(routing_rule.value.condition[\"http_error_code_returned_equals\"], null)\n---\nmodules/notification/README.md\n@@ -7,7 +7,7 @@ Creates S3 bucket notification resource with all supported types of deliveries:\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.74 |\n \n ## Providers\n---\nmodules/notification/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.13.1\"\n+ required_version = \">= 1.0\"\n \n required_providers {\n aws = {\n---\nmodules/object/README.md\n@@ -7,7 +7,7 @@ Creates S3 bucket objects with different configurations.\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.75 |\n \n ## Providers\n---\nmodules/object/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.13.1\"\n+ required_version = \">= 1.0\"\n \n required_providers {\n aws = {\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nFixes ELB log delivery in AWS China regions\r\n\r\n\r\n\r\n## Motivation and Context\r\nIn release 3.8.2, a fix was made to support newer AWS regions which use a different log delivery policy:\r\nhttps://github.com/terraform-aws-modules/terraform-aws-s3-bucket/commit/3c094b32333a177a07477c4079ef3bd8cc56eea8\r\n\r\nThe method of the fix is essentially \"if the old region exists in this list, use the old way, otherwise use the new way\". Unfortunately, the China regions were left out of this list, so this module treats them as though they're new regions, and sets the Principal to `Service\": \"logdelivery.elasticloadbalancing.amazonaws.com`, when it should be the old format: `\"AWS\": \"arn:aws-cn:iam::638102146993:root\"` (example given is for cn-north-1)\r\n\r\nDocumentation here describes regions excluding China: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/enable-access-logging.html#attach-bucket-policy\r\n\r\nChina regions are included here: https://docs.amazonaws.cn/en_us/elasticloadbalancing/latest/application/enable-access-logging.html#attach-bucket-policy\r\n\r\n## Breaking Changes\r\nNo, simply adds China regions to existing list\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\nAdded examples/china-log-bucket-failure, which is similar to the complete example with some stuff removed for clarity.\r\n\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n\r\nThis is a very simple change. I tried to create an S3 bucket with ELB log permissions and get this error:\r\n`failure configuring LB attributes: InvalidConfigurationRequest: Access Denied for bucket: test-bucket-cn-elb-logs-cn-north-1. Please check S3bucket permission`\r\nI then changed the module source to my branch in github:\r\n\r\n```\r\n# source = \"terraform-aws-modules/s3-bucket/aws\"\r\n# version = \"3.15.1\"\r\n source = \"git::https://github.com/bohnjamin/terraform-aws-s3-bucket.git?ref=add-china-regions\"\r\n```\r\nand the bucket is deployed as expected\r\n\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n\r\n```\r\n$ pre-commit run -a\r\nTerraform fmt............................................................Passed\r\nTerraform wrapper with for_each in module................................Passed\r\nTerraform validate.......................................................Passed\r\nTerraform docs...........................................................Passed\r\nTerraform validate with tflint...........................................Passed\r\ncheck for merge conflicts................................................Passed\r\nfix end of files.........................................................Passed\r\n```\n\n---\n\nChoice A:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.77.3\n+ rev: v1.86.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n@@ -24,7 +24,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.4.0\n+ rev: v4.5.0\n hooks:\n id: check-merge-conflict\n - id: end-of-file-fixer\n---\nmain.tf\n@@ -573,6 +573,8 @@ locals {\n sa-east-1 = \"507241528517\"\n us-gov-west-1 = \"048591011584\"\n us-gov-east-1 = \"190560391635\"\n+ cn-north-1 = \"638102146993\"\n+ cn-northwest-1 = \"037604701340\"\n }\n }\n \n---\n\n\n---\n\nChoice B:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.77.3\n+ rev: v1.86.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n@@ -24,7 +24,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.4.0\n+ rev: v4.5.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\nmain.tf\n@@ -573,6 +573,8 @@ locals {\n sa-east-1 = \"507241528517\"\n us-gov-west-1 = \"048591011584\"\n us-gov-east-1 = \"190560391635\"\n+ cn-north-1 = \"638102146993\"\n+ cn-northwest-1 = \"037604701340\"\n }\n }\n \n---\n\n\n---\n\nChoice C:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.77.3\n+ rev: v1.86.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n@@ -24,7 +24,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.4.0\n+ rev: v4.5.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\nmain.tf\n@@ -573,6 +573,8 @@ locals {\n sa-east-1 = \"507241528517\"\n us-gov-west-1 = \"048591011584\"\n us-gov-east-1 = \"190560391635\"\n+ cn-north-1 = \"638102146993\"\n+ cn-northwest-1 = \"037604701340\"\n }\n }\n \n---\n\n\n---\n\nChoice D:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.77.3\n+ rev: v1.86.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n@@ -24,7 +24,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.4.0\n+ rev: v4.5.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\nmain.tf\n@@ -573,6 +573,8 @@ locals {\n sa-east-1 = \"507241528517\"\n us-gov-west-1 = \"048591011584\"\n us-gov-east-1 = \"190560391635\"\n+ cn-north-1 = \"638102146993\"\n+ cn-northwest-1 = \"037604701340\"\n }\n }\n \n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nAdded support for ignoring default_tags set on provider level.\r\n\r\n## Motivation and Context\r\nThis change was required as it was not possible to deploy s3 bucket object if there are more than 10 tags set on provider level.\r\nMore info [here](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_object#ignoring-provider-default_tags).\r\n\r\n## Breaking Changes\r\nThis is not a breaking change but it does require bumping the provider version for 2 major versions, as option was only recently added to provider.\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/object/README.md\n@@ -37,6 +37,7 @@ Note that this example may create resources which cost money. Run `terraform des\n | <a name=\"module_object\"></a> [object](#module\\_object) | ../../modules/object | n/a |\n | <a name=\"module_object_complete\"></a> [object\\_complete](#module\\_object\\_complete) | ../../modules/object | n/a |\n | <a name=\"module_object_locked\"></a> [object\\_locked](#module\\_object\\_locked) | ../../modules/object | n/a |\n+| <a name=\"module_object_with_override_default_tags\"></a> [object\\_with\\_override\\_default\\_tags](#module\\_object\\_with\\_override\\_default\\_tags) | ../../modules/object | n/a |\n | <a name=\"module_s3_bucket\"></a> [s3\\_bucket](#module\\_s3\\_bucket) | ../../ | n/a |\n | <a name=\"module_s3_bucket_with_object_lock\"></a> [s3\\_bucket\\_with\\_object\\_lock](#module\\_s3\\_bucket\\_with\\_object\\_lock) | ../../ | n/a |\n \n---\nexamples/object/main.tf\n@@ -5,6 +5,12 @@ provider \"aws\" {\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n+\n+ default_tags {\n+ tags = {\n+ Example = \"object\"\n+ }\n+ }\n }\n \n locals {\n@@ -25,6 +31,7 @@ module \"object\" {\n Sensitive = \"not-really\"\n }\n }\n+\n module \"object_complete\" {\n source = \"../../modules/object\"\n \n@@ -33,7 +40,7 @@ module \"object_complete\" {\n \n content = jsonencode({ data : \"value\" })\n \n- acl = \"public-read\"\n+ # acl = \"public-read\"\n storage_class = \"ONEZONE_IA\"\n force_destroy = true\n \n@@ -68,6 +75,21 @@ module \"object_locked\" {\n object_lock_retain_until_date = formatdate(\"YYYY-MM-DD'T'hh:00:00Z\", timeadd(timestamp(), \"1h\")) # some time in the future\n }\n \n+module \"object_with_override_default_tags\" {\n+ source = \"../../modules/object\"\n+\n+ bucket = module.s3_bucket.s3_bucket_id\n+ key = \"${random_pet.this.id}-local-override-default-tags\"\n+\n+ override_default_tags = true\n+\n+ file_source = \"README.md\"\n+\n+ tags = {\n+ Override = \"true\"\n+ }\n+}\n+\n ##################\n # Extra resources\n ##################\n@@ -96,7 +118,13 @@ module \"s3_bucket_with_object_lock\" {\n bucket = \"${random_pet.this.id}-with-object-lock\"\n force_destroy = true\n \n+ object_lock_enabled = true\n object_lock_configuration = {\n- object_lock_enabled = \"Enabled\"\n+ rule = {\n+ default_retention = {\n+ mode = \"GOVERNANCE\"\n+ days = 1\n+ }\n+ }\n }\n }\n---\nmodules/object/README.md\n@@ -8,13 +8,13 @@ Creates S3 bucket objects with different configurations.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.75 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 5.24 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.75 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 5.24 |\n \n ## Modules\n \n@@ -50,6 +50,7 @@ No modules.\n | <a name=\"input_object_lock_legal_hold_status\"></a> [object\\_lock\\_legal\\_hold\\_status](#input\\_object\\_lock\\_legal\\_hold\\_status) | The legal hold status that you want to apply to the specified object. Valid values are ON and OFF. | `string` | `null` | no |\n | <a name=\"input_object_lock_mode\"></a> [object\\_lock\\_mode](#input\\_object\\_lock\\_mode) | The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE. | `string` | `null` | no |\n | <a name=\"input_object_lock_retain_until_date\"></a> [object\\_lock\\_retain\\_until\\_date](#input\\_object\\_lock\\_retain\\_until\\_date) | The date and time, in RFC3339 format, when this object's object lock will expire. | `string` | `null` | no |\n+| <a name=\"input_override_default_tags\"></a> [override\\_default\\_tags](#input\\_override\\_default\\_tags) | Ignore provider default\\_tags. S3 objects support a maximum of 10 tags. | `bool` | `false` | no |\n | <a name=\"input_server_side_encryption\"></a> [server\\_side\\_encryption](#input\\_server\\_side\\_encryption) | Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\". | `string` | `null` | no |\n | <a name=\"input_source_hash\"></a> [source\\_hash](#input\\_source\\_hash) | Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.) | `string` | `null` | no |\n | <a name=\"input_storage_class\"></a> [storage\\_class](#input\\_storage\\_class) | Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED\\_REDUNDANCY, ONEZONE\\_IA, INTELLIGENT\\_TIERING, GLACIER, DEEP\\_ARCHIVE, or STANDARD\\_IA. Defaults to STANDARD. | `string` | `null` | no |\n---\nmodules/object/main.tf\n@@ -33,6 +33,16 @@ resource \"aws_s3_object\" \"this\" {\n \n tags = var.tags\n \n+ dynamic \"override_provider\" {\n+ for_each = var.override_default_tags ? [true] : []\n+\n+ content {\n+ default_tags {\n+ tags = {}\n+ }\n+ }\n+ }\n+\n lifecycle {\n ignore_changes = [object_lock_retain_until_date]\n }\n---\nmodules/object/variables.tf\n@@ -147,3 +147,9 @@ variable \"source_hash\" {\n type = string\n default = null\n }\n+\n+variable \"override_default_tags\" {\n+ description = \"Ignore provider default_tags. S3 objects support a maximum of 10 tags.\"\n+ type = bool\n+ default = false\n+}\n---\nmodules/object/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 3.75\"\n+ version = \">= 5.24\"\n }\n }\n }\n---\nwrappers/object/main.tf\n@@ -23,6 +23,7 @@ module \"wrapper\" {\n object_lock_legal_hold_status = try(each.value.object_lock_legal_hold_status, var.defaults.object_lock_legal_hold_status, null)\n object_lock_mode = try(each.value.object_lock_mode, var.defaults.object_lock_mode, null)\n object_lock_retain_until_date = try(each.value.object_lock_retain_until_date, var.defaults.object_lock_retain_until_date, null)\n+ default_tags = try(each.value.override_default_tags, var.defaults.override_default_tags, false)\n server_side_encryption = try(each.value.server_side_encryption, var.defaults.server_side_encryption, null)\n source_hash = try(each.value.source_hash, var.defaults.source_hash, null)\n storage_class = try(each.value.storage_class, var.defaults.storage_class, null)\n---\n\n\n---\n\nChoice B:\nexamples/object/README.md\n@@ -37,6 +37,7 @@ Note that this example may create resources which cost money. Run `terraform des\n | <a name=\"module_object\"></a> [object](#module\\_object) | ../../modules/object | n/a |\n | <a name=\"module_object_complete\"></a> [object\\_complete](#module\\_object\\_complete) | ../../modules/object | n/a |\n | <a name=\"module_object_locked\"></a> [object\\_locked](#module\\_object\\_locked) | ../../modules/object | n/a |\n+| <a name=\"module_object_with_override_default_tags\"></a> [object\\_with\\_override\\_default\\_tags](#module\\_object\\_with\\_override\\_default\\_tags) | ../../modules/object | n/a |\n | <a name=\"module_s3_bucket\"></a> [s3\\_bucket](#module\\_s3\\_bucket) | ../../ | n/a |\n | <a name=\"module_s3_bucket_with_object_lock\"></a> [s3\\_bucket\\_with\\_object\\_lock](#module\\_s3\\_bucket\\_with\\_object\\_lock) | ../../ | n/a |\n \n---\nexamples/object/main.tf\n@@ -5,6 +5,12 @@ provider \"aws\" {\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n+\n+ default_tags {\n+ tags = {\n+ Example = \"object\"\n+ }\n+ }\n }\n \n locals {\n@@ -25,6 +31,7 @@ module \"object\" {\n Sensitive = \"not-really\"\n }\n }\n+\n module \"object_complete\" {\n source = \"../../modules/object\"\n \n@@ -33,7 +40,7 @@ module \"object_complete\" {\n \n content = jsonencode({ data : \"value\" })\n \n- acl = \"public-read\"\n+ # acl = \"public-read\"\n storage_class = \"ONEZONE_IA\"\n force_destroy = true\n \n@@ -68,6 +75,21 @@ module \"object_locked\" {\n object_lock_retain_until_date = formatdate(\"YYYY-MM-DD'T'hh:00:00Z\", timeadd(timestamp(), \"1h\")) # some time in the future\n }\n \n+module \"object_with_override_default_tags\" {\n+ source = \"../../modules/object\"\n+\n+ bucket = module.s3_bucket.s3_bucket_id\n+ key = \"${random_pet.this.id}-local-override-default-tags\"\n+\n+ override_default_tags = true\n+\n+ file_source = \"README.md\"\n+\n+ tags = {\n+ Override = \"true\"\n+ }\n+}\n+\n ##################\n # Extra resources\n ##################\n@@ -96,7 +118,13 @@ module \"s3_bucket_with_object_lock\" {\n bucket = \"${random_pet.this.id}-with-object-lock\"\n force_destroy = true\n \n+ object_lock_enabled = true\n object_lock_configuration = {\n- object_lock_enabled = \"Enabled\"\n+ rule = {\n+ default_retention = {\n+ mode = \"GOVERNANCE\"\n+ days = 1\n+ }\n+ }\n }\n }\n---\nmodules/object/README.md\n@@ -8,13 +8,13 @@ Creates S3 bucket objects with different configurations.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.75 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 5.24 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.75 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 5.24 |\n \n ## Modules\n \n@@ -50,6 +50,7 @@ No modules.\n | <a name=\"input_object_lock_legal_hold_status\"></a> [object\\_lock\\_legal\\_hold\\_status](#input\\_object\\_lock\\_legal\\_hold\\_status) | The legal hold status that you want to apply to the specified object. Valid values are ON and OFF. | `string` | `null` | no |\n | <a name=\"input_object_lock_mode\"></a> [object\\_lock\\_mode](#input\\_object\\_lock\\_mode) | The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE. | `string` | `null` | no |\n | <a name=\"input_object_lock_retain_until_date\"></a> [object\\_lock\\_retain\\_until\\_date](#input\\_object\\_lock\\_retain\\_until\\_date) | The date and time, in RFC3339 format, when this object's object lock will expire. | `string` | `null` | no |\n+| <a name=\"input_override_default_tags\"></a> [override\\_default\\_tags](#input\\_override\\_default\\_tags) | Ignore provider default\\_tags. S3 objects support a maximum of 10 tags. | `bool` | `false` | no |\n | <a name=\"input_server_side_encryption\"></a> [server\\_side\\_encryption](#input\\_server\\_side\\_encryption) | Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\". | `string` | `null` | no |\n | <a name=\"input_source_hash\"></a> [source\\_hash](#input\\_source\\_hash) | Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.) | `string` | `null` | no |\n | <a name=\"input_storage_class\"></a> [storage\\_class](#input\\_storage\\_class) | Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED\\_REDUNDANCY, ONEZONE\\_IA, INTELLIGENT\\_TIERING, GLACIER, DEEP\\_ARCHIVE, or STANDARD\\_IA. Defaults to STANDARD. | `string` | `null` | no |\n---\nmodules/object/main.tf\n@@ -33,6 +33,16 @@ resource \"aws_s3_object\" \"this\" {\n \n tags = var.tags\n \n+ dynamic \"override_provider\" {\n+ for_each = var.override_default_tags ? [true] : []\n+\n+ content {\n+ default_tags {\n+ tags = {}\n+ }\n+ }\n+ }\n+\n lifecycle {\n ignore_changes = [object_lock_retain_until_date]\n }\n---\nmodules/object/variables.tf\n@@ -147,3 +147,9 @@ variable \"source_hash\" {\n type = string\n default = null\n }\n+\n+variable \"override_default_tags\" {\n+ description = \"Ignore provider default_tags. S3 objects support a maximum of 10 tags.\"\n+ type = bool\n+ default = false\n+}\n---\nmodules/object/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 3.75\"\n+ version = \">= 5.24\"\n }\n }\n }\n---\nwrappers/object/main.tf\n@@ -23,6 +23,7 @@ module \"wrapper\" {\n object_lock_legal_hold_status = try(each.value.object_lock_legal_hold_status, var.defaults.object_lock_legal_hold_status, null)\n object_lock_mode this = try(each.value.object_lock_mode, var.defaults.object_lock_mode, null)\n object_lock_retain_until_date = try(each.value.object_lock_retain_until_date, var.defaults.object_lock_retain_until_date, null)\n+ override_default_tags = try(each.value.override_default_tags, var.defaults.override_default_tags, false)\n server_side_encryption = try(each.value.server_side_encryption, var.defaults.server_side_encryption, null)\n source_hash = try(each.value.source_hash, var.defaults.source_hash, null)\n storage_class = try(each.value.storage_class, var.defaults.storage_class, null)\n---\n\n\n---\n\nChoice C:\nexamples/object/README.md\n@@ -37,6 +37,7 @@ Note that this example may create resources which cost money. Run `terraform des\n | <a name=\"module_object\"></a> [object](#module\\_object) | ../../modules/object | n/a |\n | <a name=\"module_object_complete\"></a> [object\\_complete](#module\\_object\\_complete) | ../../modules/object | n/a |\n | <a name=\"module_object_locked\"></a> [object\\_locked](#module\\_object\\_locked) | ../../modules/object | n/a |\n+| <a name=\"module_object_with_override_default_tags\"></a> [object\\_with\\_override\\_default\\_tags](#module\\_object\\_with\\_override\\_default\\_tags) | ../../modules/object | n/a |\n | <a name=\"module_s3_bucket\"></a> [s3\\_bucket](#module\\_s3\\_bucket) | ../../ | n/a |\n | <a name=\"module_s3_bucket_with_object_lock\"></a> [s3\\_bucket\\_with\\_object\\_lock](#module\\_s3\\_bucket\\_with\\_object\\_lock) | ../../ | n/a |\n \n---\nexamples/object/main.tf\n@@ -5,6 +5,12 @@ provider \"aws\" {\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n+\n+ default_tags {\n+ tags = {\n+ Example = \"object\"\n+ }\n+ }\n }\n \n locals {\n@@ -25,6 +31,7 @@ module \"object\" {\n Sensitive = \"not-really\"\n }\n }\n+\n module \"object_complete\" {\n source = \"../../modules/object\"\n \n@@ -33,7 +40,7 @@ module \"object_complete\" {\n \n content = jsonencode({ data : \"value\" })\n \n- acl = \"public-read\"\n+ # acl = \"public-read\"\n storage_class = \"ONEZONE_IA\"\n force_destroy = true\n \n@@ -68,6 +75,21 @@ module \"object_locked\" {\n object_lock_retain_until_date = formatdate(\"YYYY-MM-DD'T'hh:00:00Z\", timeadd(timestamp(), \"1h\")) # some time in the future\n }\n \n+module \"object_with_override_default_tags\" {\n+ source = \"../../modules/object\"\n+\n+ bucket = module.s3_bucket.s3_bucket_id\n+ key = \"${random_pet.this.id}-local-override-default-tags\"\n+\n+ override_default_tags = true\n+\n+ file_source = \"README.md\"\n+\n+ tags = {\n+ Override = \"true\"\n+ }\n+}\n+\n ##################\n # Extra resources\n ##################\n@@ -96,7 +118,13 @@ module \"s3_bucket_with_object_lock\" {\n bucket = \"${random_pet.this.id}-with-object-lock\"\n force_destroy = true\n \n+ object_lock_enabled = true\n object_lock_configuration = {\n- object_lock_enabled = \"Enabled\"\n+ rule = {\n+ default_retention = {\n+ mode = \"GOVERNANCE\"\n+ days = 1\n+ }\n+ }\n }\n }\n---\nmodules/object/README.md\n@@ -8,13 +8,13 @@ Creates S3 bucket objects with different configurations.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.75 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 5.24 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.75 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 5.24 |\n \n ## Modules\n \n@@ -50,6 +50,7 @@ No modules.\n | <a name=\"input_object_lock_legal_hold_status\"></a> [object\\_lock\\_legal\\_hold\\_status](#input\\_object\\_lock\\_legal\\_hold\\_status) | The legal hold status that you want to apply to the specified object. Valid values are ON and OFF. | `string` | `null` | no |\n | <a name=\"input_object_lock_mode\"></a> [object\\_lock\\_mode](#input\\_object\\_lock\\_mode) | The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE. | `string` | `null` | no |\n | <a name=\"input_object_lock_retain_until_date\"></a> [object\\_lock\\_retain\\_until\\_date](#input\\_object\\_lock\\_retain\\_until\\_date) | The date and time, in RFC3339 format, when this object's object lock will expire. | `string` | `null` | no |\n+| <a name=\"input_override_default_tags\"></a> [override\\_default\\_tags](#input\\_override\\_default\\_tags) | Ignore provider default\\_tags. S3 objects support a maximum of 10 tags. | `bool` | `false` | no |\n | <a name=\"input_server_side_encryption\"></a> [server\\_side\\_encryption](#input\\_server\\_side\\_encryption) | Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\". | `string` | `null` | no |\n | <a name=\"input_source_hash\"></a> [source\\_hash](#input\\_source\\_hash) | Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.) | `string` | `null` | no |\n | <a name=\"input_storage_class\"></a> [storage\\_class](#input\\_storage\\_class) | Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED\\_REDUNDANCY, ONEZONE\\_IA, INTELLIGENT\\_TIERING, GLACIER, DEEP\\_ARCHIVE, or STANDARD\\_IA. Defaults to STANDARD. | `string` | `null` | no |\n---\nmodules/object/main.tf\n@@ -33,6 +33,16 @@ resource \"aws_s3_object\" \"this\" {\n \n tags = var.tags\n \n+ dynamic \"override_provider\" {\n+ for_each = var.override_default_tags ? [true] : []\n+\n+ content {\n+ default_tags {\n+ tags = {}\n+ }\n+ }\n+ }\n+\n lifecycle {\n ignore_changes = [object_lock_retain_until_date]\n }\n---\nmodules/object/variables.tf\n@@ -147,3 +147,9 @@ variable \"source_hash\" {\n type = string\n default = null\n }\n+\n+variable \"override_default_tags\" {\n+ description = \"Ignore provider default_tags. S3 objects support a maximum of 10 tags.\"\n+ type = bool\n+ default = false\n+}\n---\nmodules/object/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 3.75\"\n+ version = \">= 5.24\"\n }\n }\n }\n---\nwrappers/object/main.tf\n@@ -23,6 +23,7 @@ module \"wrapper\" {\n object_lock_legal_hold_status = try(each.value.object_lock_legal_hold_status, var.defaults.object_lock_legal_hold_status, null)\n object_lock_mode = try(each.value.object_lock_mode, var.defaults.object_lock_mode, null)\n object_lock_retain_until_date = try(each.value.object_lock_retain_until_date, var.defaults.object_lock_retain_until_date, null)\n+ override_default_tags = try(each.value.override_default_tags, var.defaults.override_default_tags, false)\n server_side_encryption = try(each.value.server_side_encryption, var.defaults.server_side_encryption, null)\n source_hash = try(each.value.source_hash, var.defaults.source_hash, null)\n storage_class = try(each.value.storage_class, var.defaults.storage_class, null)\n---\n\n\n---\n\nChoice D:\nexamples/object/README.md\n@@ -37,6 +37,7 @@ Note that this example may create resources which cost money. Run `terraform des\n | <a name=\"module_object\"></a> [object](#module\\_object) | ../../modules/object | n/a |\n | <a name=\"module_object_complete\"></a> [object\\_complete](#module\\_object\\_complete) | ../../modules/object | n/a |\n | <a name=\"module_object_locked\"></a> [object\\_locked](#module\\_object\\_locked) | ../../modules/object | n/a |\n+| <a name=\"module_object_with_override_default_tags\"></a> [object\\_with\\_override\\_default\\_tags](#module\\_object\\_with\\_override\\_default\\_tags) | ../../modules/object | n/a |\n | <a name=\"module_s3_bucket\"></a> [s3\\_bucket](#module\\_s3\\_bucket) | ../../ | n/a |\n | <a name=\"module_s3_bucket_with_object_lock\"></a> [s3\\_bucket\\_with\\_object\\_lock](#module\\_s3\\_bucket\\_with\\_object\\_lock) | ../../ | n/a |\n \n---\nexamples/object/main.tf\n@@ -5,6 +5,12 @@ provider \"aws\" {\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n+\n+ default_tags {\n+ tags = {\n+ Example = \"object\"\n+ }\n+ }\n }\n \n locals {\n@@ -25,6 +31,7 @@ module \"object\" {\n Sensitive = \"not-really\"\n }\n }\n+\n module \"object_complete\" {\n source = \"../../modules/object\"\n \n@@ -33,7 +40,7 @@ module \"object_complete\" {\n \n content = jsonencode({ data : \"value\" })\n \n- acl = \"public-read\"\n+ # acl = \"public-read\"\n storage_class = \"ONEZONE_IA\"\n force_destroy = true\n \n@@ -68,6 +75,21 @@ module \"object_locked\" {\n object_lock_retain_until_date = formatdate(\"YYYY-MM-DD'T'hh:00:00Z\", timeadd(timestamp(), \"1h\")) # some time in the future\n }\n \n+module \"object_with_override_default_tags\" {\n+ source = \"../../modules/object\"\n+\n+ bucket = module.s3_bucket.s3_bucket_id\n+ key = \"${random_pet.this.id}-local-override-default-tags\"\n+\n+ override_default_tags = true\n+\n+ file_source = \"README.md\"\n+\n+ tags = {\n+ Override = \"true\"\n+ }\n+}\n+\n ##################\n # Extra resources\n ##################\n@@ -96,7 +118,13 @@ module \"s3_bucket_with_object_lock\" {\n bucket = \"${random_pet.this.id}-with-object-lock\"\n force_destroy = true\n \n+ object_lock_enabled = true\n object_lock_configuration = {\n- object_lock_enabled = \"Enabled\"\n+ rule = {\n+ default_retention = {\n+ mode = \"GOVERNANCE\"\n+ days = 1\n+ }\n+ }\n }\n }\n---\nmodules/object/README.md\n@@ -8,13 +8,13 @@ Creates S3 bucket objects with different configurations.\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 1.0 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.75 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 5.24 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.75 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 5.24 |\n \n ## Modules\n \n@@ -50,6 +50,7 @@ No modules.\n | <a name=\"input_object_lock_legal_hold_status\"></a> [object\\_lock\\_legal\\_hold\\_status](#input\\_object\\_lock\\_legal\\_hold\\_status) | The legal hold status that you want to apply to the specified object. Valid values are ON and OFF. | `string` | `null` | no |\n | <a name=\"input_object_lock_mode\"></a> [object\\_lock\\_mode](#input\\_object\\_lock\\_mode) | The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE. | `string` | `null` | no |\n | <a name=\"input_object_lock_retain_until_date\"></a> [object\\_lock\\_retain\\_until\\_date](#input\\_object\\_lock\\_retain\\_until\\_date) | The date and time, in RFC3339 format, when this object's object lock will expire. | `string` | `null` | no |\n+| <a name=\"input_override_default_tags\"></a> [override\\_default\\_tags](#input\\_override\\_default\\_tags) | Ignore provider default\\_tags. S3 objects support a maximum of 10 tags. | `bool` | `false` | no |\n | <a name=\"input_server_side_encryption\"></a> [server\\_side\\_encryption](#input\\_server\\_side\\_encryption) | Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\". | `string` | `null` | no |\n | <a name=\"input_source_hash\"></a> [source\\_hash](#input\\_source\\_hash) | Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.) | `string` | `null` | no |\n | <a name=\"input_storage_class\"></a> [storage\\_class](#input\\_storage\\_class) | Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED\\_REDUNDANCY, ONEZONE\\_IA, INTELLIGENT\\_TIERING, GLACIER, DEEP\\_ARCHIVE, or STANDARD\\_IA. Defaults to STANDARD. | `string` | `null` | no |\n---\nmodules/object/main.tf\n@@ -33,6 +33,16 @@ resource \"aws_s3_object\" \"this\" {\n \n tags = var.tags\n \n+ dynamic \"override_provider\" {\n+ for_each = var.override_default_tags ? [true] : []\n+\n+ content {\n+ default_tags {\n+ tags = {}\n+ }\n+ }\n+ }\n+\n lifecycle {\n ignore_changes = [object_lock_retain_until_date]\n {\n@@ }\n---\nmodules/object/variables.tf\n@@ -147,3 +147,9 @@ variable \"source_hash\" {\n type = string\n default = null\n }\n+\n+variable \"override_default_tags\" {\n+ description = \"Ignore provider default_tags. S3 objects support a maximum of 10 tags.\"\n+ type = bool\n+ default = false\n+}\n---\nmodules/object/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 3.75\"\n+ version = \">= 5.24\"\n }\n }\n }\n---\nwrappers/object/main.tf\n@@ -23,6 +23,7 @@ module \"wrapper\" {\n object_lock_legal_hold_status = try(each.value.object_lock_legal_hold_status, var.defaults.object_lock_legal_hold_status, null)\n object_lock_mode = try(each.value.object_lock_mode, var.defaults.object_lock_mode, null)\n object_lock_retain_until_date = try(each.value.object_lock_retain_until_date, var.defaults.object_lock_retain_until_date, null)\n+ override_default_tags = try(each.value.override_default_tags, var.defaults.override_default_tags, false)\n server_side_encryption = try(each.value.server_side_encryption, var.defaults.server_side_encryption, null)\n source_hash = try(each.value.source_hash, var.defaults.source_hash, null)\n storage_class = try(each.value.storage_class, var.defaults.storage_class, null)\n---\n\n\n---\n" } ]
C
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\nAdds attachable CloudFront Origin Access Identities (deprecated by AWS) and CloudFront Origin Access Identities policies.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nAn AWS S3 bucket is often connected with an AWS CloudFront distribution and configuring a securely authenticated connection should be trivial. Workarounds such as https://github.com/terraform-aws-modules/terraform-aws-cloudfront/blob/master/examples/complete/main.tf#L294-L327 should not be needed.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nNone.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmain.tf\n@@ -556,6 +556,8 @@ data \"aws_iam_policy_document\" \"combined\" {\n var.attach_elb_log_delivery_policy ? data.aws_iam_policy_document.elb_log_delivery[0].json : \"\",\n var.attach_lb_log_delivery_policy ? data.aws_iam_policy_document.lb_log_delivery[0].json : \"\",\n var.attach_access_log_delivery_policy ? data.aws_iam_policy_document.access_log_delivery[0].json : \"\",\n+ var.attach_cloudfront_oai_read_policy ? data.aws_iam_policy_document.cloudfront_oai_read_policy[0].json : \"\",\n+ var.attach_cloudfront_oac_read_policy ? data.aws_iam_policy_document.cloudfront_oac_read_policy[0].json : \"\",\n var.attach_require_latest_tls_policy ? data.aws_iam_policy_document.require_latest_tls[0].json : \"\",\n var.attach_deny_insecure_transport_policy ? data.aws_iam_policy_document.deny_insecure_transport[0].json : \"\",\n var.attach_deny_unencrypted_object_uploads ? data.aws_iam_policy_document.deny_unencrypted_object_uploads[0].json : \"\",\n@@ -763,6 +765,66 @@ data \"aws_iam_policy_document\" \"access_log_delivery\" {\n }\n }\n \n+# Grant read and list access to CloudFront Origin Access Identities (deprecated by AWS)\n+data \"aws_iam_policy_document\" \"cloudfront_oai_read_policy\" {\n+ count = local.create_bucket && var.attach_cloudfront_oai_read_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"AWSCloudFrontOAIRead\"\n+ actions = [\"s3:GetObject\"]\n+ resources = [\"${aws_s3_bucket.this[0].arn}/*\"]\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.cloudfront_oai_iam_arns\n+ }\n+ }\n+\n+ statement {\n+ sid = \"AWSCloudFrontOAIList\"\n+ actions = [\"s3:ListBucket\"]\n+ resources = [aws_s3_bucket.this[0].arn]\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.cloudfront_oai_iam_arns\n+ }\n+ }\n+}\n+\n+# Grant read and list access to CloudFront Origin Access Controls\n+data \"aws_iam_policy_document\" \"cloudfront_oac_read_policy\" {\n+ count = local.create_bucket && var.attach_cloudfront_oac_read_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"AWSCloudFrontOACRead\"\n+ actions = [\"s3:GetObject\"]\n+ = [\"${aws_s3_bucket.this[0].arn}/*\"]\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"cloudfront.amazonaws.com\"]\n+ }\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:SourceArn\"\n+ values = var.cloudfront_oac_distribution_arns\n+ }\n+ }\n+\n+ statement {\n+ sid = \"AWSCloudFrontOACList\"\n+ actions = [\"s3:ListBucket\"]\n+ resources = [aws_s3_bucket.this[0].arn]\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"cloudfront.amazonaws.com\"]\n+ }\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:SourceArn\"\n+ values = var.cloudfront_oac_distribution_arns\n+ }\n+ }\n+}\n+\n data \"aws_iam_policy_document\" \"deny_insecure_transport\" {\n count = local.create_bucket && var.attach_deny_insecure_transport_policy ? 1 : 0\n \n---\nvariables.tf\n@@ -22,6 +22,18 @@ variable \"attach_access_log_delivery_policy\" {\n default = false\n }\n \n+variable \"attach_cloudfront_oai_read_policy\" {\n+ description = \"Controls if S3 bucket should have CloudFront Origin Access Identities policy attached (configure with `cloudfront_oai_iam_arns`)\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"attach_cloudfront_oac_read_policy\" {\n+ description = \"Controls if S3 bucket should have CloudFront Origin Access Controls policy attached (configure with `cloudfront_oac_distribution_arns`)\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"attach_deny_insecure_transport_policy\" {\n description = \"Controls if S3 bucket should have deny non-SSL transport policy attached\"\n type = bool\n@@ -100,6 +112,18 @@ variable \"acl\" {\n default = null\n }\n \n+variable \"cloudfront_oai_iam_arns\" {\n+ description = \"(Optional) List of CloudFront IAM ARNs to use in the CloudFront Origin Access Identities policy\"\n+ type = list(string)\n+ default = []\n+}\n+\n+variable \"cloudfront_oac_distribution_arns\" {\n+ description = \"(Optional) List of CloudFront distribution ARNs to use in the CloudFront Origin Access Controls policy\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"policy\" {\n description = \"(Optional) A valid bucket policy JSON document. Note that if the policy document is not specific enough (but still valid), Terraform may view the policy as constantly changing in a terraform plan. In this case, please make sure you use the verbose/specific version of the policy. For more information about building AWS IAM policy documents with Terraform, see the AWS IAM Policy Document Guide.\"\n type = string\n---\n\n\n---\n\nChoice B:\nmain.tf\n@@ -556,6 +556,8 @@ data \"aws_iam_policy_document\" -763,6 {\n var.attach_elb_log_delivery_policy ? data.aws_iam_policy_document.elb_log_delivery[0].json : \"\",\n var.attach_lb_log_delivery_policy ? data.aws_iam_policy_document.lb_log_delivery[0].json : \"\",\n var.attach_access_log_delivery_policy ? data.aws_iam_policy_document.access_log_delivery[0].json : \"\",\n+ var.attach_cloudfront_oai_read_policy ? data.aws_iam_policy_document.cloudfront_oai_read_policy[0].json : \"\",\n+ var.attach_cloudfront_oac_read_policy ? data.aws_iam_policy_document.cloudfront_oac_read_policy[0].json : \"\",\n var.attach_require_latest_tls_policy ? data.aws_iam_policy_document.require_latest_tls[0].json : \"\",\n var.attach_deny_insecure_transport_policy ? data.aws_iam_policy_document.deny_insecure_transport[0].json : \"\",\n var.attach_deny_unencrypted_object_uploads ? data.aws_iam_policy_document.deny_unencrypted_object_uploads[0].json : \"\",\n@@ -763,6 +765,66 @@ data \"aws_iam_policy_document\" \"access_log_delivery\" {\n }\n }\n \n+# Grant read and list access to CloudFront Origin Access Identities (deprecated by AWS)\n+data \"aws_iam_policy_document\" \"cloudfront_oai_read_policy\" {\n+ count = local.create_bucket && var.attach_cloudfront_oai_read_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"AWSCloudFrontOAIRead\"\n+ actions = [\"s3:GetObject\"]\n+ resources = [\"${aws_s3_bucket.this[0].arn}/*\"]\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.cloudfront_oai_iam_arns\n+ }\n+ }\n+\n+ statement {\n+ sid = \"AWSCloudFrontOAIList\"\n+ actions = [\"s3:ListBucket\"]\n+ resources = [aws_s3_bucket.this[0].arn]\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.cloudfront_oai_iam_arns\n+ }\n+ }\n+}\n+\n+# Grant read and list access to CloudFront Origin Access Controls\n+data \"aws_iam_policy_document\" \"cloudfront_oac_read_policy\" {\n+ count = local.create_bucket && var.attach_cloudfront_oac_read_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"AWSCloudFrontOACRead\"\n+ actions = [\"s3:GetObject\"]\n+ resources = [\"${aws_s3_bucket.this[0].arn}/*\"]\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"cloudfront.amazonaws.com\"]\n+ }\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:SourceArn\"\n+ values = var.cloudfront_oac_distribution_arns\n+ }\n+ }\n+\n+ statement {\n+ sid = \"AWSCloudFrontOACList\"\n+ actions = [\"s3:ListBucket\"]\n+ resources = [aws_s3_bucket.this[0].arn]\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"cloudfront.amazonaws.com\"]\n+ }\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:SourceArn\"\n+ values = var.cloudfront_oac_distribution_arns\n+ }\n+ }\n+}\n+\n data \"aws_iam_policy_document\" \"deny_insecure_transport\" {\n count = local.create_bucket && var.attach_deny_insecure_transport_policy ? 1 : 0\n \n---\nvariables.tf\n@@ -22,6 +22,18 @@ variable \"attach_access_log_delivery_policy\" {\n default = false\n }\n \n+variable \"attach_cloudfront_oai_read_policy\" {\n+ description = \"Controls if S3 bucket should have CloudFront Origin Access Identities policy attached (configure with `cloudfront_oai_iam_arns`)\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"attach_cloudfront_oac_read_policy\" {\n+ description = \"Controls if S3 bucket should have CloudFront Origin Access Controls policy attached (configure with `cloudfront_oac_distribution_arns`)\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"attach_deny_insecure_transport_policy\" {\n description = \"Controls if S3 bucket should have deny non-SSL transport policy attached\"\n type = bool\n@@ -100,6 +112,18 @@ variable \"acl\" {\n default = null\n }\n \n+variable \"cloudfront_oai_iam_arns\" {\n+ description = \"(Optional) List of CloudFront IAM ARNs to use in the CloudFront Origin Access Identities policy\"\n+ type = list(string)\n+ default = []\n+}\n+\n+variable \"cloudfront_oac_distribution_arns\" {\n+ description = \"(Optional) List of CloudFront distribution ARNs to use in the CloudFront Origin Access Controls policy\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"policy\" {\n description = \"(Optional) A valid bucket policy JSON document. Note that if the policy document is not specific enough (but still valid), Terraform may view the policy as constantly changing in a terraform plan. In this case, please make sure you use the verbose/specific version of the policy. For more information about building AWS IAM policy documents with Terraform, see the AWS IAM Policy Document Guide.\"\n type = string\n---\n\n\n---\n\nChoice C:\nmain.tf\n@@ -556,6 +556,8 @@ data \"aws_iam_policy_document\" \"combined\" var.attach_elb_log_delivery_policy ? data.aws_iam_policy_document.elb_log_delivery[0].json : \"\",\n var.attach_lb_log_delivery_policy ? data.aws_iam_policy_document.lb_log_delivery[0].json : \"\",\n var.attach_access_log_delivery_policy ? data.aws_iam_policy_document.access_log_delivery[0].json : \"\",\n+ var.attach_cloudfront_oai_read_policy ? data.aws_iam_policy_document.cloudfront_oai_read_policy[0].json : \"\",\n+ var.attach_cloudfront_oac_read_policy ? data.aws_iam_policy_document.cloudfront_oac_read_policy[0].json : \"\",\n var.attach_require_latest_tls_policy ? data.aws_iam_policy_document.require_latest_tls[0].json : \"\",\n var.attach_deny_insecure_transport_policy ? data.aws_iam_policy_document.deny_insecure_transport[0].json : \"\",\n var.attach_deny_unencrypted_object_uploads ? data.aws_iam_policy_document.deny_unencrypted_object_uploads[0].json : \"\",\n@@ -763,6 +765,66 @@ data \"aws_iam_policy_document\" \"access_log_delivery\" {\n }\n }\n \n+# Grant read and list access to CloudFront Origin Access Identities (deprecated by AWS)\n+data \"aws_iam_policy_document\" \"cloudfront_oai_read_policy\" {\n+ count = local.create_bucket && var.attach_cloudfront_oai_read_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"AWSCloudFrontOAIRead\"\n+ actions = [\"s3:GetObject\"]\n+ resources = [\"${aws_s3_bucket.this[0].arn}/*\"]\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.cloudfront_oai_iam_arns\n+ }\n+ }\n+\n+ statement {\n+ sid = \"AWSCloudFrontOAIList\"\n+ actions = [\"s3:ListBucket\"]\n+ resources = [aws_s3_bucket.this[0].arn]\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.cloudfront_oai_iam_arns\n+ }\n+ }\n+}\n+\n+# Grant read and list access to CloudFront Origin Access Controls\n+data \"aws_iam_policy_document\" \"cloudfront_oac_read_policy\" {\n+ count = local.create_bucket && var.attach_cloudfront_oac_read_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"AWSCloudFrontOACRead\"\n+ actions = [\"s3:GetObject\"]\n+ resources = [\"${aws_s3_bucket.this[0].arn}/*\"]\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"cloudfront.amazonaws.com\"]\n+ }\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:SourceArn\"\n+ values = var.cloudfront_oac_distribution_arns\n+ }\n+ }\n+\n+ statement {\n+ sid = \"AWSCloudFrontOACList\"\n+ actions = [\"s3:ListBucket\"]\n+ resources = [aws_s3_bucket.this[0].arn]\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"cloudfront.amazonaws.com\"]\n+ }\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:SourceArn\"\n+ values = var.cloudfront_oac_distribution_arns\n+ }\n+ }\n+}\n+\n data \"aws_iam_policy_document\" \"deny_insecure_transport\" {\n count = local.create_bucket && var.attach_deny_insecure_transport_policy ? 1 : 0\n \n---\nvariables.tf\n@@ -22,6 +22,18 @@ variable \"attach_access_log_delivery_policy\" {\n default = false\n }\n \n+variable \"attach_cloudfront_oai_read_policy\" {\n+ description = \"Controls if S3 bucket should have CloudFront Origin Access Identities policy attached (configure with `cloudfront_oai_iam_arns`)\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"attach_cloudfront_oac_read_policy\" {\n+ description = \"Controls if S3 bucket should have CloudFront Origin Access Controls policy attached (configure with `cloudfront_oac_distribution_arns`)\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"attach_deny_insecure_transport_policy\" {\n description = \"Controls if S3 bucket should have deny non-SSL transport policy attached\"\n type = bool\n@@ -100,6 +112,18 @@ variable \"acl\" {\n default = null\n }\n \n+variable \"cloudfront_oai_iam_arns\" {\n+ description = \"(Optional) List of CloudFront IAM ARNs to use in the CloudFront Origin Access Identities policy\"\n+ type = list(string)\n+ default = []\n+}\n+\n+variable \"cloudfront_oac_distribution_arns\" {\n+ description = \"(Optional) List of CloudFront distribution ARNs to use in the CloudFront Origin Access Controls policy\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"policy\" {\n description = \"(Optional) A valid bucket policy JSON document. Note that if the policy document is not specific enough (but still valid), Terraform may view the policy as constantly changing in a terraform plan. In this case, please make sure you use the verbose/specific version of the policy. For more information about building AWS IAM policy documents with Terraform, see the AWS IAM Policy Document Guide.\"\n type = string\n---\n\n\n---\n\nChoice D:\nmain.tf\n@@ -556,6 +556,8 @@ data \"aws_iam_policy_document\" \"combined\" {\n var.attach_elb_log_delivery_policy ? data.aws_iam_policy_document.elb_log_delivery[0].json : \"\",\n var.attach_lb_log_delivery_policy ? data.aws_iam_policy_document.lb_log_delivery[0].json : \"\",\n var.attach_access_log_delivery_policy ? data.aws_iam_policy_document.access_log_delivery[0].json : \"\",\n+ var.attach_cloudfront_oai_read_policy ? data.aws_iam_policy_document.cloudfront_oai_read_policy[0].json : \"\",\n+ var.attach_cloudfront_oac_read_policy ? data.aws_iam_policy_document.cloudfront_oac_read_policy[0].json : \"\",\n var.attach_require_latest_tls_policy ? data.aws_iam_policy_document.require_latest_tls[0].json : \"\",\n var.attach_deny_insecure_transport_policy ? data.aws_iam_policy_document.deny_insecure_transport[0].json : \"\",\n var.attach_deny_unencrypted_object_uploads ? data.aws_iam_policy_document.deny_unencrypted_object_uploads[0].json : \"\",\n@@ -763,6 +765,66 @@ data \"aws_iam_policy_document\" \"access_log_delivery\" {\n }\n }\n \n+# Grant read and list access to CloudFront Origin Access Identities (deprecated by AWS)\n+data \"aws_iam_policy_document\" \"cloudfront_oai_read_policy\" {\n+ count = local.create_bucket && var.attach_cloudfront_oai_read_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"AWSCloudFrontOAIRead\"\n+ actions = [\"s3:GetObject\"]\n+ resources = [\"${aws_s3_bucket.this[0].arn}/*\"]\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.cloudfront_oai_iam_arns\n+ }\n+ }\n+\n+ statement {\n+ sid = \"AWSCloudFrontOAIList\"\n+ actions = [\"s3:ListBucket\"]\n+ resources = [aws_s3_bucket.this[0].arn]\n+ principals {\n+ type = \"AWS\"\n+ identifiers = var.cloudfront_oai_iam_arns\n+ }\n+ }\n+}\n+\n+# Grant read and list access to CloudFront Origin Access Controls\n+data \"aws_iam_policy_document\" \"cloudfront_oac_read_policy\" {\n+ count = local.create_bucket && var.attach_cloudfront_oac_read_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"AWSCloudFrontOACRead\"\n+ actions = [\"s3:GetObject\"]\n+ resources = [\"${aws_s3_bucket.this[0].arn}/*\"]\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"cloudfront.amazonaws.com\"]\n+ }\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:SourceArn\"\n+ values = var.cloudfront_oac_distribution_arns\n+ }\n+ }\n+\n+ statement {\n+ sid = \"AWSCloudFrontOACList\"\n+ actions = [\"s3:ListBucket\"]\n+ resources = [aws_s3_bucket.this[0].arn]\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"cloudfront.amazonaws.com\"]\n+ }\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"aws:SourceArn\"\n+ values = var.cloudfront_oac_distribution_arns\n+ }\n+ }\n+}\n+\n data \"aws_iam_policy_document\" \"deny_insecure_transport\" {\n count = local.create_bucket && var.attach_deny_insecure_transport_policy ? 1 : 0\n \n---\nvariables.tf\n@@ -22,6 +22,18 @@ variable \"attach_access_log_delivery_policy\" {\n default = false\n }\n \n+variable \"attach_cloudfront_oai_read_policy\" {\n+ description = \"Controls if S3 bucket should have CloudFront Origin Access Identities policy attached (configure with `cloudfront_oai_iam_arns`)\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"attach_cloudfront_oac_read_policy\" {\n+ description = \"Controls if S3 bucket should have CloudFront Origin Access Controls policy attached (configure with `cloudfront_oac_distribution_arns`)\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"attach_deny_insecure_transport_policy\" {\n description = \"Controls if S3 bucket should have deny non-SSL transport policy attached\"\n type = bool\n@@ -100,6 +112,18 @@ variable \"acl\" {\n default = null\n }\n \n+variable \"cloudfront_oai_iam_arns\" {\n+ description = \"(Optional) List of CloudFront IAM ARNs to use in the CloudFront Origin Access Identities policy\"\n+ type = list(string)\n+ default = []\n+}\n+\n+variable \"cloudfront_oac_distribution_arns\" {\n+ description = \"(Optional) List of CloudFront distribution ARNs to use in the CloudFront Origin Access Controls policy\"\n+ type = list(string)\n+ default = []\n+}\n+\n variable \"policy\" {\n description = \"(Optional) A valid bucket policy JSON document. Note that if the policy document is not specific enough (but still valid), Terraform may view the policy as constantly changing in a terraform plan. In this case, please make sure you use the verbose/specific version of the policy. For more information about building AWS IAM policy documents with Terraform, see the AWS IAM Policy Document Guide.\"\n type = string\n---\n\n\n---\n" } ]
D
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\nThis skips executing the `data.aws_canonical_user_id.this` data source unless it is actually needed.\r\n\r\nThe data source is only needed when the `aws_s3_bucket_acl.this` resource needs to be created **and** the `var.owner[\"id\"]` value isn't available.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\nAs per [the `data.aws_canonical_user_id` documentation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/canonical_user_id), this data source requires the `s3:ListAllMyBuckets` IAM permission. Note that this permission isn't required by anything else in this module.\r\n\r\nWhen the data source isn't needed, then by the [principle of least privilege](https://en.wikipedia.org/wiki/Principle_of_least_privilege), we shouldn't require the `s3:ListAllMyBuckets` permission.\r\n\r\nThis additional permission is particularly obvious when [migrating](https://developer.hashicorp.com/terraform/tutorials/configuration-language/move-config) existing `aws_s3_*` resources into this module.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\nNot a breaking change:\r\n\r\n - the module interface (i.e. input and output variables) has not changed; and,\r\n - for existing use cases where the IAM entity already has the `s3:ListAllMyBuckets` permission, the module will continue to behave as before except simply skip the `ListBuckets` S3 API calls.\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s) - _No interface changes._\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmain.tf\n@@ -1,13 +1,17 @@\n data \"aws_region\" \"current\" {}\n \n-data \"aws_canonical_user_id\" \"this\" {}\n+data \"aws_canonical_user_id\" \"this\" {\n+ count = local.create_bucket && local.create_bucket_acl && try(var.owner[\"id\"], null) == null ? 1 : 0\n+}\n \n data \"aws_caller_identity\" \"current\" {}\n \n data \"aws_partition\" \"current\" {}\n locals {\n create_bucket = var.create_bucket && var.putin_khuylo\n \n+ create_bucket_acl = (var.acl != null && var.acl != \"null\") || length(local.grants) > 0\n+\n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_inventory_destination_policy || var.attach_deny_incorrect_encryption_headers || var.attach_deny_incorrect_kms_key_sse || var.attach_deny_unencrypted_object_uploads || var.attach_policy\n \n # Variables with \"aws_s3_bucket_acl\" `any` should be jsonencode()'d when value is coming from Terragrunt\n@@ -39,7 +43,7 @@ resource \"aws_s3_bucket_logging\" \"this\" {\n }\n \n resource \"aws_s3_bucket_acl\" \"this\" {\n- count = local.create_bucket && ((var.acl != null && var.acl != \"null\") || length(local.grants) > 0) ? 1 : 0\n+ count = local.create_bucket && local.create_bucket_acl ? 1 : 0\n \n bucket = aws_s3_bucket.this[0].id\n expected_bucket_owner = var.expected_bucket_owner\n@@ -67,7 +71,7 @@ resource \"aws_s3_bucket_acl\" \"this\" {\n }\n \n owner {\n- id = try(var.owner[\"id\"], data.aws_canonical_user_id.this.id)\n+ id = try(var.owner[\"id\"], data.aws_canonical_user_id.this[0].id)\n display_name = try(var.owner[\"display_name\"], null)\n }\n }\n---\n\n\n---\n\nChoice B:\nmain.tf\n@@ -1,13 +1,17 @@\n data \"aws_region\" \"current\" {}\n \n-data \"aws_canonical_user_id\" \"this\" {}\n+data \"aws_canonical_user_id\" \"this\" {\n+ count = local.create_bucket && local.create_bucket_acl && try(var.owner[\"id\"], null) == null ? 1 : 0\n+}\n \n data \"aws_caller_identity\" \"current\" {}\n \n data \"aws_partition\" \"current\" {}\n locals {\n create_bucket = var.create_bucket && var.putin_khuylo\n \n+ create_bucket_acl = (var.acl != null && var.acl != \"null\") || length(local.grants) > 0\n+\n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_inventory_destination_policy || var.attach_deny_incorrect_encryption_headers || var.attach_deny_incorrect_kms_key_sse || var.attach_deny_unencrypted_object_uploads || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n@@ -39,7 +43,7 @@ resource \"aws_s3_bucket_logging\" \"this\" {\n }\n \n resource \"aws_s3_bucket_acl\" \"this\" {\n- count = local.create_bucket && ((var.acl != null && var.acl != \"null\") || length(local.grants) > 0) ? 1 : 0\n+ count = local.create_bucket && local.create_bucket_acl ? 1 : 0\n \n bucket = aws_s3_bucket.this[0].id\n expected_bucket_owner = var.expected_bucket_owner\n@@ -67,7 +71,7 @@ resource \"aws_s3_bucket_acl\" \"this\" {\n }\n \n owner {\n- id = try(var.owner[\"id\"], data.aws_canonical_user_id.this.id)\n+ id = try(var.owner[\"id\"], data.aws_canonical_user_id.this[0].id)\n display_name = try(var.owner[\"display_name\"], null)\n }\n }\n---\n\n\n---\n\nChoice C:\nmain.tf\n@@ -1,13 +1,17 @@\n data \"aws_region\" \"current\" {}\n \n-data \"aws_canonical_user_id\" \"this\" {}\n+data \"aws_canonical_user_id\" \"this\" {\n+ count = local.create_bucket && local.create_bucket_acl && try(var.owner[\"id\"], null) == null ? 1 : 0\n+}\n \n data \"aws_caller_identity\" \"current\" {}\n \n data \"aws_partition\" \"current\" {}\n locals {\n create_bucket = var.create_bucket && var.putin_khuylo\n \n+ create_bucket_acl = (var.acl != null && var.acl != \"null\") || length(local.grants) > 0\n+\n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_inventory_destination_policy || var.attach_deny_incorrect_encryption_headers || var.attach_deny_incorrect_kms_key_sse || var.attach_deny_unencrypted_object_uploads || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n@@ -39,7 +43,7 @@ resource \"aws_s3_bucket_logging\" \"this\" {\n }\n \n resource \"aws_s3_bucket_acl\" \"this\" {\n- count = local.create_bucket && ((var.acl != null && var.acl != \"null\") || length(local.grants) > 0) ? 1 : 0\n+ count = local.create_bucket && local.create_bucket_acl ? 1 : 0\n \n bucket = aws_s3_bucket.this[0].id\n expected_bucket_owner = var.expected_bucket_owner\n@@ -67,7 +71,7 @@ resource \"aws_s3_bucket_acl\" \"this\" {\n }\n \n owner {\n- id = try(var.owner[\"id\"], data.aws_canonical_user_id.this.id)\n+ id = try(var.owner[\"id\"], data.aws_canonical_user_id.this[0].id)\n display_name = try(var.owner[\"display_name\"], null)\n }\n }\n---\n\n\n---\n\nChoice D:\nmain.tf\n@@ -1,13 +1,17 @@\n data \"aws_region\" \"current\" {}\n \n-data \"aws_canonical_user_id\" \"this\" {}\n+data \"aws_canonical_user_id\" \"this\" {\n+ count = local.create_bucket_acl && local.create_bucket_acl && try(var.owner[\"id\"], null) == null ? 1 : 0\n+}\n \n data \"aws_caller_identity\" \"current\" {}\n \n data \"aws_partition\" \"current\" {}\n locals {\n create_bucket = var.create_bucket && var.putin_khuylo\n \n+ create_bucket_acl = (var.acl != null && var.acl != \"null\") || length(local.grants) > 0\n+\n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_inventory_destination_policy || var.attach_deny_incorrect_encryption_headers || var.attach_deny_incorrect_kms_key_sse || var.attach_deny_unencrypted_object_uploads || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n@@ -39,7 +43,7 @@ resource \"aws_s3_bucket_logging\" \"this\" {\n }\n \n resource \"aws_s3_bucket_acl\" \"this\" {\n- count = local.create_bucket && ((var.acl != null && var.acl != \"null\") || length(local.grants) > 0) ? 1 : 0\n+ count = local.create_bucket && local.create_bucket_acl ? 1 : 0\n \n bucket = aws_s3_bucket.this[0].id\n expected_bucket_owner = var.expected_bucket_owner\n@@ -67,7 +71,7 @@ resource \"aws_s3_bucket_acl\" \"this\" {\n }\n \n owner {\n- id = try(var.owner[\"id\"], data.aws_canonical_user_id.this.id)\n+ id = try(var.owner[\"id\"], data.aws_canonical_user_id.this[0].id)\n display_name = try(var.owner[\"display_name\"], null)\n }\n }\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nAllow setting the id parameter inside the notification block.\r\n\r\n## Motivation and Context\r\nWhen configuring bucket notifications using map type inside another map, like in the example [here](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/blob/bf80a09f0955e6542a6ae8f3b7fa8fbd612148ea/examples/notification/main.tf#L145), there is no control on the order of the notifications.\r\n\r\nThis can cause terraform to change the resource and replace the notifications order after importing bucket notification, because the state contains list of sorted notifications and the map order can be different.\r\n\r\n```terraform\r\nsns_notifications = {\r\n ios = {\r\n topic_arn = \"arn:aws:sns:eu-west-1:123456789012:ios-log-upload\"\r\n events = [\"s3:ObjectCreated:*\"]\r\n filter_prefix = \"ios/\"\r\n },\r\n android = {\r\n topic_arn = \"arn:aws:sns:eu-west-1:123456789012:android-log-upload\"\r\n events = [\"s3:ObjectCreated:*\"]\r\n filter_prefix = \"android/\"\r\n }\r\n}\r\n```\r\n\r\n```terraform\r\n # aws_s3_bucket_notification.this[0] will be updated in-place\r\n ~ resource \"aws_s3_bucket_notification\" \"this\" {\r\n id = \"example-bucket-id\"\r\n # (2 unchanged attributes hidden)\r\n\r\n ~ topic {\r\n ~ filter_prefix = \"ios/\" -> \"android/\"\r\n ~ id = \"ios\" -> \"android\"\r\n ~ topic_arn = \"arn:aws:sns:eu-west-1:123456789012:ios-log-upload\" -> \"arn:aws:sns:eu-west-1:123456789012:android-log-upload\"\r\n # (1 unchanged attribute hidden)\r\n }\r\n ~ topic {\r\n ~ filter_prefix = \"android/\" -> \"ios/\"\r\n ~ id = \"android\" -> \"ios\"\r\n ~ topic_arn = \"arn:aws:sns:eu-west-1:123456789012:android-log-upload\" -> \"arn:aws:sns:eu-west-1:123456789012:ios-log-upload\"\r\n # (1 unchanged attribute hidden)\r\n }\r\n }\r\n\r\nPlan: 0 to add, 1 to change, 0 to destroy.\r\n```\r\n\r\nThis made me configure the notifications in a list rather then map type, but then I realized that the id parameter is not configurable, and will be the key (index) of the object in the list.\r\n\r\n```terraform\r\nsns_notifications = [\r\n {\r\n topic_arn = \"arn:aws:sns:eu-west-1:123456789012:ios-log-upload\"\r\n events = [\"s3:ObjectCreated:*\"]\r\n filter_prefix = \"ios/\"\r\n id = \"ios\"\r\n },\r\n {\r\n topic_arn = \"arn:aws:sns:eu-west-1:123456789012:android-log-upload\"\r\n events = [\"s3:ObjectCreated:*\"]\r\n filter_prefix = \"android/\"\r\n id = \"android\"\r\n }\r\n ]\r\n```\r\n```terraform\r\nTerraform will perform the following actions:\r\n\r\n # aws_s3_bucket_notification.this[0] will be updated in-place\r\n ~ resource \"aws_s3_bucket_notification\" \"this\" {\r\n id = \"example-bucket-id\"\r\n # (2 unchanged attributes hidden)\r\n\r\n ~ topic {\r\n ~ id = \"ios\" -> \"0\"\r\n # (3 unchanged attributes hidden)\r\n }\r\n ~ topic {\r\n ~ id = \"android\" -> \"1\"\r\n # (3 unchanged attributes hidden)\r\n }\r\n }\r\n\r\nPlan: 0 to add, 1 to change, 0 to destroy.\r\n```\r\n\r\nThe PR will make it possible to configure the id inside each notification block and will allow use of list type over map when you need to control the order of the notifications.\r\n\r\n## Breaking Changes\r\nNo breaking changes.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n\n\n---\n\nChoice A:\nmodules/notification/main.tf\n@@ -19,7 +19,7 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n for_each = var.lambda_notifications\n \n content {\n- id = lambda_function.key\n+ id = try(lambda_function.value.id, lambda_function.key)\n lambda_function_arn = lambda_function.value.function_arn\n events = lambda_function.value.events\n filter_prefix = try(lambda_function.value.filter_prefix, null)\n@@ -31,7 +31,7 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n for_each = var.sqs_notifications\n \n content {\n- id = queue.key\n+ id = try(queue.value.id, queue.key)\n queue_arn = queue.value.queue_arn\n events = queue.value.events\n filter_prefix = try(queue.value.filter_prefix, null)\n@@ -43,7 +43,7 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n for_each = var.sns_notifications\n \n content {\n- id = topic.key\n+ id = try(topic.value.id, topic.key)\n topic_arn = topic.value.topic_arn\n events = topic.value.events\n filter_prefix = try(topic.value.filter_prefix, null)\n---\n\n\n---\n\nChoice B:\nmodules/notification/main.tf\n@@ -19,7 +19,7 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n for_each = var.lambda_notifications\n \n content {\n- id = lambda_function.key\n+ id = try(lambda_function.value.id, lambda_function.key)\n lambda_function_arn = lambda_function.value.function_arn\n events = lambda_function.value.events\n filter_prefix = try(lambda_function.value.filter_prefix, null)\n@@ -31,7 +31,7 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n for_each = var.sqs_notifications\n \n content {\n- id = queue.key\n+ id = try(queue.value.id, queue.key)\n queue_arn = queue.value.queue_arn\n events = queue.value.events\n filter_prefix = try(queue.value.filter_prefix, null)\n@@ -43,7 +43,7 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n for_each = var.sns_notifications\n \n content {\n- id = topic.key\n+ id = try(topic.value.id, topic.key)\n topic_arn = topic.value.topic_arn\n events = topic.value.events\n filter_prefix = try(topic.value.filter_prefix, null)\n---\n\n\n---\n\nChoice C:\nmodules/notification/main.tf\n@@ -19,7 +19,7 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n for_each = var.lambda_notifications\n \n content {\n- id = lambda_function.key\n+ id = try(lambda_function.value.id, lambda_function.key)\n lambda_function_arn = lambda_function.value.function_arn\n events = lambda_function.value.events\n filter_prefix = try(lambda_function.value.filter_prefix, null)\n@@ -31,7 +31,7 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n for_each = var.sqs_notifications\n \n content {\n- id = queue.key\n+ id = try(queue.value.id, queue.key)\n queue_arn = queue.value.queue_arn\n events = queue.value.events\n filter_prefix = try(queue.value.filter_prefix, null)\n@@ -43,7 +43,7 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n for_each = var.sns_notifications\n \n content {\n- id = topic.key\n+ id = try(topic.value.id, topic.key)\n topic_arn = topic.value.topic_arn\n events = topic.value.events\n filter_prefix = try(topic.value.filter_prefix, null)\n---\n\n\n---\n\nChoice D:\nmodules/notification/main.tf\n@@ -19,7 +19,7 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n for_each = var.lambda_notifications\n \n content {\n- id = lambda_function.key\n+ id = try(lambda_function.value.id, lambda_function.key)\n lambda_function_arn = lambda_function.value.function_arn\n events = lambda_function.value.events\n filter_prefix = try(lambda_function.value.filter_prefix, null)\n@@ -31,7 +31,7 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n for_each = var.sqs_notifications\n \n content {\n- id = queue.key\n+ id = try(queue.value.id, queue.key)\n queue_arn = queue.value.queue_arn\n events = queue.value.events\n filter_prefix = try(queue.value.filter_prefix, null)\n@@ -43,7 +43,7 @@ resource \"aws_s3_bucket_notification\" \"this\" {\n for_each = var.sns_notifications\n \n content {\n- id = topic.key\n+ id = try(topic.value.id, topic.key)\n topic_arn = topic.value.topic_arn\n events = topic.value.events\n queue.value.queue_arn\n filter_prefix = try(topic.value.filter_prefix, null)\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nThis PR creates two new outputs: 1) a list of lifecycle rules applied to the s3 bucket and, 2) the policy applied to the s3 bucket. Each output is set to an empty string if its respective value is not provided.\r\n\r\nAdditionally, this PR removes the deprecated `skip_get_ec2_platforms` argument from the aws providers in all examples directories.\r\n\r\n## Motivation and Context\r\nWhile creating tests for my own S3 modules, I ran into a trouble when trying to validate lifecycle rules and policies applied to my S3 bucket. I was able to output the `data_iam_policy_document` easily enough but lifecycle rules are not available as a data source. My workaround was configuring the proper result in Go itself but it would be much better to output these values in case anyone wants to use them; for tests in my case.\r\n\r\nAdditionally, while running the pre-commit for these outputs, the validations were failing because the `skip_get_ec2_platforms` argument is not longer supported using Terraform version 1.4.5, the version used to perform all tests. To pass all validation checks, the `skip_get_ec2_platforms` argument was removed from the following examples directories:\r\n\r\n- [examples/notification](./examples/notification)\r\n- [examples/object](./examples/object)\r\n- [examples/s3-inventory](./examples/s3-inventory)\r\n- [examples/s3-replication](./examples/s3-replication)\r\n\r\n## Breaking Changes\r\nNo.\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n\n\n---\n\nChoice A:\nREADME.md\n@@ -236,6 +236,8 @@ No modules.\n | <a name=\"output_s3_bucket_bucket_regional_domain_name\"></a> [s3\\_bucket\\_bucket\\_regional\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_regional\\_domain\\_name) | The bucket region-specific domain name. The bucket domain name including the region name, please refer here of format. Note: The AWS CloudFront allows specifying S3 region-specific endpoint when creating S3 origin, it will prevent redirect issues from CloudFront to S3 Origin URL. |\n | <a name=\"output_s3_bucket_hosted_zone_id\"></a> [s3\\_bucket\\_hosted\\_zone\\_id](#output\\_s3\\_bucket\\_hosted\\_zone\\_id) | The Route 53 Hosted Zone ID for this bucket's region. |\n | <a name=\"output_s3_bucket_id\"></a> [s3\\_bucket\\_id](#output\\_s3\\_bucket\\_id) | The name of the bucket. |\n+| <a name=\"output_s3_bucket_lifecycle_configuration_rules\"></a> [s3\\_bucket\\_lifecycle\\_configuration\\_rules](#output\\_s3\\_bucket\\_lifecycle\\_configuration\\_rules) | The lifecycle rules of the bucket, if the bucket is configured with lifecycle rules. If not, this will be an empty string. |\n+| <a name=\"output_s3_bucket_policy\"></a> [s3\\_bucket\\_policy](#output\\_s3\\_bucket\\_policy) | The policy of the bucket, if the bucket is configured with a policy. If not, this will be an empty string. |\n | <a name=\"output_s3_bucket_region\"></a> [s3\\_bucket\\_region](#output\\_s3\\_bucket\\_region) | The AWS region this bucket resides in. |\n | <a name=\"output_s3_bucket_website_domain\"></a> [s3\\_bucket\\_website\\_domain](#output\\_s3\\_bucket\\_website\\_domain) | The domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records. |\n | <a name=\"output_s3_bucket_website_endpoint\"></a> [s3\\_bucket\\_website\\_endpoint](#output\\_s3\\_bucket\\_website\\_endpoint) | The website endpoint, if the bucket is configured with a website. If not, this will be an empty string. |\n---\nexamples/complete/README.md\n@@ -73,6 +73,8 @@ No inputs.\n | <a name=\"output_s3_bucket_bucket_regional_domain_name\"></a> [s3\\_bucket\\_bucket\\_regional\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_regional\\_domain\\_name) | The bucket region-specific domain name. The bucket domain name including the region name, please refer here for format. Note: The AWS CloudFront allows specifying S3 region-specific endpoint when creating S3 origin, it will prevent redirect issues from CloudFront to S3 Origin URL. |\n | <a name=\"output_s3_bucket_hosted_zone_id\"></a> [s3\\_bucket\\_hosted\\_zone\\_id](#output\\_s3\\_bucket\\_hosted\\_zone\\_id) | The Route 53 Hosted Zone ID for this bucket's region. |\n | <a name=\"output_s3_bucket_id\"></a> [s3\\_bucket\\_id](#output\\_s3\\_bucket\\_id) | The name of the bucket. |\n+| <a name=\"output_s3_bucket_lifecycle_configuration_rules\"></a> [s3\\_bucket\\_lifecycle\\_configuration\\_rules](#output\\_s3\\_bucket\\_lifecycle\\_configuration\\_rules) | The lifecycle rules of the bucket, if the bucket is configured with lifecycle rules. If not, this will be an empty string. |\n+| <a name=\"output_s3_bucket_policy\"></a> [s3\\_bucket\\_policy](#output\\_s3\\_bucket\\_policy) | The policy of the bucket, if the bucket is configured with a policy. If not, this will be an empty string. |\n | <a name=\"output_s3_bucket_region\"></a> [s3\\_bucket\\_region](#output\\_s3\\_bucket\\_region) | The AWS region this bucket resides in. |\n | <a name=\"output_s3_bucket_website_domain\"></a> [s3\\_bucket\\_website\\_domain](#output\\_s3\\_bucket\\_website\\_domain) | The domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records. |\n | <a name=\"output_s3_bucket_website_endpoint\"></a> [s3\\_bucket\\_website\\_endpoint](#output\\_s3\\_bucket\\_website\\_endpoint) | The website endpoint, if the bucket is configured with a website. If not, this will be an empty string. |\n---\nexamples/complete/outputs.tf\n@@ -23,6 +23,16 @@ output \"s3_bucket_hosted_zone_id\" {\n value = module.s3_bucket.s3_bucket_hosted_zone_id\n }\n \n+output \"s3_bucket_lifecycle_configuration_rules\" {\n+ description = \"The lifecycle rules of the bucket, if the bucket is configured with lifecycle rules. If not, this will be an empty string.\"\n+ value = module.s3_bucket.s3_bucket_lifecycle_configuration_rules\n+}\n+\n+output \"s3_bucket_policy\" {\n+ description = \"The policy of the bucket, if the bucket is configured with a policy. If not, this will be an empty string.\"\n+ value = module.s3_bucket.s3_bucket_policy\n+}\n+\n output \"s3_bucket_region\" {\n description = \"The AWS region this bucket resides in.\"\n value = module.s3_bucket.s3_bucket_region\n---\nexamples/notification/main.tf\n@@ -2,7 +2,6 @@ provider \"aws\" {\n region = local.region\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n---\nexamples/object/main.tf\n@@ -2,7 +2,6 @@ provider \"aws\" {\n region = local.region\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n---\nexamples/s3-inventory/main.tf\n@@ -7,7 +7,6 @@ provider \"aws\" {\n region = local.region\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n---\nexamples/s3-replication/main.tf\n@@ -2,7 +2,6 @@ provider \"aws\" {\n region = local.origin_region\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n@@ -15,7 +14,6 @@ provider \"aws\" {\n alias = \"replica\"\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n---\noutputs.tf\n@@ -23,6 +23,16 @@ output \"s3_bucket_hosted_zone_id\" {\n value = try(aws_s3_bucket.this[0].hosted_zone_id, \"\")\n }\n \n+output \"s3_bucket_lifecycle_configuration_rules\" {\n+ description = \"The lifecycle rules of the bucket, if the bucket is configured with lifecycle rules. If not, this will be an empty string.\"\n+ value = try(aws_s3_bucket_lifecycle_configuration.this[0].rule, \"\")\n+}\n+\n+output \"s3_bucket_policy\" {\n+ description = \"The policy of the bucket, if the bucket is configured with a policy. If not, this will be an empty string.\"\n+ value = try(aws_s3_bucket_policy.this[0].policy, \"\")\n+}\n+\n output \"s3_bucket_region\" {\n description = \"The AWS region this bucket resides in.\"\n value = try(aws_s3_bucket.this[0].region, \"\")\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -236,6 +236,8 @@ No modules.\n | <a name=\"output_s3_bucket_bucket_regional_domain_name\"></a> [s3\\_bucket\\_bucket\\_regional\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_regional\\_domain\\_name) | The bucket region-specific domain name. The bucket domain name including the region name, please refer here for format. Note: The AWS CloudFront allows specifying S3 region-specific endpoint when creating S3 origin, it will prevent redirect issues from CloudFront to S3 Origin URL. |\n | <a name=\"output_s3_bucket_hosted_zone_id\"></a> [s3\\_bucket\\_hosted\\_zone\\_id](#output\\_s3\\_bucket\\_hosted\\_zone\\_id) | The Route 53 Hosted Zone ID for this bucket's region. |\n | <a name=\"output_s3_bucket_id\"></a> [s3\\_bucket\\_id](#output\\_s3\\_bucket\\_id) | The name of the bucket. |\n+| <a name=\"output_s3_bucket_lifecycle_configuration_rules\"></a> [s3\\_bucket\\_lifecycle\\_configuration\\_rules](#output\\_s3\\_bucket\\_lifecycle\\_configuration\\_rules) | The lifecycle rules of the bucket, if the bucket is configured with lifecycle rules. If not, this will be an empty string. |\n+| <a name=\"output_s3_bucket_policy\"></a> [s3\\_bucket\\_policy](#output\\_s3\\_bucket\\_policy) | The policy of the bucket, if the bucket is configured with a policy. If not, this will be an empty string. |\n | <a name=\"output_s3_bucket_region\"></a> [s3\\_bucket\\_region](#output\\_s3\\_bucket\\_region) | with AWS region this bucket resides in. |\n | <a name=\"output_s3_bucket_website_domain\"></a> [s3\\_bucket\\_website\\_domain](#output\\_s3\\_bucket\\_website\\_domain) | The domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records. |\n | <a name=\"output_s3_bucket_website_endpoint\"></a> [s3\\_bucket\\_website\\_endpoint](#output\\_s3\\_bucket\\_website\\_endpoint) | The website endpoint, if the bucket is configured with a website. If not, this will be an empty string. |\n---\nexamples/complete/README.md\n@@ -73,6 +73,8 @@ No inputs.\n | <a name=\"output_s3_bucket_bucket_regional_domain_name\"></a> [s3\\_bucket\\_bucket\\_regional\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_regional\\_domain\\_name) | The bucket region-specific domain name. The bucket domain name including the region name, please refer here for format. Note: The AWS CloudFront allows specifying S3 region-specific endpoint when creating S3 origin, it will prevent redirect issues from CloudFront to S3 Origin URL. |\n | <a name=\"output_s3_bucket_hosted_zone_id\"></a> [s3\\_bucket\\_hosted\\_zone\\_id](#output\\_s3\\_bucket\\_hosted\\_zone\\_id) | The Route 53 Hosted Zone ID for this bucket's region. |\n | <a name=\"output_s3_bucket_id\"></a> [s3\\_bucket\\_id](#output\\_s3\\_bucket\\_id) | The name of the bucket. |\n+| <a name=\"output_s3_bucket_lifecycle_configuration_rules\"></a> [s3\\_bucket\\_lifecycle\\_configuration\\_rules](#output\\_s3\\_bucket\\_lifecycle\\_configuration\\_rules) | The lifecycle rules of the bucket, if the bucket is configured with lifecycle rules. If not, this will be an empty string. |\n+| <a name=\"output_s3_bucket_policy\"></a> [s3\\_bucket\\_policy](#output\\_s3\\_bucket\\_policy) | The policy of the bucket, if the bucket is configured with a policy. If not, this will be an empty string. |\n | <a name=\"output_s3_bucket_region\"></a> [s3\\_bucket\\_region](#output\\_s3\\_bucket\\_region) | The AWS region this bucket resides in. |\n | <a name=\"output_s3_bucket_website_domain\"></a> [s3\\_bucket\\_website\\_domain](#output\\_s3\\_bucket\\_website\\_domain) | The domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records. |\n | <a name=\"output_s3_bucket_website_endpoint\"></a> [s3\\_bucket\\_website\\_endpoint](#output\\_s3\\_bucket\\_website\\_endpoint) | The website endpoint, if the bucket is configured with a website. If not, this will be an empty string. |\n---\nexamples/complete/outputs.tf\n@@ -23,6 +23,16 @@ output \"s3_bucket_hosted_zone_id\" {\n value = module.s3_bucket.s3_bucket_hosted_zone_id\n }\n \n+output \"s3_bucket_lifecycle_configuration_rules\" {\n+ description = \"The lifecycle rules of the bucket, if the bucket is configured with lifecycle rules. If not, this will be an empty string.\"\n+ value = module.s3_bucket.s3_bucket_lifecycle_configuration_rules\n+}\n+\n+output \"s3_bucket_policy\" {\n+ description = \"The policy of the bucket, if the bucket is configured with a policy. If not, this will be an empty string.\"\n+ value = module.s3_bucket.s3_bucket_policy\n+}\n+\n output \"s3_bucket_region\" {\n description = \"The AWS region this bucket resides in.\"\n value = module.s3_bucket.s3_bucket_region\n---\nexamples/notification/main.tf\n@@ -2,7 +2,6 @@ provider \"aws\" {\n region = local.region\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n---\nexamples/object/main.tf\n@@ -2,7 +2,6 @@ provider \"aws\" {\n region = local.region\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n---\nexamples/s3-inventory/main.tf\n@@ -7,7 +7,6 @@ provider \"aws\" {\n region = local.region\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n---\nexamples/s3-replication/main.tf\n@@ -2,7 +2,6 @@ provider \"aws\" {\n region = local.origin_region\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n@@ -15,7 +14,6 @@ provider \"aws\" {\n alias = \"replica\"\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n---\noutputs.tf\n@@ -23,6 +23,16 @@ output \"s3_bucket_hosted_zone_id\" {\n value = try(aws_s3_bucket.this[0].hosted_zone_id, \"\")\n }\n \n+output \"s3_bucket_lifecycle_configuration_rules\" {\n+ description = \"The lifecycle rules of the bucket, if the bucket is configured with lifecycle rules. If not, this will be an empty string.\"\n+ value = try(aws_s3_bucket_lifecycle_configuration.this[0].rule, \"\")\n+}\n+\n+output \"s3_bucket_policy\" {\n+ description = \"The policy of the bucket, if the bucket is configured with a policy. If not, this will be an empty string.\"\n+ value = try(aws_s3_bucket_policy.this[0].policy, \"\")\n+}\n+\n output \"s3_bucket_region\" {\n description = \"The AWS region this bucket resides in.\"\n value = try(aws_s3_bucket.this[0].region, \"\")\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -236,6 +236,8 @@ No modules.\n | <a name=\"output_s3_bucket_bucket_regional_domain_name\"></a> [s3\\_bucket\\_bucket\\_regional\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_regional\\_domain\\_name) | The bucket region-specific domain name. The bucket domain name including the region name, please refer here for format. Note: The AWS CloudFront allows specifying S3 region-specific endpoint when creating S3 origin, it will prevent redirect issues from CloudFront to S3 Origin URL. |\n | <a name=\"output_s3_bucket_hosted_zone_id\"></a> [s3\\_bucket\\_hosted\\_zone\\_id](#output\\_s3\\_bucket\\_hosted\\_zone\\_id) | The Route 53 Hosted Zone ID for this bucket's region. |\n | <a name=\"output_s3_bucket_id\"></a> [s3\\_bucket\\_id](#output\\_s3\\_bucket\\_id) | The name of the bucket. |\n+| <a name=\"output_s3_bucket_lifecycle_configuration_rules\"></a> [s3\\_bucket\\_lifecycle\\_configuration\\_rules](#output\\_s3\\_bucket\\_lifecycle\\_configuration\\_rules) | The lifecycle rules of the bucket, if the bucket is configured with lifecycle rules. If not, this will be an empty string. |\n+| <a name=\"output_s3_bucket_policy\"></a> [s3\\_bucket\\_policy](#output\\_s3\\_bucket\\_policy) | The policy of the bucket, if the bucket is configured with a policy. If not, this will be an empty string. |\n | <a name=\"output_s3_bucket_region\"></a> [s3\\_bucket\\_region](#output\\_s3\\_bucket\\_region) | The AWS region this bucket resides in. |\n | <a name=\"output_s3_bucket_website_domain\"></a> [s3\\_bucket\\_website\\_domain](#output\\_s3\\_bucket\\_website\\_domain) | The domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records. |\n | <a name=\"output_s3_bucket_website_endpoint\"></a> [s3\\_bucket\\_website\\_endpoint](#output\\_s3\\_bucket\\_website\\_endpoint) | The website endpoint, if the bucket is configured with a website. If not, this will be an empty string. |\n---\nexamples/complete/README.md\n@@ -73,6 +73,8 @@ No inputs.\n | <a name=\"output_s3_bucket_bucket_regional_domain_name\"></a> [s3\\_bucket\\_bucket\\_regional\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_regional\\_domain\\_name) | The bucket region-specific domain name. The bucket domain name including the region name, please refer here for format. Note: The AWS CloudFront allows specifying S3 region-specific endpoint when creating S3 origin, it will prevent redirect issues from CloudFront to S3 Origin URL. |\n | <a name=\"output_s3_bucket_hosted_zone_id\"></a> [s3\\_bucket\\_hosted\\_zone\\_id](#output\\_s3\\_bucket\\_hosted\\_zone\\_id) | The Route 53 Hosted Zone ID for this bucket's region. |\n | <a name=\"output_s3_bucket_id\"></a> [s3\\_bucket\\_id](#output\\_s3\\_bucket\\_id) | The name of the bucket. |\n+| <a name=\"output_s3_bucket_lifecycle_configuration_rules\"></a> [s3\\_bucket\\_lifecycle\\_configuration\\_rules](#output\\_s3\\_bucket\\_lifecycle\\_configuration\\_rules) | The lifecycle rules of the bucket, if the bucket is configured with lifecycle rules. If not, this will be an empty string. |\n+| <a name=\"output_s3_bucket_policy\"></a> [s3\\_bucket\\_policy](#output\\_s3\\_bucket\\_policy) | The policy of the bucket, if the bucket is configured with a policy. If not, this will be an empty string. |\n | <a name=\"output_s3_bucket_region\"></a> [s3\\_bucket\\_region](#output\\_s3\\_bucket\\_region) | The AWS region this bucket resides in. |\n | <a name=\"output_s3_bucket_website_domain\"></a> [s3\\_bucket\\_website\\_domain](#output\\_s3\\_bucket\\_website\\_domain) | The domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records. |\n | <a name=\"output_s3_bucket_website_endpoint\"></a> [s3\\_bucket\\_website\\_endpoint](#output\\_s3\\_bucket\\_website\\_endpoint) | The website endpoint, if the bucket is configured with a website. If not, this will be an empty string. |\n---\nexamples/complete/outputs.tf\n@@ -23,6 +23,16 @@ output \"s3_bucket_hosted_zone_id\" {\n value = module.s3_bucket.s3_bucket_hosted_zone_id\n }\n \n+output \"s3_bucket_lifecycle_configuration_rules\" {\n+ description = \"The lifecycle rules of the bucket, if the bucket is configured with lifecycle rules. If not, this will be an empty string.\"\n+ value = module.s3_bucket.s3_bucket_lifecycle_configuration_rules\n+}\n+\n+output \"s3_bucket_policy\" {\n+ description = \"The policy of the bucket, if the bucket is configured with a policy. If not, this will be an empty string.\"\n+ value = module.s3_bucket.s3_bucket_policy\n+}\n+\n output \"s3_bucket_region\" {\n description = \"The AWS region this bucket resides in.\"\n value = module.s3_bucket.s3_bucket_region\n---\nexamples/notification/main.tf\n@@ -2,7 +2,6 @@ provider \"aws\" {\n region = local.region\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n---\nexamples/object/main.tf\n@@ -2,7 +2,6 @@ provider \"aws\" {\n region = local.region\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n---\nexamples/s3-inventory/main.tf\n@@ -7,7 +7,6 @@ provider \"aws\" {\n region = local.region\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n---\nexamples/s3-replication/main.tf\n@@ -2,7 +2,6 @@ provider \"aws\" {\n region = local.origin_region\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n@@ -15,7 +14,6 @@ provider \"aws\" {\n alias = \"replica\"\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n---\noutputs.tf\n@@ -23,6 +23,16 @@ output \"s3_bucket_hosted_zone_id\" {\n value = try(aws_s3_bucket.this[0].hosted_zone_id, \"\")\n }\n \n+output \"s3_bucket_lifecycle_configuration_rules\" {\n+ description = \"The lifecycle rules of the bucket, if the bucket is configured with lifecycle rules. If not, this will be an empty string.\"\n+ value = try(aws_s3_bucket_lifecycle_configuration.this[0].rule, \"\")\n+}\n+\n+output \"s3_bucket_policy\" {\n+ description = \"The policy of the bucket, if the bucket is configured with a policy. If not, this will be an empty string.\"\n+ value = try(aws_s3_bucket_policy.this[0].policy, \"\")\n+}\n+\n output \"s3_bucket_region\" {\n description = \"The AWS region this bucket resides in.\"\n value = try(aws_s3_bucket.this[0].region, \"\")\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -236,6 +236,8 @@ No modules.\n | <a name=\"output_s3_bucket_bucket_regional_domain_name\"></a> [s3\\_bucket\\_bucket\\_regional\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_regional\\_domain\\_name) | The bucket region-specific domain name. The bucket domain name including the region name, please refer here for format. Note: The AWS CloudFront allows specifying S3 region-specific endpoint when creating S3 origin, it will prevent redirect issues from CloudFront to S3 Origin URL. |\n | <a name=\"output_s3_bucket_hosted_zone_id\"></a> [s3\\_bucket\\_hosted\\_zone\\_id](#output\\_s3\\_bucket\\_hosted\\_zone\\_id) | The Route 53 Hosted Zone ID for this bucket's region. |\n | <a name=\"output_s3_bucket_id\"></a> [s3\\_bucket\\_id](#output\\_s3\\_bucket\\_id) | The name of the bucket. |\n+| <a name=\"output_s3_bucket_lifecycle_configuration_rules\"></a> [s3\\_bucket\\_lifecycle\\_configuration\\_rules](#output\\_s3\\_bucket\\_lifecycle\\_configuration\\_rules) | The lifecycle rules of the bucket, if the bucket is configured with lifecycle rules. If not, this will be an empty string. |\n+| <a name=\"output_s3_bucket_policy\"></a> [s3\\_bucket\\_policy](#output\\_s3\\_bucket\\_policy) | The policy of the bucket, if the bucket is configured with a policy. If not, this will be an empty string. |\n | <a name=\"output_s3_bucket_region\"></a> [s3\\_bucket\\_region](#output\\_s3\\_bucket\\_region) \"s3_bucket_policy\" The AWS region this bucket resides in. |\n | <a name=\"output_s3_bucket_website_domain\"></a> [s3\\_bucket\\_website\\_domain](#output\\_s3\\_bucket\\_website\\_domain) | The domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records. |\n | <a name=\"output_s3_bucket_website_endpoint\"></a> [s3\\_bucket\\_website\\_endpoint](#output\\_s3\\_bucket\\_website\\_endpoint) | The website endpoint, if the bucket is configured with a website. If not, this will be an empty string. |\n---\nexamples/complete/README.md\n@@ -73,6 +73,8 @@ No inputs.\n | <a name=\"output_s3_bucket_bucket_regional_domain_name\"></a> [s3\\_bucket\\_bucket\\_regional\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_regional\\_domain\\_name) | The bucket region-specific domain name. The bucket domain name including the region name, please refer here for format. Note: The AWS CloudFront allows specifying S3 region-specific endpoint when creating S3 origin, it will prevent redirect issues from CloudFront to S3 Origin URL. |\n | <a name=\"output_s3_bucket_hosted_zone_id\"></a> [s3\\_bucket\\_hosted\\_zone\\_id](#output\\_s3\\_bucket\\_hosted\\_zone\\_id) | The Route 53 Hosted Zone ID for this bucket's region. |\n | <a name=\"output_s3_bucket_id\"></a> [s3\\_bucket\\_id](#output\\_s3\\_bucket\\_id) | The name of the bucket. |\n+| <a name=\"output_s3_bucket_lifecycle_configuration_rules\"></a> [s3\\_bucket\\_lifecycle\\_configuration\\_rules](#output\\_s3\\_bucket\\_lifecycle\\_configuration\\_rules) | The lifecycle rules of the bucket, if the bucket is configured with lifecycle rules. If not, this will be an empty string. |\n+| <a name=\"output_s3_bucket_policy\"></a> [s3\\_bucket\\_policy](#output\\_s3\\_bucket\\_policy) | The policy of the bucket, if the bucket is configured with a policy. If not, this will be an empty string. |\n | <a name=\"output_s3_bucket_region\"></a> [s3\\_bucket\\_region](#output\\_s3\\_bucket\\_region) | The AWS region this bucket resides in. |\n | <a name=\"output_s3_bucket_website_domain\"></a> [s3\\_bucket\\_website\\_domain](#output\\_s3\\_bucket\\_website\\_domain) | The domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records. |\n | <a name=\"output_s3_bucket_website_endpoint\"></a> [s3\\_bucket\\_website\\_endpoint](#output\\_s3\\_bucket\\_website\\_endpoint) | The website endpoint, if the bucket is configured with a website. If not, this will be an empty string. |\n---\nexamples/complete/outputs.tf\n@@ -23,6 +23,16 @@ output \"s3_bucket_hosted_zone_id\" {\n value = module.s3_bucket.s3_bucket_hosted_zone_id\n }\n \n+output \"s3_bucket_lifecycle_configuration_rules\" {\n+ description = \"The lifecycle rules of the bucket, if the bucket is configured with lifecycle rules. If not, this will be an empty string.\"\n+ value = module.s3_bucket.s3_bucket_lifecycle_configuration_rules\n+}\n+\n+output \"s3_bucket_policy\" {\n+ description = \"The policy of the bucket, if the bucket is configured with a policy. If not, this will be an empty string.\"\n+ value = module.s3_bucket.s3_bucket_policy\n+}\n+\n output \"s3_bucket_region\" {\n description = \"The AWS region this bucket resides in.\"\n value = module.s3_bucket.s3_bucket_region\n---\nexamples/notification/main.tf\n@@ -2,7 +2,6 @@ provider \"aws\" {\n region = local.region\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n---\nexamples/object/main.tf\n@@ -2,7 +2,6 @@ provider \"aws\" {\n region = local.region\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n---\nexamples/s3-inventory/main.tf\n@@ -7,7 +7,6 @@ provider \"aws\" {\n region = local.region\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n---\nexamples/s3-replication/main.tf\n@@ -2,7 +2,6 @@ provider \"aws\" {\n region = local.origin_region\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n@@ -15,7 +14,6 @@ provider \"aws\" {\n alias = \"replica\"\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n---\noutputs.tf\n@@ -23,6 +23,16 @@ output \"s3_bucket_hosted_zone_id\" {\n value = try(aws_s3_bucket.this[0].hosted_zone_id, \"\")\n }\n \n+output \"s3_bucket_lifecycle_configuration_rules\" {\n+ description = \"The lifecycle rules of the bucket, if the bucket is configured with lifecycle rules. If not, this will be an empty string.\"\n+ value = try(aws_s3_bucket_lifecycle_configuration.this[0].rule, \"\")\n+}\n+\n+output \"s3_bucket_policy\" {\n+ description = \"The policy of the bucket, if the bucket is configured with a policy. If not, this will be an empty string.\"\n+ value = try(aws_s3_bucket_policy.this[0].policy, \"\")\n+}\n+\n output \"s3_bucket_region\" {\n description = \"The AWS region this bucket resides in.\"\n value = try(aws_s3_bucket.this[0].region, \"\")\n---\n\n\n---\n" } ]
C
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nAdded extra guard option to create lifecycle rule for expiration whole bucket\r\n\r\n## Motivation and Context\r\nIn our case, we created a bucket without any filter prefix, which causes expiration of about 1,5TB of data in bucket.\r\nWe had code like snippet bellow\r\n```hcl\r\nmodule \"s3_bucket\" {\r\n source = \"terraform-aws-modules/s3-bucket/aws\"\r\n\r\n lifecycle_rule = [\r\n {\r\n enabled = true\r\n prefix = \"prefix-to-cleanup/\"\r\n \r\n expiration = {\r\n days = 1\r\n }\r\n }\r\n ]\r\n}\r\n```\r\nThere is a missing `filter` section wrapping `prefix`. Sadly terraform does not throw any error that config is inaccurate. That code created lifecycle rules for the whole bucket.\r\n\r\nWe wanted to be sure not to make the same mistake again and create some kind of guard before this situation. Without passing extra option, no expiration section will be created - that should be less pain than losing data ;)\r\n\r\nPassing one extra option should not be a big deal - AWS Console have a similar checkbox to prevent creating rule for the whole bucket.\r\n\r\n## Breaking Changes\r\nConditionaly/Partialy - if someone wanted to create lifecycle to cleanup whole bucket it is needed to pass extra option.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nREADME.md\n@@ -90,6 +90,67 @@ module \"s3_bucket\" {\n }\n ```\n \n+## Expiration lifecycle rules for the whole bucket\n+\n+To prevent accidentally creating a lifecycle rule for the whole bucket that could remove all of your files, you must pass the `expire_all_objects_in_bucket = true` option.\n+\n+```hcl\n+# This S3 bucket has an expiration lifecycle rule only for the specified prefix\n+module \"s3_bucket\" {\n+ source = \"terraform-aws-modules/s3-bucket/aws\"\n+\n+ lifecycle_rule = [\n+ {\n+ enabled = true\n+\n+ filter = {\n+ prefix = \"prefix-to-cleanup/\"\n+ }\n+\n+ expiration = days = 1\n+ }\n+ }\n+ ]\n+}\n+```\n+\n+```hcl\n+# This S3 bucket has an expiration lifecycle for the whole bucket\n+module \"s3_bucket\" {\n+ source = \"terraform-aws-modules/s3-bucket/aws\"\n+\n+ lifecycle_rule = [\n+ {\n+ enabled = true\n+\n+ expire_all_objects_in_bucket = true\n+ expiration = {\n+ days = 1\n+ }\n+ }\n+ ]\n+}\n+```\n+\n+```hcl\n+# This S3 bucket does NOT have ANY expiration lifecycle rule\n+module \"s3_bucket\" {\n+ source = \"terraform-aws-modules/s3-bucket/aws\"\n+\n+ lifecycle_rule = [\n+ {\n+ enabled = true\n+\n+ # no option or expire_all_objects_in_bucket = false\n+ expiration = {\n+ days = 1\n+ }\n+ }\n+ ]\n+}\n+```\n+\n ## Terragrunt and `variable \"...\" { type = any }`\n \n There is a bug [#1211](https://github.com/gruntwork-io/terragrunt/issues/1211) in Terragrunt related to the way how the variables of type `any` are passed to Terraform.\n---\nmain.tf\n@@ -237,7 +237,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - expiration\n dynamic \"expiration\" {\n- for_each = try(flatten([rule.value.expiration]), [])\n+ for_each = try(rule.value.expire_all_objects_in_bucket, false) == true || try(rule.value.filter.prefix, rule.value.filter.object_size_less_than, rule.value.filter.object_size_greater_than, rule.value.filter.tags, null) != null ? try(flatten([rule.value.expiration]), []) : []\n \n content {\n date = try(expiration.value.date, null)\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -90,6 +90,67 @@ module \"s3_bucket\" {\n }\n ```\n \n+## Expiration lifecycle rules for the whole bucket\n+\n+To prevent accidentally creating a lifecycle rule for the whole bucket that could remove all of your files, you must pass the `expire_all_objects_in_bucket = true` option.\n+\n+```hcl\n+# This S3 bucket has an expiration lifecycle rule only for the specified prefix\n+module \"s3_bucket\" {\n+ source = \"terraform-aws-modules/s3-bucket/aws\"\n+\n+ lifecycle_rule = [\n+ {\n+ enabled = true\n+\n+ filter = {\n+ prefix = \"prefix-to-cleanup/\"\n+ }\n+\n+ expiration = {\n+ days = 1\n+ }\n+ }\n+ ]\n+}\n+```\n+\n+```hcl\n+# This S3 bucket has an expiration lifecycle for the whole bucket\n+module \"s3_bucket\" {\n+ source = \"terraform-aws-modules/s3-bucket/aws\"\n+\n+ lifecycle_rule = [\n+ {\n+ enabled = true\n+\n+ expire_all_objects_in_bucket = true\n+ expiration = {\n+ days = 1\n+ }\n+ }\n+ ]\n+}\n+```\n+\n+```hcl\n+# This S3 bucket does NOT have ANY expiration lifecycle rule\n+module \"s3_bucket\" {\n+ source = \"terraform-aws-modules/s3-bucket/aws\"\n+\n+ lifecycle_rule = [\n+ {\n+ enabled = true\n+\n+ # no option or expire_all_objects_in_bucket = false\n+ expiration = {\n+ days = 1\n+ }\n+ }\n+ ]\n+}\n+```\n+\n ## Terragrunt and `variable \"...\" { type = any }`\n \n There is a bug [#1211](https://github.com/gruntwork-io/terragrunt/issues/1211) in Terragrunt related to the way how the variables of type `any` are passed to Terraform.\n---\nmain.tf\n@@ -237,7 +237,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - expiration\n dynamic \"expiration\" {\n- for_each = try(flatten([rule.value.expiration]), [])\n+ for_each = try(rule.value.expire_all_objects_in_bucket, false) == true || try(rule.value.filter.prefix, rule.value.filter.object_size_less_than, rule.value.filter.object_size_greater_than, rule.value.filter.tags, null) != null ? try(flatten([rule.value.expiration]), []) : []\n \n content {\n date = try(expiration.value.date, null)\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -90,6 +90,67 @@ module \"s3_bucket\" {\n }\n ```\n \n+## Expiration lifecycle rules for the whole bucket\n+\n+To prevent accidentally creating a lifecycle rule for the whole bucket that could remove all of your files, you must pass the `expire_all_objects_in_bucket = true` option.\n+\n+```hcl\n+# This S3 bucket has an expiration lifecycle rule only for the specified prefix\n+module \"s3_bucket\" {\n+ source = \"terraform-aws-modules/s3-bucket/aws\"\n+\n+ lifecycle_rule = [\n+ {\n+ enabled = true\n+\n+ filter = {\n+ prefix = \"prefix-to-cleanup/\"\n+ }\n+\n+ expiration = {\n+ days = 1\n+ }\n+ }\n+ ]\n+}\n+```\n+\n+```hcl\n+# This S3 bucket has an expiration lifecycle for the whole bucket\n+module \"s3_bucket\" {\n+ source = \"terraform-aws-modules/s3-bucket/aws\"\n+\n+ lifecycle_rule = [\n+ {\n+ enabled = true\n+\n+ expire_all_objects_in_bucket = true\n+ expiration = {\n+ days = 1\n+ }\n+ }\n+ ]\n+}\n+```\n+\n+```hcl\n+# This S3 bucket does NOT have ANY expiration lifecycle rule\n+module \"s3_bucket\" {\n+ source = \"terraform-aws-modules/s3-bucket/aws\"\n+\n+ lifecycle_rule = [\n+ {\n+ enabled = true\n+\n+ # no option or expire_all_objects_in_bucket = false\n+ @@ expiration = {\n+ days = 1\n+ }\n+ }\n+ ]\n+}\n+```\n+\n ## Terragrunt and `variable \"...\" { type = any }`\n \n There is a bug [#1211](https://github.com/gruntwork-io/terragrunt/issues/1211) in Terragrunt related to the way how the variables of type `any` are passed to Terraform.\n---\nmain.tf\n@@ -237,7 +237,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - expiration\n dynamic \"expiration\" {\n- for_each = try(flatten([rule.value.expiration]), [])\n+ for_each = try(rule.value.expire_all_objects_in_bucket, false) == true || try(rule.value.filter.prefix, rule.value.filter.object_size_less_than, rule.value.filter.object_size_greater_than, rule.value.filter.tags, null) != null ? try(flatten([rule.value.expiration]), []) : []\n \n content {\n date = try(expiration.value.date, null)\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -90,6 +90,67 @@ module \"s3_bucket\" {\n }\n ```\n \n+## Expiration lifecycle rules for the whole bucket\n+\n+To prevent accidentally creating a lifecycle rule for the whole bucket that could remove all of your files, you must pass the `expire_all_objects_in_bucket = true` option.\n+\n+```hcl\n+# This S3 bucket has an expiration lifecycle rule only for the specified prefix\n+module \"s3_bucket\" {\n+ source = \"terraform-aws-modules/s3-bucket/aws\"\n+\n+ lifecycle_rule = [\n+ {\n+ enabled = true\n+\n+ filter = {\n+ prefix = \"prefix-to-cleanup/\"\n+ }\n+\n+ expiration = {\n+ days = 1\n+ }\n+ }\n+ ]\n+}\n+```\n+\n+```hcl\n+# This S3 bucket = an expiration lifecycle for the whole bucket\n+module \"s3_bucket\" {\n+ source = \"terraform-aws-modules/s3-bucket/aws\"\n+\n+ lifecycle_rule = [\n+ {\n+ enabled = true\n+\n+ expire_all_objects_in_bucket = true\n+ expiration = {\n+ days = 1\n+ }\n+ }\n+ ]\n+}\n+```\n+\n+```hcl\n+# This S3 bucket does NOT have ANY expiration lifecycle rule\n+module \"s3_bucket\" {\n+ source = \"terraform-aws-modules/s3-bucket/aws\"\n+\n+ lifecycle_rule = [\n+ {\n+ enabled = true\n+\n+ # no option or expire_all_objects_in_bucket = false\n+ expiration = {\n+ days = 1\n+ }\n+ }\n+ ]\n+}\n+```\n+\n ## Terragrunt and `variable \"...\" { type = any }`\n \n There is a bug [#1211](https://github.com/gruntwork-io/terragrunt/issues/1211) in Terragrunt related to the way how the variables of type `any` are passed to Terraform.\n---\nmain.tf\n@@ -237,7 +237,7 @@ resource \"aws_s3_bucket_lifecycle_configuration\" \"this\" {\n \n # Max 1 block - expiration\n dynamic \"expiration\" {\n- for_each = try(flatten([rule.value.expiration]), [])\n+ for_each = try(rule.value.expire_all_objects_in_bucket, false) == true || try(rule.value.filter.prefix, rule.value.filter.object_size_less_than, rule.value.filter.object_size_greater_than, rule.value.filter.tags, null) != null ? try(flatten([rule.value.expiration]), []) : []\n \n content {\n date = try(expiration.value.date, null)\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\nFollowing [AWS update of April 2023](https://aws.amazon.com/blogs/aws/heads-up-amazon-s3-security-changes-are-coming-in-april-of-2023/) for S3 Bucket Public Access Block default values for resources created via api calls, buckets are now created with `block all public access` enabled by default.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nIf a bucket is created with a public read policy, it will incur in 403 Access Denied caused by `block all public access` enabled at bucket creation, with the previous dependency chain the bucket policy gets created before the `block all public access` block.\r\n\r\nExample of public read bucket policy:\r\n```\r\n{\r\n \"Version\": \"2012-10-17\",\r\n \"Statement\": [\r\n {\r\n \"Sid\": \"ReadBucketPolicy\",\r\n \"Effect\": \"Allow\",\r\n \"Principal\": \"*\",\r\n \"Action\": \"s3:GetObject\",\r\n \"Resource\": \"arn:aws:s3:::bucket_name/*\"\r\n }\r\n ]\r\n}\r\n```\r\n\r\nInverting the dependency chain between `aws_s3_bucket_policy.this` and `aws_s3_bucket_public_access_block.this` will solve this issue.\r\n\r\n## Example to reproduce the issue\r\n\r\n```\r\n# https://github.com/terraform-aws-modules/terraform-aws-s3-bucket\r\nmodule \"s3-dd6271fee6c7c15a5dfa2041aef5f9e6de89b5ce\" {\r\n source = \"terraform-aws-modules/s3-bucket/aws\"\r\n\r\n bucket = \"dd6271fee6c7c15a5dfa2041aef5f9e6de89b5ce-pr227\"\r\n attach_policy = true\r\n attach_require_latest_tls_policy = true\r\n block_public_acls = true\r\n block_public_policy = false # Not updated before bucket policy due to current chain dependency\r\n restrict_public_buckets = false # Not updated before bucket policy due to current chain dependency\r\n force_destroy = true\r\n ignore_public_acls = true\r\n policy = jsonencode({\r\n \"Version\": \"2012-10-17\",\r\n \"Statement\": [\r\n {\r\n \"Sid\": \"ReadBucketPolicy\",\r\n \"Effect\": \"Allow\",\r\n \"Principal\": \"*\",\r\n \"Action\": \"s3:GetObject\",\r\n \"Resource\": \"arn:aws:s3::dd6271fee6c7c15a5dfa2041aef5f9e6de89b5ce-pr227/*\"\r\n }\r\n ]\r\n })\r\n}\r\n```\r\n\r\n### Obtained error\r\n```\r\nmodule.s3-dd6271fee6c7c15a5dfa2041aef5f9e6de89b5ce.aws_s3_bucket.this[0]: Creating...\r\nmodule.s3-dd6271fee6c7c15a5dfa2041aef5f9e6de89b5ce.aws_s3_bucket.this[0]: Creation complete after 3s [id=dd6271fee6c7c15a5dfa2041aef5f9e6de89b5ce-pr227]\r\nmodule.s3-dd6271fee6c7c15a5dfa2041aef5f9e6de89b5ce.data.aws_iam_policy_document.require_latest_tls[0]: Reading...\r\nmodule.s3-dd6271fee6c7c15a5dfa2041aef5f9e6de89b5ce.data.aws_iam_policy_document.require_latest_tls[0]: Read complete after 0s [id=3386508698]\r\nmodule.s3-dd6271fee6c7c15a5dfa2041aef5f9e6de89b5ce.data.aws_iam_policy_document.combined[0]: Reading...\r\nmodule.s3-dd6271fee6c7c15a5dfa2041aef5f9e6de89b5ce.data.aws_iam_policy_document.combined[0]: Read complete after 0s [id=3075998097]\r\nmodule.s3-dd6271fee6c7c15a5dfa2041aef5f9e6de89b5ce.aws_s3_bucket_policy.this[0]: Creating...\r\n╷\r\n│ Error: Error putting S3 policy: AccessDenied: Access Denied\r\n│ status code: 403, request id: <REDACTED>, host id: <REDACTED>\r\n│\r\n│ with module.s3-dd6271fee6c7c15a5dfa2041aef5f9e6de89b5ce.aws_s3_bucket_policy.this[0],\r\n│ on .terraform/modules/s3-dd6271fee6c7c15a5dfa2041aef5f9e6de89b5ce/main.tf line 512, in resource \"aws_s3_bucket_policy\" \"this\":\r\n│ 512: resource \"aws_s3_bucket_policy\" \"this\" {\r\n│\r\n╵\r\n```\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [x] I have provided at least one example in the PR to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n- [x] I have tested and validated these changes in aws cloud\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmain.tf\n@@ -512,8 +512,16 @@ resource \"aws_s3_bucket_replication_configuration\" \"this\" {\n resource \"aws_s3_bucket_policy\" \"this\" {\n count = local.create_bucket && local.attach_policy ? 1 : 0\n \n+ # Chain resources (s3_bucket -> s3_bucket_public_access_block -> s3_bucket_policy )\n+ # to prevent \"A conflicting conditional operation is currently in progress against this resource.\"\n+ # Ref: https://github.com/hashicorp/terraform-provider-aws/issues/7628\n+\n bucket = aws_s3_bucket.this[0].id\n policy = data.aws_iam_policy_document.combined[0].json\n+\n+ depends_on = [\n+ aws_s3_bucket_public_access_block.this\n+ ]\n }\n \n data \"aws_iam_policy_document\" \"combined\" {\n@@ -789,11 +797,7 @@ data \"aws_iam_policy_document\" \"require_latest_tls\" {\n resource \"aws_s3_bucket_public_access_block\" \"this\" {\n count = local.create_bucket && var.attach_public_policy ? 1 : 0\n \n- # Chain resources (s3_bucket -> \n -> s3_bucket_public_access_block)\n- # to prevent \"A conflicting conditional operation is currently in progress against this resource.\"\n- # Ref: https://github.com/hashicorp/terraform-provider-aws/issues/7628\n-\n- bucket = local.attach_policy ? aws_s3_bucket_policy.this[0].id : aws_s3_bucket.this[0].id\n+ bucket = aws_s3_bucket.this[0].id\n \n block_public_acls = var.block_public_acls\n block_public_policy = var.block_public_policy\n---\n\n\n---\n\nChoice B:\nmain.tf\n@@ -512,8 +512,16 @@ resource \"aws_s3_bucket_replication_configuration\" \"this\" {\n resource \"aws_s3_bucket_policy\" \"this\" {\n count = local.create_bucket && local.attach_policy ? 1 : 0\n \n+ # Chain resources (s3_bucket -> s3_bucket_public_access_block -> s3_bucket_policy )\n+ # to prevent \"A conflicting conditional operation is currently in progress against resource resource.\"\n+ # Ref: https://github.com/hashicorp/terraform-provider-aws/issues/7628\n+\n bucket = aws_s3_bucket.this[0].id\n policy = data.aws_iam_policy_document.combined[0].json\n+\n+ depends_on = [\n+ aws_s3_bucket_public_access_block.this\n+ ]\n }\n \n data \"aws_iam_policy_document\" \"combined\" {\n@@ -789,11 +797,7 @@ data \"aws_iam_policy_document\" \"require_latest_tls\" {\n resource \"aws_s3_bucket_public_access_block\" \"this\" {\n count = local.create_bucket && var.attach_public_policy ? 1 : 0\n \n- # Chain resources (s3_bucket -> s3_bucket_policy -> s3_bucket_public_access_block)\n- # to prevent \"A conflicting conditional operation is currently in progress against this resource.\"\n- # Ref: https://github.com/hashicorp/terraform-provider-aws/issues/7628\n-\n- bucket = local.attach_policy ? aws_s3_bucket_policy.this[0].id : aws_s3_bucket.this[0].id\n+ bucket = aws_s3_bucket.this[0].id\n \n block_public_acls = var.block_public_acls\n block_public_policy = var.block_public_policy\n---\n\n\n---\n\nChoice C:\nmain.tf\n@@ -512,8 +512,16 @@ resource \"aws_s3_bucket_replication_configuration\" \"this\" {\n resource \"aws_s3_bucket_policy\" \"this\" {\n count = local.create_bucket && local.attach_policy ? 1 : 0\n \n+ # Chain resources (s3_bucket -> s3_bucket_public_access_block -> s3_bucket_policy )\n+ # to prevent \"A conflicting conditional operation is currently in progress against this resource.\"\n+ # Ref: https://github.com/hashicorp/terraform-provider-aws/issues/7628\n+\n bucket = aws_s3_bucket.this[0].id\n policy = data.aws_iam_policy_document.combined[0].json\n+\n+ depends_on = [\n+ aws_s3_bucket_public_access_block.this\n+ ]\n }\n \n data \"aws_iam_policy_document\" \"combined\" {\n@@ -789,11 +797,7 @@ data \"aws_iam_policy_document\" \"require_latest_tls\" {\n resource \"aws_s3_bucket_public_access_block\" \"this\" {\n count = local.create_bucket && var.attach_public_policy ? 1 : 0\n \n- # Chain resources (s3_bucket -> s3_bucket_policy -> s3_bucket_public_access_block)\n- # to prevent \"A conflicting conditional operation is currently in progress against this resource.\"\n- # Ref: https://github.com/hashicorp/terraform-provider-aws/issues/7628\n-\n- bucket = local.attach_policy ? aws_s3_bucket_policy.this[0].id : aws_s3_bucket.this[0].id\n+ bucket = aws_s3_bucket.this[0].id\n \n block_public_acls = var.block_public_acls\n block_public_policy = var.block_public_policy\n---\n\n\n---\n\nChoice D:\nmain.tf\n@@ -512,8 +512,16 @@ resource \"aws_s3_bucket_replication_configuration\" \"this\" {\n resource \"aws_s3_bucket_policy\" \"this\" {\n count = local.create_bucket && local.attach_policy ? 1 : 0\n \n+ # Chain resources (s3_bucket -> s3_bucket_public_access_block -> s3_bucket_policy )\n+ # to prevent \"A conflicting conditional operation is currently in progress against this resource.\"\n+ # Ref: https://github.com/hashicorp/terraform-provider-aws/issues/7628\n+\n bucket = aws_s3_bucket.this[0].id\n policy = data.aws_iam_policy_document.combined[0].json\n+\n+ depends_on = [\n+ aws_s3_bucket_public_access_block.this\n+ ]\n }\n \n data \"aws_iam_policy_document\" \"combined\" {\n@@ -789,11 +797,7 @@ data \"aws_iam_policy_document\" \"require_latest_tls\" {\n resource \"aws_s3_bucket_public_access_block\" \"this\" {\n count = local.create_bucket && var.attach_public_policy ? 1 : 0\n \n- # Chain resources (s3_bucket -> s3_bucket_policy -> s3_bucket_public_access_block)\n- # to prevent \"A conflicting conditional operation is currently in progress against this resource.\"\n- # Ref: https://github.com/hashicorp/terraform-provider-aws/issues/7628\n-\n- bucket = local.attach_policy ? aws_s3_bucket_policy.this[0].id : aws_s3_bucket.this[0].id\n+ bucket = aws_s3_bucket.this[0].id\n \n block_public_acls = var.block_public_acls\n block_public_policy resources = var.block_public_policy\n---\n\n\n---\n" } ]
C
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n…rship default values\r\n\r\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nexamples/complete-legacy/main.tf\n@@ -62,9 +62,11 @@ module \"log_bucket\" {\n source = \"terraform-aws-modules/s3-bucket/aws\"\n version = \"~> 2.0\"\n \n- bucket = \"logs-${random_pet.this.id}\"\n- acl = \"log-delivery-write\"\n- force_destroy = true\n+ bucket = \"logs-${random_pet.this.id}\"\n+ acl = \"log-delivery-write\"\n+ control_object_ownership = true\n+ object_ownership = \"ObjectWriter\" //(default object_ownership has now changed by aws to \"BucketOwnerEnforced\")\n+ force_destroy = true\n \n attach_elb_log_delivery_policy = true\n attach_lb_log_delivery_policy = true\n@@ -206,11 +208,11 @@ module \"s3_bucket\" {\n }\n }\n \n- # S3 bucket-level Public Access Block configuration\n- block_public_acls = true\n- block_public_policy = true\n- ignore_public_acls = true\n- restrict_public_buckets = true\n+ # S3 bucket-level Public Access Block configuration (by default now aws has made this default as true for s3 bucket-level block public access)\n+ # block_public_acls = true\n+ # block_public_policy = true\n+ # ignore_public_acls = true\n+ # restrict_public_buckets = true\n \n # S3 Bucket Ownership Controls\n control_object_ownership = true\n---\nexamples/complete/main.tf\n@@ -66,9 +66,11 @@ data \"aws_iam_policy_document\" \"bucket_policy\" {\n module \"log_bucket\" {\n source = \"../../\"\n \n- bucket = \"logs-${random_pet.this.id}\"\n- acl = \"log-delivery-write\"\n- force_destroy = true\n+ bucket = \"logs-${random_pet.this.id}\"\n+ acl = \"log-delivery-write\"\n+ control_object_ownership = true\n+ object_ownership = \"ObjectWriter\" //(default object_ownership has now changed by aws to \"BucketOwnerEnforced\")\n+ force_destroy = true\n \n attach_elb_log_delivery_policy = true\n attach_lb_log_delivery_policy = true\n@@ -79,7 +81,9 @@ module \"log_bucket\" {\n module \"cloudfront_log_bucket\" {\n source = \"../../\"\n \n- bucket = \"cloudfront-logs-${random_pet.this.id}\"\n+ bucket = \"cloudfront-logs-${random_pet.this.id}\"\n+ control_object_ownership = true\n+ object_ownership = \"ObjectWriter\" //(default object_ownership has now changed by aws to \"BucketOwnerEnforced\")\n \n grant = [{\n type = \"CanonicalUser\"\n@@ -130,11 +134,11 @@ module \"s3_bucket\" {\n attach_deny_insecure_transport_policy = true\n attach_require_latest_tls_policy = true\n \n- # S3 bucket-level Public Access Block configuration\n- block_public_acls = true\n- block_public_policy = true\n- ignore_public_acls = true\n- restrict_public_buckets = true\n+ # S3 bucket-level Public Access Block configuration (by default now aws has made this default as true for bucket-level block public access)\n+ # block_public_acls = true\n+ # block_public_policy = true\n+ # ignore_public_acls = true\n+ # restrict_public_buckets = true\n \n # S3 Bucket Ownership Controls\n # https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls\n---\nvariables.tf\n@@ -235,25 +235,25 @@ variable \"object_lock_enabled\" {\n variable \"block_public_acls\" {\n description = \"Whether Amazon S3 should block public ACLs for this bucket.\"\n type = bool\n- default = false\n+ default = true\n }\n \n variable \"block_public_policy\" {\n description = \"Whether Amazon S3 should block public bucket policies for this bucket.\"\n type = bool\n- default = false\n+ default = true\n }\n \n variable \"ignore_public_acls\" {\n description = \"Whether Amazon S3 should ignore public ACLs for this bucket.\"\n type = bool\n- default = false\n+ default = true\n }\n \n variable \"restrict_public_buckets\" {\n description = \"Whether Amazon S3 should restrict public bucket policies for this bucket.\"\n type = bool\n- default = false\n+ default = true\n }\n \n variable \"control_object_ownership\" {\n@@ -265,7 +265,7 @@ variable \"control_object_ownership\" {\n variable \"object_ownership\" {\n description = \"Object ownership. Valid values: BucketOwnerEnforced, BucketOwnerPreferred or ObjectWriter. 'BucketOwnerEnforced': ACLs are disabled, and the bucket owner automatically owns and has full control over every object in the bucket. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL.\"\n type = string\n- default = \"ObjectWriter\"\n+ default = \"BucketOwnerEnforced\"\n }\n \n variable \"putin_khuylo\" {\n---\n\n\n---\n\nChoice B:\nexamples/complete-legacy/main.tf\n@@ -62,9 +62,11 @@ module \"log_bucket\" {\n source = \"terraform-aws-modules/s3-bucket/aws\"\n version = \"~> 2.0\"\n \n- bucket = \"logs-${random_pet.this.id}\"\n- acl = \"log-delivery-write\"\n- force_destroy = true\n+ bucket = \"logs-${random_pet.this.id}\"\n+ acl = \"log-delivery-write\"\n+ control_object_ownership = true\n+ object_ownership = \"ObjectWriter\" //(default object_ownership has now changed by aws to \"BucketOwnerEnforced\")\n+ force_destroy = true\n \n attach_elb_log_delivery_policy = true\n attach_lb_log_delivery_policy = true\n@@ -206,11 +208,11 @@ module \"s3_bucket\" {\n }\n }\n \n- # S3 bucket-level Public Access Block configuration\n- block_public_acls = true\n- block_public_policy = true\n- ignore_public_acls = true\n- restrict_public_buckets = true\n+ # S3 bucket-level Public Access Block configuration (by default now aws has made this default as true for s3 bucket-level block public access)\n+ # block_public_acls = true\n+ # block_public_policy = true\n+ # ignore_public_acls = true\n+ # restrict_public_buckets = true\n \n # S3 Bucket Ownership Controls\n control_object_ownership = true\n---\nexamples/complete/main.tf\n@@ -66,9 +66,11 @@ data \"aws_iam_policy_document\" \"bucket_policy\" {\n module \"log_bucket\" {\n source = \"../../\"\n \n- bucket = \"logs-${random_pet.this.id}\"\n- acl = \"log-delivery-write\"\n- force_destroy = true\n+ bucket = \"logs-${random_pet.this.id}\"\n+ acl = \"log-delivery-write\"\n+ control_object_ownership = true\n+ object_ownership = \"ObjectWriter\" //(default object_ownership has now changed by aws to \"BucketOwnerEnforced\")\n+ force_destroy = true\n \n attach_elb_log_delivery_policy = true\n attach_lb_log_delivery_policy = true\n@@ -79,7 +81,9 @@ module \"log_bucket\" {\n module \"cloudfront_log_bucket\" {\n source = \"../../\"\n \n- bucket = \"cloudfront-logs-${random_pet.this.id}\"\n+ bucket = \"cloudfront-logs-${random_pet.this.id}\"\n+ control_object_ownership = true\n+ object_ownership = \"ObjectWriter\" //(default object_ownership has now changed by aws to \"BucketOwnerEnforced\")\n \n grant = [{\n type = \"CanonicalUser\"\n@@ -130,11 +134,11 @@ module \"s3_bucket\" {\n attach_deny_insecure_transport_policy = true\n attach_require_latest_tls_policy = true\n \n- # S3 bucket-level Public Access Block configuration\n- block_public_acls = true\n- block_public_policy = true\n- ignore_public_acls = true\n- restrict_public_buckets = true\n+ # S3 bucket-level Public Access Block configuration (by default now aws has made this default as true for s3 bucket-level block public access)\n+ # block_public_acls = true\n+ # block_public_policy = true\n+ # ignore_public_acls = true\n+ # restrict_public_buckets = true\n \n # S3 Bucket Ownership Controls\n # https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls\n---\nvariables.tf\n@@ -235,25 +235,25 @@ variable \"object_lock_enabled\" {\n variable \"block_public_acls\" {\n description = \"Whether Amazon S3 should block public ACLs for this bucket.\"\n type = bool\n- default = false\n+ default = true\n }\n \n variable \"block_public_policy\" {\n description = \"Whether Amazon S3 should block public bucket policies for this bucket.\"\n type = bool\n- default = false\n+ default = true\n }\n \n variable \"ignore_public_acls\" {\n description = \"Whether Amazon S3 should ignore public ACLs for this bucket.\"\n type = bool\n- default = false\n+ default = true\n }\n \n variable \"restrict_public_buckets\" {\n description = \"Whether Amazon S3 should restrict public bucket policies for this bucket.\"\n type = bool\n- default = false\n+ default = true\n }\n \n variable \"control_object_ownership\" {\n@@ -265,7 +265,7 @@ variable \"control_object_ownership\" {\n variable \"object_ownership\" {\n description = \"Object ownership. Valid values: BucketOwnerEnforced, BucketOwnerPreferred or ObjectWriter. 'BucketOwnerEnforced': ACLs are disabled, and the bucket owner automatically owns and has full control over every object in the bucket. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL.\"\n type = string\n- default = \"ObjectWriter\"\n+ default = \"BucketOwnerEnforced\"\n }\n \n variable \"putin_khuylo\" {\n---\n\n\n---\n\nChoice C:\nexamples/complete-legacy/main.tf\n@@ -62,9 +62,11 @@ module \"log_bucket\" {\n source = \"terraform-aws-modules/s3-bucket/aws\"\n version = \"~> 2.0\"\n \n- bucket = \"logs-${random_pet.this.id}\"\n- acl = \"log-delivery-write\"\n- force_destroy = true\n+ bucket = \"logs-${random_pet.this.id}\"\n+ acl = \"log-delivery-write\"\n+ control_object_ownership = true\n+ object_ownership = \"ObjectWriter\" //(default object_ownership has now changed by aws to \"BucketOwnerEnforced\")\n+ force_destroy = true\n \n attach_elb_log_delivery_policy = true\n attach_lb_log_delivery_policy = true\n@@ -206,11 +208,11 @@ module \"s3_bucket\" {\n }\n }\n \n- # S3 bucket-level Public Access Block configuration\n- block_public_acls = true\n- block_public_policy = true\n- ignore_public_acls = true\n- restrict_public_buckets = true\n+ # S3 bucket-level Public Access Block configuration (by default now aws has made this default as true for s3 bucket-level block public access)\n+ # block_public_acls = true\n+ # block_public_policy = true\n+ # ignore_public_acls = true\n+ # restrict_public_buckets = true\n \n # S3 Bucket Ownership Controls\n control_object_ownership = true\n---\nexamples/complete/main.tf\n@@ -66,9 +66,11 @@ data \"aws_iam_policy_document\" \"bucket_policy\" {\n module \"log_bucket\" {\n source = \"../../\"\n \n- bucket = \"logs-${random_pet.this.id}\"\n- acl = \"log-delivery-write\"\n- force_destroy = true\n+ bucket = \"logs-${random_pet.this.id}\"\n+ acl = \"log-delivery-write\"\n+ control_object_ownership = true\n+ object_ownership = \"ObjectWriter\" //(default object_ownership has now changed by aws to \"BucketOwnerEnforced\")\n+ force_destroy = true\n \n attach_elb_log_delivery_policy = true\n attach_lb_log_delivery_policy = true\n@@ -79,7 +81,9 @@ module \"log_bucket\" {\n module \"cloudfront_log_bucket\" {\n source = \"../../\"\n \n- bucket = \"cloudfront-logs-${random_pet.this.id}\"\n+ bucket = \"cloudfront-logs-${random_pet.this.id}\"\n+ control_object_ownership = true\n+ object_ownership = \"ObjectWriter\" //(default object_ownership has now changed by aws to \"BucketOwnerEnforced\")\n \n grant = [{\n type = \"CanonicalUser\"\n@@ -130,11 +134,11 @@ module \"s3_bucket\" {\n attach_deny_insecure_transport_policy = true\n attach_require_latest_tls_policy = true\n \n- # S3 bucket-level Public Access Block configuration\n- block_public_acls = true\n- block_public_policy = true\n- ignore_public_acls configuration\n- = true\n- restrict_public_buckets = true\n+ # S3 bucket-level Public Access Block configuration (by default now aws has made this default as true for s3 bucket-level block public access)\n+ # block_public_acls = true\n+ # block_public_policy = true\n+ # ignore_public_acls = true\n+ # restrict_public_buckets = true\n \n # S3 Bucket Ownership Controls\n # https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls\n---\nvariables.tf\n@@ -235,25 +235,25 @@ variable \"object_lock_enabled\" {\n variable \"block_public_acls\" {\n description = \"Whether Amazon S3 should block public ACLs for this bucket.\"\n type = bool\n- default = false\n+ default = true\n }\n \n variable \"block_public_policy\" {\n description = \"Whether Amazon S3 should block public bucket policies for this bucket.\"\n type = bool\n- default = false\n+ default = true\n }\n \n variable \"ignore_public_acls\" {\n description = \"Whether Amazon S3 should ignore public ACLs for this bucket.\"\n type = bool\n- default = false\n+ default = true\n }\n \n variable \"restrict_public_buckets\" {\n description = \"Whether Amazon S3 should restrict public bucket policies for this bucket.\"\n type = bool\n- default = false\n+ default = true\n }\n \n variable \"control_object_ownership\" {\n@@ -265,7 +265,7 @@ variable \"control_object_ownership\" {\n variable \"object_ownership\" {\n description = \"Object ownership. Valid values: BucketOwnerEnforced, BucketOwnerPreferred or ObjectWriter. 'BucketOwnerEnforced': ACLs are disabled, and the bucket owner automatically owns and has full control over every object in the bucket. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL.\"\n type = string\n- default = \"ObjectWriter\"\n+ default = \"BucketOwnerEnforced\"\n }\n \n variable \"putin_khuylo\" {\n---\n\n\n---\n\nChoice D:\nexamples/complete-legacy/main.tf\n@@ -62,9 +62,11 @@ module \"log_bucket\" {\n source = \"terraform-aws-modules/s3-bucket/aws\"\n version = \"~> 2.0\"\n \n- bucket = \"logs-${random_pet.this.id}\"\n- acl = \"log-delivery-write\"\n- force_destroy = true\n+ bucket = \"logs-${random_pet.this.id}\"\n+ acl = \"log-delivery-write\"\n+ control_object_ownership = true\n+ object_ownership = \"ObjectWriter\" //(default object_ownership has now changed by aws to \"BucketOwnerEnforced\")\n+ force_destroy = true\n \n attach_elb_log_delivery_policy = true\n attach_lb_log_delivery_policy = true\n@@ -206,11 +208,11 @@ module \"s3_bucket\" {\n }\n }\n \n- # S3 bucket-level Public Access Block configuration\n- block_public_acls = true\n- block_public_policy = true\n- ignore_public_acls = true\n- restrict_public_buckets = true\n+ # S3 bucket-level Public Access Block configuration (by default now aws has made this default as true for s3 bucket-level block public access)\n+ # block_public_acls = true\n+ # block_public_policy = true\n+ # ignore_public_acls = true\n+ # restrict_public_buckets = true\n \n # S3 Bucket Ownership Controls\n control_object_ownership = true\n---\nexamples/complete/main.tf\n@@ -66,9 +66,11 @@ data \"aws_iam_policy_document\" \"bucket_policy\" {\n module \"log_bucket\" {\n source = \"../../\"\n \n- bucket = \"logs-${random_pet.this.id}\"\n- acl = \"log-delivery-write\"\n- force_destroy = true\n+ bucket = \"logs-${random_pet.this.id}\"\n+ acl = \"log-delivery-write\"\n+ control_object_ownership = true\n+ object_ownership = \"ObjectWriter\" //(default object_ownership has now changed by aws to \"BucketOwnerEnforced\")\n+ force_destroy = true\n \n attach_elb_log_delivery_policy = true\n attach_lb_log_delivery_policy = true\n@@ -79,7 +81,9 @@ module \"log_bucket\" {\n module \"cloudfront_log_bucket\" {\n source = \"../../\"\n \n- bucket = \"cloudfront-logs-${random_pet.this.id}\"\n+ bucket = \"cloudfront-logs-${random_pet.this.id}\"\n+ control_object_ownership = true\n+ object_ownership = \"ObjectWriter\" //(default object_ownership has now changed by aws to \"BucketOwnerEnforced\")\n \n grant = [{\n type = \"CanonicalUser\"\n@@ -130,11 +134,11 @@ module \"s3_bucket\" {\n attach_deny_insecure_transport_policy = true\n attach_require_latest_tls_policy = true\n \n- # S3 bucket-level Public Access Block configuration\n- block_public_acls = true\n- block_public_policy = true\n- ignore_public_acls = true\n- restrict_public_buckets = true\n+ # S3 bucket-level Public Access Block configuration (by default now aws has made this default as true for s3 bucket-level block public access)\n+ # block_public_acls = true\n+ # block_public_policy = true\n+ # ignore_public_acls = true\n+ # restrict_public_buckets = true\n \n # S3 Bucket Ownership Controls\n # https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls\n---\nvariables.tf\n@@ -235,25 +235,25 @@ variable \"object_lock_enabled\" {\n variable \"block_public_acls\" {\n description = \"Whether Amazon S3 should block public ACLs for this bucket.\"\n type = bool\n- default = false\n+ default = true\n }\n \n variable \"block_public_policy\" {\n description = \"Whether Amazon S3 should block public bucket policies for this bucket.\"\n type = bool\n- default = false\n+ default = true\n }\n \n variable \"ignore_public_acls\" {\n description = \"Whether Amazon S3 should ignore public ACLs for this bucket.\"\n type = bool\n- default = false\n+ default = true\n }\n \n = \"restrict_public_buckets\" {\n description = \"Whether Amazon S3 should restrict public bucket policies for this bucket.\"\n type = bool\n- default = false\n+ default = true\n }\n \n variable \"control_object_ownership\" {\n@@ -265,7 +265,7 @@ variable \"control_object_ownership\" {\n variable \"object_ownership\" {\n description = \"Object ownership. Valid values: BucketOwnerEnforced, BucketOwnerPreferred or ObjectWriter. 'BucketOwnerEnforced': ACLs are disabled, and the bucket owner automatically owns and has full control over every object in the bucket. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL.\"\n type = string\n- default = \"ObjectWriter\"\n+ default = \"BucketOwnerEnforced\"\n }\n \n variable \"putin_khuylo\" {\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nUse `Data Source: aws_partition` to determine the proper partition to define in the IAM policy.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\nFixes #220 \r\n\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nREADME.md\n@@ -161,6 +161,7 @@ No modules.\n | [aws_iam_policy_document.inventory_and_analytics_destination_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.lb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.require_latest_tls](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |\n | [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |\n \n ## Inputs\n---\nmain.tf\n@@ -4,6 +4,7 @@ data \"aws_canonical_user_id\" \"this\" {}\n \n data \"aws_caller_identity\" \"current\" {}\n \n+data \"aws_partition\" \"current\" {}\n locals {\n create_bucket = var.create_bucket && var.putin_khuylo\n \n@@ -571,7 +572,7 @@ data \"elb_log_delivery\" {\n \n principals {\n type = \"AWS\"\n- identifiers = [format(\"arn:aws:iam::%s:root\", statement.value)]\n+ identifiers = [format(\"arn:%s:iam::%s:root\", data.aws_partition.current.partition, statement.value)]\n }\n \n effect = \"Allow\"\n---\n\n\n---\n\nChoice B:\n{\n -161,6 +161,7 @@ No modules.\n | [aws_iam_policy_document.inventory_and_analytics_destination_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.lb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.require_latest_tls](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |\n | [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |\n \n ## Inputs\n---\nmain.tf\n@@ -4,6 +4,7 @@ data \"aws_canonical_user_id\" \"this\" {}\n \n data \"aws_caller_identity\" \"current\" {}\n \n+data \"aws_partition\" \"current\" {}\n locals {\n create_bucket = var.create_bucket && var.putin_khuylo\n \n@@ -571,7 +572,7 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n \n principals {\n type = \"AWS\"\n- identifiers = [format(\"arn:aws:iam::%s:root\", statement.value)]\n+ identifiers = [format(\"arn:%s:iam::%s:root\", data.aws_partition.current.partition, statement.value)]\n }\n \n effect = \"Allow\"\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -161,6 +161,7 @@ No modules.\n | [aws_iam_policy_document.inventory_and_analytics_destination_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.lb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.require_latest_tls](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |\n | [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |\n \n ## Inputs\n---\nmain.tf\n@@ -4,6 +4,7 @@ data \"aws_canonical_user_id\" \"this\" {}\n \n data \"aws_caller_identity\" \"current\" {}\n \n+data \"aws_partition\" \"current\" {}\n locals {\n create_bucket = var.create_bucket && var.putin_khuylo\n \n@@ -571,7 +572,7 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n \n principals {\n type = \"AWS\"\n- identifiers = [format(\"arn:aws:iam::%s:root\", statement.value)]\n+ identifiers = [format(\"arn:%s:iam::%s:root\", data.aws_partition.current.partition, statement.value)]\n }\n \n effect = \"Allow\"\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -161,6 +161,7 @@ No modules.\n | [aws_iam_policy_document.inventory_and_analytics_destination_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.lb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n create_bucket [aws_iam_policy_document.require_latest_tls](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |\n | [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |\n \n ## Inputs\n---\nmain.tf\n@@ -4,6 +4,7 @@ data \"aws_canonical_user_id\" \"this\" {}\n \n data \"aws_caller_identity\" \"current\" {}\n \n+data \"aws_partition\" \"current\" {}\n locals {\n create_bucket = var.create_bucket && var.putin_khuylo\n \n@@ -571,7 +572,7 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n \n principals {\n type = \"AWS\"\n- identifiers = [format(\"arn:aws:iam::%s:root\", statement.value)]\n+ identifiers = [format(\"arn:%s:iam::%s:root\", data.aws_partition.current.partition, statement.value)]\n }\n \n effect = \"Allow\"\n---\n\n\n---\n" } ]
C
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\nFixes #217 \n\n---\n\nChoice A:\nREADME.md\n@@ -155,13 +155,13 @@ No modules.\n | [aws_s3_bucket_website_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_website_configuration) | resource |\n | [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |\n | [aws_canonical_user_id.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/canonical_user_id) | data source |\n-| [aws_elb_service_account.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/elb_service_account) | data source |\n | [aws_iam_policy_document.combined](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.deny_insecure_transport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.elb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.inventory_and_analytics_destination_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.lb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.require_latest_tls](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |\n \n ## Inputs\n \n---\nexamples/complete/main.tf\n@@ -13,7 +13,6 @@ locals {\n region = \"eu-west-1\"\n }\n \n-\n data \"aws_caller_identity\" \"current\" {}\n \n data \"aws_canonical_user_id\" \"current\" {}\n---\nmain.tf\n@@ -1,3 +1,5 @@\n+data \"aws_region\" \"current\" {}\n+\n data \"aws_canonical_user_id\" \"this\" {}\n \n data \"aws_caller_identity\" \"current\" {}\n@@ -527,31 +529,61 @@ data \"aws_iam_policy_document\" \"combined\" {\n }\n \n # AWS Load Balancer access log delivery policy\n-data \"aws_elb_service_account\" \"this\" {\n- count = local.create_bucket && var.attach_elb_log_delivery_policy ? 1 : 0\n+locals {\n+ # List of AWS regions where permissions should be granted to the specified Elastic Load Balancing account ID ( https://docs.aws.amazon.com/elasticloadbalancing/latest/application/enable-access-logging.html#attach-bucket-policy )\n+ elb_service_accounts = {\n+ us-east-1 = \"127311923021\"\n+ us-east-2 = \"033677994240\"\n+ us-west-1 = \"027434742980\"\n+ us-west-2 = \"797873946194\"\n+ af-south-1 = \"098369216593\"\n+ ap-east-1 = \"754344448648\"\n+ ap-south-1 = \"718504428378\"\n+ ap-northeast-1 = \"582318560864\"\n+ ap-northeast-2 = \"600734575887\"\n+ ap-northeast-3 = \"383597477331\"\n+ ap-southeast-1 = \"114774131450\"\n+ ap-southeast-2 = \"783225319266\"\n+ ap-southeast-3 = \"589379963580\"\n+ ca-central-1 = \"985666609251\"\n+ eu-central-1 = \"054676820928\"\n+ eu-west-1 = \"156460612806\"\n+ eu-west-2 = \"652711504416\"\n+ eu-west-3 = \"009996457667\"\n+ eu-south-1 = \"635631232127\"\n+ eu-north-1 = \"897822967062\"\n+ me-south-1 = \"076674570225\"\n+ sa-east-1 = \"507241528517\"\n+ us-gov-west-1 = \"048591011584\"\n+ us-gov-east-1 = \"190560391635\"\n+ }\n }\n \n data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n count = local.create_bucket && var.attach_elb_log_delivery_policy ? 1 : 0\n \n # Policy for AWS Regions created before August 2022 (e.g. US East (N. Virginia), Asia Pacific (Singapore), Asia Pacific (Sydney), Asia Pacific (Tokyo), Europe (Ireland))\n- statement {\n- sid = \"\"\n+ dynamic \"statement\" {\n+ for_each = { for k, v in local.elb_service_accounts : k => v if k == data.aws_region.current.name }\n \n- principals {\n- type = \"AWS\"\n- identifiers = data.aws_elb_service_account.this[*].arn\n- }\n+ content {\n+ sid = format(\"ELBRegion%s\", title(statement.key))\n \n- effect = \"Allow\"\n+ principals {\n+ type = \"AWS\"\n+ identifiers = [format(\"arn:aws:iam::%s:root\", statement.value)]\n+ }\n \n- actions = [\n- \"s3:PutObject\",\n- ]\n+ effect = \"Allow\"\n \n- resources = [\n- \"${aws_s3_bucket.this[0].arn}/*\",\n- ]\n+ actions = [\n+ \"s3:PutObject\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}/*\",\n+ ]\n+ }\n }\n \n # Policy for AWS Regions created after August 2022 (e.g. Asia Pacific (Hyderabad), Asia Pacific (Melbourne), Europe (Spain), Europe (Zurich), Middle East (UAE))\n@@ -576,7 +608,6 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n }\n \n # ALB/NLB\n-\n data \"aws_iam_policy_document\" \"lb_log_delivery\" {\n count = local.create_bucket && var.attach_lb_log_delivery_policy ? 1 : 0\n \n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -155,13 +155,13 @@ No modules.\n | [aws_s3_bucket_website_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_website_configuration) | resource |\n | [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |\n | [aws_canonical_user_id.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/canonical_user_id) | data source |\n-| [aws_elb_service_account.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/elb_service_account) | data source |\n | [aws_iam_policy_document.combined](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.deny_insecure_transport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.elb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.inventory_and_analytics_destination_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.lb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.require_latest_tls](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |\n \n ## Inputs\n \n---\nexamples/complete/main.tf\n@@ -13,7 +13,6 @@ locals {\n region = \"eu-west-1\"\n }\n \n-\n data \"aws_caller_identity\" \"current\" {}\n \n data \"aws_canonical_user_id\" \"current\" {}\n---\nmain.tf\n@@ -1,3 +1,5 @@\n+data \"aws_region\" \"current\" {}\n+\n data \"aws_canonical_user_id\" \"this\" {}\n \n data \"aws_caller_identity\" \"current\" {}\n@@ -527,31 +529,61 @@ data \"aws_iam_policy_document\" \"combined\" {\n }\n \n # AWS Load Balancer access log delivery policy\n-data \"aws_elb_service_account\" \"this\" {\n- count = local.create_bucket && var.attach_elb_log_delivery_policy ? 1 : 0\n+locals {\n+ # List of AWS regions where permissions should be granted to the specified Elastic Load Balancing account ID ( https://docs.aws.amazon.com/elasticloadbalancing/latest/application/enable-access-logging.html#attach-bucket-policy )\n+ elb_service_accounts = {\n+ us-east-1 source \"127311923021\"\n+ us-east-2 = \"033677994240\"\n+ us-west-1 = \"027434742980\"\n+ us-west-2 = \"797873946194\"\n+ af-south-1 = \"098369216593\"\n+ ap-east-1 = \"754344448648\"\n+ ap-south-1 = \"718504428378\"\n+ ap-northeast-1 = \"582318560864\"\n+ ap-northeast-2 = \"600734575887\"\n+ ap-northeast-3 = \"383597477331\"\n+ ap-southeast-1 = \"114774131450\"\n+ ap-southeast-2 = \"783225319266\"\n+ ap-southeast-3 = \"589379963580\"\n+ ca-central-1 = \"985666609251\"\n+ eu-central-1 = \"054676820928\"\n+ eu-west-1 = \"156460612806\"\n+ eu-west-2 = \"652711504416\"\n+ eu-west-3 = \"009996457667\"\n+ eu-south-1 = \"635631232127\"\n+ eu-north-1 = \"897822967062\"\n+ me-south-1 = \"076674570225\"\n+ sa-east-1 = \"507241528517\"\n+ us-gov-west-1 = \"048591011584\"\n+ us-gov-east-1 = \"190560391635\"\n+ }\n }\n \n data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n count = local.create_bucket && var.attach_elb_log_delivery_policy ? 1 : 0\n \n # Policy for AWS Regions created before August 2022 (e.g. US East (N. Virginia), Asia Pacific (Singapore), Asia Pacific (Sydney), Asia Pacific (Tokyo), Europe (Ireland))\n- statement {\n- sid = \"\"\n+ dynamic \"statement\" {\n+ for_each = { for k, v in local.elb_service_accounts : k => v if k == data.aws_region.current.name }\n \n- principals {\n- type = \"AWS\"\n- identifiers = data.aws_elb_service_account.this[*].arn\n- }\n+ content {\n+ sid = format(\"ELBRegion%s\", title(statement.key))\n \n- effect = \"Allow\"\n+ principals {\n+ type = \"AWS\"\n+ identifiers = [format(\"arn:aws:iam::%s:root\", statement.value)]\n+ }\n \n- actions = [\n- \"s3:PutObject\",\n- ]\n+ effect = \"Allow\"\n \n- resources = [\n- \"${aws_s3_bucket.this[0].arn}/*\",\n- ]\n+ actions = [\n+ \"s3:PutObject\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}/*\",\n+ ]\n+ }\n }\n \n # Policy for AWS Regions created after August 2022 (e.g. Asia Pacific (Hyderabad), Asia Pacific (Melbourne), Europe (Spain), Europe (Zurich), Middle East (UAE))\n@@ -576,7 +608,6 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n }\n \n # ALB/NLB\n-\n data \"aws_iam_policy_document\" \"lb_log_delivery\" {\n count = local.create_bucket && var.attach_lb_log_delivery_policy ? 1 : 0\n \n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -155,13 +155,13 @@ No modules.\n | [aws_s3_bucket_website_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_website_configuration) | resource |\n | [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |\n | [aws_canonical_user_id.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/canonical_user_id) | data source |\n-| [aws_elb_service_account.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/elb_service_account) | data source |\n | [aws_iam_policy_document.combined](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.deny_insecure_transport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.elb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.inventory_and_analytics_destination_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.lb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.require_latest_tls](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |\n \n ## Inputs\n \n---\nexamples/complete/main.tf\n@@ -13,7 +13,6 @@ locals {\n region = \"eu-west-1\"\n }\n \n-\n data \"aws_caller_identity\" \"current\" {}\n \n data \"aws_canonical_user_id\" \"current\" {}\n---\nmain.tf\n@@ -1,3 +1,5 @@\n+data \"aws_region\" \"current\" {}\n+\n data \"aws_canonical_user_id\" \"this\" {}\n \n data \"aws_caller_identity\" \"current\" {}\n@@ -527,31 +529,61 @@ data \"aws_iam_policy_document\" \"combined\" var.attach_lb_log_delivery_policy }\n \n # AWS Load Balancer access log delivery policy\n-data \"aws_elb_service_account\" \"this\" {\n- count = local.create_bucket && var.attach_elb_log_delivery_policy ? 1 : 0\n+locals {\n+ # List of AWS regions where permissions should be granted to the specified Elastic Load Balancing account ID ( https://docs.aws.amazon.com/elasticloadbalancing/latest/application/enable-access-logging.html#attach-bucket-policy )\n+ elb_service_accounts = {\n+ us-east-1 = \"127311923021\"\n+ us-east-2 = \"033677994240\"\n+ us-west-1 = \"027434742980\"\n+ us-west-2 = \"797873946194\"\n+ af-south-1 = \"098369216593\"\n+ ap-east-1 = \"754344448648\"\n+ ap-south-1 = \"718504428378\"\n+ ap-northeast-1 = \"582318560864\"\n+ ap-northeast-2 = \"600734575887\"\n+ ap-northeast-3 = \"383597477331\"\n+ ap-southeast-1 = \"114774131450\"\n+ ap-southeast-2 = \"783225319266\"\n+ ap-southeast-3 = \"589379963580\"\n+ ca-central-1 = \"985666609251\"\n+ eu-central-1 = \"054676820928\"\n+ eu-west-1 = \"156460612806\"\n+ eu-west-2 = \"652711504416\"\n+ eu-west-3 = \"009996457667\"\n+ eu-south-1 = \"635631232127\"\n+ eu-north-1 = \"897822967062\"\n+ me-south-1 = \"076674570225\"\n+ sa-east-1 = \"507241528517\"\n+ us-gov-west-1 = \"048591011584\"\n+ us-gov-east-1 = \"190560391635\"\n+ }\n }\n \n data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n count = local.create_bucket && var.attach_elb_log_delivery_policy ? 1 : 0\n \n # Policy for AWS Regions created before August 2022 (e.g. US East (N. Virginia), Asia Pacific (Singapore), Asia Pacific (Sydney), Asia Pacific (Tokyo), Europe (Ireland))\n- statement {\n- sid = \"\"\n+ dynamic \"statement\" {\n+ for_each = { for k, v in local.elb_service_accounts : k => v if k == data.aws_region.current.name }\n \n- principals {\n- type = \"AWS\"\n- identifiers = data.aws_elb_service_account.this[*].arn\n- }\n+ content {\n+ sid = format(\"ELBRegion%s\", title(statement.key))\n \n- effect = \"Allow\"\n+ principals {\n+ type = \"AWS\"\n+ identifiers = [format(\"arn:aws:iam::%s:root\", statement.value)]\n+ }\n \n- actions = [\n- \"s3:PutObject\",\n- ]\n+ effect = \"Allow\"\n \n- resources = [\n- \"${aws_s3_bucket.this[0].arn}/*\",\n- ]\n+ actions = [\n+ \"s3:PutObject\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}/*\",\n+ ]\n+ }\n }\n \n # Policy for AWS Regions created after August 2022 (e.g. Asia Pacific (Hyderabad), Asia Pacific (Melbourne), Europe (Spain), Europe (Zurich), Middle East (UAE))\n@@ -576,7 +608,6 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n }\n \n # ALB/NLB\n-\n data \"aws_iam_policy_document\" \"lb_log_delivery\" {\n count = local.create_bucket && var.attach_lb_log_delivery_policy ? 1 : 0\n \n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -155,13 +155,13 @@ No modules.\n | [aws_s3_bucket_website_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_website_configuration) | resource |\n | [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |\n | [aws_canonical_user_id.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/canonical_user_id) | data source |\n-| [aws_elb_service_account.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/elb_service_account) | data source |\n | [aws_iam_policy_document.combined](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.deny_insecure_transport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.elb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.inventory_and_analytics_destination_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.lb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.require_latest_tls](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |\n \n ## Inputs\n \n---\nexamples/complete/main.tf\n@@ -13,7 +13,6 @@ locals {\n region = \"eu-west-1\"\n }\n \n-\n data \"aws_caller_identity\" \"current\" {}\n \n data \"aws_canonical_user_id\" \"current\" {}\n---\nmain.tf\n@@ -1,3 +1,5 @@\n+data \"aws_region\" \"current\" {}\n+\n data \"aws_canonical_user_id\" \"this\" {}\n \n data \"aws_caller_identity\" \"current\" {}\n@@ -527,31 +529,61 @@ data \"aws_iam_policy_document\" \"combined\" {\n }\n \n # AWS Load Balancer access log delivery policy\n-data \"aws_elb_service_account\" \"this\" {\n- count = local.create_bucket && var.attach_elb_log_delivery_policy ? 1 : 0\n+locals {\n+ # List of AWS regions where permissions should be granted to the specified Elastic Load Balancing account ID ( https://docs.aws.amazon.com/elasticloadbalancing/latest/application/enable-access-logging.html#attach-bucket-policy )\n+ elb_service_accounts = {\n+ us-east-1 = \"127311923021\"\n+ us-east-2 = \"033677994240\"\n+ us-west-1 = \"027434742980\"\n+ us-west-2 = \"797873946194\"\n+ af-south-1 = \"098369216593\"\n+ ap-east-1 = \"754344448648\"\n+ ap-south-1 = \"718504428378\"\n+ ap-northeast-1 = \"582318560864\"\n+ ap-northeast-2 = \"600734575887\"\n+ ap-northeast-3 = \"383597477331\"\n+ ap-southeast-1 = \"114774131450\"\n+ ap-southeast-2 = \"783225319266\"\n+ ap-southeast-3 = \"589379963580\"\n+ ca-central-1 = \"985666609251\"\n+ eu-central-1 = \"054676820928\"\n+ eu-west-1 = \"156460612806\"\n+ eu-west-2 = \"652711504416\"\n+ eu-west-3 = \"009996457667\"\n+ eu-south-1 = \"635631232127\"\n+ eu-north-1 = \"897822967062\"\n+ me-south-1 = \"076674570225\"\n+ sa-east-1 = \"507241528517\"\n+ us-gov-west-1 = \"048591011584\"\n+ us-gov-east-1 = \"190560391635\"\n+ }\n }\n \n data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n count = local.create_bucket && var.attach_elb_log_delivery_policy ? 1 : 0\n \n # Policy for AWS Regions created before August 2022 (e.g. US East (N. Virginia), Asia Pacific (Singapore), Asia Pacific (Sydney), Asia Pacific (Tokyo), Europe (Ireland))\n- statement {\n- sid = \"\"\n+ dynamic \"statement\" {\n+ for_each = { for k, v in local.elb_service_accounts : k => v if k == data.aws_region.current.name }\n \n- principals {\n- type = \"AWS\"\n- identifiers = data.aws_elb_service_account.this[*].arn\n- }\n+ content {\n+ sid = format(\"ELBRegion%s\", title(statement.key))\n \n- effect = \"Allow\"\n+ principals {\n+ type = \"AWS\"\n+ identifiers = [format(\"arn:aws:iam::%s:root\", statement.value)]\n+ }\n \n- actions = [\n- \"s3:PutObject\",\n- ]\n+ effect = \"Allow\"\n \n- resources = [\n- \"${aws_s3_bucket.this[0].arn}/*\",\n- ]\n+ actions = [\n+ \"s3:PutObject\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}/*\",\n+ ]\n+ }\n }\n \n # Policy for AWS Regions created after August 2022 (e.g. Asia Pacific (Hyderabad), Asia Pacific (Melbourne), Europe (Spain), Europe (Zurich), Middle East (UAE))\n@@ -576,7 +608,6 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n }\n \n # ALB/NLB\n-\n data \"aws_iam_policy_document\" \"lb_log_delivery\" {\n count = local.create_bucket && var.attach_lb_log_delivery_policy ? 1 : 0\n \n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\nFixes #217 \r\n\r\nIt doesn't introduce BC break, and no need for another variable\n\n---\n\nChoice A:\nexamples/complete/main.tf\n@@ -2,7 +2,6 @@ provider \"aws\" {\n region = local.region\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n---\nmain.tf\n@@ -531,6 +531,7 @@ data \"aws_elb_service_account\" \"this\" {\n data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n count = local.create_bucket && var.attach_elb_log_delivery_policy ? 1 : 0\n \n+ # Policy for AWS Regions created before August 2022 (e.g. US East (N. Virginia), Asia Pacific (Singapore), Asia Pacific (Sydney), Asia Pacific (Tokyo), Europe (Ireland))\n statement {\n sid = \"\"\n \n@@ -549,6 +550,26 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n \"${aws_s3_bucket.this[0].arn}/*\",\n ]\n }\n+\n+ # Policy for AWS Regions created after August 2022 (e.g. Asia Pacific (Hyderabad), Asia Pacific (Melbourne), Europe (Spain), Europe (Zurich), Middle East (UAE))\n+ statement {\n+ sid = \"\"\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"logdelivery.elasticloadbalancing.amazonaws.com\"]\n+ }\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"s3:PutObject\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}/*\",\n+ ]\n+ }\n }\n \n # ALB/NLB\n---\n\n\n---\n\nChoice B:\nexamples/complete/main.tf\n@@ -2,7 +2,6 @@ provider \"aws\" {\n region = local.region\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n---\nmain.tf\n@@ -531,6 +531,7 @@ data \"aws_elb_service_account\" \"this\" {\n data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n count = local.create_bucket && var.attach_elb_log_delivery_policy ? 1 : 0\n \n+ # Policy for AWS Regions created before August 2022 (e.g. US East (N. Virginia), Asia Pacific (Singapore), Asia Pacific (Sydney), Asia Pacific (Tokyo), Europe (Ireland))\n statement {\n sid = \"\"\n \n@@ -549,6 +550,26 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n \"${aws_s3_bucket.this[0].arn}/*\",\n ]\n }\n+\n+ # Policy for AWS Regions created after August 2022 (e.g. Asia Pacific (Hyderabad), Asia Pacific (Melbourne), Europe (Spain), Europe (Zurich), Middle East (UAE))\n+ statement {\n+ sid = \"\"\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"logdelivery.elasticloadbalancing.amazonaws.com\"]\n+ }\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"s3:PutObject\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}/*\",\n+ ]\n+ }\n }\n \n # ALB/NLB\n---\n\n\n---\n\nChoice C:\nexamples/complete/main.tf\n@@ -2,7 +2,6 @@ provider \"aws\" {\n region = local.region\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n---\nmain.tf\n@@ -531,6 +531,7 @@ data \"aws_elb_service_account\" \"this\" {\n data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n count = local.create_bucket && var.attach_elb_log_delivery_policy ? 1 : 0\n \n+ # Policy for AWS Regions created before August 2022 (e.g. US East (N. Virginia), Asia Pacific (Singapore), Asia Pacific (Sydney), Asia Pacific (Tokyo), Europe (Ireland))\n statement {\n sid = \"\"\n \n@@ -549,6 +550,26 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n \"${aws_s3_bucket.this[0].arn}/*\",\n ]\n }\n+\n+ # Policy for AWS Regions created after August 2022 (e.g. Asia Pacific (Hyderabad), Asia Pacific (Melbourne), Europe (Spain), Europe (Zurich), Middle East (UAE))\n+ statement {\n+ sid = \"\"\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"logdelivery.elasticloadbalancing.amazonaws.com\"]\n+ }\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ AWS \"s3:PutObject\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}/*\",\n+ ]\n+ }\n }\n \n # ALB/NLB\n---\n\n\n---\n\nChoice D:\nexamples/complete/main.tf\n@@ -2,7 +2,6 @@ provider \"aws\" {\n region = local.region\n \n # Make it faster by skipping something\n- skip_get_ec2_platforms = true\n skip_metadata_api_check = true\n skip_region_validation = true\n skip_credentials_validation = true\n---\nmain.tf\n@@ -531,6 +531,7 @@ data \"aws_elb_service_account\" \"this\" {\n data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n count = local.create_bucket && var.attach_elb_log_delivery_policy ? 1 : 0\n # Policy for AWS Regions created before August 2022 (e.g. US East (N. Virginia), Asia Pacific (Singapore), Asia Pacific (Sydney), Asia Pacific (Tokyo), Europe (Ireland))\n statement {\n sid = \"\"\n \n@@ -549,6 +550,26 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n \"${aws_s3_bucket.this[0].arn}/*\",\n ]\n }\n+\n+ # Policy for AWS Regions created after August 2022 (e.g. Asia Pacific (Hyderabad), Asia Pacific (Melbourne), Europe (Spain), Europe (Zurich), Middle East (UAE))\n+ statement {\n+ sid = \"\"\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"logdelivery.elasticloadbalancing.amazonaws.com\"]\n+ }\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"s3:PutObject\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}/*\",\n+ ]\n+ }\n }\n \n # ALB/NLB\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\nThe `Release` and `Lock` workflow are using an old version and hence a [deprecated runtime (Node.js 12)](https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/). Bumping these workflows will resolve the deprecation warning in the affected workflows.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nMake sure that CI workflows uses non-deprecated runtimes.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nNone.\n\n---\n\nChoice A:\n.github/workflows/lock.yml\n@@ -8,7 +8,7 @@ jobs:\n lock:\n runs-on: ubuntu-latest\n steps:\n- - uses: dessant/lock-threads@v3\n+ - uses: dessant/lock-threads@v4\n with:\n github-token: ${{ secrets.GITHUB_TOKEN }}\n issue-comment: >\n---\n.github/workflows/release.yml\n@@ -26,7 +26,7 @@ jobs:\n fetch-depth: 0\n \n - name: Release\n- uses: cycjimmy/semantic-release-action@v2\n+ uses: cycjimmy/semantic-release-action@v3\n with:\n semantic_version: 18.0.0\n extra_plugins: |\n---\n\n\n---\n\nChoice B:\n.github/workflows/lock.yml\n@@ -8,7 +8,7 @@ jobs:\n lock:\n runs-on: ubuntu-latest\n steps:\n- - uses: dessant/lock-threads@v3\n+ - uses: dessant/lock-threads@v4\n with:\n github-token: ${{ secrets.GITHUB_TOKEN }}\n issue-comment: >\n---\n.github/workflows/release.yml\n@@ -26,7 +26,7 @@ jobs:\n fetch-depth: 0\n \n - name: Release\n- uses: cycjimmy/semantic-release-action@v2\n+ uses: cycjimmy/semantic-release-action@v3\n with:\n semantic_version: 18.0.0\n extra_plugins: |\n---\n\n\n---\n\nChoice C:\n.github/workflows/lock.yml\n@@ -8,7 +8,7 @@ jobs:\n lock:\n runs-on: ubuntu-latest\n steps:\n- - uses: dessant/lock-threads@v3\n+ - uses: dessant/lock-threads@v4\n with:\n github-token: ${{ secrets.GITHUB_TOKEN }}\n issue-comment: >\n---\n.github/workflows/release.yml\n@@ -26,7 +26,7 @@ jobs:\n fetch-depth: \n - name: Release\n- uses: cycjimmy/semantic-release-action@v2\n+ uses: cycjimmy/semantic-release-action@v3\n with:\n semantic_version: 18.0.0\n extra_plugins: |\n---\n\n\n---\n\nChoice D:\n.github/workflows/lock.yml\n@@ -8,7 +8,7 @@ jobs:\n lock:\n runs-on: ubuntu-latest\n steps:\n- - uses: dessant/lock-threads@v3\n+ - uses: dessant/lock-threads@v4\n with:\n github-token: ${{ secrets.GITHUB_TOKEN }}\n issue-comment: >\n---\n.github/workflows/release.yml\n@@ -26,7 +26,7 @@ jobs:\n fetch-depth: 0\n \n - name: Release\n- uses: cycjimmy/semantic-release-action@v2\n+ uses: cycjimmy/semantic-release-action@v3\n with:\n semantic_version: 18.0.0\n extra_plugins: |\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\n\n- Update pre-commit workflow CI checks to use pinned version for `tflint` to avoid GitHub API rate limiting and use latest action versions\n- Update pre-commit versions to latest\n\n## Motivation and Context\n\n- Avoid failing CI checks due to GitHub API rate limiting\n\n## Breaking Changes\n\n- No\n\n## How Has This Been Tested?\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\n- [x] I have executed `pre-commit run -a` on my pull request\n\n\n---\n\nChoice A:\n.github/workflows/pre-commit.yml\n@@ -8,6 +8,7 @@ on:\n \n env:\n TERRAFORM_DOCS_VERSION: v0.16.0\n+ TFLINT_VERSION: v0.44.1\n \n jobs:\n collectInputs:\n@@ -21,7 +22,7 @@ jobs:\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -36,24 +37,26 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'\n \n preCommitMaxVersion:\n@@ -69,18 +72,12 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n-\n- - name: Install hcledit (for terraform_wrapper_module_for_each hook)\n- shell: bash\n- run: |\n- curl -L \"$(curl -s https://api.github.com/repos/minamijoyo/hcledit/releases/latest | grep -o -E -m 1 \"https://.+?_linux_amd64.tar.gz\")\" > hcledit.tgz\n- sudo tar -xzf hcledit.tgz -C /usr/bin/ hcledit\n- rm -f hcledit.tgz 2> /dev/null\n- hcledit version\n+ uses: clowdhaus/[email protected]\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n+ install-hcledit: true\n---\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.76.0\n+ rev: v1.77.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n@@ -24,7 +24,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.3.0\n+ rev: v4.4.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\n\n\n---\n\nChoice B:\n.github/workflows/pre-commit.yml\n@@ -8,6 +8,7 @@ on:\n \n env:\n TERRAFORM_DOCS_VERSION: v0.16.0\n+ TFLINT_VERSION: v0.44.1\n \n jobs:\n collectInputs:\n@@ -21,7 +22,7 @@ jobs:\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -36,24 +37,26 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n with:\n directory: ${{ }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'\n \n preCommitMaxVersion:\n@@ -69,18 +72,12 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n-\n- - name: Install hcledit (for terraform_wrapper_module_for_each hook)\n- shell: bash\n- run: |\n- curl -L \"$(curl -s https://api.github.com/repos/minamijoyo/hcledit/releases/latest | grep -o -E -m 1 \"https://.+?_linux_amd64.tar.gz\")\" > hcledit.tgz\n- sudo tar -xzf hcledit.tgz -C /usr/bin/ hcledit\n- rm -f hcledit.tgz 2> /dev/null\n- hcledit version\n+ uses: clowdhaus/[email protected]\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n+ install-hcledit: true\n---\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.76.0\n+ rev: v1.77.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n@@ -24,7 +24,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.3.0\n+ rev: v4.4.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\n\n\n---\n\nChoice C:\n.github/workflows/pre-commit.yml\n@@ -8,6 +8,7 @@ on:\n \n env:\n TERRAFORM_DOCS_VERSION: v0.16.0\n+ TFLINT_VERSION: v0.44.1\n \n jobs:\n collectInputs:\n@@ -21,7 +22,7 @@ jobs:\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -36,24 +37,26 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'\n \n preCommitMaxVersion:\n@@ -69,18 +72,12 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n-\n- - name: Install hcledit (for terraform_wrapper_module_for_each hook)\n- shell: bash\n- run: |\n- curl -L \"$(curl -s https://api.github.com/repos/minamijoyo/hcledit/releases/latest | grep -o -E -m 1 \"https://.+?_linux_amd64.tar.gz\")\" > hcledit.tgz\n- sudo tar -xzf hcledit.tgz -C /usr/bin/ hcledit\n- rm -f hcledit.tgz 2> /dev/null\n- hcledit version\n+ uses: clowdhaus/[email protected]\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n+ install-hcledit: true\n---\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.76.0\n+ rev: v1.77.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n@@ -24,7 +24,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.3.0\n+ rev: v4.4.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\n\n\n---\n\nChoice D:\n.github/workflows/pre-commit.yml\n@@ -8,6 +8,7 @@ on:\n \n env:\n TERRAFORM_DOCS_VERSION: v0.16.0\n+ TFLINT_VERSION: v0.44.1\n \n jobs:\n collectInputs:\n@@ -21,7 +22,7 @@ jobs:\n \n - name: Get root directories\n id: dirs\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n \n preCommitMinVersions:\n name: Min TF pre-commit\n@@ -36,24 +37,26 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n+ uses: clowdhaus/[email protected]\n version\n+ with:\n directory: ${{ matrix.directory }}\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory != '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}\n # Run only validate pre-commit check on min version supported\n if: ${{ matrix.directory == '.' }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.minVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'\n \n preCommitMaxVersion:\n@@ -69,18 +72,12 @@ jobs:\n \n - name: Terraform min/max versions\n id: minMax\n- uses: clowdhaus/[email protected]\n-\n- - name: Install hcledit (for terraform_wrapper_module_for_each hook)\n- shell: bash\n- run: |\n- curl -L \"$(curl -s https://api.github.com/repos/minamijoyo/hcledit/releases/latest | grep -o -E -m 1 \"https://.+?_linux_amd64.tar.gz\")\" > hcledit.tgz\n- sudo tar -xzf hcledit.tgz -C /usr/bin/ hcledit\n- rm -f hcledit.tgz 2> /dev/null\n- hcledit version\n+ uses: clowdhaus/[email protected]\n \n - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}\n- uses: clowdhaus/terraform-composite-actions/[email protected]\n+ uses: clowdhaus/terraform-composite-actions/[email protected]\n with:\n terraform-version: ${{ steps.minMax.outputs.maxVersion }}\n+ tflint-version: ${{ env.TFLINT_VERSION }}\n terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}\n+ install-hcledit: true\n---\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.76.0\n+ rev: v1.77.0\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n@@ -24,7 +24,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.3.0\n+ rev: v4.4.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nThat's prefect for wrapper modules, we will be using it in production. However most of time we would have some tag is for the same departments, but custom tag for individual.\r\n\r\n## Motivation and Context\r\nallow more flexible aws tags\r\n\r\n## Breaking Changes\r\nN/A\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nwrappers/main.tf\n@@ -15,7 +15,7 @@ module \"wrapper\" {\n bucket_prefix = try(each.value.bucket_prefix, var.defaults.bucket_prefix, null)\n acl = try(each.value.acl, var.defaults.acl, null)\n policy = try(each.value.policy, var.defaults.policy, null)\n- tags = try(each.value.tags, var.defaults.tags, {})\n+ tags = merge(try(var.defaults.tags, null), try(each.value.tags, null))\n force_destroy = try(each.value.force_destroy, var.defaults.force_destroy, false)\n acceleration_status = try(each.value.acceleration_status, var.defaults.acceleration_status, null)\n request_payer = try(each.value.request_payer, var.defaults.request_payer, null)\n---\nwrappers/object/main.tf\n@@ -22,7 +22,7 @@ module \"wrapper\" {\n kms_key_id = try(each.value.kms_key_id, var.defaults.kms_key_id, null)\n bucket_key_enabled = try(each.value.bucket_key_enabled, var.defaults.bucket_key_enabled, null)\n metadata = try(each.value.metadata, var.defaults.metadata, {})\n- tags = try(each.value.tags, var.defaults.tags, {})\n+ tags = merge(try(var.defaults.tags, null), try(each.value.tags, null))\n force_destroy = try(each.value.force_destroy, var.defaults.force_destroy, false)\n object_lock_legal_hold_status = try(each.value.object_lock_legal_hold_status, var.defaults.object_lock_legal_hold_status, object_lock_mode = try(each.value.object_lock_mode, var.defaults.object_lock_mode, null)\n---\n\n\n---\n\nChoice B:\nwrappers/main.tf\n@@ -15,7 +15,7 @@ module \"wrapper\" {\n bucket_prefix = try(each.value.bucket_prefix, var.defaults.bucket_prefix, null)\n acl = try(each.value.acl, var.defaults.acl, null)\n policy = try(each.value.policy, var.defaults.policy, null)\n- tags = try(each.value.tags, var.defaults.tags, {})\n+ tags = merge(try(var.defaults.tags, null), try(each.value.tags, null))\n force_destroy = try(each.value.force_destroy, var.defaults.force_destroy, false)\n acceleration_status = try(each.value.acceleration_status, var.defaults.acceleration_status, null)\n request_payer = try(each.value.request_payer, var.defaults.request_payer, null)\n---\nwrappers/object/main.tf\n@@ -22,7 +22,7 @@ module \"wrapper\" {\n kms_key_id = try(each.value.kms_key_id, var.defaults.kms_key_id, null)\n bucket_key_enabled = try(each.value.bucket_key_enabled, var.defaults.bucket_key_enabled, null)\n metadata = try(each.value.metadata, var.defaults.metadata, {})\n- tags = try(each.value.tags, var.defaults.tags, {})\n+ tags = merge(try(var.defaults.tags, null), try(each.value.tags, null))\n force_destroy = try(each.value.force_destroy, var.defaults.force_destroy, false)\n object_lock_legal_hold_status = try(each.value.object_lock_legal_hold_status, var.defaults.object_lock_legal_hold_status, null)\n object_lock_mode = try(each.value.object_lock_mode, var.defaults.object_lock_mode, null)\n---\n\n\n---\n\nChoice C:\nwrappers/main.tf\n@@ -15,7 +15,7 @@ module \"wrapper\" {\n bucket_prefix = try(each.value.bucket_prefix, var.defaults.bucket_prefix, null)\n acl = try(each.value.acl, var.defaults.acl, null)\n policy = try(each.value.policy, var.defaults.policy, null)\n- tags = try(each.value.tags, var.defaults.tags, {})\n+ tags = merge(try(var.defaults.tags, null), try(each.value.tags, null))\n force_destroy = try(each.value.force_destroy, var.defaults.force_destroy, false)\n acceleration_status = try(each.value.acceleration_status, var.defaults.acceleration_status, null)\n request_payer = try(each.value.request_payer, var.defaults.request_payer, null)\n---\nwrappers/object/main.tf\n@@ -22,7 +22,7 @@ module \"wrapper\" {\n kms_key_id = try(each.value.kms_key_id, var.defaults.kms_key_id, null)\n bucket_key_enabled = try(each.value.bucket_key_enabled, var.defaults.bucket_key_enabled, null)\n metadata = try(each.value.metadata, var.defaults.metadata, {})\n- tags = try(each.value.tags, var.defaults.tags, {})\n+ tags = merge(try(var.defaults.tags, null), try(each.value.tags, null))\n force_destroy = try(each.value.force_destroy, var.defaults.force_destroy, false)\n object_lock_legal_hold_status = try(each.value.object_lock_legal_hold_status, var.defaults.object_lock_legal_hold_status, null)\n object_lock_mode = try(each.value.object_lock_mode, var.defaults.object_lock_mode, null)\n---\n\n\n---\n\nChoice D:\nwrappers/main.tf\n@@ -15,7 +15,7 @@ module \"wrapper\" {\n bucket_prefix = try(each.value.bucket_prefix, var.defaults.bucket_prefix, null)\n acl = try(each.value.acl, var.defaults.acl, null)\n policy = try(each.value.policy, var.defaults.policy, null)\n- tags = try(each.value.tags, var.defaults.tags, {})\n+ tags = merge(try(var.defaults.tags, null), try(each.value.tags, null))\n force_destroy = try(each.value.force_destroy, var.defaults.force_destroy, false)\n acceleration_status = try(each.value.acceleration_status, var.defaults.acceleration_status, null)\n request_payer = try(each.value.request_payer, var.defaults.request_payer, null)\n---\nwrappers/object/main.tf\n@@ -22,7 +22,7 @@ module \"wrapper\" {\n kms_key_id = try(each.value.kms_key_id, var.defaults.kms_key_id, null)\n bucket_key_enabled = try(each.value.bucket_key_enabled, var.defaults.bucket_key_enabled, null)\n metadata = try(each.value.metadata, var.defaults.metadata, {})\n- tags = try(each.value.tags, var.defaults.tags, {})\n+ tags = merge(try(var.defaults.tags, null), try(each.value.tags, null))\n force_destroy = try(each.value.force_destroy, var.defaults.force_destroy, false)\n object_lock_legal_hold_status = try(each.value.object_lock_legal_hold_status, var.defaults.object_lock_legal_hold_status, null)\n object_lock_mode = try(each.value.object_lock_mode, var.defaults.object_lock_mode, null)\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nRemoved s3_bucket_ suffixes from all points in output from README. \r\n\r\n## Motivation and Context\r\ns3_bucket_ suffixes do not exist anymore\r\n\r\n## Breaking Changes\r\nNot known\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nREADME.md\n@@ -212,14 +212,14 @@ No modules.\n \n | Name | Description |\n |------|-------------|\n-| <a name=\"output_s3_bucket_arn\"></a> [s3\\_bucket\\_arn](#output\\_s3\\_bucket\\_arn) | The ARN of the bucket. Will be of format arn:aws:s3:::bucketname. |\n-| <a name=\"output_s3_bucket_bucket_domain_name\"></a> [s3\\_bucket\\_bucket\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_domain\\_name) | The bucket domain name. Will be of format bucketname.s3.amazonaws.com. |\n-| <a name=\"output_s3_bucket_bucket_regional_domain_name\"></a> [s3\\_bucket\\_bucket\\_regional\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_regional\\_domain\\_name) | The bucket region-specific domain name. The bucket domain name including the region name, please refer here for format. Note: The AWS CloudFront allows specifying S3 region-specific endpoint when creating S3 origin, it will prevent redirect issues from CloudFront to S3 Origin URL. |\n-| <a name=\"output_s3_bucket_hosted_zone_id\"></a> [s3\\_bucket\\_hosted\\_zone\\_id](#output\\_s3\\_bucket\\_hosted\\_zone\\_id) | The Route 53 Hosted Zone ID for this bucket's region. |\n-| <a name=\"output_s3_bucket_id\"></a> [s3\\_bucket\\_id](#output\\_s3\\_bucket\\_id) | The name of the bucket. |\n-| <a name=\"output_s3_bucket_region\"></a> [s3\\_bucket\\_region](#output\\_s3\\_bucket\\_region) | The AWS region this bucket resides in. |\n-| <a name=\"output_s3_bucket_website_domain\"></a> [s3\\_bucket\\_website\\_domain](#output\\_s3\\_bucket\\_website\\_domain) | The domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records. |\n-| <a name=\"output_s3_bucket_website_endpoint\"></a> [s3\\_bucket\\_website\\_endpoint](#output\\_s3\\_bucket\\_website\\_endpoint) | The website endpoint, a the bucket is configured with a website. If not, this will be an empty string. |\n+| <a name=\"output_s3_bucket_arn\"></a> [arn](#output\\_s3\\_bucket\\_arn) | The ARN of the bucket. Will be of format arn:aws:s3:::bucketname. |\n+| <a name=\"output_s3_bucket_bucket_domain_name\"></a> [bucket\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_domain\\_name) | The bucket domain name. Will be of format bucketname.s3.amazonaws.com. |\n+| <a name=\"output_s3_bucket_bucket_regional_domain_name\"></a> [bucket\\_regional\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_regional\\_domain\\_name) | The bucket region-specific domain name. The bucket domain name including the region name, please refer here for format. Note: The AWS CloudFront allows specifying S3 region-specific endpoint when creating S3 origin, it will prevent redirect issues from CloudFront to S3 Origin URL. |\n+| <a name=\"output_s3_bucket_hosted_zone_id\"></a> [hosted\\_zone\\_id](#output\\_s3\\_bucket\\_hosted\\_zone\\_id) | The Route 53 Hosted Zone ID for this bucket's region. |\n+| <a name=\"output_s3_bucket_id\"></a> [id](#output\\_s3\\_bucket\\_id) | The name of the bucket. |\n+| <a name=\"output_s3_bucket_region\"></a> [region](#output\\_s3\\_bucket\\_region) | The AWS region this bucket resides in. |\n+| <a name=\"output_s3_bucket_website_domain\"></a> [website\\_domain](#output\\_s3\\_bucket\\_website\\_domain) | The domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records. |\n+| <a name=\"output_s3_bucket_website_endpoint\"></a> [website\\_endpoint](#output\\_s3\\_bucket\\_website\\_endpoint) | The website endpoint, if the bucket is configured with a website. If not, this will be an empty string. |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n \n ## Authors\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -212,14 +212,14 @@ No modules.\n \n | Name | Description |\n |------|-------------|\n-| <a name=\"output_s3_bucket_arn\"></a> [s3\\_bucket\\_arn](#output\\_s3\\_bucket\\_arn) | The ARN of the bucket. Will be of format arn:aws:s3:::bucketname. |\n-| <a name=\"output_s3_bucket_bucket_domain_name\"></a> [s3\\_bucket\\_bucket\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_domain\\_name) | The bucket domain name. Will be of format bucketname.s3.amazonaws.com. |\n-| <a name=\"output_s3_bucket_bucket_regional_domain_name\"></a> [s3\\_bucket\\_bucket\\_regional\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_regional\\_domain\\_name) | The bucket region-specific domain name. The bucket domain name including the region name, please refer here for format. Note: The AWS CloudFront allows specifying S3 region-specific endpoint when creating S3 origin, it will prevent redirect issues from CloudFront to S3 Origin URL. |\n-| <a name=\"output_s3_bucket_hosted_zone_id\"></a> [s3\\_bucket\\_hosted\\_zone\\_id](#output\\_s3\\_bucket\\_hosted\\_zone\\_id) | The Route 53 Hosted Zone ID for this bucket's region. |\n-| <a name=\"output_s3_bucket_id\"></a> [s3\\_bucket\\_id](#output\\_s3\\_bucket\\_id) | The name of the bucket. |\n-| <a name=\"output_s3_bucket_region\"></a> [s3\\_bucket\\_region](#output\\_s3\\_bucket\\_region) | The AWS region this bucket resides in. |\n-| <a name=\"output_s3_bucket_website_domain\"></a> [s3\\_bucket\\_website\\_domain](#output\\_s3\\_bucket\\_website\\_domain) | The domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records. |\n-| <a name=\"output_s3_bucket_website_endpoint\"></a> [s3\\_bucket\\_website\\_endpoint](#output\\_s3\\_bucket\\_website\\_endpoint) | The website endpoint, if the bucket is configured with a website. If not, this will be an empty string. |\n+| <a name=\"output_s3_bucket_arn\"></a> [arn](#output\\_s3\\_bucket\\_arn) | The ARN of the bucket. Will be of format arn:aws:s3:::bucketname. |\n+| <a name=\"output_s3_bucket_bucket_domain_name\"></a> [bucket\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_domain\\_name) | The bucket domain name. Will be of format bucketname.s3.amazonaws.com. |\n+| <a name=\"output_s3_bucket_bucket_regional_domain_name\"></a> [bucket\\_regional\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_regional\\_domain\\_name) | The bucket region-specific domain name. The bucket domain name including the region name, please refer here for format. Note: The AWS CloudFront allows specifying S3 region-specific endpoint when creating S3 origin, it will prevent redirect issues from CloudFront to S3 Origin URL. |\n+| <a name=\"output_s3_bucket_hosted_zone_id\"></a> [hosted\\_zone\\_id](#output\\_s3\\_bucket\\_hosted\\_zone\\_id) | The Route 53 Hosted Zone ID for this bucket's region. |\n+| <a name=\"output_s3_bucket_id\"></a> [id](#output\\_s3\\_bucket\\_id) | The name of the bucket. |\n+| <a name=\"output_s3_bucket_region\"></a> [region](#output\\_s3\\_bucket\\_region) | The AWS region this bucket resides in. |\n+| <a name=\"output_s3_bucket_website_domain\"></a> [website\\_domain](#output\\_s3\\_bucket\\_website\\_domain) | The domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records. |\n+| <a name=\"output_s3_bucket_website_endpoint\"></a> [website\\_endpoint](#output\\_s3\\_bucket\\_website\\_endpoint) | The website endpoint, if the bucket is configured with a website. If not, this will be an empty string. |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n \n ## Authors\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -212,14 +212,14 @@ No modules.\n \n | Name | Description |\n |------|-------------|\n-| <a name=\"output_s3_bucket_arn\"></a> [s3\\_bucket\\_arn](#output\\_s3\\_bucket\\_arn) | The ARN of the bucket. Will be of format arn:aws:s3:::bucketname. |\n-| <a name=\"output_s3_bucket_bucket_domain_name\"></a> [s3\\_bucket\\_bucket\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_domain\\_name) | The bucket domain name. Will be of format bucketname.s3.amazonaws.com. |\n-| <a name=\"output_s3_bucket_bucket_regional_domain_name\"></a> [s3\\_bucket\\_bucket\\_regional\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_regional\\_domain\\_name) | The bucket region-specific domain name. The bucket domain name including the region name, please refer here for format. Note: The AWS CloudFront allows specifying S3 region-specific endpoint when creating S3 origin, it will prevent redirect issues from CloudFront to S3 Origin URL. |\n-| <a name=\"output_s3_bucket_hosted_zone_id\"></a> [s3\\_bucket\\_hosted\\_zone\\_id](#output\\_s3\\_bucket\\_hosted\\_zone\\_id) | The Route 53 Hosted Zone ID for this bucket's region. |\n-| <a name=\"output_s3_bucket_id\"></a> [s3\\_bucket\\_id](#output\\_s3\\_bucket\\_id) | The name of the bucket. |\n-| <a name=\"output_s3_bucket_region\"></a> [s3\\_bucket\\_region](#output\\_s3\\_bucket\\_region) | The AWS region this bucket resides in. |\n-| <a name=\"output_s3_bucket_website_domain\"></a> [s3\\_bucket\\_website\\_domain](#output\\_s3\\_bucket\\_website\\_domain) | The domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records. |\n-| <a name=\"output_s3_bucket_website_endpoint\"></a> [s3\\_bucket\\_website\\_endpoint](#output\\_s3\\_bucket\\_website\\_endpoint) | The website endpoint, if the bucket is configured with a website. If not, this will be an empty string. |\n+| <a name=\"output_s3_bucket_arn\"></a> [arn](#output\\_s3\\_bucket\\_arn) | The ARN of the bucket. Will be of format arn:aws:s3:::bucketname. |\n+| <a name=\"output_s3_bucket_bucket_domain_name\"></a> [bucket\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_domain\\_name) | The bucket domain name. Will be of format bucketname.s3.amazonaws.com. |\n+| <a name=\"output_s3_bucket_bucket_regional_domain_name\"></a> [bucket\\_regional\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_regional\\_domain\\_name) | The bucket region-specific domain name. The bucket domain name including the region name, please refer here for format. Note: The AWS CloudFront allows specifying S3 region-specific endpoint when creating S3 origin, it will prevent redirect issues from CloudFront to S3 Origin URL. |\n+| <a name=\"output_s3_bucket_hosted_zone_id\"></a> [hosted\\_zone\\_id](#output\\_s3\\_bucket\\_hosted\\_zone\\_id) | The Route 53 Hosted Zone ID for this bucket's region. |\n+| <a name=\"output_s3_bucket_id\"></a> [id](#output\\_s3\\_bucket\\_id) | The name of the bucket. |\n+| <a name=\"output_s3_bucket_region\"></a> [region](#output\\_s3\\_bucket\\_region) | The AWS region this bucket resides in. |\n+| <a name=\"output_s3_bucket_website_domain\"></a> [website\\_domain](#output\\_s3\\_bucket\\_website\\_domain) | The domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to name Route 53 alias records. |\n+| <a name=\"output_s3_bucket_website_endpoint\"></a> [website\\_endpoint](#output\\_s3\\_bucket\\_website\\_endpoint) | The website endpoint, if the bucket is configured with a website. If not, this will be an empty string. |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n \n ## Authors\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -212,14 +212,14 @@ No modules.\n \n | Name | Description |\n |------|-------------|\n-| <a name=\"output_s3_bucket_arn\"></a> [s3\\_bucket\\_arn](#output\\_s3\\_bucket\\_arn) | The ARN of the bucket. Will be of format arn:aws:s3:::bucketname. |\n-| <a name=\"output_s3_bucket_bucket_domain_name\"></a> [s3\\_bucket\\_bucket\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_domain\\_name) | The bucket domain | Will be of format bucketname.s3.amazonaws.com. |\n-| <a name=\"output_s3_bucket_bucket_regional_domain_name\"></a> [s3\\_bucket\\_bucket\\_regional\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_regional\\_domain\\_name) | The bucket region-specific domain name. The bucket domain name including the region name, please refer here for format. Note: The AWS CloudFront allows specifying S3 region-specific endpoint when creating S3 origin, it will prevent redirect issues from CloudFront to S3 Origin URL. |\n-| <a name=\"output_s3_bucket_hosted_zone_id\"></a> [s3\\_bucket\\_hosted\\_zone\\_id](#output\\_s3\\_bucket\\_hosted\\_zone\\_id) | The Route 53 Hosted Zone ID for this bucket's region. |\n-| <a name=\"output_s3_bucket_id\"></a> [s3\\_bucket\\_id](#output\\_s3\\_bucket\\_id) | The name of the bucket. |\n-| <a name=\"output_s3_bucket_region\"></a> [s3\\_bucket\\_region](#output\\_s3\\_bucket\\_region) | The AWS region this bucket resides in. |\n-| <a name=\"output_s3_bucket_website_domain\"></a> [s3\\_bucket\\_website\\_domain](#output\\_s3\\_bucket\\_website\\_domain) | The domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records. |\n-| <a name=\"output_s3_bucket_website_endpoint\"></a> [s3\\_bucket\\_website\\_endpoint](#output\\_s3\\_bucket\\_website\\_endpoint) | The website endpoint, if the bucket is configured with a website. If not, this will be an empty string. |\n+| <a name=\"output_s3_bucket_arn\"></a> [arn](#output\\_s3\\_bucket\\_arn) | The ARN of the bucket. Will be of format arn:aws:s3:::bucketname. |\n+| <a name=\"output_s3_bucket_bucket_domain_name\"></a> [bucket\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_domain\\_name) | The bucket domain name. Will be of format bucketname.s3.amazonaws.com. |\n+| <a name=\"output_s3_bucket_bucket_regional_domain_name\"></a> [bucket\\_regional\\_domain\\_name](#output\\_s3\\_bucket\\_bucket\\_regional\\_domain\\_name) | The bucket region-specific domain name. The bucket domain name including the region name, please refer here for format. Note: The AWS CloudFront allows specifying S3 region-specific endpoint when creating S3 origin, it will prevent redirect issues from CloudFront to S3 Origin URL. |\n+| <a name=\"output_s3_bucket_hosted_zone_id\"></a> [hosted\\_zone\\_id](#output\\_s3\\_bucket\\_hosted\\_zone\\_id) | The Route 53 Hosted Zone ID for this bucket's region. |\n+| <a name=\"output_s3_bucket_id\"></a> [id](#output\\_s3\\_bucket\\_id) | The name of the bucket. |\n+| <a name=\"output_s3_bucket_region\"></a> [region](#output\\_s3\\_bucket\\_region) | The AWS region this bucket resides in. |\n+| <a name=\"output_s3_bucket_website_domain\"></a> [website\\_domain](#output\\_s3\\_bucket\\_website\\_domain) | The domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records. |\n+| <a name=\"output_s3_bucket_website_endpoint\"></a> [website\\_endpoint](#output\\_s3\\_bucket\\_website\\_endpoint) | The website endpoint, if the bucket is configured with a website. If not, this will be an empty string. |\n <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->\n \n ## Authors\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n\r\nEnable jsonencode support for replication config\r\n\r\n## Motivation and Context\r\n\r\n```\r\nlocals {\r\n replication_config = jsonencode({\r\n role = var.role_arn\r\n rules = [\r\n {\r\n id = \"sync to staging\"\r\n status = true\r\n priority = 0\r\n\r\n delete_marker_replication = true\r\n\r\n destination = {\r\n bucket = \"arn:aws:s3:::test2\"\r\n account_id = \"xxxxxx\"\r\n access_control_translation = {\r\n owner = \"Destination\"\r\n }\r\n }\r\n },\r\n ]\r\n })\r\n}\r\n\r\nmodule \"bucket\" {\r\n source = \"terraform-aws-modules/s3-bucket/aws\"\r\n version = \"3.6.x\"\r\n bucket = \"test\"\r\n replication_configuration = var.env == \"prod\" ? local.replication_config : \"{}\"\r\n}\r\n```\r\n\r\n## Breaking Changes\r\n\r\nNo.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\r\n\n\n---\n\nChoice A:\nmain.tf\n@@ -8,11 +8,12 @@ locals {\n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_inventory_destination_policy || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n- grants = try(jsondecode(var.grant), var.grant)\n- cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n- lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n- intelligent_tiering = try(jsondecode(var.intelligent_tiering), var.intelligent_tiering)\n- metric_configuration = try(jsondecode(var.metric_configuration), var.metric_configuration)\n+ grants ? = try(jsondecode(var.grant), var.grant)\n+ cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n+ lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ intelligent_tiering = try(jsondecode(var.intelligent_tiering), var.intelligent_tiering)\n+ metric_configuration = try(jsondecode(var.metric_configuration), var.metric_configuration)\n+ replication_configuration = try(jsondecode(var.replication_configuration), var.replication_configuration)\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -338,13 +339,13 @@ resource \"aws_s3_bucket_object_lock_configuration\" \"this\" {\n }\n \n resource \"aws_s3_bucket_replication_configuration\" \"this\" {\n- count = local.create_bucket && length(keys(var.replication_configuration)) > 0 ? 1 : 0\n+ count = local.create_bucket && length(keys(local.replication_configuration)) > 0 ? 1 : 0\n \n bucket = aws_s3_bucket.this[0].id\n- role = var.replication_configuration[\"role\"]\n+ role = local.replication_configuration[\"role\"]\n \n dynamic \"rule\" {\n- for_each = flatten(try([var.replication_configuration[\"rule\"]], [var.replication_configuration[\"rules\"]], []))\n+ for_each = flatten(try([local.replication_configuration[\"rule\"]], [local.replication_configuration[\"rules\"]], []))\n \n content {\n id = try(rule.value.id, null)\n---\n\n\n---\n\nChoice B:\nmain.tf\n@@ -8,11 +8,12 @@ locals {\n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_inventory_destination_policy || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n- grants = try(jsondecode(var.grant), var.grant)\n- cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n- lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n- intelligent_tiering = try(jsondecode(var.intelligent_tiering), var.intelligent_tiering)\n- metric_configuration = try(jsondecode(var.metric_configuration), var.metric_configuration)\n+ grants = try(jsondecode(var.grant), var.grant)\n+ cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n+ lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ intelligent_tiering = try(jsondecode(var.intelligent_tiering), var.intelligent_tiering)\n+ metric_configuration = try(jsondecode(var.metric_configuration), var.metric_configuration)\n+ replication_configuration = try(jsondecode(var.replication_configuration), var.replication_configuration)\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -338,13 +339,13 @@ resource \"aws_s3_bucket_object_lock_configuration\" \"this\" {\n }\n \n resource \"aws_s3_bucket_replication_configuration\" \"this\" {\n- count = local.create_bucket && length(keys(var.replication_configuration)) > 0 ? 1 : 0\n+ count = local.create_bucket && length(keys(local.replication_configuration)) > 0 ? 1 : 0\n \n bucket = aws_s3_bucket.this[0].id\n- role = var.replication_configuration[\"role\"]\n+ role = local.replication_configuration[\"role\"]\n \n dynamic \"rule\" {\n- for_each = flatten(try([var.replication_configuration[\"rule\"]], [var.replication_configuration[\"rules\"]], []))\n+ for_each = flatten(try([local.replication_configuration[\"rule\"]], [local.replication_configuration[\"rules\"]], []))\n \n content {\n id = try(rule.value.id, null)\n---\n\n\n---\n\nChoice C:\nmain.tf\n@@ -8,11 +8,12 @@ locals {\n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_inventory_destination_policy || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n- grants = try(jsondecode(var.grant), var.grant)\n- cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n- lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n- intelligent_tiering = try(jsondecode(var.intelligent_tiering), var.intelligent_tiering)\n- metric_configuration = try(jsondecode(var.metric_configuration), var.metric_configuration)\n+ grants = try(jsondecode(var.grant), var.grant)\n+ cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n+ lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ intelligent_tiering = try(jsondecode(var.intelligent_tiering), var.intelligent_tiering)\n+ metric_configuration = try(jsondecode(var.metric_configuration), var.metric_configuration)\n+ replication_configuration = try(jsondecode(var.replication_configuration), var.replication_configuration)\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -338,13 +339,13 @@ resource \"aws_s3_bucket_object_lock_configuration\" \"this\" {\n }\n \n resource \"aws_s3_bucket_replication_configuration\" \"this\" {\n- count = local.create_bucket && length(keys(var.replication_configuration)) > 0 ? 1 : 0\n+ count = local.create_bucket && length(keys(local.replication_configuration)) > 0 ? 1 : 0\n \n bucket = aws_s3_bucket.this[0].id\n- role = var.replication_configuration[\"role\"]\n+ role = local.replication_configuration[\"role\"]\n \n dynamic \"rule\" {\n- for_each = flatten(try([var.replication_configuration[\"rule\"]], [var.replication_configuration[\"rules\"]], []))\n+ for_each = flatten(try([local.replication_configuration[\"rule\"]], [local.replication_configuration[\"rules\"]], []))\n \n content {\n id = try(rule.value.id, null)\n---\n\n\n---\n\nChoice D:\nmain.tf\n@@ -8,11 +8,12 @@ locals {\n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_inventory_destination_policy || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n- grants = try(jsondecode(var.grant), var.grant)\n- cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n- lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n- intelligent_tiering = try(jsondecode(var.intelligent_tiering), var.intelligent_tiering)\n- metric_configuration = try(jsondecode(var.metric_configuration), var.metric_configuration)\n+ grants = try(jsondecode(var.grant), var.grant)\n+ cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n+ lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ intelligent_tiering = try(jsondecode(var.intelligent_tiering), var.intelligent_tiering)\n+ metric_configuration = try(jsondecode(var.metric_configuration), var.metric_configuration)\n+ replication_configuration = try(jsondecode(var.replication_configuration), var.replication_configuration)\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ try(jsondecode(var.grant), +339,13 @@ resource \"aws_s3_bucket_object_lock_configuration\" \"this\" {\n }\n \n resource \"aws_s3_bucket_replication_configuration\" \"this\" {\n- count = local.create_bucket && length(keys(var.replication_configuration)) > 0 ? 1 : 0\n+ count = local.create_bucket && length(keys(local.replication_configuration)) > 0 ? 1 : 0\n \n bucket = aws_s3_bucket.this[0].id\n- role = var.replication_configuration[\"role\"]\n+ role = local.replication_configuration[\"role\"]\n \n dynamic \"rule\" {\n- for_each = flatten(try([var.replication_configuration[\"rule\"]], [var.replication_configuration[\"rules\"]], []))\n+ for_each = flatten(try([local.replication_configuration[\"rule\"]], [local.replication_configuration[\"rules\"]], []))\n \n content {\n id = try(rule.value.id, null)\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nAdds bucket metrics support. \r\n\r\n## Motivation and Context\r\nFixes https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/issues/187\r\n\r\n## Breaking Changes\r\nNo.\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n\n\n---\n\nChoice A:\nREADME.md\n@@ -141,6 +141,7 @@ No modules.\n | [aws_s3_bucket_intelligent_tiering_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_intelligent_tiering_configuration) | resource |\n | [aws_s3_bucket_lifecycle_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |\n | [aws_s3_bucket_logging.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_logging) | resource |\n+| [aws_s3_bucket_metric.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_metric) | resource |\n | [aws_s3_bucket_object_lock_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object_lock_configuration) | resource |\n | [aws_s3_bucket_ownership_controls.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls) | resource |\n | [aws_s3_bucket_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |\n@@ -184,6 +185,7 @@ No modules.\n | <a name=\"input_intelligent_tiering\"></a> [intelligent\\_tiering](#input\\_intelligent\\_tiering) | Map containing intelligent tiering configuration. | `any` | `{}` | no |\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n+| <a name=\"input_metric_configuration\"></a> [metric\\_configuration](#input\\_metric\\_configuration) | Map containing bucket metric configuration. | `any` | `[]` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n | <a name=\"input_object_lock_enabled\"></a> [object\\_lock\\_enabled](#input\\_object\\_lock\\_enabled) | Whether S3 bucket should have an Object Lock configuration enabled. | `bool` | `false` | no |\n | <a name=\"input_object_ownership\"></a> [object\\_ownership](#input\\_object\\_ownership) | Object ownership. Valid values: BucketOwnerEnforced, BucketOwnerPreferred or ObjectWriter. 'BucketOwnerEnforced': ACLs are disabled, and the bucket owner automatically owns and has full control over every object in the bucket. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL. | `string` | `\"ObjectWriter\"` | no |\n---\nexamples/complete/main.tf\n@@ -324,4 +324,28 @@ module \"s3_bucket\" {\n }\n }\n }\n+\n+ metric_configuration = [\n+ {\n+ name = \"documents\"\n+ filter = {\n+ prefix = \"documents/\"\n+ tags = {\n+ priority = \"high\"\n+ }\n+ }\n+ },\n+ {\n+ name = \"other\"\n+ filter = {\n+ tags = {\n+ production = \"true\"\n+ }\n+ }\n+ },\n+ {\n+ name = \"all\"\n+ }\n+ ]\n+\n }\n---\nmain.tf\n@@ -6,10 +6,11 @@ locals {\n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n- grants = try(jsondecode(var.grant), var.grant)\n- cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n- lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n- intelligent_tiering = try(jsondecode(var.intelligent_tiering), var.intelligent_tiering)\n+ grants = try(jsondecode(var.grant), var.grant)\n+ cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n+ lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ intelligent_tiering = try(jsondecode(var.intelligent_tiering), var.intelligent_tiering)\n+ metric_configuration = try(jsondecode(var.metric_configuration), var.metric_configuration)\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -719,3 +720,18 @@ resource \"aws_s3_bucket_intelligent_tiering_configuration\" \"this\" {\n }\n \n }\n+\n+resource \"aws_s3_bucket_metric\" \"this\" {\n+ for_each = { for k, v in local.metric_configuration : k => v if local.create_bucket }\n+\n+ name = each.value.name\n+ bucket = aws_s3_bucket.this[0].id\n+\n+ dynamic \"filter\" {\n+ for_each = length(try(flatten([each.value.filter]), [])) == 0 ? [] : [true]\n+ content {\n+ prefix = try(each.value.filter.prefix, null)\n+ tags = try(each.value.filter.tags, null)\n+ }\n+ }\n+}\n---\nvariables.tf\n@@ -160,6 +160,12 @@ variable \"object_lock_configuration\" {\n default = {}\n }\n \n+variable \"metric_configuration\" {\n+ description = \"Map containing bucket metric configuration.\"\n+ type = any\n+ default = []\n+}\n+\n variable \"object_lock_enabled\" {\n description = \"Whether S3 bucket should have an Object Lock configuration enabled.\"\n type = bool\n---\nwrappers/main.tf\n@@ -30,6 +30,7 @@ module \"wrapper\" {\n server_side_encryption_configuration = try(each.value.server_side_encryption_configuration, var.defaults.server_side_encryption_configuration, {})\n intelligent_tiering = try(each.value.intelligent_tiering, var.defaults.intelligent_tiering, {})\n object_lock_configuration = try(each.value.object_lock_configuration, var.defaults.object_lock_configuration, {})\n+ metric_configuration = try(each.value.metric_configuration, var.defaults.metric_configuration, [])\n object_lock_enabled = try(each.value.object_lock_enabled, var.defaults.object_lock_enabled, false)\n block_public_acls = try(each.value.block_public_acls, var.defaults.block_public_acls, false)\n block_public_policy = try(each.value.block_public_policy, var.defaults.block_public_policy, false)\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -141,6 +141,7 @@ No modules.\n | [aws_s3_bucket_intelligent_tiering_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_intelligent_tiering_configuration) | resource |\n | [aws_s3_bucket_lifecycle_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |\n | [aws_s3_bucket_logging.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_logging) | resource |\n+| [aws_s3_bucket_metric.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_metric) | resource |\n | [aws_s3_bucket_object_lock_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object_lock_configuration) | resource |\n | [aws_s3_bucket_ownership_controls.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls) | resource |\n | [aws_s3_bucket_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |\n@@ -184,6 +185,7 @@ No modules.\n | <a name=\"input_intelligent_tiering\"></a> [intelligent\\_tiering](#input\\_intelligent\\_tiering) | Map containing intelligent tiering configuration. | `any` | `{}` | no |\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n+| <a name=\"input_metric_configuration\"></a> [metric\\_configuration](#input\\_metric\\_configuration) | Map containing bucket metric configuration. | `any` | `[]` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n values: <a name=\"input_object_lock_enabled\"></a> [object\\_lock\\_enabled](#input\\_object\\_lock\\_enabled) | Whether S3 bucket should have an Object Lock configuration enabled. | `bool` | `false` | no |\n | <a name=\"input_object_ownership\"></a> [object\\_ownership](#input\\_object\\_ownership) | Object ownership. Valid values: BucketOwnerEnforced, BucketOwnerPreferred or ObjectWriter. 'BucketOwnerEnforced': ACLs are disabled, and the bucket owner automatically owns and has full control over every object in the bucket. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL. | `string` | `\"ObjectWriter\"` | no |\n---\nexamples/complete/main.tf\n@@ -324,4 +324,28 @@ module \"s3_bucket\" {\n }\n }\n }\n+\n+ metric_configuration = [\n+ {\n+ name = \"documents\"\n+ filter = {\n+ prefix = \"documents/\"\n+ tags = {\n+ priority = \"high\"\n+ }\n+ }\n+ },\n+ {\n+ name = \"other\"\n+ filter = {\n+ tags = {\n+ production = \"true\"\n+ }\n+ }\n+ },\n+ {\n+ name = \"all\"\n+ }\n+ ]\n+\n }\n---\nmain.tf\n@@ -6,10 +6,11 @@ locals {\n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n- grants = try(jsondecode(var.grant), var.grant)\n- cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n- lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n- intelligent_tiering = try(jsondecode(var.intelligent_tiering), var.intelligent_tiering)\n+ grants = try(jsondecode(var.grant), var.grant)\n+ cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n+ lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ intelligent_tiering = try(jsondecode(var.intelligent_tiering), var.intelligent_tiering)\n+ metric_configuration = try(jsondecode(var.metric_configuration), var.metric_configuration)\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -719,3 +720,18 @@ resource \"aws_s3_bucket_intelligent_tiering_configuration\" \"this\" {\n }\n \n }\n+\n+resource \"aws_s3_bucket_metric\" \"this\" {\n+ for_each = { for k, v in local.metric_configuration : k => v if local.create_bucket }\n+\n+ name = each.value.name\n+ bucket = aws_s3_bucket.this[0].id\n+\n+ dynamic \"filter\" {\n+ for_each = length(try(flatten([each.value.filter]), [])) == 0 ? [] : [true]\n+ content {\n+ prefix = try(each.value.filter.prefix, null)\n+ tags = try(each.value.filter.tags, null)\n+ }\n+ }\n+}\n---\nvariables.tf\n@@ -160,6 +160,12 @@ variable \"object_lock_configuration\" {\n default = {}\n }\n \n+variable \"metric_configuration\" {\n+ description = \"Map containing bucket metric configuration.\"\n+ type = any\n+ default = []\n+}\n+\n variable \"object_lock_enabled\" {\n description = \"Whether S3 bucket should have an Object Lock configuration enabled.\"\n type = bool\n---\nwrappers/main.tf\n@@ -30,6 +30,7 @@ module \"wrapper\" {\n server_side_encryption_configuration = try(each.value.server_side_encryption_configuration, var.defaults.server_side_encryption_configuration, {})\n intelligent_tiering = try(each.value.intelligent_tiering, var.defaults.intelligent_tiering, {})\n object_lock_configuration = try(each.value.object_lock_configuration, var.defaults.object_lock_configuration, {})\n+ metric_configuration = try(each.value.metric_configuration, var.defaults.metric_configuration, [])\n object_lock_enabled = try(each.value.object_lock_enabled, var.defaults.object_lock_enabled, false)\n block_public_acls = try(each.value.block_public_acls, var.defaults.block_public_acls, false)\n block_public_policy = try(each.value.block_public_policy, var.defaults.block_public_policy, false)\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -141,6 +141,7 @@ No modules.\n | [aws_s3_bucket_intelligent_tiering_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_intelligent_tiering_configuration) resource |\n | [aws_s3_bucket_lifecycle_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |\n | [aws_s3_bucket_logging.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_logging) | resource |\n+| [aws_s3_bucket_metric.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_metric) | resource |\n | [aws_s3_bucket_object_lock_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object_lock_configuration) | resource |\n | [aws_s3_bucket_ownership_controls.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls) | resource |\n | [aws_s3_bucket_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |\n@@ -184,6 +185,7 @@ No modules.\n | <a name=\"input_intelligent_tiering\"></a> [intelligent\\_tiering](#input\\_intelligent\\_tiering) | Map containing intelligent tiering configuration. | `any` | `{}` | no |\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n+| <a name=\"input_metric_configuration\"></a> [metric\\_configuration](#input\\_metric\\_configuration) | Map containing bucket metric configuration. | `any` | `[]` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n | <a name=\"input_object_lock_enabled\"></a> [object\\_lock\\_enabled](#input\\_object\\_lock\\_enabled) | Whether S3 bucket should have an Object Lock configuration enabled. | `bool` | `false` | no |\n | <a name=\"input_object_ownership\"></a> [object\\_ownership](#input\\_object\\_ownership) | Object ownership. Valid values: BucketOwnerEnforced, BucketOwnerPreferred or ObjectWriter. 'BucketOwnerEnforced': ACLs are disabled, and the bucket owner automatically owns and has full control over every object in the bucket. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL. | `string` | `\"ObjectWriter\"` | no |\n---\nexamples/complete/main.tf\n@@ -324,4 +324,28 @@ module \"s3_bucket\" {\n }\n }\n }\n+\n+ metric_configuration = [\n+ {\n+ name = \"documents\"\n+ filter = {\n+ prefix = \"documents/\"\n+ tags = {\n+ priority = \"high\"\n+ }\n+ }\n+ },\n+ {\n+ name = \"other\"\n+ filter = {\n+ tags = {\n+ production = \"true\"\n+ }\n+ }\n+ },\n+ {\n+ name = \"all\"\n+ }\n+ ]\n+\n }\n---\nmain.tf\n@@ -6,10 +6,11 @@ locals {\n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n- grants = try(jsondecode(var.grant), var.grant)\n- cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n- lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n- intelligent_tiering = try(jsondecode(var.intelligent_tiering), var.intelligent_tiering)\n+ grants = try(jsondecode(var.grant), var.grant)\n+ cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n+ lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ intelligent_tiering = try(jsondecode(var.intelligent_tiering), var.intelligent_tiering)\n+ metric_configuration = try(jsondecode(var.metric_configuration), var.metric_configuration)\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -719,3 +720,18 @@ resource \"aws_s3_bucket_intelligent_tiering_configuration\" \"this\" {\n }\n \n }\n+\n+resource \"aws_s3_bucket_metric\" \"this\" {\n+ for_each = { for k, v in local.metric_configuration : k => v if local.create_bucket }\n+\n+ name = each.value.name\n+ bucket = aws_s3_bucket.this[0].id\n+\n+ dynamic \"filter\" {\n+ for_each = length(try(flatten([each.value.filter]), [])) == 0 ? [] : [true]\n+ content {\n+ prefix = try(each.value.filter.prefix, null)\n+ tags = try(each.value.filter.tags, null)\n+ }\n+ }\n+}\n---\nvariables.tf\n@@ -160,6 +160,12 @@ variable \"object_lock_configuration\" {\n default = {}\n }\n \n+variable \"metric_configuration\" {\n+ description = \"Map containing bucket metric configuration.\"\n+ type = any\n+ default = []\n+}\n+\n variable \"object_lock_enabled\" {\n description = \"Whether S3 bucket should have an Object Lock configuration enabled.\"\n type = bool\n---\nwrappers/main.tf\n@@ -30,6 +30,7 @@ module \"wrapper\" {\n server_side_encryption_configuration = try(each.value.server_side_encryption_configuration, var.defaults.server_side_encryption_configuration, {})\n intelligent_tiering = try(each.value.intelligent_tiering, var.defaults.intelligent_tiering, {})\n object_lock_configuration = try(each.value.object_lock_configuration, var.defaults.object_lock_configuration, {})\n+ metric_configuration = try(each.value.metric_configuration, var.defaults.metric_configuration, [])\n object_lock_enabled = try(each.value.object_lock_enabled, var.defaults.object_lock_enabled, false)\n block_public_acls = try(each.value.block_public_acls, var.defaults.block_public_acls, false)\n block_public_policy = try(each.value.block_public_policy, var.defaults.block_public_policy, false)\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -141,6 +141,7 @@ No modules.\n | [aws_s3_bucket_intelligent_tiering_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_intelligent_tiering_configuration) | resource |\n | [aws_s3_bucket_lifecycle_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |\n | [aws_s3_bucket_logging.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_logging) | resource [aws_s3_bucket_metric.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_metric) | resource |\n | [aws_s3_bucket_object_lock_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object_lock_configuration) | resource |\n | [aws_s3_bucket_ownership_controls.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls) | resource |\n | [aws_s3_bucket_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |\n@@ -184,6 +185,7 @@ No modules.\n | <a name=\"input_intelligent_tiering\"></a> [intelligent\\_tiering](#input\\_intelligent\\_tiering) | Map containing intelligent tiering configuration. | `any` | `{}` | no |\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n+| <a name=\"input_metric_configuration\"></a> [metric\\_configuration](#input\\_metric\\_configuration) | Map containing bucket metric configuration. | `any` | `[]` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n | <a name=\"input_object_lock_enabled\"></a> [object\\_lock\\_enabled](#input\\_object\\_lock\\_enabled) | Whether S3 bucket should have an Object Lock configuration enabled. | `bool` | `false` | no |\n | <a name=\"input_object_ownership\"></a> [object\\_ownership](#input\\_object\\_ownership) | Object ownership. Valid values: BucketOwnerEnforced, BucketOwnerPreferred or ObjectWriter. 'BucketOwnerEnforced': ACLs are disabled, and the bucket owner automatically owns and has full control over every object in the bucket. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL. | `string` | `\"ObjectWriter\"` | no |\n---\nexamples/complete/main.tf\n@@ -324,4 +324,28 @@ module \"s3_bucket\" {\n }\n }\n }\n+\n+ metric_configuration = [\n+ {\n+ name = \"documents\"\n+ filter = {\n+ prefix = \"documents/\"\n+ tags = {\n+ priority = \"high\"\n+ }\n+ }\n+ },\n+ {\n+ name = \"other\"\n+ filter = {\n+ tags = {\n+ production = \"true\"\n+ }\n+ }\n+ },\n+ {\n+ name = \"all\"\n+ }\n+ ]\n+\n }\n---\nmain.tf\n@@ -6,10 +6,11 @@ locals {\n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n- grants = try(jsondecode(var.grant), var.grant)\n- cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n- lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n- intelligent_tiering = try(jsondecode(var.intelligent_tiering), var.intelligent_tiering)\n+ grants = try(jsondecode(var.grant), var.grant)\n+ cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n+ lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ intelligent_tiering = try(jsondecode(var.intelligent_tiering), var.intelligent_tiering)\n+ metric_configuration = try(jsondecode(var.metric_configuration), var.metric_configuration)\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -719,3 +720,18 @@ resource \"aws_s3_bucket_intelligent_tiering_configuration\" \"this\" {\n }\n \n }\n+\n+resource \"aws_s3_bucket_metric\" \"this\" {\n+ for_each = { for k, v in local.metric_configuration : k => v if local.create_bucket }\n+\n+ name = each.value.name\n+ bucket = aws_s3_bucket.this[0].id\n+\n+ dynamic \"filter\" {\n+ for_each = length(try(flatten([each.value.filter]), [])) == 0 ? [] : [true]\n+ content {\n+ prefix = try(each.value.filter.prefix, null)\n+ tags = try(each.value.filter.tags, null)\n+ }\n+ }\n+}\n---\nvariables.tf\n@@ -160,6 +160,12 @@ variable \"object_lock_configuration\" {\n default = {}\n }\n \n+variable \"metric_configuration\" {\n+ description = \"Map containing bucket metric configuration.\"\n+ type = any\n+ default = []\n+}\n+\n variable \"object_lock_enabled\" {\n description = \"Whether S3 bucket should have an Object Lock configuration enabled.\"\n type = bool\n---\nwrappers/main.tf\n@@ -30,6 +30,7 @@ module \"wrapper\" {\n server_side_encryption_configuration = try(each.value.server_side_encryption_configuration, var.defaults.server_side_encryption_configuration, {})\n intelligent_tiering = try(each.value.intelligent_tiering, var.defaults.intelligent_tiering, {})\n object_lock_configuration = try(each.value.object_lock_configuration, var.defaults.object_lock_configuration, {})\n+ metric_configuration = try(each.value.metric_configuration, var.defaults.metric_configuration, [])\n object_lock_enabled = try(each.value.object_lock_enabled, var.defaults.object_lock_enabled, false)\n block_public_acls = try(each.value.block_public_acls, var.defaults.block_public_acls, false)\n block_public_policy = try(each.value.block_public_policy, var.defaults.block_public_policy, false)\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nThis PR removes deprecated attributes from the `aws_s3_bucket` resource. This required a change to the required AWS provider version, version `4.9.0` made the removed attributes optional - this module uses the standalone resources.\r\n\r\nI also updated one of the examples as the hard-coded value caused errors when testing.\r\n\r\nFixes https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/issues/174\r\nFixes https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/issues/177\r\nFixes https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/issues/176\r\n\r\n## Motivation and Context\r\nPrior to this change, Terraform shows `Warning: Deprecated attribute` when running an apply. This no longer happens with these changes.\r\n\r\nThis fixes https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/issues/174 and https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/issues/177\r\n\r\n## Breaking Changes\r\nThere are no breaking changes\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n - A fix was applied to the `complete` example\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n - The `complete` example was used\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n\r\nAs mentioned above, I use the `complete` example to show the behaviour before and after these changes. This example required removing a hardcoded canonical ID to get it to deploy before any changes had been made.\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.71.0\n+ rev: v1.74.1\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n@@ -24,7 +24,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.2.0\n+ rev: v4.3.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\nREADME.md\n@@ -118,13 +118,13 @@ Users of Terragrunt can achieve similar results by using modules provided in the\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.5 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.9 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.5 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.9 |\n \n ## Modules\n \n---\nexamples/complete/README.md\n@@ -30,14 +30,14 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.5 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.9 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.5 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.9 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/complete/main.tf\n@@ -95,7 +95,7 @@ module \"cloudfront_log_bucket\" {\n ]\n \n owner = {\n- id = \"457414f555e45c2e6fe1069d1a527a90d6337e1acb012ba99f3833859b23d338\"\n+ id = data.aws_canonical_user_id.current.id\n }\n \n force_destroy = true\n---\nexamples/complete/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.5\"\n+ version = \">= 4.9\"\n }\n random = {\n name=\"provider_random\"></a> = \"hashicorp/random\"\n---\nexamples/notification/README.md\n@@ -20,15 +20,15 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.5 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.9 |\n | <a name=\"requirement_null\"></a> [null](#requirement\\_null) | >= 2.0 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.5 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.9 |\n | <a name=\"provider_null\"></a> [null](#provider\\_null) | >= 2.0 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n---\nexamples/notification/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.5\"\n+ version = \">= 4.9\"\n }\n random = {\n source = \"hashicorp/random\"\n---\nexamples/object/README.md\n@@ -20,14 +20,14 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.5 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.9 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.5 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.9 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/object/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.5\"\n+ version = \">= 4.9\"\n }\n random = {\n source = \"hashicorp/random\"\n---\nexamples/s3-replication/README.md\n@@ -22,15 +22,15 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.5 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.9 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.5 |\n-| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 4.5 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.9 |\n+| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 4.9 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/s3-replication/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.5\"\n+ version = \">= 4.9\"\n }\n random = {\n source = \"hashicorp/random\"\n---\nmain.tf\n@@ -21,23 +21,6 @@ resource \"aws_s3_bucket\" \"this\" {\n force_destroy = var.force_destroy\n object_lock_enabled = var.object_lock_enabled\n tags = var.tags\n-\n- lifecycle {\n- ignore_changes = [\n- acceleration_status,\n- acl,\n- grant,\n- cors_rule,\n- lifecycle_rule,\n- logging,\n- object_lock_configuration,\n- replication_configuration,\n- request_payer,\n- server_side_encryption_configuration,\n- versioning,\n- website\n- ]\n- }\n }\n \n resource \"aws_s3_bucket_logging\" \"this\" {\n---\nversions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.5\"\n+ version = \">= 4.9\"\n }\n }\n }\n---\n\n\n---\n\nChoice B:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.71.0\n+ rev: v1.74.1\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n@@ -24,7 +24,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.2.0\n+ rev: v4.3.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\nREADME.md\n@@ -118,13 +118,13 @@ Users of Terragrunt can achieve similar results by using modules provided in the\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.5 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.9 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.5 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.9 |\n \n ## Modules\n \n---\nexamples/complete/README.md\n@@ -30,14 +30,14 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.5 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.9 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.5 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.9 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/complete/main.tf\n@@ -95,7 +95,7 @@ module \"cloudfront_log_bucket\" {\n ]\n \n owner = {\n- id = \"457414f555e45c2e6fe1069d1a527a90d6337e1acb012ba99f3833859b23d338\"\n+ id = data.aws_canonical_user_id.current.id\n }\n \n force_destroy = true\n---\nexamples/complete/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.5\"\n+ version = \">= 4.9\"\n }\n random = {\n source = \"hashicorp/random\"\n---\nexamples/notification/README.md\n@@ -20,15 +20,15 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.5 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.9 |\n | <a name=\"requirement_null\"></a> [null](#requirement\\_null) | >= 2.0 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.5 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.9 |\n | <a name=\"provider_null\"></a> [null](#provider\\_null) | >= 2.0 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n---\nexamples/notification/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.5\"\n+ version = \">= 4.9\"\n }\n random = {\n source = \"hashicorp/random\"\n---\nexamples/object/README.md\n@@ -20,14 +20,14 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.5 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.9 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.5 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.9 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/object/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.5\"\n+ version = \">= 4.9\"\n }\n random = {\n source = \"hashicorp/random\"\n---\nexamples/s3-replication/README.md\n@@ -22,15 +22,15 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.5 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) >= 4.9 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.5 |\n-| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 4.5 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.9 |\n+| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 4.9 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/s3-replication/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.5\"\n+ version = \">= 4.9\"\n }\n random = {\n source = \"hashicorp/random\"\n---\nmain.tf\n@@ -21,23 +21,6 @@ resource \"aws_s3_bucket\" \"this\" {\n force_destroy = var.force_destroy\n object_lock_enabled = var.object_lock_enabled\n tags = var.tags\n-\n- lifecycle {\n- ignore_changes = [\n- acceleration_status,\n- acl,\n- grant,\n- cors_rule,\n- lifecycle_rule,\n- logging,\n- object_lock_configuration,\n- replication_configuration,\n- request_payer,\n- server_side_encryption_configuration,\n- versioning,\n- website\n- ]\n- }\n }\n \n resource \"aws_s3_bucket_logging\" \"this\" {\n---\nversions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.5\"\n+ version = \">= 4.9\"\n }\n }\n }\n---\n\n\n---\n\nChoice C:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.71.0\n+ rev: v1.74.1\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n@@ -24,7 +24,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.2.0\n+ rev: v4.3.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\nREADME.md\n@@ -118,13 +118,13 @@ Users of Terragrunt can achieve similar results by using modules provided in the\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.5 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.9 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.5 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.9 |\n \n ## Modules\n \n---\nexamples/complete/README.md\n@@ -30,14 +30,14 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.5 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.9 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.5 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.9 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/complete/main.tf\n@@ -95,7 +95,7 @@ module \"cloudfront_log_bucket\" {\n ]\n \n owner = {\n- id = \"457414f555e45c2e6fe1069d1a527a90d6337e1acb012ba99f3833859b23d338\"\n+ id = data.aws_canonical_user_id.current.id\n }\n \n force_destroy = true\n---\nexamples/complete/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.5\"\n+ version = \">= 4.9\"\n }\n random = {\n source = \"hashicorp/random\"\n---\nexamples/notification/README.md\n@@ -20,15 +20,15 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.5 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.9 |\n | <a name=\"requirement_null\"></a> [null](#requirement\\_null) | >= 2.0 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.5 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.9 |\n | <a name=\"provider_null\"></a> [null](#provider\\_null) | >= 2.0 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n---\nexamples/notification/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.5\"\n+ version = \">= 4.9\"\n }\n random = {\n source = \"hashicorp/random\"\n---\nexamples/object/README.md\n@@ -20,14 +20,14 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.5 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.9 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.5 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.9 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/object/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.5\"\n+ version = \">= 4.9\"\n }\n random = {\n source = \"hashicorp/random\"\n---\nexamples/s3-replication/README.md\n@@ -22,15 +22,15 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.5 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.9 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.5 |\n-| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 4.5 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.9 |\n+| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 4.9 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/s3-replication/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.5\"\n+ version = \">= 4.9\"\n }\n random = {\n source = \"hashicorp/random\"\n---\nmain.tf\n@@ -21,23 +21,6 @@ resource \"aws_s3_bucket\" \"this\" {\n force_destroy = var.force_destroy\n object_lock_enabled = var.object_lock_enabled\n tags = var.tags\n-\n- lifecycle {\n- ignore_changes = [\n- acceleration_status,\n- acl,\n- grant,\n- cors_rule,\n- lifecycle_rule,\n- logging,\n- object_lock_configuration,\n- replication_configuration,\n- request_payer,\n- server_side_encryption_configuration,\n- versioning,\n- website\n- ]\n- }\n }\n \n resource \"aws_s3_bucket_logging\" \"this\" {\n---\nversions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.5\"\n+ version = \">= 4.9\"\n }\n }\n }\n---\n\n\n---\n\nChoice D:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.71.0\n+ rev: v1.74.1\n hooks:\n - id: terraform_fmt\n - id: terraform_wrapper_module_for_each\n@@ -24,7 +24,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.2.0\n+ rev: v4.3.0\n hooks:\n - id: check-merge-conflict\n - id: end-of-file-fixer\n---\nREADME.md\n@@ -118,13 +118,13 @@ Users of Terragrunt can achieve similar results by using modules provided in the\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.5 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.9 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.5 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.9 |\n \n ## Modules\n \n---\nexamples/complete/README.md\n@@ -30,14 +30,14 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.5 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.9 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.5 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.9 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/complete/main.tf\n@@ -95,7 +95,7 @@ module \"cloudfront_log_bucket\" {\n ]\n \n owner = {\n- id = \"457414f555e45c2e6fe1069d1a527a90d6337e1acb012ba99f3833859b23d338\"\n+ id = data.aws_canonical_user_id.current.id\n }\n \n force_destroy = true\n---\nexamples/complete/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.5\"\n+ version = \">= 4.9\"\n }\n random = {\n source = \"hashicorp/random\"\n---\nexamples/notification/README.md\n@@ -20,15 +20,15 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.5 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.9 |\n | <a name=\"requirement_null\"></a> [null](#requirement\\_null) | >= 2.0 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.5 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.9 |\n | <a name=\"provider_null\"></a> [null](#provider\\_null) | >= 2.0 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n---\nexamples/notification/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.5\"\n+ version = \">= 4.9\"\n }\n random = {\n source = \"hashicorp/random\"\n---\nexamples/object/README.md\n@@ -20,14 +20,14 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.5 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.9 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.5 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.9 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/object/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.5\"\n+ version = \">= 4.9\"\n }\n random = {\n source = \"hashicorp/random\"\n---\nexamples/s3-replication/README.md\n@@ -22,15 +22,15 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.5 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 4.9 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.5 |\n-| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 4.5 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 4.9 |\n+| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 4.9 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/s3-replication/versions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.5\"\n+ version = \">= 4.9\"\n }\n random = {\n source = \"hashicorp/random\"\n---\nmain.tf\n@@ -21,23 +21,6 @@ resource \"aws_s3_bucket\" \"this\" {\n force_destroy = var.force_destroy\n object_lock_enabled = var.object_lock_enabled\n tags = var.tags\n-\n- lifecycle {\n- ignore_changes = [\n- acceleration_status,\n- acl,\n- grant,\n- cors_rule,\n- lifecycle_rule,\n- logging,\n- object_lock_configuration,\n- replication_configuration,\n- request_payer,\n- server_side_encryption_configuration,\n- versioning,\n- website\n- ]\n- }\n }\n \n resource \"aws_s3_bucket_logging\" \"this\" {\n---\nversions.tf\n@@ -4,7 +4,7 @@ terraform {\n required_providers {\n aws = {\n source = \"hashicorp/aws\"\n- version = \">= 4.5\"\n+ version = \">= 4.9\"\n }\n }\n }\n---\n\n\n---\n" } ]
C
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\nI added the source_hash parameter for the S3 bucket object.\r\nFixes #171 \r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\n> Attribute etag is not compatible with KMS encryption, so I can`t use it during update of uploaded file via terraform. Need to use attribute source_hash instead etag, but this attribute is missing in current object module.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\nNo breaking change.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmodules/object/README.md\n@@ -51,6 +51,7 @@ object. modules.\n | <a name=\"input_object_lock_mode\"></a> [object\\_lock\\_mode](#input\\_object\\_lock\\_mode) | The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE. | `string` | `null` | no |\n | <a name=\"input_object_lock_retain_until_date\"></a> [object\\_lock\\_retain\\_until\\_date](#input\\_object\\_lock\\_retain\\_until\\_date) | The date and time, in RFC3339 format, when this object's object lock will expire. | `string` | `null` | no |\n | <a name=\"input_server_side_encryption\"></a> [server\\_side\\_encryption](#input\\_server\\_side\\_encryption) | Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\". | `string` | `null` | no |\n+| <a name=\"input_source_hash\"></a> [source\\_hash](#input\\_source\\_hash) | Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.) | `string` | `null` | no |\n | <a name=\"input_storage_class\"></a> [storage\\_class](#input\\_storage\\_class) | Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED\\_REDUNDANCY, ONEZONE\\_IA, INTELLIGENT\\_TIERING, GLACIER, DEEP\\_ARCHIVE, or STANDARD\\_IA. Defaults to STANDARD. | `string` | `null` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to assign to the object. | `map(string)` | `{}` | no |\n | <a name=\"input_website_redirect\"></a> [website\\_redirect](#input\\_website\\_redirect) | Specifies a target URL for website redirect. | `string` | `null` | no |\n---\nmodules/object/main.tf\n@@ -29,6 +29,8 @@ resource \"aws_s3_object\" \"this\" {\n object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode)\n object_lock_retain_until_date = var.object_lock_retain_until_date\n \n+ source_hash = var.source_hash\n+\n tags = var.tags\n \n lifecycle {\n---\nmodules/object/variables.tf\n@@ -141,3 +141,9 @@ variable \"object_lock_retain_until_date\" {\n type = string\n default = null\n }\n+\n+variable \"source_hash\" {\n+ description = \"Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\\\"path/to/source\\\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)\"\n+ type = string\n+ default = null\n+}\n---\nwrappers/object/main.tf\n@@ -27,4 +27,5 @@ module \"wrapper\" {\n object_lock_legal_hold_status = try(each.value.object_lock_legal_hold_status, var.defaults.object_lock_legal_hold_status, null)\n object_lock_mode = try(each.value.object_lock_mode, var.defaults.object_lock_mode, null)\n object_lock_retain_until_date = try(each.value.object_lock_retain_until_date, var.defaults.object_lock_retain_until_date, null)\n+ source_hash = try(each.value.source_hash, var.defaults.source_hash, null)\n }\n---\n\n\n---\n\nChoice B:\nmodules/object/README.md\n@@ -51,6 +51,7 @@ No modules.\n | <a name=\"input_object_lock_mode\"></a> [object\\_lock\\_mode](#input\\_object\\_lock\\_mode) | The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE. | `string` | `null` | no |\n | <a name=\"input_object_lock_retain_until_date\"></a> [object\\_lock\\_retain\\_until\\_date](#input\\_object\\_lock\\_retain\\_until\\_date) | The date and time, in RFC3339 format, when this object's object lock will expire. | `string` | `null` | no |\n | <a name=\"input_server_side_encryption\"></a> [server\\_side\\_encryption](#input\\_server\\_side\\_encryption) | Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\". | `string` | `null` | no |\n+| <a name=\"input_source_hash\"></a> [source\\_hash](#input\\_source\\_hash) | Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.) | `string` | `null` | no |\n | <a name=\"input_storage_class\"></a> [storage\\_class](#input\\_storage\\_class) | Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED\\_REDUNDANCY, ONEZONE\\_IA, INTELLIGENT\\_TIERING, GLACIER, DEEP\\_ARCHIVE, or STANDARD\\_IA. Defaults to STANDARD. | `string` | `null` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to assign to the object. | `map(string)` | `{}` | no |\n | <a name=\"input_website_redirect\"></a> [website\\_redirect](#input\\_website\\_redirect) | Specifies a target URL for website redirect. | `string` | `null` | no |\n---\nmodules/object/main.tf\n@@ -29,6 +29,8 @@ resource \"aws_s3_object\" \"this\" {\n object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode)\n object_lock_retain_until_date = var.object_lock_retain_until_date\n \n+ source_hash = var.source_hash\n+\n tags = var.tags\n \n lifecycle {\n---\nmodules/object/variables.tf\n@@ -141,3 +141,9 @@ variable \"object_lock_retain_until_date\" {\n type = string\n default = null\n }\n+\n+variable \"source_hash\" {\n+ description = \"Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\\\"path/to/source\\\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)\"\n+ type = string\n+ default = null\n+}\n---\nwrappers/object/main.tf\n@@ -27,4 +27,5 @@ module \"wrapper\" {\n object_lock_legal_hold_status = try(each.value.object_lock_legal_hold_status, var.defaults.object_lock_legal_hold_status, null)\n object_lock_mode = try(each.value.object_lock_mode, var.defaults.object_lock_mode, null)\n object_lock_retain_until_date = try(each.value.object_lock_retain_until_date, var.defaults.object_lock_retain_until_date, null)\n+ source_hash = try(each.value.source_hash, var.defaults.source_hash, null)\n }\n---\n\n\n---\n\nChoice C:\nmodules/object/README.md\n@@ -51,6 +51,7 @@ No modules.\n | <a name=\"input_object_lock_mode\"></a> [object\\_lock\\_mode](#input\\_object\\_lock\\_mode) | The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE. | `string` | `null` | no |\n | <a name=\"input_object_lock_retain_until_date\"></a> [object\\_lock\\_retain\\_until\\_date](#input\\_object\\_lock\\_retain\\_until\\_date) | The date and time, in RFC3339 format, when this object's object lock will expire. | `string` | `null` | no |\n | <a name=\"input_server_side_encryption\"></a> [server\\_side\\_encryption](#input\\_server\\_side\\_encryption) | Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\". | `string` | `null` | no |\n+| <a name=\"input_source_hash\"></a> [source\\_hash](#input\\_source\\_hash) | Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.) | `string` | `null` | no |\n | <a name=\"input_storage_class\"></a> [storage\\_class](#input\\_storage\\_class) | Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED\\_REDUNDANCY, ONEZONE\\_IA, INTELLIGENT\\_TIERING, GLACIER, DEEP\\_ARCHIVE, or STANDARD\\_IA. Defaults to STANDARD. | `string` | `null` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to assign to the object. | `map(string)` | `{}` | no |\n | <a name=\"input_website_redirect\"></a> [website\\_redirect](#input\\_website\\_redirect) | Specifies a target URL for website redirect. | `string` | `null` | no |\n---\nmodules/object/main.tf\n@@ -29,6 +29,8 @@ resource \"aws_s3_object\" \"this\" {\n object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode)\n object_lock_retain_until_date = var.object_lock_retain_until_date\n \n+ source_hash = var.source_hash\n+\n tags = var.tags\n \n lifecycle {\n---\nmodules/object/variables.tf\n@@ -141,3 +141,9 @@ variable \"object_lock_retain_until_date\" {\n type = string\n default = null\n }\n+\n+variable \"source_hash\" {\n+ description = \"Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\\\"path/to/source\\\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)\"\n+ type = string\n+ default = null\n+}\n---\nwrappers/object/main.tf\n@@ -27,4 +27,5 @@ module \"wrapper\" {\n object_lock_legal_hold_status = try(each.value.object_lock_legal_hold_status, var.defaults.object_lock_legal_hold_status, null)\n object_lock_mode = try(each.value.object_lock_mode, var.defaults.object_lock_mode, null)\n object_lock_retain_until_date = try(each.value.object_lock_retain_until_date, var.defaults.object_lock_retain_until_date, null)\n+ source_hash = try(each.value.source_hash, var.defaults.source_hash, null)\n }\n---\n\n\n---\n\nChoice D:\nmodules/object/README.md\n@@ -51,6 +51,7 @@ No modules.\n | <a name=\"input_object_lock_mode\"></a> [object\\_lock\\_mode](#input\\_object\\_lock\\_mode) | The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE. | `string` | `null` | no |\n | <a name=\"input_object_lock_retain_until_date\"></a> [object\\_lock\\_retain\\_until\\_date](#input\\_object\\_lock\\_retain\\_until\\_date) | The date and time, in RFC3339 format, when this object's object lock will expire. | `string` | `null` | no |\n | <a name=\"input_server_side_encryption\"></a> [server\\_side\\_encryption](#input\\_server\\_side\\_encryption) | Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\". | `string` | `null` | no |\n+| <a name=\"input_source_hash\"></a> [source\\_hash](#input\\_source\\_hash) | Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.) | `string` | `null` | no |\n | <a name=\"input_storage_class\"></a> [storage\\_class](#input\\_storage\\_class) | Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED\\_REDUNDANCY, ONEZONE\\_IA, INTELLIGENT\\_TIERING, GLACIER, DEEP\\_ARCHIVE, or STANDARD\\_IA. Defaults to STANDARD. | `string` | `null` | no |\n | <a name=\"input_tags\"></a> [tags](#input\\_tags) | A map of tags to assign to the object. | `map(string)` | `{}` | no |\n | <a name=\"input_website_redirect\"></a> [website\\_redirect](#input\\_website\\_redirect) | Specifies a target URL for website redirect. | `string` | `null` | no |\n---\nmodules/object/main.tf\n@@ -29,6 +29,8 @@ resource \"aws_s3_object\" \"this\" {\n object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode)\n object_lock_retain_until_date = var.object_lock_retain_until_date\n \n+ source_hash = var.source_hash\n+\n tags = var.tags\n \n lifecycle {\n---\nmodules/object/variables.tf\n@@ -141,3 +141,9 @@ variable \"object_lock_retain_until_date\" {\n type = string\n default = null\n }\n+\n+variable \"source_hash\" {\n+ description }\n---\n \"Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\\\"path/to/source\\\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)\"\n+ type = string\n+ default = null\n+}\n---\nwrappers/object/main.tf\n@@ -27,4 +27,5 @@ module \"wrapper\" {\n object_lock_legal_hold_status = try(each.value.object_lock_legal_hold_status, var.defaults.object_lock_legal_hold_status, null)\n object_lock_mode = try(each.value.object_lock_mode, var.defaults.object_lock_mode, null)\n object_lock_retain_until_date = try(each.value.object_lock_retain_until_date, var.defaults.object_lock_retain_until_date, null)\n+ source_hash = try(each.value.source_hash, var.defaults.source_hash, null)\n }\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\n\r\nRemove ignores_changes that are related to deprecated parameters.\r\nFixes #174 \r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\nSome S3 bucket parameters got their own resources instead of being simple parameters.\r\nTherefore, the ignore_changes is related to non-existent parameters.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\nNo breaking change.\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nmain.tf\n@@ -21,23 +21,6 @@ resource \"aws_s3_bucket\" \"this\" {\n force_destroy = var.force_destroy\n object_lock_enabled = var.object_lock_enabled\n tags = var.tags\n-\n- lifecycle {\n- ignore_changes = [\n- acceleration_status,\n- acl,\n- grant,\n- cors_rule,\n- lifecycle_rule,\n- logging,\n- object_lock_configuration,\n- replication_configuration,\n- request_payer,\n- server_side_encryption_configuration,\n- versioning,\n- website\n- ]\n- }\n }\n \n resource \"aws_s3_bucket_logging\" \"this\" {\n---\n\n\n---\n\nChoice B:\nmain.tf\n@@ -21,23 +21,6 @@ resource \"aws_s3_bucket\" \"this\" {\n force_destroy = var.force_destroy\n object_lock_enabled = var.object_lock_enabled\n tags = var.tags\n-\n- lifecycle {\n- ignore_changes = [\n- acceleration_status,\n- acl,\n- grant,\n- cors_rule,\n- lifecycle_rule,\n- logging,\n- object_lock_configuration,\n- replication_configuration,\n- request_payer,\n- server_side_encryption_configuration,\n- versioning,\n- website\n- ]\n- }\n }\n \n resource \"aws_s3_bucket_logging\" \"this\" {\n---\n\n\n---\n\nChoice C:\nmain.tf\n@@ -21,23 +21,6 @@ resource \"aws_s3_bucket\" \"this\" {\n force_destroy = var.force_destroy\n object_lock_enabled = var.object_lock_enabled\n tags = var.tags\n-\n- lifecycle {\n- ignore_changes = [\n- acceleration_status,\n- acl,\n- grant,\n- cors_rule,\n- lifecycle_rule,\n- logging,\n- object_lock_configuration,\n- replication_configuration,\n- request_payer,\n- server_side_encryption_configuration,\n- versioning,\n- website\n- ]\n- }\n }\n \n resource \"aws_s3_bucket_logging\" \"this\" {\n---\n\n\n---\n\nChoice D:\nmain.tf\n@@ -21,23 +21,6 @@ resource \"aws_s3_bucket\" \"this\" {\n force_destroy = var.force_destroy\n object_lock_enabled = var.object_lock_enabled\n tags = var.tags\n-\n- lifecycle {\n- ignore_changes = [\n- acceleration_status,\n- acl,\n- grant,\n- cors_rule,\n- lifecycle_rule,\n- logging,\n- object_lock_configuration,\n- replication_configuration,\n- request_payer,\n- server_side_encryption_configuration,\n- versioning,\n- website\n- ]\n- }\n }\n \n -21,23 \"aws_s3_bucket_logging\" \"this\" {\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\nBased on #166 (I didn't have push permissions to the fork) by @bamaralf.\r\n\r\nCloses #166.\r\n\r\nAdded support for intelligent tiering configuration - [registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_intelligent_tiering_configuration](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_intelligent_tiering_configuration)\n\n---\n\nChoice A:\nREADME.md\n@@ -138,6 +138,7 @@ No modules.\n | [aws_s3_bucket_accelerate_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_accelerate_configuration) | resource |\n | [aws_s3_bucket_acl.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_acl) | resource |\n | [aws_s3_bucket_cors_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_cors_configuration) | resource |\n+| [aws_s3_bucket_intelligent_tiering_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_intelligent_tiering_configuration) | resource |\n | [aws_s3_bucket_lifecycle_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |\n | [aws_s3_bucket_logging.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_logging) | resource |\n | [aws_s3_bucket_object_lock_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object_lock_configuration) | resource |\n@@ -180,6 +181,7 @@ No modules.\n | <a name=\"input_force_destroy\"></a> [force\\_destroy](#input\\_force\\_destroy) are (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n | <a name=\"input_grant\"></a> [grant](#input\\_grant) | An ACL policy grant. Conflicts with `acl` | `any` | `[]` | no |\n | <a name=\"input_ignore_public_acls\"></a> [ignore\\_public\\_acls](#input\\_ignore\\_public\\_acls) | Whether Amazon S3 should ignore public ACLs for this bucket. | `bool` | `false` | no |\n+| <a name=\"input_intelligent_tiering\"></a> [intelligent\\_tiering](#input\\_intelligent\\_tiering) | Map containing intelligent tiering configuration. | `any` | `{}` | no |\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n---\nexamples/complete/main.tf\n@@ -293,4 +293,35 @@ module \"s3_bucket\" {\n }\n },\n ]\n+\n+ intelligent_tiering = {\n+ general = {\n+ status = \"Enabled\"\n+ filter = {\n+ prefix = \"/\"\n+ tags = {\n+ Environment = \"dev\"\n+ }\n+ }\n+ tiering = {\n+ ARCHIVE_ACCESS = {\n+ days = 180\n+ }\n+ }\n+ },\n+ documents = {\n+ status = false\n+ filter = {\n+ prefix = \"documents/\"\n+ }\n+ tiering = {\n+ ARCHIVE_ACCESS = {\n+ days = 125\n+ }\n+ DEEP_ARCHIVE_ACCESS = {\n+ days = 200\n+ }\n+ }\n+ }\n+ }\n }\n---\nmain.tf\n@@ -6,9 +6,10 @@ locals {\n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n- grants = try(jsondecode(var.grant), var.grant)\n- cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n- lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ grants = try(jsondecode(var.grant), var.grant)\n+ cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n+ lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ intelligent_tiering = try(jsondecode(var.intelligent_tiering), var.intelligent_tiering)\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -707,3 +708,31 @@ resource \"aws_s3_bucket_ownership_controls\" \"this\" {\n aws_s3_bucket.this\n ]\n }\n+\n+resource \"aws_s3_bucket_intelligent_tiering_configuration\" \"this\" {\n+ for_each = { for k, v in local.intelligent_tiering : k => v if local.create_bucket }\n+\n+ name = each.key\n+ bucket = aws_s3_bucket.this[0].id\n+ status = try(tobool(each.value.status) ? \"Enabled\" : \"Disabled\", title(lower(each.value.status)), null)\n+\n+ # Max 1 block - filter\n+ dynamic \"filter\" {\n+ for_each = length(try(flatten([each.value.filter]), [])) == 0 ? [] : [true]\n+\n+ content {\n+ prefix = try(each.value.filter.prefix, null)\n+ tags = try(each.value.filter.tags, null)\n+ }\n+ }\n+\n+ dynamic \"tiering\" {\n+ for_each = each.value.tiering\n+\n+ content {\n+ access_tier = tiering.key\n+ days = tiering.value.days\n+ }\n+ }\n+\n+}\n---\nvariables.tf\n@@ -148,6 +148,12 @@ variable \"server_side_encryption_configuration\" {\n default = {}\n }\n \n+variable \"intelligent_tiering\" {\n+ description = \"Map containing intelligent tiering configuration.\"\n+ type = any\n+ default = {}\n+}\n+\n variable \"object_lock_configuration\" {\n description = \"Map containing S3 object locking configuration.\"\n type = any\n---\nwrappers/main.tf\n@@ -28,6 +28,7 @@ module \"wrapper\" {\n lifecycle_rule = try(each.value.lifecycle_rule, var.defaults.lifecycle_rule, [])\n replication_configuration = try(each.value.replication_configuration, var.defaults.replication_configuration, {})\n server_side_encryption_configuration = try(each.value.server_side_encryption_configuration, var.defaults.server_side_encryption_configuration, {})\n+ intelligent_tiering = try(each.value.intelligent_tiering, var.defaults.intelligent_tiering, {})\n object_lock_configuration = try(each.value.object_lock_configuration, var.defaults.object_lock_configuration, {})\n object_lock_enabled = try(each.value.object_lock_enabled, var.defaults.object_lock_enabled, false)\n block_public_acls = try(each.value.block_public_acls, var.defaults.block_public_acls, false)\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -138,6 +138,7 @@ No modules.\n | [aws_s3_bucket_accelerate_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_accelerate_configuration) | resource |\n | [aws_s3_bucket_acl.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_acl) | resource |\n | [aws_s3_bucket_cors_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_cors_configuration) | resource |\n+| [aws_s3_bucket_intelligent_tiering_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_intelligent_tiering_configuration) | resource |\n | [aws_s3_bucket_lifecycle_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |\n | [aws_s3_bucket_logging.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_logging) | resource |\n | [aws_s3_bucket_object_lock_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object_lock_configuration) | resource |\n@@ -180,6 +181,7 @@ No modules.\n | <a name=\"input_force_destroy\"></a> [force\\_destroy](#input\\_force\\_destroy) | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n | <a name=\"input_grant\"></a> [grant](#input\\_grant) | An ACL policy grant. Conflicts with `acl` | `any` | `[]` | no |\n | <a name=\"input_ignore_public_acls\"></a> [ignore\\_public\\_acls](#input\\_ignore\\_public\\_acls) | Whether Amazon S3 should ignore public ACLs for this bucket. | `bool` | `false` | no |\n+| <a name=\"input_intelligent_tiering\"></a> [intelligent\\_tiering](#input\\_intelligent\\_tiering) | Map containing intelligent tiering configuration. | `any` | `{}` | no |\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n---\nexamples/complete/main.tf\n@@ -293,4 +293,35 @@ module \"s3_bucket\" {\n }\n },\n ]\n+\n+ intelligent_tiering = {\n+ general = {\n+ status = \"Enabled\"\n+ filter = {\n+ prefix = \"/\"\n+ tags = {\n+ Environment = \"dev\"\n+ }\n+ }\n+ tiering = {\n+ ARCHIVE_ACCESS = {\n+ days = 180\n+ }\n+ }\n+ },\n+ documents = {\n+ status = false\n+ filter = {\n+ prefix = \"documents/\"\n+ }\n+ tiering = {\n+ ARCHIVE_ACCESS = {\n+ days = 125\n+ }\n+ DEEP_ARCHIVE_ACCESS = {\n+ days = 200\n+ }\n+ }\n+ }\n+ }\n }\n---\nmain.tf\n@@ -6,9 +6,10 @@ locals {\n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n- grants = try(jsondecode(var.grant), var.grant)\n- cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n- lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ grants = try(jsondecode(var.grant), var.grant)\n+ cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n+ lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ intelligent_tiering = try(jsondecode(var.intelligent_tiering), var.intelligent_tiering)\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -707,3 +708,31 @@ resource \"aws_s3_bucket_ownership_controls\" \"this\" {\n aws_s3_bucket.this\n ]\n }\n+\n+resource \"aws_s3_bucket_intelligent_tiering_configuration\" \"this\" {\n+ for_each = { for k, v in local.intelligent_tiering : k => v if local.create_bucket }\n+\n+ name = each.key\n+ bucket = aws_s3_bucket.this[0].id\n+ status = try(tobool(each.value.status) ? \"Enabled\" : \"Disabled\", title(lower(each.value.status)), null)\n+\n+ # Max 1 block - filter\n+ dynamic \"filter\" {\n+ for_each = length(try(flatten([each.value.filter]), [])) == 0 ? [] : [true]\n+\n+ content {\n+ prefix = try(each.value.filter.prefix, null)\n+ tags = try(each.value.filter.tags, null)\n+ }\n+ }\n+\n+ dynamic \"tiering\" {\n+ for_each = each.value.tiering\n+\n+ content {\n+ access_tier = tiering.key\n+ days = tiering.value.days\n+ }\n+ }\n+\n+}\n---\nvariables.tf\n@@ -148,6 +148,12 @@ variable \"server_side_encryption_configuration\" {\n default = {}\n }\n \n+variable \"intelligent_tiering\" {\n+ description = \"Map containing intelligent tiering configuration.\"\n+ type = any\n+ default = {}\n+}\n+\n variable \"object_lock_configuration\" {\n description = \"Map containing S3 object locking configuration.\"\n type = any\n---\nwrappers/main.tf\n@@ -28,6 +28,7 @@ module \"wrapper\" {\n lifecycle_rule = try(each.value.lifecycle_rule, var.defaults.lifecycle_rule, [])\n replication_configuration = try(each.value.replication_configuration, var.defaults.replication_configuration, {})\n server_side_encryption_configuration = try(each.value.server_side_encryption_configuration, var.defaults.server_side_encryption_configuration, {})\n+ intelligent_tiering = try(each.value.intelligent_tiering, var.defaults.intelligent_tiering, {})\n object_lock_configuration = try(each.value.object_lock_configuration, var.defaults.object_lock_configuration, {})\n object_lock_enabled = try(each.value.object_lock_enabled, var.defaults.object_lock_enabled, false)\n block_public_acls = try(each.value.block_public_acls, var.defaults.block_public_acls, false)\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -138,6 +138,7 @@ No modules.\n | [aws_s3_bucket_accelerate_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_accelerate_configuration) | resource |\n | [aws_s3_bucket_acl.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_acl) | resource |\n | [aws_s3_bucket_cors_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_cors_configuration) | resource |\n+| [aws_s3_bucket_intelligent_tiering_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_intelligent_tiering_configuration) | resource |\n | [aws_s3_bucket_lifecycle_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |\n | [aws_s3_bucket_logging.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_logging) | resource |\n | [aws_s3_bucket_object_lock_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object_lock_configuration) | resource |\n@@ -180,6 +181,7 @@ No modules.\n | <a name=\"input_force_destroy\"></a> [force\\_destroy](#input\\_force\\_destroy) | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n | <a name=\"input_grant\"></a> [grant](#input\\_grant) | An ACL policy grant. Conflicts with `acl` | `any` | `[]` | no |\n | <a name=\"input_ignore_public_acls\"></a> [ignore\\_public\\_acls](#input\\_ignore\\_public\\_acls) | Whether Amazon S3 should ignore public ACLs for this bucket. | `bool` | `false` | no |\n+| <a name=\"input_intelligent_tiering\"></a> [intelligent\\_tiering](#input\\_intelligent\\_tiering) | Map containing intelligent tiering configuration. | `any` | `{}` | no |\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n---\nexamples/complete/main.tf\n@@ -293,4 +293,35 @@ module \"s3_bucket\" {\n }\n },\n ]\n+\n+ intelligent_tiering = {\n+ general = {\n+ status = \"Enabled\"\n+ filter = {\n+ prefix = \"/\"\n+ tags = {\n+ Environment = \"dev\"\n+ }\n+ }\n+ tiering = {\n+ ARCHIVE_ACCESS = {\n+ days = 180\n+ }\n+ }\n+ },\n+ documents = {\n+ status = false\n+ filter = {\n+ prefix = \"documents/\"\n+ }\n+ tiering = {\n+ ARCHIVE_ACCESS = {\n+ days = 125\n+ }\n+ DEEP_ARCHIVE_ACCESS = {\n+ days = 200\n+ }\n+ }\n+ }\n+ }\n }\n---\nmain.tf\n@@ -6,9 +6,10 @@ locals {\n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n- grants = try(jsondecode(var.grant), var.grant)\n- cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n- lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ grants = try(jsondecode(var.grant), var.grant)\n+ cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n+ lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ intelligent_tiering = try(jsondecode(var.intelligent_tiering), var.intelligent_tiering)\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -707,3 +708,31 @@ resource \"aws_s3_bucket_ownership_controls\" \"this\" {\n aws_s3_bucket.this\n ]\n }\n+\n+resource \"aws_s3_bucket_intelligent_tiering_configuration\" \"this\" {\n+ for_each = { for k, v in local.intelligent_tiering : k => v if local.create_bucket }\n+\n+ name = each.key\n+ bucket = aws_s3_bucket.this[0].id\n+ status = try(tobool(each.value.status) ? \"Enabled\" : \"Disabled\", title(lower(each.value.status)), null)\n+\n+ # Max 1 block - filter\n+ dynamic \"filter\" {\n+ for_each = length(try(flatten([each.value.filter]), [])) == 0 ? [] : [true]\n+\n+ content {\n+ prefix = try(each.value.filter.prefix, null)\n+ tags = try(each.value.filter.tags, null)\n+ }\n+ }\n+\n+ dynamic \"tiering\" \"documents/\"\n+ for_each = each.value.tiering\n+\n+ content {\n+ access_tier = tiering.key\n+ days = tiering.value.days\n+ }\n+ }\n+\n+}\n---\nvariables.tf\n@@ -148,6 +148,12 @@ variable \"server_side_encryption_configuration\" {\n default = {}\n }\n \n+variable \"intelligent_tiering\" {\n+ description = \"Map containing intelligent tiering configuration.\"\n+ type = any\n+ default = {}\n+}\n+\n variable \"object_lock_configuration\" {\n description = \"Map containing S3 object locking configuration.\"\n type = any\n---\nwrappers/main.tf\n@@ -28,6 +28,7 @@ module \"wrapper\" {\n lifecycle_rule = try(each.value.lifecycle_rule, var.defaults.lifecycle_rule, [])\n replication_configuration = try(each.value.replication_configuration, var.defaults.replication_configuration, {})\n server_side_encryption_configuration = try(each.value.server_side_encryption_configuration, var.defaults.server_side_encryption_configuration, {})\n+ intelligent_tiering = try(each.value.intelligent_tiering, var.defaults.intelligent_tiering, {})\n object_lock_configuration = try(each.value.object_lock_configuration, var.defaults.object_lock_configuration, {})\n object_lock_enabled = try(each.value.object_lock_enabled, var.defaults.object_lock_enabled, false)\n block_public_acls = try(each.value.block_public_acls, var.defaults.block_public_acls, false)\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -138,6 +138,7 @@ No modules.\n | [aws_s3_bucket_accelerate_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_accelerate_configuration) | resource |\n | [aws_s3_bucket_acl.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_acl) | resource |\n | [aws_s3_bucket_cors_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_cors_configuration) | resource |\n+| [aws_s3_bucket_intelligent_tiering_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_intelligent_tiering_configuration) | resource |\n | [aws_s3_bucket_lifecycle_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |\n | [aws_s3_bucket_logging.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_logging) | resource |\n | [aws_s3_bucket_object_lock_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object_lock_configuration) | resource |\n@@ -180,6 +181,7 @@ No modules.\n | <a name=\"input_force_destroy\"></a> [force\\_destroy](#input\\_force\\_destroy) | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n | <a name=\"input_grant\"></a> [grant](#input\\_grant) | An ACL policy grant. Conflicts with `acl` | `any` | `[]` | no |\n | <a name=\"input_ignore_public_acls\"></a> [ignore\\_public\\_acls](#input\\_ignore\\_public\\_acls) | Whether Amazon S3 should ignore public ACLs for this bucket. | `bool` | `false` | no |\n+| <a name=\"input_intelligent_tiering\"></a> [intelligent\\_tiering](#input\\_intelligent\\_tiering) | Map containing intelligent tiering configuration. | `any` | `{}` | no |\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n---\nexamples/complete/main.tf\n@@ -293,4 +293,35 @@ module \"s3_bucket\" {\n }\n },\n ]\n+\n+ intelligent_tiering = {\n+ general = {\n+ status = \"Enabled\"\n+ filter = {\n+ prefix = \"/\"\n+ tags = {\n+ Environment = \"dev\"\n+ }\n+ }\n+ tiering = {\n+ ARCHIVE_ACCESS = {\n+ days = 180\n+ }\n+ }\n+ },\n+ documents = {\n+ status = false\n+ filter = {\n+ prefix = \"documents/\"\n+ }\n+ tiering = {\n+ ARCHIVE_ACCESS = {\n+ days = 125\n+ }\n+ DEEP_ARCHIVE_ACCESS = {\n+ days = 200\n+ }\n+ }\n+ }\n+ }\n }\n---\nmain.tf\n@@ -6,9 +6,10 @@ locals {\n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n- grants k = try(jsondecode(var.grant), var.grant)\n- cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n- lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ grants = try(jsondecode(var.grant), var.grant)\n+ cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n+ lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ intelligent_tiering = try(jsondecode(var.intelligent_tiering), var.intelligent_tiering)\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -707,3 +708,31 @@ resource \"aws_s3_bucket_ownership_controls\" \"this\" {\n aws_s3_bucket.this\n ]\n }\n+\n+resource \"aws_s3_bucket_intelligent_tiering_configuration\" \"this\" {\n+ for_each = { for k, v in local.intelligent_tiering : k => v if local.create_bucket }\n+\n+ name = each.key\n+ bucket = aws_s3_bucket.this[0].id\n+ status = try(tobool(each.value.status) ? \"Enabled\" : \"Disabled\", title(lower(each.value.status)), null)\n+\n+ # Max 1 block - filter\n+ dynamic \"filter\" {\n+ for_each = length(try(flatten([each.value.filter]), [])) == 0 ? [] : [true]\n+\n+ content {\n+ prefix = try(each.value.filter.prefix, null)\n+ tags = try(each.value.filter.tags, null)\n+ }\n+ }\n+\n+ dynamic \"tiering\" {\n+ for_each = each.value.tiering\n+\n+ content {\n+ access_tier = tiering.key\n+ days = tiering.value.days\n+ }\n+ }\n+\n+}\n---\nvariables.tf\n@@ -148,6 +148,12 @@ variable \"server_side_encryption_configuration\" {\n default = {}\n }\n \n+variable \"intelligent_tiering\" {\n+ description = \"Map containing intelligent tiering configuration.\"\n+ type = any\n+ default = {}\n+}\n+\n variable \"object_lock_configuration\" {\n description = \"Map containing S3 object locking configuration.\"\n type = any\n---\nwrappers/main.tf\n@@ -28,6 +28,7 @@ module \"wrapper\" {\n lifecycle_rule = try(each.value.lifecycle_rule, var.defaults.lifecycle_rule, [])\n replication_configuration = try(each.value.replication_configuration, var.defaults.replication_configuration, {})\n server_side_encryption_configuration = try(each.value.server_side_encryption_configuration, var.defaults.server_side_encryption_configuration, {})\n+ intelligent_tiering = try(each.value.intelligent_tiering, var.defaults.intelligent_tiering, {})\n object_lock_configuration = try(each.value.object_lock_configuration, var.defaults.object_lock_configuration, {})\n object_lock_enabled = try(each.value.object_lock_enabled, var.defaults.object_lock_enabled, false)\n block_public_acls = try(each.value.block_public_acls, var.defaults.block_public_acls, false)\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nThis pull request adds the option of managing the bucket intelligent tiering configuration by passing a map of objects to this module. This map of objects encapsulates the configuration options from this resource: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_intelligent_tiering_configuration\r\n\r\n## Motivation and Context\r\nIntelligent tiering configuration can optimize the costs of the S3 buckets infrastructure and the changes in this pull request make these configurations available from the module.\r\n\r\n## Breaking Changes\r\nNone\r\n\r\n## How Has This Been Tested?\r\n- [x] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [x] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nREADME.md\n@@ -138,6 +138,7 @@ No modules.\n | [aws_s3_bucket_accelerate_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_accelerate_configuration) | resource |\n | [aws_s3_bucket_acl.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_acl) | resource |\n | [aws_s3_bucket_cors_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_cors_configuration) | resource |\n+| [aws_s3_bucket_intelligent_tiering_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_intelligent_tiering_configuration) | resource |\n | [aws_s3_bucket_lifecycle_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |\n | [aws_s3_bucket_logging.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_logging) | resource |\n | [aws_s3_bucket_object_lock_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object_lock_configuration) | resource |\n@@ -180,6 +181,7 @@ No modules.\n | <a name=\"input_force_destroy\"></a> [force\\_destroy](#input\\_force\\_destroy) | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n | <a name=\"input_grant\"></a> [grant](#input\\_grant) | An ACL policy grant. Conflicts with `acl` | `any` | `[]` | no |\n | <a name=\"input_ignore_public_acls\"></a> [ignore\\_public\\_acls](#input\\_ignore\\_public\\_acls) | Whether Amazon S3 should ignore public ACLs for this bucket. | `bool` | `false` | no |\n+| <a name=\"input_intelligent_tiering_config\"></a> [intelligent\\_tiering\\_config](#input\\_intelligent\\_tiering\\_config) | Map containing inteligent tiering config encryption configuration. | `any` | `{}` | no |\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n---\nexamples/complete/main.tf\n@@ -114,6 +114,31 @@ module \"s3_bucket\" {\n Owner = \"Anton\"\n }\n \n+ intelligent_tiering_config = {\n+ general = {\n+ status = \"Enabled\"\n+ filter = {\n+ prefix = \"/\"\n+ tags = { Environment = \"dev\" }\n+ }\n+ tiering = {\n+ \"ARCHIVE_ACCESS\" = {\n+ days = 180\n+ }\n+ }\n+ },\n+ documents = {\n+ status = false\n+ filter = {\n+ prefix = \"documents/\"\n+ }\n+ tiering = {\n+ \"ARCHIVE_ACCESS\" = {\n+ days = 125\n+ }\n+ }\n+ }\n+ }\n # Note: Object Lock configuration can be enabled only on new buckets\n # https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object_lock_configuration\n object_lock_enabled = true\n---\nmain.tf\n@@ -6,9 +6,10 @@ locals {\n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n- grants = try(jsondecode(var.grant), var.grant)\n- cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n- lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ grants = try(jsondecode(var.grant), var.grant)\n+ cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n+ lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ intelligent_tiering_config = try(jsondecode(var.intelligent_tiering_config), var.intelligent_tiering_config)\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -707,3 +708,30 @@ resource \"aws_s3_bucket_ownership_controls\" \"this\" {\n aws_s3_bucket.this\n ]\n }\n+\n+resource \"aws_s3_bucket_intelligent_tiering_configuration\" \"this\" {\n+ for_each = local.create_bucket ? local.intelligent_tiering_config : {}\n+\n+ name = each.key\n+ bucket = aws_s3_bucket.this[0].id\n+ status = each.value.status || each.value.status == \"Enabled\" ? \"Enabled\" : \"Disabled\"\n+\n+ dynamic \"filter\" {\n+ for_each = length(try(flatten([each.value.filter]), [])) == 0 ? [true] : []\n+\n+ content {\n+ prefix = try(filter.value.prefix, null)\n+ tags = try(filter.value.tags, null)\n+ }\n+ }\n+\n+ dynamic \"tiering\" {\n+ for_each = each.value.tiering\n+\n+ content {\n+ access_tier = tiering.key\n+ days = tiering.value.days\n+ }\n+ }\n+\n+}\n---\nvariables.tf\n@@ -201,3 +201,9 @@ variable \"putin_khuylo\" {\n type = bool\n default = true\n }\n+\n+variable \"intelligent_tiering_config\" {\n+ description = \"Map containing inteligent tiering config encryption configuration.\"\n+ type = any\n+ default = {}\n+}\n---\nwrappers/main.tf\n@@ -37,4 +37,5 @@ module \"wrapper\" {\n control_object_ownership = try(each.value.control_object_ownership, var.defaults.control_object_ownership, false)\n object_ownership = try(each.value.object_ownership, var.defaults.object_ownership, \"ObjectWriter\")\n putin_khuylo \"Disabled\"\n+\n+ = try(each.value.putin_khuylo, var.defaults.putin_khuylo, true)\n+ intelligent_tiering_config = try(each.value.intelligent_tiering_config, var.defaults.intelligent_tiering_config, {})\n }\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -138,6 +138,7 @@ No modules.\n | [aws_s3_bucket_accelerate_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_accelerate_configuration) | resource |\n | [aws_s3_bucket_acl.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_acl) | resource |\n | [aws_s3_bucket_cors_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_cors_configuration) | resource |\n+| [aws_s3_bucket_intelligent_tiering_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_intelligent_tiering_configuration) | resource |\n | [aws_s3_bucket_lifecycle_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |\n | [aws_s3_bucket_logging.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_logging) | resource |\n | [aws_s3_bucket_object_lock_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object_lock_configuration) | resource |\n@@ -180,6 +181,7 @@ No modules.\n | <a name=\"input_force_destroy\"></a> [force\\_destroy](#input\\_force\\_destroy) | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n | <a name=\"input_grant\"></a> [grant](#input\\_grant) | An ACL policy grant. Conflicts with `acl` | `any` | `[]` | no |\n | <a name=\"input_ignore_public_acls\"></a> [ignore\\_public\\_acls](#input\\_ignore\\_public\\_acls) | Whether Amazon S3 should ignore public ACLs for this bucket. | `bool` | `false` | no |\n+| <a name=\"input_intelligent_tiering_config\"></a> [intelligent\\_tiering\\_config](#input\\_intelligent\\_tiering\\_config) | Map containing inteligent tiering config encryption configuration. | `any` | `{}` | no |\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n---\nexamples/complete/main.tf\n@@ -114,6 +114,31 @@ module \"s3_bucket\" {\n Owner = \"Anton\"\n }\n \n+ intelligent_tiering_config = {\n+ general = {\n+ status = \"Enabled\"\n+ filter = {\n+ prefix = \"/\"\n+ tags = { Environment = \"dev\" }\n+ }\n+ tiering = {\n+ \"ARCHIVE_ACCESS\" = {\n+ days = 180\n+ }\n+ }\n+ },\n+ documents = {\n+ status = false\n+ filter = {\n+ prefix = \"documents/\"\n+ }\n+ tiering = {\n+ \"ARCHIVE_ACCESS\" = {\n+ days = 125\n+ }\n+ }\n+ }\n+ }\n # Note: Object Lock configuration can be enabled only on new buckets\n # https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object_lock_configuration\n object_lock_enabled = true\n---\nmain.tf\n@@ -6,9 +6,10 @@ locals {\n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n- grants = try(jsondecode(var.grant), var.grant)\n- cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n- lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ grants = try(jsondecode(var.grant), var.grant)\n+ cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n+ lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ intelligent_tiering_config = try(jsondecode(var.intelligent_tiering_config), var.intelligent_tiering_config)\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -707,3 +708,30 @@ resource \"aws_s3_bucket_ownership_controls\" \"this\" {\n aws_s3_bucket.this\n ]\n }\n+\n+resource \"aws_s3_bucket_intelligent_tiering_configuration\" \"this\" {\n+ for_each = local.create_bucket ? local.intelligent_tiering_config : {}\n+\n+ name = each.key\n+ bucket = aws_s3_bucket.this[0].id\n+ status = each.value.status || each.value.status == \"Enabled\" ? \"Enabled\" : \"Disabled\"\n+\n+ dynamic \"filter\" {\n+ for_each = length(try(flatten([each.value.filter]), [])) == 0 ? [true] : []\n+\n+ content {\n+ prefix = try(filter.value.prefix, null)\n+ tags = try(filter.value.tags, null)\n+ }\n+ }\n+\n+ dynamic \"tiering\" {\n+ for_each = each.value.tiering\n+\n+ content {\n+ access_tier = tiering.key\n+ days = tiering.value.days\n+ }\n+ }\n+\n+}\n---\nvariables.tf\n@@ -201,3 +201,9 @@ variable \"putin_khuylo\" {\n type = bool\n default = true\n }\n+\n+variable \"intelligent_tiering_config\" {\n+ description = \"Map containing inteligent tiering config encryption configuration.\"\n+ type = any\n+ default = {}\n+}\n---\nwrappers/main.tf\n@@ -37,4 +37,5 @@ module \"wrapper\" {\n control_object_ownership = try(each.value.control_object_ownership, var.defaults.control_object_ownership, false)\n object_ownership = try(each.value.object_ownership, var.defaults.object_ownership, \"ObjectWriter\")\n putin_khuylo = try(each.value.putin_khuylo, var.defaults.putin_khuylo, true)\n+ intelligent_tiering_config = try(each.value.intelligent_tiering_config, var.defaults.intelligent_tiering_config, {})\n }\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -138,6 +138,7 @@ No modules.\n | [aws_s3_bucket_accelerate_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_accelerate_configuration) | resource |\n | [aws_s3_bucket_acl.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_acl) | resource |\n | [aws_s3_bucket_cors_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_cors_configuration) | resource |\n+| [aws_s3_bucket_intelligent_tiering_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_intelligent_tiering_configuration) | resource |\n | [aws_s3_bucket_lifecycle_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |\n | [aws_s3_bucket_logging.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_logging) | resource |\n | [aws_s3_bucket_object_lock_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object_lock_configuration) | resource |\n@@ -180,6 +181,7 @@ No modules.\n | <a name=\"input_force_destroy\"></a> [force\\_destroy](#input\\_force\\_destroy) | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n | <a name=\"input_grant\"></a> [grant](#input\\_grant) | An ACL policy grant. Conflicts with `acl` | `any` | `[]` | no |\n | <a name=\"input_ignore_public_acls\"></a> [ignore\\_public\\_acls](#input\\_ignore\\_public\\_acls) | Whether Amazon S3 should ignore public ACLs for this bucket. | `bool` | `false` | no |\n+| <a name=\"input_intelligent_tiering_config\"></a> [intelligent\\_tiering\\_config](#input\\_intelligent\\_tiering\\_config) | Map containing inteligent tiering config encryption configuration. | `any` | `{}` | no |\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n---\nexamples/complete/main.tf\n@@ -114,6 +114,31 @@ module \"s3_bucket\" {\n Owner = \"Anton\"\n }\n \n+ intelligent_tiering_config = {\n+ general = {\n+ status = \"Enabled\"\n+ filter = {\n+ prefix = \"/\"\n+ tags = { Environment = \"dev\" }\n+ }\n+ tiering = {\n+ \"ARCHIVE_ACCESS\" = {\n+ days = 180\n+ }\n+ }\n+ },\n+ documents = {\n+ status = false\n+ filter = {\n+ prefix = \"documents/\"\n+ }\n+ tiering = {\n+ \"ARCHIVE_ACCESS\" = {\n+ days = 125\n+ }\n+ }\n+ }\n+ }\n # Note: Object Lock configuration can be enabled only on new buckets\n # https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object_lock_configuration\n object_lock_enabled = true\n---\nmain.tf\n@@ -6,9 +6,10 @@ locals {\n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n- grants = try(jsondecode(var.grant), var.grant)\n- cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n- lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ grants = try(jsondecode(var.grant), var.grant)\n+ cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n+ lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ intelligent_tiering_config = try(jsondecode(var.intelligent_tiering_config), var.intelligent_tiering_config)\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -707,3 +708,30 @@ resource \"aws_s3_bucket_ownership_controls\" \"this\" {\n aws_s3_bucket.this\n ]\n }\n+\n+resource \"aws_s3_bucket_intelligent_tiering_configuration\" \"this\" {\n+ for_each = local.create_bucket ? local.intelligent_tiering_config : {}\n+\n+ name = each.key\n+ bucket = aws_s3_bucket.this[0].id\n+ status = each.value.status || each.value.status == \"Enabled\" ? \"Enabled\" : \"Disabled\"\n+\n+ dynamic \"filter\" {\n+ for_each = length(try(flatten([each.value.filter]), [])) == 0 ? [true] : []\n+\n+ content {\n+ prefix = try(filter.value.prefix, null)\n+ tags = try(filter.value.tags, null)\n+ }\n+ }\n+\n+ dynamic \"tiering\" {\n+ for_each = each.value.tiering\n+\n+ content {\n+ access_tier = tiering.key\n+ days = tiering.value.days\n+ }\n+ }\n+\n+}\n---\nvariables.tf\n@@ -201,3 +201,9 @@ variable \"putin_khuylo\" {\n type = bool\n default = true\n }\n+\n+variable \"intelligent_tiering_config\" {\n+ description = \"Map containing inteligent tiering config encryption configuration.\"\n+ type = any\n+ default = {}\n+}\n---\nwrappers/main.tf\n@@ -37,4 +37,5 @@ module \"wrapper\" {\n control_object_ownership = try(each.value.control_object_ownership, var.defaults.control_object_ownership, false)\n object_ownership = try(each.value.object_ownership, var.defaults.object_ownership, \"ObjectWriter\")\n putin_khuylo = try(each.value.putin_khuylo, var.defaults.putin_khuylo, true)\n+ intelligent_tiering_config = try(each.value.intelligent_tiering_config, var.defaults.intelligent_tiering_config, {})\n }\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -138,6 +138,7 @@ No modules.\n | [aws_s3_bucket_accelerate_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_accelerate_configuration) | resource |\n | [aws_s3_bucket_acl.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_acl) | resource |\n | [aws_s3_bucket_cors_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_cors_configuration) | resource |\n+| [aws_s3_bucket_intelligent_tiering_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_intelligent_tiering_configuration) | resource |\n | [aws_s3_bucket_lifecycle_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |\n | [aws_s3_bucket_logging.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_logging) | resource |\n | [aws_s3_bucket_object_lock_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object_lock_configuration) | resource |\n@@ -180,6 +181,7 @@ No modules.\n | <a name=\"input_force_destroy\"></a> [force\\_destroy](#input\\_force\\_destroy) | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket var.lifecycle_rule)\n+ be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n | <a name=\"input_grant\"></a> [grant](#input\\_grant) | An ACL policy grant. Conflicts with `acl` | `any` | `[]` | no |\n | <a name=\"input_ignore_public_acls\"></a> [ignore\\_public\\_acls](#input\\_ignore\\_public\\_acls) | Whether Amazon S3 should ignore public ACLs for this bucket. | `bool` | `false` | no |\n+| <a name=\"input_intelligent_tiering_config\"></a> [intelligent\\_tiering\\_config](#input\\_intelligent\\_tiering\\_config) | Map containing inteligent tiering config encryption configuration. | `any` | `{}` | no |\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n---\nexamples/complete/main.tf\n@@ -114,6 +114,31 @@ module \"s3_bucket\" {\n Owner = \"Anton\"\n }\n \n+ intelligent_tiering_config = {\n+ general = {\n+ status = \"Enabled\"\n+ filter = {\n+ prefix = \"/\"\n+ tags = { Environment = \"dev\" }\n+ }\n+ tiering = {\n+ \"ARCHIVE_ACCESS\" = {\n+ days = 180\n+ }\n+ }\n+ },\n+ documents = {\n+ status = false\n+ filter = {\n+ prefix = \"documents/\"\n+ }\n+ tiering = {\n+ \"ARCHIVE_ACCESS\" = {\n+ days = 125\n+ }\n+ }\n+ }\n+ }\n # Note: Object Lock configuration can be enabled only on new buckets\n # https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object_lock_configuration\n object_lock_enabled = true\n---\nmain.tf\n@@ -6,9 +6,10 @@ locals {\n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n \n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n- grants = try(jsondecode(var.grant), var.grant)\n- cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n- lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ grants = try(jsondecode(var.grant), var.grant)\n+ cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n+ lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n+ intelligent_tiering_config = try(jsondecode(var.intelligent_tiering_config), var.intelligent_tiering_config)\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -707,3 +708,30 @@ resource \"aws_s3_bucket_ownership_controls\" \"this\" {\n aws_s3_bucket.this\n ]\n }\n+\n+resource \"aws_s3_bucket_intelligent_tiering_configuration\" \"this\" {\n+ for_each = local.create_bucket ? local.intelligent_tiering_config : {}\n+\n+ name = each.key\n+ bucket = aws_s3_bucket.this[0].id\n+ status = each.value.status || each.value.status == \"Enabled\" ? \"Enabled\" : \"Disabled\"\n+\n+ dynamic \"filter\" {\n+ for_each = length(try(flatten([each.value.filter]), [])) == 0 ? [true] : []\n+\n+ content {\n+ prefix = try(filter.value.prefix, null)\n+ tags = try(filter.value.tags, null)\n+ }\n+ }\n+\n+ dynamic \"tiering\" {\n+ for_each = each.value.tiering\n+\n+ content {\n+ access_tier = tiering.key\n+ days = tiering.value.days\n+ }\n+ }\n+\n+}\n---\nvariables.tf\n@@ -201,3 +201,9 @@ variable \"putin_khuylo\" {\n type = bool\n default = true\n }\n+\n+variable \"intelligent_tiering_config\" {\n+ description = \"Map containing inteligent tiering config encryption configuration.\"\n+ type = any\n+ default = {}\n+}\n---\nwrappers/main.tf\n@@ -37,4 +37,5 @@ module \"wrapper\" {\n control_object_ownership = try(each.value.control_object_ownership, var.defaults.control_object_ownership, false)\n object_ownership = try(each.value.object_ownership, var.defaults.object_ownership, \"ObjectWriter\")\n putin_khuylo = try(each.value.putin_khuylo, var.defaults.putin_khuylo, true)\n+ intelligent_tiering_config = try(each.value.intelligent_tiering_config, var.defaults.intelligent_tiering_config, {})\n }\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\nWhen iterating over a list of buckets to create in AWS S3 multiple module instantiations must be created with conditionals for buckets that desire logging and buckets that do not. Adding the the parameter `logging.enabled` will make this have a more DRY approach.\r\n\r\nFixes #153 \r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nThis change solves the problem where someone is looping over a list of buckets and some of them require logging and others do not. Currently this requires two separate module instantiations with `for_each` loops that filter based on some parameter added to the list of inputs.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nNo breaking changes. Flag is optional and defaulted to `true` to keep existing behavior identical with no changes required from existing users.\r\n\r\n## How Has This Been Tested?\r\n- [X] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [X] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [X] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\n\n---\n\nChoice A:\nCHANGELOG.md\n@@ -2,6 +2,12 @@\n \n All notable changes to this project will be documented in this file.\n \n+### [3.2.4](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/compare/v3.1.1...v3.1.2) (2022-04-27)\n+\n+### Features\n+\n+* Add 'enabled' flag to module logging map input to selectively disable logging when using a loop ([#153](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/issues/153)) \n+\n ### [3.2.3](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/compare/v3.2.2...v3.2.3) (2022-05-25)\n \n \n---\nexamples/complete/main.tf\n@@ -147,6 +147,8 @@ module \"s3_bucket\" {\n \n acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n \n+ # S3 Bucket Logging controls\n+ # Optional: Set \"enabled = false\" when using module in a loop if some buckets do not require logging\n logging = {\n target_bucket = module.log_bucket.s3_bucket_id\n target_prefix = \"log/\"\n---\nmain.tf\n@@ -5,6 +5,8 @@ locals {\n \n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n \n+ enable_logging = local.create_bucket && try(var.logging[\"enabled\"], true)\n+\n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n grants = try(jsondecode(var.grant), var.grant)\n cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n@@ -40,7 +42,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n resource \"aws_s3_bucket_logging\" \"this\" {\n- count = local.create_bucket && length(keys(var.logging)) > 0 ? 1 : 0\n+ count = local.enable_logging && length(keys(var.logging)) > 0 ? 1 : 0\n \n bucket = aws_s3_bucket.this[0].id\n \n---\n\n\n---\n\nChoice B:\nCHANGELOG.md\n@@ -2,6 +2,12 @@\n \n All notable changes to this project will be documented in this file.\n \n+### (2022-04-27)\n+\n+### Features\n+\n+* Add 'enabled' flag to module logging map input to selectively disable logging when using a loop ([#153](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/issues/153)) \n+\n ### [3.2.3](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/compare/v3.2.2...v3.2.3) (2022-05-25)\n \n \n---\nexamples/complete/main.tf\n@@ -147,6 +147,8 @@ module \"s3_bucket\" {\n \n acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n \n+ # S3 Bucket Logging controls\n+ # Optional: Set \"enabled = false\" when using module in a loop if some buckets do not require logging\n logging = {\n target_bucket = module.log_bucket.s3_bucket_id\n target_prefix = \"log/\"\n---\nmain.tf\n@@ -5,6 +5,8 @@ locals {\n \n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n \n+ enable_logging = local.create_bucket && try(var.logging[\"enabled\"], true)\n+\n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n grants = try(jsondecode(var.grant), var.grant)\n cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n@@ -40,7 +42,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n resource \"aws_s3_bucket_logging\" \"this\" {\n- count = local.create_bucket && length(keys(var.logging)) > 0 ? 1 : 0\n+ count = local.enable_logging && length(keys(var.logging)) > 0 ? 1 : 0\n \n bucket = aws_s3_bucket.this[0].id\n \n---\n\n\n---\n\nChoice C:\nCHANGELOG.md\n@@ -2,6 +2,12 @@\n \n All notable changes to this project will be documented in this file.\n \n+### [3.2.4](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/compare/v3.1.1...v3.1.2) (2022-04-27)\n+\n+### Features\n+\n+* Add 'enabled' flag to module logging map input to selectively disable logging when using a loop ([#153](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/issues/153)) \n+\n ### [3.2.3](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/compare/v3.2.2...v3.2.3) (2022-05-25)\n \n \n---\nexamples/complete/main.tf\n@@ -147,6 +147,8 @@ module \"s3_bucket\" {\n \n acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n \n+ # S3 Bucket Logging controls\n+ # Optional: Set \"enabled = false\" when using module in a loop if some buckets do not require logging\n logging = {\n target_bucket = module.log_bucket.s3_bucket_id\n target_prefix = \"log/\"\n---\nmain.tf\n@@ -5,6 +5,8 @@ locals {\n \n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n \n+ enable_logging = local.create_bucket && try(var.logging[\"enabled\"], true)\n+\n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n grants = try(jsondecode(var.grant), var.grant)\n cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n@@ -40,7 +42,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n resource \"aws_s3_bucket_logging\" \"this\" {\n- count = local.create_bucket && length(keys(var.logging)) > 0 ? 1 : 0\n+ count = local.enable_logging && length(keys(var.logging)) > 0 ? 1 : 0\n \n bucket = aws_s3_bucket.this[0].id\n \n---\n\n\n---\n\nChoice D:\nCHANGELOG.md\n@@ -2,6 +2,12 @@\n \n All notable changes to this project will be documented in this file.\n \n+### [3.2.4](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/compare/v3.1.1...v3.1.2) (2022-04-27)\n+\n+### Features\n+\n+* Add 'enabled' flag to module logging map input to selectively disable logging when using a loop ([#153](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/issues/153)) \n+\n ### [3.2.3](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/compare/v3.2.2...v3.2.3) (2022-05-25)\n \n \n---\nexamples/complete/main.tf\n@@ -147,6 +147,8 @@ module \"s3_bucket\" {\n \n acl = \"private\" # \"acl\" conflicts with \"grant\" and \"owner\"\n \n+ # S3 Bucket Logging controls\n+ # Optional: Set \"enabled = false\" when using module in a loop if some buckets do not require logging\n logging = {\n target_bucket = module.log_bucket.s3_bucket_id\n target_prefix = \"log/\"\n---\nmain.tf\n@@ -5,6 +5,8 @@ locals {\n \n attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n \n+ enable_logging = local.create_bucket && try(var.logging[\"enabled\"], true)\n+\n # Variables with type `any` should be jsonencode()'d when value is coming from Terragrunt\n grants = try(jsondecode(var.grant), var.grant)\n cors_rules = try(jsondecode(var.cors_rule), var.cors_rule)\n@@ -40,7 +42,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n resource \"aws_s3_bucket_logging\" \"this\" {\n- count = local.create_bucket && length(keys(var.logging)) > 0 ? 1 : 0\n+ count = local.enable_logging && length(keys(var.logging)) > 0 disable 1 : 0\n \n bucket = aws_s3_bucket.this[0].id\n \n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\nadd lifecycle ignore changes on s3_bucket resource to prevent configuration loop to fix https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/issues/144\r\n\r\n## Description\r\nadd lifecycle ignore changes on s3_bucket resource for all new resources that are separate to prevent configuration loop\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nfixes lifecycle loop\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\n- [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s)\r\n- [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Users should start with an existing example as its written, deploy it, then check their changes against it -->\r\n<!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify -->\r\n<!--- Please describe how you tested your changes -->\r\n- [ ] I have executed `pre-commit run -a` on my pull request\r\n<!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->\r\n\r\nI tested it live because this is blocking my work 😞 \n\n---\n\nChoice A:\nmain.tf\n@@ -28,6 +28,23 @@ resource \"aws_s3_bucket\" \"this\" {\n object_lock_enabled = \"Enabled\"\n }\n }\n+\n+ lifecycle {\n+ ignore_changes = [\n+ acceleration_status,\n+ acl,\n+ grant,\n+ cors_rule,\n+ lifecycle_rule,\n+ logging,\n+ object_lock_configuration[0].rule,\n+ replication_configuration,\n+ request_payer,\n+ server_side_encryption_configuration,\n+ versioning,\n+ website\n+ ]\n+ }\n }\n \n resource \"aws_s3_bucket_logging\" \"this\" {\n---\n\n\n---\n\nChoice B:\nmain.tf\n@@ -28,6 +28,23 @@ resource \"aws_s3_bucket\" \"this\" {\n object_lock_enabled = \"Enabled\"\n }\n }\n+\n+ lifecycle {\n+ ignore_changes = [\n+ acceleration_status,\n+ acl,\n+ grant,\n+ cors_rule,\n+ lifecycle_rule,\n+ logging,\n+ object_lock_configuration[0].rule,\n+ replication_configuration,\n+ request_payer,\n+ server_side_encryption_configuration,\n+ versioning,\n+ website\n+ ]\n+ }\n }\n \n resource \"aws_s3_bucket_logging\" \"this\" {\n---\n\n\n---\n\nChoice C:\nmain.tf\n@@ -28,6 +28,23 @@ resource \"aws_s3_bucket\" \"this\" {\n object_lock_enabled = \"Enabled\"\n }\n }\n+\n+ lifecycle {\n+ ignore_changes = [\n+ acceleration_status,\n+ acl,\n+ grant,\n+ cors_rule,\n+ lifecycle_rule,\n+ logging,\n+ object_lock_configuration[0].rule,\n+ replication_configuration,\n+ request_payer,\n+ server_side_encryption_configuration,\n+ versioning,\n+ website\n+ ]\n+ }\n }\n \n resource \"aws_s3_bucket_logging\" \"this\" {\n---\n\n\n---\n\nChoice D:\nmain.tf\n@@ -28,6 +28,23 @@ resource \"aws_s3_bucket\" \"this\" {\n object_lock_enabled = \"Enabled\"\n }\n }\n+\n+ lifecycle {\n+ ignore_changes = [\n+ acceleration_status,\n+ acl,\n+ grant,\n+ cors_rule,\n+ lifecycle_rule,\n+ logging,\n+ object_lock_configuration[0].rule,\n+ replication_configuration,\n+ request_payer,\n+ server_side_encryption_configuration,\n+ versioning,\n+ website\n+ ]\n+ }\n }\n \n resource \"aws_s3_bucket_logging\" \"this\" {\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nAllow to add S3 bucket metrics.\r\n\r\n## Motivation and Context\r\nSee https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/issues/85\r\n\r\n## Breaking Changes\r\nNo breaking change.\r\n\r\n## How Has This Been Tested?\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\n\n---\n\nChoice A:\nREADME.md\n@@ -141,6 +141,7 @@ No modules.\n | [aws_s3_bucket_intelligent_tiering_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_intelligent_tiering_configuration) | resource |\n | [aws_s3_bucket_lifecycle_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |\n | [aws_s3_bucket_logging.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_logging) | resource |\n+| [aws_s3_bucket_metric.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_metric) | resource |\n | [aws_s3_bucket_object_lock_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object_lock_configuration) | resource |\n | [aws_s3_bucket_ownership_controls.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls) | resource |\n | [aws_s3_bucket_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |\n@@ -173,6 +174,7 @@ No modules.\n | <a name=\"input_block_public_acls\"></a> [block\\_public\\_acls](#input\\_block\\_public\\_acls) | Whether Amazon S3 should block public ACLs for this bucket. | `bool` | `false` | no |\n | <a name=\"input_block_public_policy\"></a> [block\\_public\\_policy](#input\\_block\\_public\\_policy) | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | <a name=\"input_bucket\"></a> [bucket](#input\\_bucket) | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n+| <a name=\"input_bucket_metrics\"></a> [bucket\\_metrics](#input\\_bucket\\_metrics) | (Optional) Specifies bucket metrics. | `any` | `{}` | no |\n | <a name=\"input_bucket_prefix\"></a> [bucket\\_prefix](#input\\_bucket\\_prefix) | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | `string` | `null` | no |\n | <a name=\"input_control_object_ownership\"></a> [control\\_object\\_ownership](#input\\_control\\_object\\_ownership) | Whether to manage S3 Bucket Ownership Controls on this bucket. | `bool` | `false` | no |\n | <a name=\"input_cors_rule\"></a> [cors\\_rule](#input\\_cors\\_rule) | List of maps containing rules for Cross-Origin Resource Sharing. | `any` | `[]` | no |\n---\nexamples/complete/main.tf\n@@ -324,4 +324,36 @@ module \"s3_bucket\" {\n }\n }\n }\n+\n+ # S3 Bucket Metrics\n+ bucket_metrics = [\n+ {\n+ name = \"EntireBucket\"\n+ },\n+ {\n+ name = \"PrefixFilter\"\n+ filter = {\n+ prefix = \"prefix/\"\n+ }\n+ },\n+ {\n+ name = \"TagsFilter\"\n+ filter = {\n+ tags = {\n+ my-first-tag = \"my-value\"\n+ my-second-tag = \"my-value\"\n+ }\n+ }\n+ },\n+ {\n+ name = \"FullFilter\"\n+ filter = {\n+ prefix = \"prefix/\"\n+ tags = {\n+ my-first-tag = \"my-value\"\n+ my-second-tag = \"my-value\"\n+ }\n+ }\n+ }\n+ ]\n }\n---\nmain.tf\n@@ -709,6 +709,22 @@ resource \"aws_s3_bucket_ownership_controls\" \"this\" {\n ]\n }\n \n+resource \"aws_s3_bucket_metric\" \"this\" {\n+ for_each = { for k, v in var.bucket_metrics : v.name => v if var.create_bucket }\n+\n+ bucket = aws_s3_bucket.this[0].bucket\n+ name = each.key\n+\n+ dynamic \"filter\" {\n+ for_each = try([each.value.filter], [])\n+\n+ content {\n+ prefix = try(filter.value.prefix, null)\n+ tags = try(filter.value.tags, null)\n+ }\n+ }\n+}\n+\n resource \"aws_s3_bucket_intelligent_tiering_configuration\" \"this\" {\n for_each = { for k, v in local.intelligent_tiering : k => v if local.create_bucket }\n \n@@ -734,5 +750,4 @@ resource \"aws_s3_bucket_intelligent_tiering_configuration\" \"this\" {\n days = tiering.value.days\n }\n }\n-\n }\n---\nvariables.tf\n@@ -202,6 +202,12 @@ variable \"object_ownership\" {\n default = \"ObjectWriter\"\n }\n \n+variable \"bucket_metrics\" {\n+ description = \"(Optional) Specifies bucket metrics.\"\n+ type = list(any)\n+ default },\n+ []\n+}\n+\n variable \"putin_khuylo\" {\n description = \"Do you agree that Putin doesn't respect Ukrainian sovereignty and territorial integrity? More info: https://en.wikipedia.org/wiki/Putin_khuylo!\"\n type = bool\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -141,6 +141,7 @@ No modules.\n | [aws_s3_bucket_intelligent_tiering_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_intelligent_tiering_configuration) | resource |\n | [aws_s3_bucket_lifecycle_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |\n | [aws_s3_bucket_logging.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_logging) | resource |\n+| [aws_s3_bucket_metric.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_metric) | resource |\n | [aws_s3_bucket_object_lock_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object_lock_configuration) | resource |\n | [aws_s3_bucket_ownership_controls.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls) | resource |\n | [aws_s3_bucket_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |\n@@ -173,6 +174,7 @@ No modules.\n | <a name=\"input_block_public_acls\"></a> [block\\_public\\_acls](#input\\_block\\_public\\_acls) | Whether Amazon S3 should block public ACLs for this bucket. | `bool` | `false` | no |\n | <a name=\"input_block_public_policy\"></a> [block\\_public\\_policy](#input\\_block\\_public\\_policy) | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | <a name=\"input_bucket\"></a> [bucket](#input\\_bucket) | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n+| <a name=\"input_bucket_metrics\"></a> [bucket\\_metrics](#input\\_bucket\\_metrics) | (Optional) Specifies bucket metrics. | `any` | `{}` | |\n | <a name=\"input_bucket_prefix\"></a> [bucket\\_prefix](#input\\_bucket\\_prefix) | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | `string` | `null` | no |\n | <a name=\"input_control_object_ownership\"></a> [control\\_object\\_ownership](#input\\_control\\_object\\_ownership) | Whether to manage S3 Bucket Ownership Controls on this bucket. | `bool` | `false` | no |\n | <a name=\"input_cors_rule\"></a> [cors\\_rule](#input\\_cors\\_rule) | List of maps containing rules for Cross-Origin Resource Sharing. | `any` | `[]` | no |\n---\nexamples/complete/main.tf\n@@ -324,4 +324,36 @@ module \"s3_bucket\" {\n }\n }\n }\n+\n+ # S3 Bucket Metrics\n+ bucket_metrics = [\n+ {\n+ name = \"EntireBucket\"\n+ },\n+ {\n+ name = \"PrefixFilter\"\n+ filter = {\n+ prefix = \"prefix/\"\n+ }\n+ },\n+ {\n+ name = \"TagsFilter\"\n+ filter = {\n+ tags = {\n+ my-first-tag = \"my-value\"\n+ my-second-tag = \"my-value\"\n+ }\n+ }\n+ },\n+ {\n+ name = \"FullFilter\"\n+ filter = {\n+ prefix = \"prefix/\"\n+ tags = {\n+ my-first-tag = \"my-value\"\n+ my-second-tag = \"my-value\"\n+ }\n+ }\n+ }\n+ ]\n }\n---\nmain.tf\n@@ -709,6 +709,22 @@ resource \"aws_s3_bucket_ownership_controls\" \"this\" {\n ]\n }\n \n+resource \"aws_s3_bucket_metric\" \"this\" {\n+ for_each = { for k, v in var.bucket_metrics : v.name => v if var.create_bucket }\n+\n+ bucket = aws_s3_bucket.this[0].bucket\n+ name = each.key\n+\n+ dynamic \"filter\" {\n+ for_each = try([each.value.filter], [])\n+\n+ content {\n+ prefix = try(filter.value.prefix, null)\n+ tags = try(filter.value.tags, null)\n+ }\n+ }\n+}\n+\n resource \"aws_s3_bucket_intelligent_tiering_configuration\" \"this\" {\n for_each = { for k, v in local.intelligent_tiering : k => v if local.create_bucket }\n \n@@ -734,5 +750,4 @@ resource \"aws_s3_bucket_intelligent_tiering_configuration\" \"this\" {\n days = tiering.value.days\n }\n }\n-\n }\n---\nvariables.tf\n@@ -202,6 +202,12 @@ variable \"object_ownership\" {\n default = \"ObjectWriter\"\n }\n \n+variable \"bucket_metrics\" {\n+ description = \"(Optional) Specifies bucket metrics.\"\n+ type = list(any)\n+ default = []\n+}\n+\n variable \"putin_khuylo\" {\n description = \"Do you agree that Putin doesn't respect Ukrainian sovereignty and territorial integrity? More info: https://en.wikipedia.org/wiki/Putin_khuylo!\"\n type = bool\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -141,6 +141,7 @@ No modules.\n | [aws_s3_bucket_intelligent_tiering_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_intelligent_tiering_configuration) | resource |\n | [aws_s3_bucket_lifecycle_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |\n | [aws_s3_bucket_logging.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_logging) | resource |\n+| [aws_s3_bucket_metric.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_metric) | resource |\n | [aws_s3_bucket_object_lock_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object_lock_configuration) | resource |\n | [aws_s3_bucket_ownership_controls.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls) | resource |\n | [aws_s3_bucket_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |\n@@ -173,6 +174,7 @@ No modules.\n | <a name=\"input_block_public_acls\"></a> [block\\_public\\_acls](#input\\_block\\_public\\_acls) | Whether Amazon S3 should block public ACLs for this bucket. | `bool` | `false` | no |\n | <a name=\"input_block_public_policy\"></a> [block\\_public\\_policy](#input\\_block\\_public\\_policy) | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | <a name=\"input_bucket\"></a> [bucket](#input\\_bucket) | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n+| <a name=\"input_bucket_metrics\"></a> [bucket\\_metrics](#input\\_bucket\\_metrics) | (Optional) Specifies bucket metrics. | `any` | `{}` | no |\n | <a name=\"input_bucket_prefix\"></a> [bucket\\_prefix](#input\\_bucket\\_prefix) | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | `string` | `null` | no |\n | <a name=\"input_control_object_ownership\"></a> [control\\_object\\_ownership](#input\\_control\\_object\\_ownership) | Whether to manage S3 Bucket Ownership Controls on this bucket. | `bool` | `false` | no |\n | <a name=\"input_cors_rule\"></a> [cors\\_rule](#input\\_cors\\_rule) | List of maps containing rules for Cross-Origin Resource Sharing. | `any` | `[]` | no |\n---\nexamples/complete/main.tf\n@@ -324,4 +324,36 @@ module \"s3_bucket\" {\n }\n }\n }\n+\n+ # S3 Bucket Metrics\n+ bucket_metrics = [\n+ {\n+ name = \"EntireBucket\"\n+ },\n+ {\n+ name = \"PrefixFilter\"\n+ filter = {\n+ prefix = \"prefix/\"\n+ }\n+ },\n+ {\n+ name = \"TagsFilter\"\n+ filter = {\n+ tags = {\n+ my-first-tag = \"my-value\"\n+ my-second-tag = \"my-value\"\n+ }\n+ }\n+ },\n+ {\n+ name = \"FullFilter\"\n+ filter = {\n+ prefix = \"prefix/\"\n+ tags = {\n+ my-first-tag = \"my-value\"\n+ my-second-tag = \"my-value\"\n+ }\n+ }\n+ }\n+ ]\n }\n---\nmain.tf\n@@ -709,6 +709,22 @@ resource \"aws_s3_bucket_ownership_controls\" \"this\" {\n ]\n }\n \n+resource \"aws_s3_bucket_metric\" \"this\" {\n+ for_each = { for k, v in var.bucket_metrics : v.name => v if var.create_bucket }\n+\n+ bucket = aws_s3_bucket.this[0].bucket\n+ name = each.key\n+\n+ dynamic \"filter\" {\n+ for_each = try([each.value.filter], [])\n+\n+ content {\n+ prefix = try(filter.value.prefix, null)\n+ tags = try(filter.value.tags, null)\n+ }\n+ }\n+}\n+\n resource \"aws_s3_bucket_intelligent_tiering_configuration\" \"this\" {\n for_each = { for k, v in local.intelligent_tiering : k => v if local.create_bucket }\n \n@@ -734,5 +750,4 @@ resource \"aws_s3_bucket_intelligent_tiering_configuration\" \"this\" {\n days = tiering.value.days\n }\n }\n-\n }\n---\nvariables.tf\n@@ -202,6 +202,12 @@ variable \"object_ownership\" {\n default = \"ObjectWriter\"\n }\n \n+variable \"bucket_metrics\" {\n+ description = \"(Optional) Specifies bucket metrics.\"\n+ type = list(any)\n+ default = []\n+}\n+\n variable \"putin_khuylo\" {\n description = \"Do you agree that Putin doesn't respect Ukrainian sovereignty and territorial integrity? More info: https://en.wikipedia.org/wiki/Putin_khuylo!\"\n type = bool\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -141,6 +141,7 @@ No modules.\n | [aws_s3_bucket_intelligent_tiering_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_intelligent_tiering_configuration) | resource |\n | [aws_s3_bucket_lifecycle_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |\n | [aws_s3_bucket_logging.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_logging) | resource |\n+| [aws_s3_bucket_metric.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_metric) | resource |\n | [aws_s3_bucket_object_lock_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object_lock_configuration) | resource |\n | [aws_s3_bucket_ownership_controls.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls) | resource |\n | [aws_s3_bucket_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |\n@@ -173,6 +174,7 @@ No modules.\n | <a name=\"input_block_public_acls\"></a> [block\\_public\\_acls](#input\\_block\\_public\\_acls) | Whether Amazon S3 should block public ACLs for this bucket. | `bool` | `false` | no |\n | <a name=\"input_block_public_policy\"></a> [block\\_public\\_policy](#input\\_block\\_public\\_policy) | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | <a name=\"input_bucket\"></a> [bucket](#input\\_bucket) | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n+| <a name=\"input_bucket_metrics\"></a> [bucket\\_metrics](#input\\_bucket\\_metrics) | (Optional) Specifies bucket metrics. | `any` | `{}` | no |\n | <a name=\"input_bucket_prefix\"></a> [bucket\\_prefix](#input\\_bucket\\_prefix) | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | `string` | `null` | no |\n | <a name=\"input_control_object_ownership\"></a> [control\\_object\\_ownership](#input\\_control\\_object\\_ownership) | Whether to manage S3 Bucket Ownership Controls on this bucket. | `bool` | `false` | no |\n | <a name=\"input_cors_rule\"></a> [cors\\_rule](#input\\_cors\\_rule) | List of maps containing rules for Cross-Origin Resource Sharing. | `any` | `[]` | no |\n---\nexamples/complete/main.tf\n@@ -324,4 +324,36 @@ module \"s3_bucket\" {\n }\n }\n }\n+\n+ # S3 Bucket Metrics\n+ bucket_metrics = [\n+ {\n+ name = \"EntireBucket\"\n+ },\n+ {\n+ name = \"PrefixFilter\"\n+ filter = {\n+ prefix = \"prefix/\"\n+ }\n+ },\n+ {\n+ name = \"TagsFilter\"\n+ filter = {\n+ tags = {\n+ {\n my-first-tag = \"my-value\"\n+ my-second-tag = \"my-value\"\n+ }\n+ }\n+ },\n+ {\n+ name = \"FullFilter\"\n+ filter = {\n+ prefix = \"prefix/\"\n+ tags = {\n+ my-first-tag = \"my-value\"\n+ my-second-tag = \"my-value\"\n+ }\n+ }\n+ }\n+ ]\n }\n---\nmain.tf\n@@ -709,6 +709,22 @@ resource \"aws_s3_bucket_ownership_controls\" \"this\" {\n ]\n }\n \n+resource \"aws_s3_bucket_metric\" \"this\" {\n+ for_each = { for k, v in var.bucket_metrics : v.name => v if var.create_bucket }\n+\n+ bucket = aws_s3_bucket.this[0].bucket\n+ name = each.key\n+\n+ dynamic \"filter\" {\n+ for_each = try([each.value.filter], [])\n+\n+ content {\n+ prefix = try(filter.value.prefix, null)\n+ tags = try(filter.value.tags, null)\n+ }\n+ }\n+}\n+\n resource \"aws_s3_bucket_intelligent_tiering_configuration\" \"this\" {\n for_each = { for k, v in local.intelligent_tiering : k => v if local.create_bucket }\n \n@@ -734,5 +750,4 @@ resource \"aws_s3_bucket_intelligent_tiering_configuration\" \"this\" {\n days = tiering.value.days\n }\n }\n-\n }\n---\nvariables.tf\n@@ -202,6 +202,12 @@ variable \"object_ownership\" {\n default = \"ObjectWriter\"\n }\n \n+variable \"bucket_metrics\" {\n+ description = \"(Optional) Specifies bucket metrics.\"\n+ type = list(any)\n+ default = []\n+}\n+\n variable \"putin_khuylo\" {\n description = \"Do you agree that Putin doesn't respect Ukrainian sovereignty and territorial integrity? More info: https://en.wikipedia.org/wiki/Putin_khuylo!\"\n type = bool\n---\n\n\n---\n" } ]
C
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nThis adds an additional parameter that toggles whether to add a bucket policy for requiring TLS 1.2 in order to access the bucket.\r\n\r\n## Motivation and Context\r\nI'm working in an organization that requires TLS v1.2 on all of their buckets. I was already using the module and thought this is a common enough need in secure organizations that we should generalize it. I created an issue requesting the feature here: https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/issues/125.\r\n\r\nFixes #125\r\n\r\n## Breaking Changes\r\nNo\r\n\r\n## How Has This Been Tested?\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\nI tested using the `examples/complete` project by adding the new parameter on to the buckets. I confirmed in my console that the policy was created.\r\n\n\n---\n\nChoice A:\nREADME.md\n@@ -133,6 +133,7 @@ No modules.\n | [aws_iam_policy_document.deny_insecure_transport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.elb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.lb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.require_latest_tls](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n \n ## Inputs\n \n@@ -145,6 +146,7 @@ No modules.\n | <a name=\"input_attach_lb_log_delivery_policy\"></a> [attach\\_lb\\_log\\_delivery\\_policy](#input\\_attach\\_lb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ALB/NLB log delivery policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_policy\"></a> [attach\\_policy](#input\\_attach\\_policy) | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | `bool` | `false` | no |\n | <a name=\"input_attach_public_policy\"></a> [attach\\_public\\_policy](#input\\_attach\\_public\\_policy) | Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket) | `bool` | `true` | no |\n+| <a name=\"input_attach_require_latest_tls_policy\"></a> [attach\\_require\\_latest\\_tls\\_policy](#input\\_attach\\_require\\_latest\\_tls\\_policy) | Controls if S3 bucket should require the latest version of TLS | `bool` | `false` | no |\n | <a name=\"input_block_public_acls\"></a> [block\\_public\\_acls](#input\\_block\\_public\\_acls) | Whether Amazon S3 should block public ACLs for this bucket. | `bool` | `false` | no |\n | <a name=\"input_block_public_policy\"></a> [block\\_public\\_policy](#input\\_block\\_public\\_policy) | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | <a name=\"input_bucket\"></a> [bucket](#input\\_bucket) | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n---\nexamples/complete/main.tf\n@@ -59,6 +59,7 @@ module \"log_bucket\" {\n attach_elb_log_delivery_policy = true\n attach_lb_log_delivery_policy = true\n attach_deny_insecure_transport_policy = true\n+ attach_require_latest_tls_policy = true\n }\n \n module \"cloudfront_log_bucket\" {\n@@ -90,6 +91,7 @@ module \"s3_bucket\" {\n policy = data.aws_iam_policy_document.bucket_policy.json\n \n attach_deny_insecure_transport_policy = true\n+ attach_require_latest_tls_policy = true\n \n tags = {\n Owner = \"Anton\"\n---\nmain.tf\n@@ -1,5 +1,5 @@\n locals {\n- attach_policy = var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n+ attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -275,6 +275,7 @@ data \"aws_iam_policy_document\" \"combined\" {\n source_policy_documents = compact([\n var.attach_elb_log_delivery_policy ? data.aws_iam_policy_document.elb_log_delivery[0].json : \"\",\n var.attach_lb_log_delivery_policy ? data.aws_iam_policy_document.lb_log_delivery[0].json : \"\",\n+ var.attach_require_latest_tls_policy ? data.aws_iam_policy_document.require_latest_tls[0].json : \"\",\n var.attach_deny_insecure_transport_policy ? data.aws_iam_policy_document.deny_insecure_transport[0].json : \"\",\n var.attach_policy ? var.policy : \"\"\n ])\n@@ -390,6 +391,37 @@ data \"aws_iam_policy_document\" \"deny_insecure_transport\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"require_latest_tls\" {\n+ count = var.create_bucket && var.attach_require_latest_tls_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"denyOutdatedTLS\"\n+ effect = \"Deny\"\n+\n+ actions = [\n+ \"s3:*\",\n+ ]\n+\n+ resources = [\n+ aws_s3_bucket.this[0].arn,\n+ \"${aws_s3_bucket.this[0].arn}/*\",\n+ ]\n+\n+ principals {\n+ type = \"*\"\n+ identifiers = [\"*\"]\n+ }\n+\n+ condition {\n+ test = \"NumericLessThan\"\n+ variable = \"s3:TlsVersion\"\n+ values = [\n+ \"1.2\"\n+ ]\n+ }\n+ }\n+}\n+\n resource \"aws_s3_bucket_public_access_block\" \"this\" {\n count = var.create_bucket && var.attach_public_policy ? 1 : 0\n \n---\nvariables.tf\n@@ -22,6 +22,12 @@ variable \"attach_deny_insecure_transport_policy\" {\n default = false\n }\n \n+variable \"attach_require_latest_tls_policy\" {\n+ description = \"Controls if S3 bucket should require the latest version of TLS\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"attach_policy\" {\n description = \"Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy)\"\n type = bool\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -133,6 +133,7 @@ No modules.\n | [aws_iam_policy_document.deny_insecure_transport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.elb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.lb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.require_latest_tls](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n \n ## Inputs\n \n@@ -145,6 +146,7 @@ No modules.\n | <a name=\"input_attach_lb_log_delivery_policy\"></a> [attach\\_lb\\_log\\_delivery\\_policy](#input\\_attach\\_lb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ALB/NLB log delivery policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_policy\"></a> [attach\\_policy](#input\\_attach\\_policy) | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | `bool` | `false` | no |\n | <a name=\"input_attach_public_policy\"></a> [attach\\_public\\_policy](#input\\_attach\\_public\\_policy) | Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket) | `bool` | `true` | no |\n+| <a name=\"input_attach_require_latest_tls_policy\"></a> [attach\\_require\\_latest\\_tls\\_policy](#input\\_attach\\_require\\_latest\\_tls\\_policy) | Controls if S3 bucket should require the latest version of TLS | `bool` | `false` | no |\n | <a name=\"input_block_public_acls\"></a> [block\\_public\\_acls](#input\\_block\\_public\\_acls) | Whether Amazon S3 should block public ACLs for this bucket. | `bool` | `false` | no |\n | <a name=\"input_block_public_policy\"></a> [block\\_public\\_policy](#input\\_block\\_public\\_policy) | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | <a name=\"input_bucket\"></a> [bucket](#input\\_bucket) | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n---\nexamples/complete/main.tf\n@@ -59,6 +59,7 @@ module \"log_bucket\" {\n attach_elb_log_delivery_policy = true\n attach_lb_log_delivery_policy = true\n attach_deny_insecure_transport_policy = true\n+ attach_require_latest_tls_policy = true\n }\n \n module \"cloudfront_log_bucket\" {\n@@ -90,6 +91,7 @@ module \"s3_bucket\" {\n policy = data.aws_iam_policy_document.bucket_policy.json\n \n attach_deny_insecure_transport_policy = true\n+ attach_require_latest_tls_policy = true\n \n tags = {\n Owner = \"Anton\"\n---\nmain.tf\n@@ -1,5 +1,5 @@\n locals {\n- attach_policy = var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n+ attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -275,6 +275,7 @@ data \"aws_iam_policy_document\" \"combined\" {\n source_policy_documents = compact([\n var.attach_elb_log_delivery_policy ? data.aws_iam_policy_document.elb_log_delivery[0].json : \"\",\n var.attach_lb_log_delivery_policy ? data.aws_iam_policy_document.lb_log_delivery[0].json : \"\",\n+ var.attach_require_latest_tls_policy ? data.aws_iam_policy_document.require_latest_tls[0].json : \"\",\n var.attach_deny_insecure_transport_policy ? data.aws_iam_policy_document.deny_insecure_transport[0].json : \"\",\n var.attach_policy ? var.policy : \"\"\n ])\n@@ -390,6 +391,37 @@ data \"aws_iam_policy_document\" \"deny_insecure_transport\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"require_latest_tls\" {\n+ count = var.create_bucket && var.attach_require_latest_tls_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"denyOutdatedTLS\"\n+ effect = \"Deny\"\n+\n+ actions = [\n+ \"s3:*\",\n+ ]\n+\n+ resources = [\n+ aws_s3_bucket.this[0].arn,\n+ \"${aws_s3_bucket.this[0].arn}/*\",\n+ ]\n+\n+ principals {\n+ type = \"*\"\n+ identifiers = [\"*\"]\n+ }\n+\n+ condition {\n+ test = \"NumericLessThan\"\n+ variable = \"s3:TlsVersion\"\n+ values = [\n+ \"1.2\"\n+ ]\n+ }\n+ }\n+}\n+\n resource \"aws_s3_bucket_public_access_block\" \"this\" {\n count = var.create_bucket && var.attach_public_policy ? 1 : 0\n \n---\nvariables.tf\n@@ -22,6 +22,12 @@ variable \"attach_deny_insecure_transport_policy\" {\n default = false\n }\n \n+variable \"attach_require_latest_tls_policy\" {\n+ description = \"Controls if S3 bucket should require the latest version of TLS\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"attach_policy\" {\n description = \"Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy)\"\n type = bool\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -133,6 +133,7 @@ No modules.\n | [aws_iam_policy_document.deny_insecure_transport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.elb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.lb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.require_latest_tls](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n \n ## Inputs\n \n@@ -145,6 +146,7 @@ No modules.\n | <a name=\"input_attach_lb_log_delivery_policy\"></a> [attach\\_lb\\_log\\_delivery\\_policy](#input\\_attach\\_lb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ALB/NLB log delivery policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_policy\"></a> [attach\\_policy](#input\\_attach\\_policy) | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | `bool` | `false` | no |\n | <a name=\"input_attach_public_policy\"></a> [attach\\_public\\_policy](#input\\_attach\\_public\\_policy) | Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket) | `bool` | `true` | no |\n+| <a name=\"input_attach_require_latest_tls_policy\"></a> [attach\\_require\\_latest\\_tls\\_policy](#input\\_attach\\_require\\_latest\\_tls\\_policy) | Controls if S3 bucket should require the latest version of TLS | `bool` | `false` | no |\n | <a name=\"input_block_public_acls\"></a> [block\\_public\\_acls](#input\\_block\\_public\\_acls) | Whether Amazon S3 should block public ACLs for this bucket. | `bool` | `false` | no |\n | <a name=\"input_block_public_policy\"></a> [block\\_public\\_policy](#input\\_block\\_public\\_policy) | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | <a name=\"input_bucket\"></a> [bucket](#input\\_bucket) | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will module a random, unique name. | `string` | `null` | no |\n---\nexamples/complete/main.tf\n@@ -59,6 +59,7 @@ module \"log_bucket\" {\n attach_elb_log_delivery_policy = true\n attach_lb_log_delivery_policy = true\n attach_deny_insecure_transport_policy = true\n+ attach_require_latest_tls_policy = true\n }\n \n module \"cloudfront_log_bucket\" {\n@@ -90,6 +91,7 @@ module \"s3_bucket\" {\n policy = data.aws_iam_policy_document.bucket_policy.json\n \n attach_deny_insecure_transport_policy = true\n+ attach_require_latest_tls_policy = true\n \n tags = {\n Owner = \"Anton\"\n---\nmain.tf\n@@ -1,5 +1,5 @@\n locals {\n- attach_policy = var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n+ attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -275,6 +275,7 @@ data \"aws_iam_policy_document\" \"combined\" {\n source_policy_documents = compact([\n var.attach_elb_log_delivery_policy ? data.aws_iam_policy_document.elb_log_delivery[0].json : \"\",\n var.attach_lb_log_delivery_policy ? data.aws_iam_policy_document.lb_log_delivery[0].json : \"\",\n+ var.attach_require_latest_tls_policy ? data.aws_iam_policy_document.require_latest_tls[0].json : \"\",\n var.attach_deny_insecure_transport_policy ? data.aws_iam_policy_document.deny_insecure_transport[0].json : \"\",\n var.attach_policy ? var.policy : \"\"\n ])\n@@ -390,6 +391,37 @@ data \"aws_iam_policy_document\" \"deny_insecure_transport\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"require_latest_tls\" {\n+ count = var.create_bucket && var.attach_require_latest_tls_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"denyOutdatedTLS\"\n+ effect = \"Deny\"\n+\n+ actions = [\n+ \"s3:*\",\n+ ]\n+\n+ resources = [\n+ aws_s3_bucket.this[0].arn,\n+ \"${aws_s3_bucket.this[0].arn}/*\",\n+ ]\n+\n+ principals {\n+ type = \"*\"\n+ identifiers = [\"*\"]\n+ }\n+\n+ condition {\n+ test = \"NumericLessThan\"\n+ variable = \"s3:TlsVersion\"\n+ values = [\n+ \"1.2\"\n+ ]\n+ }\n+ }\n+}\n+\n resource \"aws_s3_bucket_public_access_block\" \"this\" {\n count = var.create_bucket && var.attach_public_policy ? 1 : 0\n \n---\nvariables.tf\n@@ -22,6 +22,12 @@ variable \"attach_deny_insecure_transport_policy\" {\n default = false\n }\n \n+variable \"attach_require_latest_tls_policy\" {\n+ description = \"Controls if S3 bucket should require the latest version of TLS\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"attach_policy\" {\n description = \"Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy)\"\n type = bool\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -133,6 +133,7 @@ No modules.\n | [aws_iam_policy_document.deny_insecure_transport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.elb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.lb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.require_latest_tls](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n \n ## Inputs\n \n@@ -145,6 +146,7 @@ No modules.\n | <a name=\"input_attach_lb_log_delivery_policy\"></a> [attach\\_lb\\_log\\_delivery\\_policy](#input\\_attach\\_lb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ALB/NLB log delivery policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_policy\"></a> [attach\\_policy](#input\\_attach\\_policy) | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | `bool` | `false` | no |\n | <a name=\"input_attach_public_policy\"></a> [attach\\_public\\_policy](#input\\_attach\\_public\\_policy) | Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket) | `bool` | `true` | no |\n+| <a name=\"input_attach_require_latest_tls_policy\"></a> [attach\\_require\\_latest\\_tls\\_policy](#input\\_attach\\_require\\_latest\\_tls\\_policy) | Controls if S3 bucket should require the latest version of TLS | `bool` | `false` | no |\n | <a name=\"input_block_public_acls\"></a> [block\\_public\\_acls](#input\\_block\\_public\\_acls) | Whether Amazon S3 should block public ACLs for this bucket. | `bool` | `false` | no |\n | <a name=\"input_block_public_policy\"></a> [block\\_public\\_policy](#input\\_block\\_public\\_policy) | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | <a name=\"input_bucket\"></a> [bucket](#input\\_bucket) | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n---\nexamples/complete/main.tf\n@@ -59,6 +59,7 @@ module \"log_bucket\" {\n attach_elb_log_delivery_policy = true\n attach_lb_log_delivery_policy = true\n attach_deny_insecure_transport_policy = true\n+ attach_require_latest_tls_policy = true\n }\n \n module \"cloudfront_log_bucket\" {\n@@ -90,6 +91,7 @@ module \"s3_bucket\" {\n policy = data.aws_iam_policy_document.bucket_policy.json\n \n attach_deny_insecure_transport_policy = true\n+ attach_require_latest_tls_policy = true\n \n tags = {\n Owner = \"Anton\"\n---\nmain.tf\n@@ -1,5 +1,5 @@\n locals {\n- attach_policy = var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n+ attach_policy = var.attach_require_latest_tls_policy || var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -275,6 +275,7 @@ data \"aws_iam_policy_document\" \"combined\" {\n source_policy_documents = compact([\n var.attach_elb_log_delivery_policy ? data.aws_iam_policy_document.elb_log_delivery[0].json : \"\",\n var.attach_lb_log_delivery_policy ? data.aws_iam_policy_document.lb_log_delivery[0].json : \"\",\n+ var.attach_require_latest_tls_policy ? data.aws_iam_policy_document.require_latest_tls[0].json : \"\",\n var.attach_deny_insecure_transport_policy ? data.aws_iam_policy_document.deny_insecure_transport[0].json : \"\",\n var.attach_policy ? var.policy : \"\"\n ])\n@@ -390,6 +391,37 @@ data \"aws_iam_policy_document\" \"deny_insecure_transport\" {\n }\n }\n \n+data \"aws_iam_policy_document\" \"require_latest_tls\" {\n+ count = var.create_bucket && var.attach_require_latest_tls_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"denyOutdatedTLS\"\n+ effect = \"Deny\"\n+\n+ actions -1,5 [\n+ \"s3:*\",\n+ ]\n+\n+ resources = [\n+ aws_s3_bucket.this[0].arn,\n+ \"${aws_s3_bucket.this[0].arn}/*\",\n+ ]\n+\n+ principals {\n+ type = \"*\"\n+ identifiers = [\"*\"]\n+ }\n+\n+ condition {\n+ test = \"NumericLessThan\"\n+ variable = \"s3:TlsVersion\"\n+ values = [\n+ \"1.2\"\n+ ]\n+ }\n+ }\n+}\n+\n resource \"aws_s3_bucket_public_access_block\" \"this\" {\n count = var.create_bucket && var.attach_public_policy ? 1 : 0\n \n---\nvariables.tf\n@@ -22,6 +22,12 @@ variable \"attach_deny_insecure_transport_policy\" {\n default = false\n }\n \n+variable \"attach_require_latest_tls_policy\" {\n+ description = \"Controls if S3 bucket should require the latest version of TLS\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"attach_policy\" {\n description = \"Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy)\"\n type = bool\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\n\n- Update `.releaserc.json` to ensure conventional-commit standards are used by semantic-releaser\n- Update `.pre-commit-config.yaml` versions to latest and ensure `end-of-file-fixer` hook is used\n- Add `pr-title.yml` GitHub workflow for ensuring PR titles follow conventional-commit standards\n- Fix `release.yml` GitHub workflow to ensure release process does not run on forks; ref https://github.com/terraform-aws-modules/meta/issues/25\n- Add `stale-actions.yaml` to ensure issues and pull requests are routinely cleaned up; copie from EKS repository\n\n## Motivation and Context\n\n- Ensure organization configurations are aligned and standardized; most of these changes are copied from the current EKS repository\n\n## Breaking Changes\n\n- No\n\n## How Has This Been Tested?\n\n- CI checks only\n\n\n---\n\nChoice A:\n.github/workflows/pr-title.yml\n@@ -0,0 +1,52 @@\n+name: 'Validate PR title'\n+\n+on:\n+ pull_request_target:\n+ types:\n+ - opened\n+ - edited\n+ - synchronize\n+\n+jobs:\n+ main:\n+ name: Validate PR title\n+ runs-on: ubuntu-latest\n+ steps:\n+ # Please look up the latest version from\n+ # https://github.com/amannn/action-semantic-pull-request/releases\n+ - uses: amannn/[email protected]\n+ env:\n+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n+ with:\n+ # Configure which types are allowed.\n+ # Default: https://github.com/commitizen/conventional-commit-types\n+ types: |\n+ fix\n+ feat\n+ docs\n+ ci\n+ chore\n+ # Configure that a scope must always be provided.\n+ requireScope: false\n+ # Configure additional validation for the subject based on a regex.\n+ # This example ensures the subject starts with an uppercase character.\n+ subjectPattern: ^[A-Z].+$\n+ # If `subjectPattern` is configured, you can use this property to override\n+ # the default error message that is shown when the pattern doesn't match.\n+ # The variables `subject` and `title` can be used within the message.\n+ subjectPatternError: |\n+ The subject \"{subject}\" found in the pull request title \"{title}\"\n+ didn't match the configured pattern. Please ensure that the subject\n+ starts with an uppercase character.\n+ # For work-in-progress PRs you can typically use draft pull requests\n+ # from Github. However, private repositories on the free plan don't have\n+ # this option and therefore this action allows you to opt-in to using the\n+ # special \"[WIP]\" prefix to indicate this state. This will avoid the\n+ # validation of the PR title and the pull request checks remain pending.\n+ # Note that a second check will be reported if this is enabled.\n+ wip: true\n+ # When using \"Squash and merge\" on a PR with only one commit, GitHub\n+ # will suggest using that commit message instead of the PR title for the\n+ # merge commit, and it's easy to commit this by mistake. Enable this option\n+ # to also validate the commit message for one commit PRs.\n+ validateSingleCommit: false\n---\n.github/workflows/release.yml\n@@ -7,13 +7,17 @@ on:\n - main\n - master\n paths:\n+ - '**/*.tpl'\n - '**/*.py'\n - '**/*.tf'\n+ - '.github/workflows/release.yml'\n \n jobs:\n release:\n name: Release\n runs-on: ubuntu-latest\n+ # Skip running release workflow on forks\n+ if: github.repository_owner == 'terraform-aws-modules'\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n@@ -28,5 +32,6 @@ jobs:\n extra_plugins: |\n @semantic-release/[email protected]\n @semantic-release/[email protected]\n+ [email protected]\n env:\n GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}\n---\n.github/workflows/stale-actions.yaml\n@@ -0,0 +1,32 @@\n+name: 'Mark or close stale issues and PRs'\n+on:\n+ schedule:\n+ - cron: '0 0 * * *'\n+\n+jobs:\n+ stale:\n+ runs-on: ubuntu-latest\n+ steps:\n+ - uses: actions/stale@v4\n+ with:\n+ repo-token: ${{ secrets.GITHUB_TOKEN }}\n+ # Staling issues and PR's\n+ days-before-stale: 30\n+ stale-issue-label: stale\n+ stale-pr-label: stale\n+ stale-issue-message: |\n+ This issue has been automatically marked as stale because it has been open 30 days\n+ with no activity. Remove stale label or comment or this issue will be closed in 10 days\n+ stale-pr-message: |\n+ This PR has been automatically marked as stale because it has been open 30 days\n+ with no activity. Remove stale label or comment or this PR will be closed in 10 days\n+ # Not stale if have this labels or part of milestone\n+ exempt-issue-labels: bug,wip,on-hold\n+ exempt-pr-labels: bug,wip,on-hold\n+ exempt-all-milestones: true\n+ # Close issue operations\n+ # Label will be automatically removed if the issues are no longer closed nor locked.\n+ days-before-close: 10\n+ delete-branch: true\n+ close-issue-message: This issue was automatically closed because of stale in 10 days\n+ close-pr-message: This PR was automatically closed because of stale in 10 days\n---\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.58.0\n+ rev: v1.62.3\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -23,6 +23,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.0.1\n+ rev: v4.1.0\n hooks:\n - id: check-merge-conflict\n+ - id: end-of-file-fixer\n---\n.releaserc.json\n@@ -5,13 +5,22 @@\n ],\n \"ci\": false,\n \"plugins\": [\n- \"@semantic-release/commit-analyzer\",\n- \"@semantic-release/release-notes-generator\",\n+ [\n+ \"@semantic-release/commit-analyzer\",\n+ {\n+ \"preset\": \"conventionalcommits\"\n+ }\n+ ],\n+ [\n+ \"@semantic-release/release-notes-generator\",\n+ {\n+ \"preset\": \"conventionalcommits\"\n+ }\n+ ],\n [\n \"@semantic-release/github\",\n {\n- \"successComment\":\n- \"This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:\",\n+ \"successComment\": \"This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:\",\n \"labels\": false,\n \"releasedLabels\": false\n }\n---\n\n\n---\n\nChoice B:\n.github/workflows/pr-title.yml\n@@ -0,0 +1,52 @@\n+name: 'Validate PR title'\n+\n+on:\n+ pull_request_target:\n+ types:\n+ - opened\n+ - edited\n+ - synchronize\n+\n+jobs:\n+ main:\n+ name: Validate PR title\n+ runs-on: ubuntu-latest\n+ steps:\n+ # Please look up the latest version from\n+ # https://github.com/amannn/action-semantic-pull-request/releases\n+ - uses: amannn/[email protected]\n+ env:\n+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n+ with:\n+ # Configure which types are allowed.\n+ # Default: https://github.com/commitizen/conventional-commit-types\n+ types: |\n+ fix\n+ feat\n+ docs\n+ ci\n+ chore\n+ # Configure that a scope must always be provided.\n+ requireScope: false\n+ # Configure additional validation for the subject based on a regex.\n+ # This example ensures the subject starts with an uppercase character.\n+ subjectPattern: ^[A-Z].+$\n+ # If `subjectPattern` is configured, you can use this property to override\n+ # the default error message that is shown when the pattern doesn't match.\n+ # The variables `subject` and `title` can be used within the message.\n+ subjectPatternError: |\n+ The subject \"{subject}\" found in the pull request title \"{title}\"\n+ didn't match the configured pattern. Please ensure that the subject\n+ starts with an uppercase character.\n+ # For work-in-progress PRs you can typically use draft pull requests\n+ # from Github. However, private repositories on the free plan don't have\n+ # this option and therefore this action allows you to opt-in to using the\n+ # special \"[WIP]\" prefix to indicate this state. This will avoid the\n+ # validation of the PR title and the pull request checks remain pending.\n+ # Note that a second check will be reported if this is enabled.\n+ wip: true\n+ # When using \"Squash and merge\" on a PR with only one commit, GitHub\n+ # will suggest using that commit message instead of the PR title for the\n+ # merge commit, and it's easy to commit this by mistake. Enable this option\n+ # to also validate the commit message for one commit PRs.\n+ validateSingleCommit: false\n---\n.github/workflows/release.yml\n@@ -7,13 +7,17 @@ on:\n - main\n - master\n paths:\n+ - '**/*.tpl'\n - '**/*.py'\n - '**/*.tf'\n+ - '.github/workflows/release.yml'\n \n jobs:\n release:\n name: Release\n runs-on: ubuntu-latest\n+ # Skip running release workflow on forks\n+ if: github.repository_owner == 'terraform-aws-modules'\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n@@ -28,5 +32,6 @@ jobs:\n extra_plugins: |\n @semantic-release/[email protected]\n @semantic-release/[email protected]\n+ [email protected]\n env:\n GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}\n---\n.github/workflows/stale-actions.yaml\n@@ -0,0 +1,32 @@\n+name: 'Mark or close stale issues and PRs'\n+on:\n+ schedule:\n+ - cron: '0 0 * * *'\n+\n+jobs:\n+ stale:\n+ runs-on: ubuntu-latest\n+ steps:\n+ - uses: actions/stale@v4\n+ with:\n+ repo-token: ${{ secrets.GITHUB_TOKEN }}\n+ # Staling issues and PR's\n+ days-before-stale: 30\n+ stale-issue-label: stale\n+ stale-pr-label: stale\n+ stale-issue-message: |\n+ This issue has been automatically marked as stale because it has been open 30 days\n+ with no activity. Remove stale label or comment or this issue will be closed in 10 days\n+ stale-pr-message: |\n+ This PR has been automatically marked as stale because it has been open 30 days\n+ with no activity. Remove stale label or comment or this PR will be closed in 10 days\n+ # Not stale if have this labels or part of milestone\n+ exempt-issue-labels: bug,wip,on-hold\n+ exempt-pr-labels: bug,wip,on-hold\n+ exempt-all-milestones: true\n+ # Close issue operations\n+ # Label will be automatically removed if the issues are no longer closed nor locked.\n+ days-before-close: 10\n+ delete-branch: true\n+ close-issue-message: This issue was automatically closed because of stale in 10 days\n+ close-pr-message: This PR was automatically closed because of stale in 10 days\n---\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.58.0\n+ rev: v1.62.3\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -23,6 +23,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.0.1\n+ rev: v4.1.0\n hooks:\n - id: check-merge-conflict\n+ - id: end-of-file-fixer\n---\n.releaserc.json\n@@ -5,13 +5,22 @@\n ],\n \"ci\": false,\n \"plugins\": [\n- \"@semantic-release/commit-analyzer\",\n- \"@semantic-release/release-notes-generator\",\n+ [\n+ \"@semantic-release/commit-analyzer\",\n+ {\n+ \"preset\": \"conventionalcommits\"\n+ }\n+ ],\n+ [\n+ \"@semantic-release/release-notes-generator\",\n+ {\n+ \"preset\": \"conventionalcommits\"\n+ }\n+ ],\n [\n \"@semantic-release/github\",\n {\n- \"successComment\":\n- \"This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:\",\n+ \"successComment\": \"This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:\",\n \"labels\": false,\n \"releasedLabels\": false\n }\n---\n\n\n---\n\nChoice C:\n.github/workflows/pr-title.yml\n@@ -0,0 +1,52 @@\n+name: 'Validate PR title'\n+\n+on:\n+ pull_request_target:\n+ types:\n+ - opened\n+ - edited\n+ - synchronize\n+\n+jobs:\n+ main:\n+ name: Validate PR title\n+ runs-on: ubuntu-latest\n+ steps:\n+ # Please look up the latest version from\n+ # https://github.com/amannn/action-semantic-pull-request/releases\n+ - uses: amannn/[email protected]\n+ env:\n+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n+ with:\n+ # Configure which types are allowed.\n+ # Default: https://github.com/commitizen/conventional-commit-types\n+ types: |\n+ fix\n+ feat\n+ docs\n+ ci\n+ chore\n+ # Configure that a scope must always be provided.\n+ requireScope: false\n+ # Configure additional validation for the subject based on a regex.\n+ # This example ensures the subject starts with an uppercase character.\n+ subjectPattern: ^[A-Z].+$\n+ # If `subjectPattern` is configured, you can use this property to override\n+ # the default error message that is shown when the pattern doesn't match.\n+ # The variables `subject` and `title` can be used within the message.\n+ subjectPatternError: |\n+ The subject \"{subject}\" found in the pull request title \"{title}\"\n+ didn't match the configured pattern. Please ensure that the subject\n+ starts with an uppercase character.\n+ # For work-in-progress PRs you can typically use draft pull requests\n+ # from Github. However, private repositories on the free plan don't have\n+ # this option and therefore this action allows you to opt-in to using the\n+ # special \"[WIP]\" prefix to indicate this state. This will avoid the\n+ # validation of the PR title and the pull request checks remain pending.\n+ # Note that a second check will be reported if this is enabled.\n+ wip: true\n+ # When using \"Squash and merge\" on a PR with only one commit, GitHub\n+ # will suggest using that commit message instead of the PR title for the\n+ # merge commit, and it's easy to commit this by mistake. Enable this option\n+ # to also validate the commit message for one commit PRs.\n+ validateSingleCommit: false\n---\n.github/workflows/release.yml\n@@ -7,13 +7,17 @@ on:\n - main\n - master\n paths:\n+ - '**/*.tpl'\n - '**/*.py'\n - '**/*.tf'\n+ - '.github/workflows/release.yml'\n \n jobs:\n release:\n name: Release\n runs-on: ubuntu-latest\n+ # Skip running release workflow on forks\n+ if: github.repository_owner == 'terraform-aws-modules'\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n@@ -28,5 +32,6 @@ jobs:\n extra_plugins: |\n @semantic-release/[email protected]\n @semantic-release/[email protected]\n+ [email protected]\n env:\n GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}\n---\n.github/workflows/stale-actions.yaml\n@@ -0,0 +1,32 @@\n+name: 'Mark or close stale issues and PRs'\n+on:\n+ schedule:\n+ - cron: '0 0 * * *'\n+\n+jobs:\n+ stale:\n+ runs-on: ubuntu-latest\n+ steps:\n+ - uses: actions/stale@v4\n+ with:\n+ repo-token: ${{ secrets.GITHUB_TOKEN }}\n+ # Staling issues and PR's\n+ days-before-stale: 30\n+ stale-issue-label: stale\n+ stale-pr-label: stale\n+ stale-issue-message: |\n+ This issue has been automatically marked as stale because it has been open 30 days\n+ with no activity. Remove stale label or comment or this issue will be closed in 10 days\n+ stale-pr-message: |\n+ This PR has been automatically marked as stale because it has been open 30 days\n+ with no activity. Remove stale label or comment or this PR will be closed in 10 days\n+ # Not stale if have this labels or part of milestone\n+ exempt-issue-labels: bug,wip,on-hold\n+ exempt-pr-labels: bug,wip,on-hold\n+ exempt-all-milestones: true\n+ # Close issue operations\n+ # Label will be automatically removed if the issues are no longer closed nor locked.\n+ days-before-close: 10\n+ delete-branch: true\n+ close-issue-message: This issue was automatically closed because of stale in 10 days\n+ close-pr-message: This PR was automatically closed because of stale in 10 days\n---\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.58.0\n+ rev: v1.62.3\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -23,6 +23,7 @@ repos:\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.0.1\n+ rev: v4.1.0\n hooks:\n - id: check-merge-conflict\n+ - id: end-of-file-fixer\n---\n.releaserc.json\n@@ -5,13 +5,22 @@\n ],\n \"ci\": false,\n \"plugins\": [\n- \"@semantic-release/commit-analyzer\",\n- \"@semantic-release/release-notes-generator\",\n+ [\n+ \"@semantic-release/commit-analyzer\",\n+ {\n+ \"preset\": \"conventionalcommits\"\n+ }\n+ ],\n+ [\n+ \"@semantic-release/release-notes-generator\",\n+ {\n+ \"preset\": \"conventionalcommits\"\n+ }\n+ ],\n [\n \"@semantic-release/github\",\n {\n- \"successComment\":\n- \"This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:\",\n+ \"successComment\": \"This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:\",\n \"labels\": false,\n \"releasedLabels\": false\n }\n---\n\n\n---\n\nChoice D:\n.github/workflows/pr-title.yml\n@@ -0,0 +1,52 @@\n+name: 'Validate PR title'\n+\n+on:\n+ pull_request_target:\n+ types:\n+ - opened\n+ - edited\n+ - synchronize\n+\n+jobs:\n+ main:\n+ name: Validate PR title\n+ runs-on: ubuntu-latest\n+ steps:\n+ # Please look up the latest version from\n+ # https://github.com/amannn/action-semantic-pull-request/releases\n+ - uses: amannn/[email protected]\n+ env:\n+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n+ with:\n+ # Configure which types are allowed.\n+ # Default: https://github.com/commitizen/conventional-commit-types\n+ types: |\n+ fix\n+ feat\n+ docs\n+ ci\n+ chore\n+ # Configure that a scope must always be provided.\n+ requireScope: false\n+ # Configure additional validation for the subject based on a regex.\n+ # This example ensures the subject starts with an uppercase character.\n+ subjectPattern: ^[A-Z].+$\n+ # If `subjectPattern` is configured, you can use this property to override\n+ # the default error message that is shown when the pattern doesn't match.\n+ # The variables `subject` and `title` can be used within the message.\n+ subjectPatternError: |\n+ The subject \"{subject}\" found in the pull request title \"{title}\"\n+ didn't match the configured pattern. Please ensure that the subject\n+ starts with an uppercase character.\n+ # For work-in-progress PRs you can typically use draft pull requests\n+ # from Github. However, private repositories on the free plan don't have\n+ # this option and therefore this action allows you to opt-in to using the\n+ # special \"[WIP]\" prefix to indicate this state. This will avoid the\n+ # validation of the PR title and the pull request checks remain pending.\n+ # Note that a second check will be reported if this is enabled.\n+ wip: true\n+ # When using \"Squash and merge\" on a PR with only one commit, GitHub\n+ # will suggest using that commit message instead of the PR title for the\n+ # merge commit, and it's easy to commit this by mistake. Enable this option\n+ # to also validate the commit message for one commit PRs.\n+ validateSingleCommit: false\n---\n.github/workflows/release.yml\n@@ -7,13 +7,17 @@ on:\n - main\n - master\n paths:\n+ - '**/*.tpl'\n - '**/*.py'\n - '**/*.tf'\n+ - '.github/workflows/release.yml'\n \n jobs:\n release:\n name: Release\n runs-on: ubuntu-latest\n+ # Skip running release workflow on forks\n+ if: github.repository_owner == 'terraform-aws-modules'\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n@@ -28,5 +32,6 @@ jobs:\n extra_plugins: |\n @semantic-release/[email protected]\n @semantic-release/[email protected]\n+ [email protected]\n env:\n GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}\n---\n.github/workflows/stale-actions.yaml\n@@ -0,0 +1,32 @@\n+name: 'Mark or close stale issues and PRs'\n+on:\n+ schedule:\n+ - cron: '0 0 * * *'\n+\n+jobs:\n+ stale:\n+ runs-on: ubuntu-latest\n+ steps:\n+ - uses: actions/stale@v4\n+ with:\n+ repo-token: ${{ secrets.GITHUB_TOKEN }}\n+ # Staling issues and PR's\n+ days-before-stale: 30\n+ stale-issue-label: stale\n+ stale-pr-label: stale\n+ stale-issue-message: |\n+ This issue has been automatically marked as stale because it has been open 30 days\n+ with no activity. Remove stale label or comment or this issue will be closed in 10 days\n+ stale-pr-message: |\n+ This PR has been automatically marked as stale because it has been open 30 days\n+ with no activity. Remove stale label or comment or this PR will be closed in 10 days\n+ # Not stale if have this labels or part of milestone\n+ exempt-issue-labels: bug,wip,on-hold\n+ exempt-pr-labels: bug,wip,on-hold\n+ exempt-all-milestones: true\n+ # Close issue operations\n+ # Label will be automatically removed if the issues are no longer closed nor locked.\n+ days-before-close: 10\n+ delete-branch: true\n+ close-issue-message: This issue was automatically closed because of stale in 10 days\n+ close-pr-message: This PR was automatically closed because of stale in 10 days\n---\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.58.0\n+ rev: v1.62.3\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -23,6 +23,7 @@ repos:\n Release\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n - repo: https://github.com/pre-commit/pre-commit-hooks\n- rev: v4.0.1\n+ rev: v4.1.0\n hooks:\n - id: check-merge-conflict\n+ - id: end-of-file-fixer\n---\n.releaserc.json\n@@ -5,13 +5,22 @@\n ],\n \"ci\": false,\n \"plugins\": [\n- \"@semantic-release/commit-analyzer\",\n- \"@semantic-release/release-notes-generator\",\n+ [\n+ \"@semantic-release/commit-analyzer\",\n+ {\n+ \"preset\": \"conventionalcommits\"\n+ }\n+ ],\n+ [\n+ \"@semantic-release/release-notes-generator\",\n+ {\n+ \"preset\": \"conventionalcommits\"\n+ }\n+ ],\n [\n \"@semantic-release/github\",\n {\n- \"successComment\":\n- \"This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:\",\n+ \"successComment\": \"This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:\",\n \"labels\": false,\n \"releasedLabels\": false\n }\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nUpdate description of the `object_ownership` variable by adding information about the `BucketOwnerEnforced` option.\r\n\r\n## Motivation and Context\r\nOn November 30, 2021, Amazon announced a new S3 Object Ownership setting, `BucketOwnerEnforced`. \r\nRef. https://aws.amazon.com/about-aws/whats-new/2021/11/amazon-s3-object-ownership-simplify-access-management-data-s3/\r\n\r\n> Amazon S3 introduces a new S3 Object Ownership setting, Bucket owner enforced, that disables access control lists (ACLs), simplifying access management for data stored in S3. When you apply this bucket-level setting, every object in an S3 bucket is owned by the bucket owner, and ACLs are no longer used to grant permissions\r\n\r\nThe new setting already has been integrated into AWS provider in v.3.69.0\r\nRef. https://github.com/hashicorp/terraform-provider-aws/issues/21980\r\n\r\nAlso, we might consider setting the default value to the `BucketOwnerEnforced` as per AWS recommendation.\r\nRef. https://docs.aws.amazon.com/AmazonS3/latest/userguide/about-object-ownership.html\r\n\r\n## Breaking Changes\r\n\r\n## How Has This Been Tested?\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\nThe change has been tested in production _with_ updated AWS provider to v.3.69.0\r\n\n\n---\n\nChoice A:\nREADME.md\n@@ -108,13 +108,13 @@ inputs = {\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.64 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.69 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.64 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.69 |\n \n ## Modules\n \n@@ -158,7 +158,7 @@ No modules.\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n own <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n-| <a name=\"input_object_ownership\"></a> [object\\_ownership](#input\\_object\\_ownership) | Object ownership. Valid values: BucketOwnerPreferred or ObjectWriter. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL. | `string` | `\"ObjectWriter\"` | no |\n+| <a name=\"input_object_ownership\"></a> [object\\_ownership](#input\\_object\\_ownership) | Object ownership. Valid values: BucketOwnerEnforced, BucketOwnerPreferred or ObjectWriter. 'BucketOwnerEnforced': ACLs are disabled, and the bucket owner automatically owns and has full control over every object in the bucket. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL. | `string` | `\"ObjectWriter\"` | no |\n | <a name=\"input_policy\"></a> [policy](#input\\_policy) | (Optional) A valid bucket policy JSON document. Note that if the policy document is not specific enough (but still valid), Terraform may view the policy as constantly changing in a terraform plan. In this case, please make sure you use the verbose/specific version of the policy. For more information about building AWS IAM policy documents with Terraform, see the AWS IAM Policy Document Guide. | `string` | `null` | no |\n | <a name=\"input_replication_configuration\"></a> [replication\\_configuration](#input\\_replication\\_configuration) | Map containing cross-region replication configuration. | `any` | `{}` | no |\n | <a name=\"input_request_payer\"></a> [request\\_payer](#input\\_request\\_payer) | (Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information. | `string` | `null` | no |\n---\nexamples/s3-replication/README.md\n@@ -22,15 +22,15 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.64 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.69 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.64 |\n-| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.64 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.69 |\n+| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.69 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/s3-replication/versions.tf\n@@ -2,7 +2,7 @@ terraform {\n required_version = \">= 0.13.1\"\n \n required_providers {\n- aws = \">= 3.64\"\n+ aws = \">= 3.69\"\n random = \">= 2.0\"\n }\n }\n---\nvariables.tf\n@@ -167,7 +167,7 @@ variable \"control_object_ownership\" {\n }\n \n variable \"object_ownership\" {\n- description = \"Object ownership. Valid values: BucketOwnerPreferred or ObjectWriter. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL.\"\n+ description = \"Object ownership. Valid values: BucketOwnerEnforced, BucketOwnerPreferred or ObjectWriter. 'BucketOwnerEnforced': ACLs are disabled, and the bucket owner automatically owns and has full control over every object in the bucket. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL.\"\n type = string\n default = \"ObjectWriter\"\n }\n---\nversions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \">= 0.13.1\"\n \n required_providers {\n- aws = \">= 3.64\"\n+ aws = \">= 3.69\"\n }\n }\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -108,13 +108,13 @@ inputs = {\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.64 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.69 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.64 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.69 |\n \n ## Modules\n \n@@ -158,7 +158,7 @@ No modules.\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n-| <a name=\"input_object_ownership\"></a> [object\\_ownership](#input\\_object\\_ownership) | Object ownership. Valid values: BucketOwnerPreferred or ObjectWriter. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL. | `string` | `\"ObjectWriter\"` | no |\n+| <a name=\"input_object_ownership\"></a> [object\\_ownership](#input\\_object\\_ownership) | Object ownership. Valid values: BucketOwnerEnforced, BucketOwnerPreferred or ObjectWriter. 'BucketOwnerEnforced': ACLs are disabled, and the bucket owner automatically owns and has full control over every object in the bucket. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL. | `string` | `\"ObjectWriter\"` | no |\n | <a name=\"input_policy\"></a> [policy](#input\\_policy) | (Optional) A valid bucket policy JSON document. Note that if the policy document is not specific enough (but still valid), Terraform may view the policy as constantly changing in a terraform plan. In this case, please make sure you use the verbose/specific version of the policy. For more information about building AWS IAM policy documents with Terraform, see the AWS IAM Policy Document Guide. | `string` | `null` | no |\n | <a name=\"input_replication_configuration\"></a> [replication\\_configuration](#input\\_replication\\_configuration) | Map containing cross-region replication configuration. | `any` | `{}` | no |\n | <a name=\"input_request_payer\"></a> [request\\_payer](#input\\_request\\_payer) | (Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information. | `string` | `null` | no |\n---\nexamples/s3-replication/README.md\n@@ -22,15 +22,15 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 in <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.64 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.69 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.64 |\n-| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.64 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.69 |\n+| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.69 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/s3-replication/versions.tf\n@@ -2,7 +2,7 @@ terraform {\n required_version = \">= 0.13.1\"\n \n required_providers {\n- aws = \">= 3.64\"\n+ aws = \">= 3.69\"\n random = \">= 2.0\"\n }\n }\n---\nvariables.tf\n@@ -167,7 +167,7 @@ variable \"control_object_ownership\" {\n }\n \n variable \"object_ownership\" {\n- description = \"Object ownership. Valid values: BucketOwnerPreferred or ObjectWriter. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL.\"\n+ description = \"Object ownership. Valid values: BucketOwnerEnforced, BucketOwnerPreferred or ObjectWriter. 'BucketOwnerEnforced': ACLs are disabled, and the bucket owner automatically owns and has full control over every object in the bucket. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL.\"\n type = string\n default = \"ObjectWriter\"\n }\n---\nversions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \">= 0.13.1\"\n \n required_providers {\n- aws = \">= 3.64\"\n+ aws = \">= 3.69\"\n }\n }\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -108,13 +108,13 @@ inputs = {\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.64 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.69 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.64 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.69 |\n \n ## Modules\n \n@@ -158,7 +158,7 @@ No modules.\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n-| <a name=\"input_object_ownership\"></a> [object\\_ownership](#input\\_object\\_ownership) | Object ownership. Valid values: BucketOwnerPreferred or ObjectWriter. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL. | `string` | `\"ObjectWriter\"` | no |\n+| <a name=\"input_object_ownership\"></a> [object\\_ownership](#input\\_object\\_ownership) | Object ownership. Valid values: BucketOwnerEnforced, BucketOwnerPreferred or ObjectWriter. 'BucketOwnerEnforced': ACLs are disabled, and the bucket owner automatically owns and has full control over every object in the bucket. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL. | `string` | `\"ObjectWriter\"` | no |\n | <a name=\"input_policy\"></a> [policy](#input\\_policy) | (Optional) A valid bucket policy JSON document. Note that if the policy document is not specific enough (but still valid), Terraform may view the policy as constantly changing in a terraform plan. In this case, please make sure you use the verbose/specific version of the policy. For more information about building AWS IAM policy documents with Terraform, see the AWS IAM Policy Document Guide. | `string` | `null` | no |\n | <a name=\"input_replication_configuration\"></a> [replication\\_configuration](#input\\_replication\\_configuration) | Map containing cross-region replication configuration. | `any` | `{}` | no |\n | <a name=\"input_request_payer\"></a> [request\\_payer](#input\\_request\\_payer) | (Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information. | `string` | `null` | no |\n---\nexamples/s3-replication/README.md\n@@ -22,15 +22,15 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.64 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.69 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.64 |\n-| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.64 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.69 |\n+| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.69 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/s3-replication/versions.tf\n@@ -2,7 +2,7 @@ terraform {\n required_version = \">= 0.13.1\"\n \n required_providers {\n- aws = \">= 3.64\"\n+ aws = \">= 3.69\"\n random = \">= 2.0\"\n }\n }\n---\nvariables.tf\n@@ -167,7 +167,7 @@ variable \"control_object_ownership\" {\n }\n \n variable \"object_ownership\" {\n- description = \"Object ownership. Valid values: BucketOwnerPreferred or ObjectWriter. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL.\"\n+ description = \"Object ownership. Valid values: BucketOwnerEnforced, BucketOwnerPreferred or ObjectWriter. 'BucketOwnerEnforced': ACLs are disabled, and the bucket owner automatically owns and has full control over every object in the bucket. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL.\"\n type = string\n default = \"ObjectWriter\"\n }\n---\nversions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \">= 0.13.1\"\n \n required_providers {\n- aws = \">= 3.64\"\n+ aws = \">= 3.69\"\n }\n }\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -108,13 +108,13 @@ inputs = {\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.64 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.69 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.64 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.69 |\n \n ## Modules\n \n@@ -158,7 +158,7 @@ No modules.\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n-| <a name=\"input_object_ownership\"></a> [object\\_ownership](#input\\_object\\_ownership) | Object ownership. Valid values: BucketOwnerPreferred or ObjectWriter. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL. | `string` | `\"ObjectWriter\"` | no |\n+| <a name=\"input_object_ownership\"></a> [object\\_ownership](#input\\_object\\_ownership) | Object ownership. Valid values: BucketOwnerEnforced, BucketOwnerPreferred or ObjectWriter. 'BucketOwnerEnforced': ACLs are disabled, and the bucket owner automatically owns and has full control over every object in the bucket. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL. | `string` | Guide. | no |\n | <a name=\"input_policy\"></a> [policy](#input\\_policy) | (Optional) A valid bucket policy JSON document. Note that if the policy document is not specific enough (but still valid), Terraform may view the policy as constantly changing in a terraform plan. In this case, please make sure you use the verbose/specific version of the policy. For more information about building AWS IAM policy documents with Terraform, see the AWS IAM Policy Document Guide. | `string` | `null` | no |\n | <a name=\"input_replication_configuration\"></a> [replication\\_configuration](#input\\_replication\\_configuration) | Map containing cross-region replication configuration. | `any` | `{}` | no |\n | <a name=\"input_request_payer\"></a> [request\\_payer](#input\\_request\\_payer) | (Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information. | `string` | `null` | no |\n---\nexamples/s3-replication/README.md\n@@ -22,15 +22,15 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.64 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.69 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.64 |\n-| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.64 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.69 |\n+| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.69 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/s3-replication/versions.tf\n@@ -2,7 +2,7 @@ terraform {\n required_version = \">= 0.13.1\"\n \n required_providers {\n- aws = \">= 3.64\"\n+ aws = \">= 3.69\"\n random = \">= 2.0\"\n }\n }\n---\nvariables.tf\n@@ -167,7 +167,7 @@ variable \"control_object_ownership\" {\n }\n \n variable \"object_ownership\" {\n- description = \"Object ownership. Valid values: BucketOwnerPreferred or ObjectWriter. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL.\"\n+ description = \"Object ownership. Valid values: BucketOwnerEnforced, BucketOwnerPreferred or ObjectWriter. 'BucketOwnerEnforced': ACLs are disabled, and the bucket owner automatically owns and has full control over every object in the bucket. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL.\"\n type = string\n default = \"ObjectWriter\"\n }\n---\nversions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \">= 0.13.1\"\n \n required_providers {\n- aws = \">= 3.64\"\n+ aws = \">= 3.69\"\n }\n }\n---\n\n\n---\n" } ]
C
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n- update release configurations to match latest standard that is being used across all repos\r\n\r\n## Motivation and Context\r\n- standardize new CI workflow\r\n\r\n## Breaking Changes\r\n- No\r\n\r\n## How Has This Been Tested?\r\n- [x] https://github.com/terraform-aws-modules/terraform-aws-rds/pull/361\n\n---\n\nChoice A:\n.github/workflows/release.yml\n@@ -1,6 +1,7 @@\n name: Release\n \n on:\n+ workflow_dispatch:\n push:\n branches:\n - main\n---\n.pre-commit-config.yaml\n@@ -1,23 +1,6 @@\n repos:\n-# - repo: local # @todo: move to pre-commit-terraform, add support for multiple module dirs, and run before terraform_docs\n-# hooks:\n-# - id: terraform_wrapper\n-# name: \"Terraform module wrapper - root\"\n-# entry: /Users/Bob/Sites/terraform-aws-modules/scripts/generate-terraform-wrappers.sh --overwrite\n-# language: system\n-# pass_filenames: false\n-# - id: terraform_wrapper\n-# name: \"Terraform module wrapper - object\"\n-# entry: /Users/Bob/Sites/terraform-aws-modules/scripts/generate-terraform-wrappers.sh --module-dir modules/object --overwrite\n-# language: system\n-# pass_filenames: false\n-# - id: terraform_wrapper\n-# name: \"Terraform module wrapper - notification\"\n-# entry: /Users/Bob/Sites/terraform-aws-modules/scripts/generate-terraform-wrappers.sh --module-dir modules/notification --overwrite\n-# language: system\n-# pass_filenames: false\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.55.0\n+ rev: v1.58.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -43,4 +26,3 @@ repos:\n rev: v4.0.1\n hooks:\n - id: check-merge-conflict\n- - id: end-of-file-fixer\n---\n.releaserc.json\n@@ -7,12 +7,20 @@\n \"plugins\": [\n \"@semantic-release/commit-analyzer\",\n \"@semantic-release/release-notes-generator\",\n- \"@semantic-release/github\",\n+ [\n+ \"@semantic-release/github\",\n+ {\n+ \"successComment\":\n+ \"This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:\",\n+ \"labels\": false,\n+ \"releasedLabels\": false\n+ }\n+ ],\n [\n \"@semantic-release/changelog\",\n {\n \"changelogFile\": \"CHANGELOG.md\",\n- \"changelogTitle\": \"# Changelog\\n\\nAll notable changes to this project will be documented in this file\"\n+ \"changelogTitle\": \"# Changelog\\n\\nAll notable changes to this project will be documented in this file.\"\n }\n ],\n [\n---\n\n\n---\n\nChoice B:\n.github/workflows/release.yml\n@@ -1,6 +1,7 @@\n name: Release\n \n on:\n+ workflow_dispatch:\n push:\n branches:\n - main\n---\n.pre-commit-config.yaml\n@@ -1,23 +1,6 @@\n repos:\n-# - repo: local # @todo: move to pre-commit-terraform, add support for multiple module dirs, and run before terraform_docs\n-# hooks:\n-# - id: terraform_wrapper\n-# name: \"Terraform module wrapper - root\"\n-# entry: /Users/Bob/Sites/terraform-aws-modules/scripts/generate-terraform-wrappers.sh --overwrite\n-# language: system\n-# pass_filenames: false\n-# - id: terraform_wrapper\n-# name: \"Terraform module wrapper - object\"\n-# entry: /Users/Bob/Sites/terraform-aws-modules/scripts/generate-terraform-wrappers.sh --module-dir modules/object --overwrite\n-# language: system\n-# pass_filenames: false\n-# - id: terraform_wrapper\n-# name: \"Terraform module wrapper - notification\"\n-# entry: /Users/Bob/Sites/terraform-aws-modules/scripts/generate-terraform-wrappers.sh --module-dir modules/notification --overwrite\n-# language: system\n-# pass_filenames: false\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.55.0\n+ rev: v1.58.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -43,4 +26,3 @@ repos:\n rev: v4.0.1\n hooks:\n - id: check-merge-conflict\n- - id: end-of-file-fixer\n---\n.releaserc.json\n@@ -7,12 +7,20 @@\n \"plugins\": [\n \"@semantic-release/commit-analyzer\",\n \"@semantic-release/release-notes-generator\",\n- \"@semantic-release/github\",\n+ [\n+ \"@semantic-release/github\",\n+ {\n+ \"successComment\":\n+ \"This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:\",\n+ \"labels\": false,\n+ \"releasedLabels\": false\n+ }\n+ ],\n [\n \"@semantic-release/changelog\",\n {\n \"changelogFile\": \"CHANGELOG.md\",\n- \"changelogTitle\": \"# Changelog\\n\\nAll notable changes to this project will be documented in this file\"\n+ \"changelogTitle\": \"# Changelog\\n\\nAll notable changes to this project will be documented in this }\n ],\n [\n---\n\n\n---\n\nChoice C:\n.github/workflows/release.yml\n@@ -1,6 +1,7 @@\n name: Release\n \n on:\n+ workflow_dispatch:\n push:\n branches:\n - main\n---\n.pre-commit-config.yaml\n@@ -1,23 +1,6 @@\n repos:\n-# - repo: local # @todo: move to pre-commit-terraform, add support for multiple module dirs, and run before terraform_docs\n-# hooks:\n-# - id: terraform_wrapper\n-# name: \"Terraform module wrapper - root\"\n-# entry: /Users/Bob/Sites/terraform-aws-modules/scripts/generate-terraform-wrappers.sh --overwrite\n-# language: system\n-# pass_filenames: false\n-# - id: terraform_wrapper\n-# name: \"Terraform module wrapper - object\"\n-# entry: /Users/Bob/Sites/terraform-aws-modules/scripts/generate-terraform-wrappers.sh --module-dir modules/object --overwrite\n-# language: system\n-# pass_filenames: false\n-# - id: terraform_wrapper\n-# name: \"Terraform module wrapper - notification\"\n-# entry: /Users/Bob/Sites/terraform-aws-modules/scripts/generate-terraform-wrappers.sh --module-dir modules/notification --overwrite\n-# language: system\n-# pass_filenames: false\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.55.0\n+ rev: v1.58.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -43,4 +26,3 @@ repos:\n rev: v4.0.1\n hooks:\n - id: check-merge-conflict\n- - id: end-of-file-fixer\n---\n.releaserc.json\n@@ -7,12 +7,20 @@\n \"plugins\": [\n \"@semantic-release/commit-analyzer\",\n \"@semantic-release/release-notes-generator\",\n- \"@semantic-release/github\",\n+ [\n+ \"@semantic-release/github\",\n+ {\n+ \"successComment\":\n+ \"This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:\",\n+ \"labels\": false,\n+ \"releasedLabels\": false\n+ }\n+ ],\n [\n \"@semantic-release/changelog\",\n {\n \"changelogFile\": \"CHANGELOG.md\",\n- \"changelogTitle\": \"# Changelog\\n\\nAll notable changes to this project will be documented in this file\"\n+ \"changelogTitle\": \"# Changelog\\n\\nAll notable changes to this project will be documented in this file.\"\n }\n ],\n [\n---\n\n\n---\n\nChoice D:\n.github/workflows/release.yml\n@@ -1,6 +1,7 @@\n name: Release\n \n on:\n+ workflow_dispatch:\n push:\n branches:\n - main\n---\n.pre-commit-config.yaml\n@@ -1,23 +1,6 @@\n repos:\n-# - repo: local # @todo: move to pre-commit-terraform, add support for multiple module dirs, and run before terraform_docs\n-# hooks:\n-# - id: terraform_wrapper\n-# name: \"Terraform module wrapper - root\"\n-# entry: /Users/Bob/Sites/terraform-aws-modules/scripts/generate-terraform-wrappers.sh --overwrite\n-# language: system\n-# pass_filenames: false\n-# - id: terraform_wrapper\n-# name: \"Terraform module wrapper - object\"\n-# entry: /Users/Bob/Sites/terraform-aws-modules/scripts/generate-terraform-wrappers.sh --module-dir modules/object --overwrite\n-# language: system\n-# pass_filenames: false\n-# - id: terraform_wrapper\n-# name: \"Terraform module wrapper - notification\"\n-# entry: /Users/Bob/Sites/terraform-aws-modules/scripts/generate-terraform-wrappers.sh --module-dir modules/notification --overwrite\n-# language: system\n-# pass_filenames: false\n - repo: https://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.55.0\n+ rev: v1.58.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -43,4 +26,3 @@ repos:\n rev: v4.0.1\n hooks:\n - id: check-merge-conflict\n- - id: end-of-file-fixer\n---\n.releaserc.json\n@@ -7,12 +7,20 @@\n \"plugins\": [\n \"@semantic-release/commit-analyzer\",\n \"@semantic-release/release-notes-generator\",\n- \"@semantic-release/github\",\n+ [\n+ \"@semantic-release/github\",\n+ {\n+ \"successComment\":\n+ \"This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:\",\n+ \"labels\": false,\n+ \"releasedLabels\": false\n+ }\n+ ],\n [\n \"@semantic-release/changelog\",\n {\n \"changelogFile\": \"CHANGELOG.md\",\n- \"changelogTitle\": \"# Changelog\\n\\nAll notable changes to this project will be documented in this file\"\n+ \"changelogTitle\": \"# Changelog\\n\\nAll notable changes to this project will be documented in this file.\"\n }\n ],\n [\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n- add new hook to pre-commit to fix eof lines\r\n- add new `release.yml` workflow. this workflow will automatically:\r\n\t- create and push new tag for next [semver based on conventional-commits](https://github.com/semantic-release/semantic-release#commit-message-format)\r\n\t- create GitHub release with notes\r\n\t- update Changelog with release notes\r\n\t- this workflow will also automatically notify PRs that are included in the release, mimicking the manual behavior but now its automated https://github.com/clowdhaus/terraform-aws-rds/pull/1#issuecomment-952097291\r\n- remove old `chglog` configs and Makefile\r\n\r\n## Motivation and Context\r\n- automate release process in a standardized manner\r\n- standardize new CI workflow (copying from RDS)\r\n\r\n## Breaking Changes\r\n- No\r\n\r\n## How Has This Been Tested?\r\n- [x] https://github.com/terraform-aws-modules/terraform-aws-rds/pull/361\n\n---\n\nChoice A:\n.chglog/CHANGELOG.tpl.md\n@@ -1,111 +0,0 @@\n-# Change Log\n-\n-All notable changes to this project will be documented in this file.\n-\n-{{ if .Versions -}}\n-<a name=\"unreleased\"></a>\n-## [Unreleased]\n-{{ if .Unreleased.CommitGroups -}}\n-{{ range .Unreleased.CommitGroups -}}\n-### {{ .Title }}\n-{{ range .Commits -}}\n-{{/* SKIPPING RULES - START */ -}}\n-{{- if not (hasPrefix .Subject \"Updated CHANGELOG\") -}}\n-{{- if not (contains .Subject \"[ci skip]\") -}}\n-{{- if not (contains .Subject \"[skip ci]\") -}}\n-{{- if not (hasPrefix .Subject \"Merge pull request \") -}}\n-{{- if not (hasPrefix .Subject \"Added CHANGELOG\") -}}\n-{{- /* SKIPPING RULES - END */ -}}\n-- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}\n-{{/* SKIPPING RULES - START */ -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{/* SKIPPING RULES - END */ -}}\n-{{ end }}\n-{{ end -}}\n-{{ else }}\n-{{ range .Unreleased.Commits -}}\n-{{/* SKIPPING RULES - START */ -}}\n-{{- if not (hasPrefix .Subject \"Updated CHANGELOG\") -}}\n-{{- if not (contains .Subject \"[ci skip]\") -}}\n-{{- if not (contains .Subject \"[skip ci]\") -}}\n-{{- if not (hasPrefix .Subject \"Merge pull request \") -}}\n-{{- if not (hasPrefix .Subject \"Added CHANGELOG\") -}}\n-{{- /* SKIPPING RULES - END */ -}}\n-- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}\n-{{/* SKIPPING RULES - START */ -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{/* SKIPPING RULES - END */ -}}\n-{{ end }}\n-{{ end -}}\n-{{ end -}}\n-\n-{{ range .Versions }}\n-<a name=\"{{ .Tag.Name }}\"></a>\n-## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime \"2006-01-02\" .Tag.Date }}\n-{{ if .CommitGroups -}}\n-{{ range .CommitGroups -}}\n-### {{ .Title }}\n-{{ range .Commits -}}\n-{{/* SKIPPING RULES - START */ -}}\n-{{- if not (hasPrefix .Subject \"Updated CHANGELOG\") -}}\n-{{- if not (contains .Subject \"[ci skip]\") -}}\n-{{- if not (contains .Subject \"[skip ci]\") -}}\n-{{- if not (hasPrefix .Subject \"Merge pull request \") -}}\n-{{- if not (hasPrefix .Subject \"Added CHANGELOG\") -}}\n-{{- push:\n+ SKIPPING RULES - END */ -}}\n-- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}\n-{{/* SKIPPING RULES - START */ -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{/* SKIPPING RULES - END */ -}}\n-{{ end }}\n-{{ end -}}\n-{{ else }}\n-{{ range .Commits -}}\n-{{/* SKIPPING RULES - START */ -}}\n-{{- if not (hasPrefix .Subject \"Updated CHANGELOG\") -}}\n-{{- if not (contains .Subject \"[ci skip]\") -}}\n-{{- if not (contains .Subject \"[skip ci]\") -}}\n-{{- if not (hasPrefix .Subject \"Merge pull request \") -}}\n-{{- if not (hasPrefix .Subject \"Added CHANGELOG\") -}}\n-{{- /* SKIPPING RULES - END */ -}}\n-- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}\n-{{/* SKIPPING RULES - START */ -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{/* SKIPPING RULES - END */ -}}\n-{{ end }}\n-{{ end -}}\n-\n-{{- if .NoteGroups -}}\n-{{ range .NoteGroups -}}\n-### {{ .Title }}\n-{{ range .Notes }}\n-{{ .Body }}\n-{{ end }}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-\n-{{- if .Versions }}\n-[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD\n-{{ range .Versions -}}\n-{{ if .Tag.Previous -}}\n-[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n---\n.chglog/config.yml\n@@ -1,10 +0,0 @@\n-style: github\n-template: CHANGELOG.tpl.md\n-info:\n- title: CHANGELOG\n- repository_url: https://github.com/terraform-aws-modules/terraform-aws-s3-bucket\n-options:\n- header:\n- pattern: \"^(.*)$\"\n- pattern_maps:\n- - Subject\n---\n.github/workflows/release.yml\n@@ -0,0 +1,31 @@\n+name: Release\n+\n+on:\n+ push:\n+ branches:\n+ - main\n+ - master\n+ paths:\n+ - '**/*.py'\n+ - '**/*.tf'\n+\n+jobs:\n+ release:\n+ name: Release\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+ with:\n+ persist-credentials: false\n+ fetch-depth: 0\n+\n+ - name: Release\n+ uses: cycjimmy/semantic-release-action@v2\n+ with:\n+ semantic_version: 18.0.0\n+ extra_plugins: |\n+ @semantic-release/[email protected]\n+ @semantic-release/[email protected]\n+ env:\n+ GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}\n---\n.pre-commit-config.yaml\n@@ -43,3 +43,4 @@ repos:\n rev: v4.0.1\n hooks:\n - id: check-merge-conflict\n+ - id: end-of-file-fixer\n---\n.releaserc.json\n@@ -0,0 +1,28 @@\n+{\n+ \"branches\": [\n+ \"main\",\n+ \"master\"\n+ ],\n+ \"ci\": false,\n+ \"plugins\": [\n+ \"@semantic-release/commit-analyzer\",\n+ \"@semantic-release/release-notes-generator\",\n+ \"@semantic-release/github\",\n+ [\n+ \"@semantic-release/changelog\",\n+ {\n+ \"changelogFile\": \"CHANGELOG.md\",\n+ \"changelogTitle\": \"# Changelog\\n\\nAll notable changes to this project will be documented in this file\"\n+ }\n+ ],\n+ [\n+ \"@semantic-release/git\",\n+ {\n+ \"assets\": [\n+ \"CHANGELOG.md\"\n+ ],\n+ \"message\": \"chore(release): version ${nextRelease.version} [skip ci]\\n\\n${nextRelease.notes}\"\n+ }\n+ ]\n+ ]\n+}\n---\nCHANGELOG.md\n@@ -1,12 +1,3 @@\n-# Change Log\n-\n-All notable changes to this project will be documented in this file.\n-\n-<a name=\"unreleased\"></a>\n-## [Unreleased]\n-\n-\n-\n <a name=\"v2.11.0\"></a>\n ## [v2.11.0] - 2021-11-07\n \n---\nMakefile\n@@ -1,12 +0,0 @@\n-.PHONY: changelog release\n-\n-scope ?= \"minor\"\n-\n-changelog-unrelease:\n-\tgit-chglog --no-case -o CHANGELOG.md\n-\n-changelog:\n-\tgit-chglog --no-case -o CHANGELOG.md --next-tag `semtag final -s $(scope) -o -f`\n-\n-release:\n-\tsemtag final -s $(scope)\n---\nexamples/s3-replication/main.tf\n@@ -136,4 +136,4 @@ module \"s3_bucket\" {\n ]\n }\n \n-}\n\\ No newline at end of file\n+}\n---\n\n\n---\n\nChoice B:\n.chglog/CHANGELOG.tpl.md\n@@ -1,111 +0,0 @@\n-# Change Log\n-\n-All notable changes to this project will be documented in this file.\n-\n-{{ if .Versions -}}\n-<a name=\"unreleased\"></a>\n-## [Unreleased]\n-{{ if .Unreleased.CommitGroups -}}\n-{{ range .Unreleased.CommitGroups -}}\n-### {{ .Title }}\n-{{ range .Commits -}}\n-{{/* SKIPPING RULES - START */ -}}\n-{{- if not (hasPrefix .Subject \"Updated CHANGELOG\") -}}\n-{{- if not (contains .Subject \"[ci skip]\") -}}\n-{{- if not (contains .Subject \"[skip ci]\") -}}\n-{{- if not (hasPrefix .Subject \"Merge pull request \") -}}\n-{{- if not (hasPrefix .Subject \"Added CHANGELOG\") -}}\n-{{- /* SKIPPING RULES - END */ -}}\n-- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}\n-{{/* SKIPPING RULES - START */ -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{/* SKIPPING RULES - END */ -}}\n-{{ end }}\n-{{ end -}}\n-{{ else }}\n-{{ range .Unreleased.Commits -}}\n-{{/* SKIPPING RULES - START */ -}}\n-{{- if not (hasPrefix .Subject \"Updated CHANGELOG\") -}}\n-{{- if not (contains .Subject \"[ci skip]\") -}}\n-{{- if not (contains .Subject \"[skip ci]\") -}}\n-{{- if not (hasPrefix .Subject \"Merge pull request \") -}}\n-{{- if not (hasPrefix .Subject \"Added CHANGELOG\") -}}\n-{{- /* SKIPPING RULES - END */ -}}\n-- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}\n-{{/* SKIPPING RULES - START */ -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{/* SKIPPING RULES - END */ -}}\n-{{ end }}\n-{{ end -}}\n-{{ end -}}\n-\n-{{ range .Versions }}\n-<a name=\"{{ .Tag.Name }}\"></a>\n-## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime \"2006-01-02\" .Tag.Date }}\n-{{ if .CommitGroups -}}\n-{{ range .CommitGroups -}}\n-### {{ .Title }}\n-{{ range .Commits -}}\n-{{/* SKIPPING RULES - START */ -}}\n-{{- if not (hasPrefix .Subject \"Updated CHANGELOG\") -}}\n-{{- if not (contains .Subject \"[ci skip]\") -}}\n-{{- if not (contains .Subject \"[skip ci]\") -}}\n-{{- if not (hasPrefix .Subject \"Merge pull request \") -}}\n-{{- if not (hasPrefix .Subject \"Added CHANGELOG\") -}}\n-{{- /* SKIPPING RULES - END */ -}}\n-- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}\n-{{/* SKIPPING RULES - START */ -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{/* SKIPPING RULES - END */ -}}\n-{{ end }}\n-{{ end -}}\n-{{ else }}\n-{{ range .Commits -}}\n-{{/* SKIPPING RULES - START */ -}}\n-{{- if not (hasPrefix .Subject \"Updated CHANGELOG\") -}}\n-{{- if not (contains .Subject \"[ci skip]\") -}}\n-{{- if not (contains .Subject \"[skip ci]\") -}}\n-{{- if not (hasPrefix .Subject \"Merge pull request \") -}}\n-{{- if not (hasPrefix .Subject \"Added CHANGELOG\") -}}\n-{{- /* SKIPPING RULES - END */ -}}\n-- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}\n-{{/* SKIPPING RULES - START */ -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{/* SKIPPING RULES - END */ -}}\n-{{ end }}\n-{{ end -}}\n-\n-{{- if .NoteGroups -}}\n-{{ range .NoteGroups -}}\n-### {{ .Title }}\n-{{ range .Notes }}\n-{{ .Body }}\n-{{ end }}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-\n-{{- if .Versions }}\n-[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD\n-{{ range .Versions -}}\n-{{ if .Tag.Previous -}}\n-[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n---\n.chglog/config.yml\n@@ -1,10 +0,0 @@\n-style: github\n-template: CHANGELOG.tpl.md\n-info:\n- title: CHANGELOG\n- repository_url: https://github.com/terraform-aws-modules/terraform-aws-s3-bucket\n-options:\n- header:\n- pattern: \"^(.*)$\"\n- pattern_maps:\n- - Subject\n---\n.github/workflows/release.yml\n@@ -0,0 +1,31 @@\n+name: Release\n+\n+on:\n+ push:\n+ branches:\n+ - main\n+ - master\n+ paths:\n+ - '**/*.py'\n+ - '**/*.tf'\n+\n+jobs:\n+ release:\n+ name: Release\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+ with:\n+ persist-credentials: false\n+ fetch-depth: 0\n+\n+ - name: Release\n+ uses: cycjimmy/semantic-release-action@v2\n+ with:\n+ semantic_version: 18.0.0\n+ extra_plugins: |\n+ @semantic-release/[email protected]\n+ @semantic-release/[email protected]\n+ env:\n+ GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}\n---\n.pre-commit-config.yaml\n@@ -43,3 +43,4 @@ repos:\n rev: v4.0.1\n hooks:\n - id: check-merge-conflict\n+ - id: end-of-file-fixer\n---\n.releaserc.json\n@@ -0,0 +1,28 @@\n+{\n+ \"branches\": [\n+ \"main\",\n+ \"master\"\n+ ],\n+ \"ci\": false,\n+ \"plugins\": [\n+ \"@semantic-release/commit-analyzer\",\n+ \"@semantic-release/release-notes-generator\",\n+ \"@semantic-release/github\",\n+ [\n+ \"@semantic-release/changelog\",\n+ {\n+ \"changelogFile\": \"CHANGELOG.md\",\n+ \"changelogTitle\": \"# Changelog\\n\\nAll notable changes to this project will be documented in this file\"\n+ }\n+ ],\n+ [\n+ \"@semantic-release/git\",\n+ {\n+ \"assets\": [\n+ \"CHANGELOG.md\"\n+ ],\n+ \"message\": \"chore(release): version ${nextRelease.version} [skip ci]\\n\\n${nextRelease.notes}\"\n+ }\n+ ]\n+ ]\n+}\n---\nCHANGELOG.md\n@@ -1,12 +1,3 @@\n-# Change Log\n-\n-All notable changes to this project will be documented in this file.\n-\n-<a name=\"unreleased\"></a>\n-## [Unreleased]\n-\n-\n-\n <a name=\"v2.11.0\"></a>\n ## [v2.11.0] - 2021-11-07\n \n---\nMakefile\n@@ -1,12 +0,0 @@\n-.PHONY: changelog release\n-\n-scope ?= \"minor\"\n-\n-changelog-unrelease:\n-\tgit-chglog --no-case -o CHANGELOG.md\n-\n-changelog:\n-\tgit-chglog --no-case -o CHANGELOG.md --next-tag `semtag final -s $(scope) -o -f`\n-\n-release:\n-\tsemtag final -s $(scope)\n---\nexamples/s3-replication/main.tf\n@@ -136,4 +136,4 @@ module \"s3_bucket\" {\n ]\n }\n \n-}\n\\ No newline at end of file\n+}\n---\n\n\n---\n\nChoice C:\n.chglog/CHANGELOG.tpl.md\n@@ -1,111 +0,0 @@\n-# Change Log\n-\n-All notable changes to this project will be documented in this file.\n-\n-{{ if .Versions -}}\n-<a name=\"unreleased\"></a>\n-## [Unreleased]\n-{{ if .Unreleased.CommitGroups -}}\n-{{ range .Unreleased.CommitGroups -}}\n-### {{ .Title }}\n-{{ range .Commits -}}\n-{{/* SKIPPING RULES - START */ -}}\n-{{- if not (hasPrefix .Subject \"Updated CHANGELOG\") -}}\n-{{- if not (contains .Subject \"[ci skip]\") -}}\n-{{- if not (contains .Subject \"[skip ci]\") -}}\n-{{- if not (hasPrefix .Subject \"Merge pull request \") -}}\n-{{- if not (hasPrefix .Subject \"Added CHANGELOG\") -}}\n-{{- /* SKIPPING RULES - END */ -}}\n-- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}\n-{{/* SKIPPING RULES - START */ -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{/* SKIPPING RULES - END */ -}}\n-{{ end }}\n-{{ end -}}\n-{{ else }}\n-{{ range .Unreleased.Commits -}}\n-{{/* SKIPPING RULES - START */ -}}\n-{{- if not (hasPrefix .Subject \"Updated CHANGELOG\") -}}\n-{{- if not (contains .Subject \"[ci skip]\") -}}\n-{{- if not (contains .Subject \"[skip ci]\") -}}\n-{{- if not (hasPrefix .Subject \"Merge pull request \") -}}\n-{{- if not (hasPrefix .Subject \"Added CHANGELOG\") -}}\n-{{- /* SKIPPING RULES - END */ -}}\n-- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}\n-{{/* SKIPPING RULES - START */ -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{/* SKIPPING RULES - END */ -}}\n-{{ end }}\n-{{ end -}}\n-{{ end -}}\n-\n-{{ range .Versions }}\n-<a name=\"{{ .Tag.Name }}\"></a>\n-## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime \"2006-01-02\" .Tag.Date }}\n-{{ if .CommitGroups -}}\n-{{ range .CommitGroups -}}\n-### {{ .Title }}\n-{{ range .Commits -}}\n-{{/* SKIPPING RULES - START */ -}}\n-{{- if not (hasPrefix .Subject \"Updated CHANGELOG\") -}}\n-{{- if not (contains .Subject \"[ci skip]\") -}}\n-{{- if not (contains .Subject \"[skip ci]\") -}}\n-{{- if not (hasPrefix .Subject \"Merge pull request \") -}}\n-{{- if not (hasPrefix .Subject \"Added CHANGELOG\") -}}\n-{{- /* SKIPPING RULES - END */ -}}\n-- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}\n-{{/* SKIPPING RULES - START */ -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{/* SKIPPING RULES - END */ -}}\n-{{ end }}\n-{{ end -}}\n-{{ else }}\n-{{ range .Commits -}}\n-{{/* SKIPPING RULES - START */ -}}\n-{{- if not (hasPrefix .Subject \"Updated CHANGELOG\") -}}\n-{{- if not (contains .Subject \"[ci skip]\") -}}\n-{{- if not (contains .Subject \"[skip ci]\") -}}\n-{{- if not (hasPrefix .Subject \"Merge pull request \") -}}\n-{{- if not (hasPrefix .Subject \"Added CHANGELOG\") -}}\n-{{- /* SKIPPING RULES - END */ -}}\n-- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}\n-{{/* SKIPPING RULES - START */ -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{/* SKIPPING RULES - END */ -}}\n-{{ end }}\n-{{ end -}}\n-\n-{{- if .NoteGroups -}}\n-{{ range .NoteGroups -}}\n-### {{ .Title }}\n-{{ range .Notes }}\n-{{ .Body }}\n-{{ end }}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-\n-{{- if .Versions }}\n-[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD\n-{{ range .Versions -}}\n-{{ if .Tag.Previous -}}\n-[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n---\n.chglog/config.yml\n@@ -1,10 +0,0 @@\n-style: github\n-template: CHANGELOG.tpl.md\n-info:\n- title: CHANGELOG\n- repository_url: https://github.com/terraform-aws-modules/terraform-aws-s3-bucket\n-options:\n- header:\n- pattern: \"^(.*)$\"\n- pattern_maps:\n- - Subject\n---\n.github/workflows/release.yml\n@@ -0,0 +1,31 @@\n+name: Release\n+\n+on:\n+ push:\n+ branches:\n+ - main\n+ - master\n+ paths:\n+ - '**/*.py'\n+ - '**/*.tf'\n+\n+jobs:\n+ release:\n+ name: Release\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+ with:\n+ persist-credentials: false\n+ fetch-depth: 0\n+\n+ - name: Release\n+ uses: cycjimmy/semantic-release-action@v2\n+ with:\n+ semantic_version: 18.0.0\n+ extra_plugins: |\n+ @semantic-release/[email protected]\n+ @semantic-release/[email protected]\n+ env:\n+ GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}\n---\n.pre-commit-config.yaml\n@@ -43,3 +43,4 @@ repos:\n rev: v4.0.1\n hooks:\n - id: check-merge-conflict\n+ - id: end-of-file-fixer\n---\n.releaserc.json\n@@ -0,0 +1,28 @@\n+{\n+ \"branches\": [\n+ \"main\",\n+ \"master\"\n+ ],\n+ \"ci\": false,\n+ \"plugins\": [\n+ \"@semantic-release/commit-analyzer\",\n+ \"@semantic-release/release-notes-generator\",\n+ \"@semantic-release/github\",\n+ [\n+ \"@semantic-release/changelog\",\n+ {\n+ \"changelogFile\": \"CHANGELOG.md\",\n+ \"changelogTitle\": \"# Changelog\\n\\nAll notable changes to this project will be documented in this file\"\n+ }\n+ ],\n+ [\n+ \"@semantic-release/git\",\n+ {\n+ \"assets\": [\n+ \"CHANGELOG.md\"\n+ ],\n+ \"message\": \"chore(release): version ${nextRelease.version} [skip ci]\\n\\n${nextRelease.notes}\"\n+ }\n+ ]\n+ ]\n+}\n---\nCHANGELOG.md\n@@ -1,12 +1,3 @@\n-# Change Log\n-\n-All notable changes to this project will be documented in this file.\n-\n-<a name=\"unreleased\"></a>\n-## [Unreleased]\n-\n-\n-\n <a name=\"v2.11.0\"></a>\n ## [v2.11.0] - 2021-11-07\n \n---\nMakefile\n@@ -1,12 +0,0 @@\n-.PHONY: changelog release\n-\n-scope ?= \"minor\"\n-\n-changelog-unrelease:\n-\tgit-chglog --no-case -o CHANGELOG.md\n-\n-changelog:\n-\tgit-chglog --no-case -o CHANGELOG.md --next-tag `semtag final -s $(scope) -o -f`\n-\n-release:\n-\tsemtag final -s $(scope)\n---\nexamples/s3-replication/main.tf\n@@ -136,4 +136,4 @@ module \"s3_bucket\" {\n end ]\n }\n \n-}\n\\ No newline at end of file\n+}\n---\n\n\n---\n\nChoice D:\n.chglog/CHANGELOG.tpl.md\n@@ -1,111 +0,0 @@\n-# Change Log\n-\n-All notable changes to this project will be documented in this file.\n-\n-{{ if .Versions -}}\n-<a name=\"unreleased\"></a>\n-## [Unreleased]\n-{{ if .Unreleased.CommitGroups -}}\n-{{ range .Unreleased.CommitGroups -}}\n-### {{ .Title }}\n-{{ range .Commits -}}\n-{{/* SKIPPING RULES - START */ -}}\n-{{- if not (hasPrefix .Subject \"Updated CHANGELOG\") -}}\n-{{- if not (contains .Subject \"[ci skip]\") -}}\n-{{- if not (contains .Subject \"[skip ci]\") -}}\n-{{- if not (hasPrefix .Subject \"Merge pull request \") -}}\n-{{- if not (hasPrefix .Subject \"Added CHANGELOG\") -}}\n-{{- /* SKIPPING RULES - END */ -}}\n-- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}\n-{{/* SKIPPING RULES - START */ -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{/* SKIPPING RULES - END */ -}}\n-{{ end }}\n-{{ end -}}\n-{{ else }}\n-{{ range .Unreleased.Commits -}}\n-{{/* SKIPPING RULES - START */ -}}\n-{{- if not (hasPrefix .Subject \"Updated CHANGELOG\") -}}\n-{{- if not (contains .Subject \"[ci skip]\") -}}\n-{{- if not (contains .Subject \"[skip ci]\") -}}\n-{{- if not (hasPrefix .Subject \"Merge pull request \") -}}\n-{{- if not (hasPrefix .Subject \"Added CHANGELOG\") -}}\n-{{- /* SKIPPING RULES - END */ -}}\n-- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}\n-{{/* SKIPPING RULES - START */ -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{/* SKIPPING RULES - END */ -}}\n-{{ end }}\n-{{ end -}}\n-{{ end -}}\n-\n-{{ range .Versions }}\n-<a name=\"{{ .Tag.Name }}\"></a>\n-## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime \"2006-01-02\" .Tag.Date }}\n-{{ if .CommitGroups -}}\n-{{ range .CommitGroups -}}\n-### {{ .Title }}\n-{{ range .Commits -}}\n-{{/* SKIPPING RULES - START */ -}}\n-{{- if not (hasPrefix .Subject \"Updated CHANGELOG\") -}}\n-{{- if not (contains .Subject \"[ci skip]\") -}}\n-{{- if not (contains .Subject \"[skip ci]\") -}}\n-{{- if not (hasPrefix .Subject \"Merge pull request \") -}}\n-{{- if not (hasPrefix .Subject \"Added CHANGELOG\") -}}\n-{{- /* SKIPPING RULES - END */ -}}\n-- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}\n-{{/* SKIPPING RULES - START */ -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{/* SKIPPING RULES - END */ -}}\n-{{ end }}\n-{{ end -}}\n-{{ else }}\n-{{ range .Commits -}}\n-{{/* SKIPPING RULES - START */ -}}\n-{{- if not (hasPrefix .Subject \"Updated CHANGELOG\") -}}\n-{{- if not (contains .Subject \"[ci skip]\") -}}\n-{{- if not (contains .Subject \"[skip ci]\") -}}\n-{{- if not (hasPrefix .Subject \"Merge pull request \") -}}\n-{{- if not (hasPrefix .Subject \"Added CHANGELOG\") -}}\n-{{- /* SKIPPING RULES - END */ -}}\n-- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}\n-{{/* SKIPPING RULES - START */ -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-{{/* SKIPPING RULES - END */ -}}\n-{{ end }}\n-{{ end -}}\n-\n-{{- if .NoteGroups -}}\n-{{ range .NoteGroups -}}\n-### {{ .Title }}\n-{{ range .Notes }}\n-{{ .Body }}\n-{{ end }}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n-\n-{{- if .Versions }}\n-[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD\n-{{ range .Versions -}}\n-{{ if .Tag.Previous -}}\n-[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}\n-{{ end -}}\n-{{ end -}}\n-{{ end -}}\n---\n.chglog/config.yml\n@@ -1,10 +0,0 @@\n-style: github\n-template: CHANGELOG.tpl.md\n-info:\n- title: CHANGELOG\n- repository_url: https://github.com/terraform-aws-modules/terraform-aws-s3-bucket\n-options:\n- header:\n- pattern: \"^(.*)$\"\n- pattern_maps:\n- - Subject\n---\n.github/workflows/release.yml\n@@ -0,0 +1,31 @@\n+name: Release\n+\n+on:\n+ push:\n+ branches:\n+ - main\n+ - master\n+ paths:\n+ - '**/*.py'\n+ - '**/*.tf'\n+\n+jobs:\n+ release:\n+ name: Release\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+ with:\n+ persist-credentials: false\n+ skip]\") fetch-depth: 0\n+\n+ - name: Release\n+ uses: cycjimmy/semantic-release-action@v2\n+ with:\n+ semantic_version: 18.0.0\n+ extra_plugins: |\n+ @semantic-release/[email protected]\n+ @semantic-release/[email protected]\n+ env:\n+ GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}\n---\n.pre-commit-config.yaml\n@@ -43,3 +43,4 @@ repos:\n rev: v4.0.1\n hooks:\n - id: check-merge-conflict\n+ - id: end-of-file-fixer\n---\n.releaserc.json\n@@ -0,0 +1,28 @@\n+{\n+ \"branches\": [\n+ \"main\",\n+ \"master\"\n+ ],\n+ \"ci\": false,\n+ \"plugins\": [\n+ \"@semantic-release/commit-analyzer\",\n+ \"@semantic-release/release-notes-generator\",\n+ \"@semantic-release/github\",\n+ [\n+ \"@semantic-release/changelog\",\n+ {\n+ \"changelogFile\": \"CHANGELOG.md\",\n+ \"changelogTitle\": \"# Changelog\\n\\nAll notable changes to this project will be documented in this file\"\n+ }\n+ ],\n+ [\n+ \"@semantic-release/git\",\n+ {\n+ \"assets\": [\n+ \"CHANGELOG.md\"\n+ ],\n+ \"message\": \"chore(release): version ${nextRelease.version} [skip ci]\\n\\n${nextRelease.notes}\"\n+ }\n+ ]\n+ ]\n+}\n---\nCHANGELOG.md\n@@ -1,12 +1,3 @@\n-# Change Log\n-\n-All notable changes to this project will be documented in this file.\n-\n-<a name=\"unreleased\"></a>\n-## [Unreleased]\n-\n-\n-\n <a name=\"v2.11.0\"></a>\n ## [v2.11.0] - 2021-11-07\n \n---\nMakefile\n@@ -1,12 +0,0 @@\n-.PHONY: changelog release\n-\n-scope ?= \"minor\"\n-\n-changelog-unrelease:\n-\tgit-chglog --no-case -o CHANGELOG.md\n-\n-changelog:\n-\tgit-chglog --no-case -o CHANGELOG.md --next-tag `semtag final -s $(scope) -o -f`\n-\n-release:\n-\tsemtag final -s $(scope)\n---\nexamples/s3-replication/main.tf\n@@ -136,4 +136,4 @@ module \"s3_bucket\" {\n ]\n }\n \n-}\n\\ No newline at end of file\n+}\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nThis change is about taking into account the recent enhancement of the AWS Terraform Provider which now allows to set S3 Replication Time Control (RTC)\r\n\r\n## Motivation and Context\r\nThanks to this enhancement, we will be able to provision S3 Bucket Replication Configurations with SLAs and Metrics on the Replication itself from this terraform module.\r\nIt's the reflection on the module of the closure of the following issue : https://github.com/hashicorp/terraform-provider-aws/issues/10974\r\n\r\n## Breaking Changes\r\nThere is no breaking change since I have just added the right attributes on the Replication configuration which are read from user input in the destination block of the replication_configuration attribute.\r\n\r\n## How Has This Been Tested?\r\n- [X ] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n\r\nI have adapted the s3-replication example by adding the right input and I was able to successfully see metrics on the AWS S3 Bucket Console.\r\n\r\nThere was no need to add any control over user input since AWS API provides meaningful error messages in case user input is wrong :\r\n\r\n│ Error: expected replication_configuration.0.rules.0.destination.0.replication_time.0.minutes to be in the range (15 - 15), got 16\r\n│\r\n│ with module.s3_bucket.aws_s3_bucket.this[0],\r\n│ on ../../main.tf line 5, in resource \"aws_s3_bucket\" \"this\":\r\n│ 5: resource \"aws_s3_bucket\" \"this\" {\r\n│\r\n\r\n│ Error: expected replication_configuration.0.rules.0.destination.0.replication_time.0.status to be one of [Enabled Disabled], got yes\r\n│\r\n│ with module.s3_bucket.aws_s3_bucket.this[0],\r\n│ on ../../main.tf line 5, in resource \"aws_s3_bucket\" \"this\":\r\n│ 5: resource \"aws_s3_bucket\" \"this\" {\r\n│\r\n\r\n│ Error: expected replication_configuration.0.rules.0.destination.0.metrics.0.minutes to be in the range (10 - 15), got 16\r\n│\r\n│ with module.s3_bucket.aws_s3_bucket.this[0],\r\n│ on ../../main.tf line 5, in resource \"aws_s3_bucket\" \"this\":\r\n│ 5: resource \"aws_s3_bucket\" \"this\" {\r\n│\r\n\r\n│ Error: expected replication_configuration.0.rules.0.destination.0.metrics.0.status to be one of [Enabled Disabled], got true\r\n│\r\n│ with module.s3_bucket.aws_s3_bucket.this[0],\r\n│ on ../../main.tf line 5, in resource \"aws_s3_bucket\" \"this\":\r\n│ 5: resource \"aws_s3_bucket\" \"this\" {\r\n│\r\n\r\nIn this case the module users, will be easily able to correct their input to feed with the right values.\r\n\r\nI have also ran pre-commit hooks as per the original pre-commit config file.\r\n\r\nThanks again for your review and feedback.\r\n\r\nBests.\n\n---\n\nChoice A:\n.pre-commit-config.yaml\n@@ -16,8 +16,8 @@ repos:\n # entry: /Users/Bob/Sites/terraform-aws-modules/scripts/generate-terraform-wrappers.sh --module-dir modules/notification --overwrite\n # language: system\n # pass_filenames: false\n- - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.50.0\n+ - repo: https://github.com/antonbabenko/pre-commit-terraform\n+ rev: v1.55.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -37,7 +37,7 @@ repos:\n - '--args=--only=terraform_required_providers'\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n- - repo: git://github.com/pre-commit/pre-commit-hooks\n- rev: v3.4.0\n+ - repo: https://github.com/pre-commit/pre-commit-hooks\n+ rev: v4.0.1\n hooks:\n - id: check-merge-conflict\n---\nREADME.md\n@@ -108,13 +108,13 @@ inputs = {\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.64 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.64 |\n \n ## Modules\n \n---\nexamples/s3-replication/README.md\n@@ -22,15 +22,15 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.64 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n-| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.50 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.64 |\n+| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.64 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/s3-replication/main.tf\n@@ -83,6 +83,14 @@ module \"s3_bucket\" {\n access_control_translation = {\n owner = \"Destination\"\n }\n+ replication_time = {\n+ status = \"Enabled\"\n+ minutes = 15\n+ }\n+ metrics = {\n+ status = \"Enabled\"\n+ minutes = 15\n+ }\n }\n },\n {\n@@ -128,4 +136,4 @@ module \"s3_bucket\" {\n ]\n }\n \n-}\n+}\n\\ No newline at end of file\n---\nexamples/s3-replication/versions.tf\n@@ -2,7 +2,7 @@ terraform {\n required_version = \">= 0.13.1\"\n \n required_providers {\n- aws = \">= 3.50\"\n+ aws = \">= 3.64\"\n random = \">= 2.0\"\n }\n }\n---\nmain.tf\n@@ -154,6 +154,24 @@ resource \"aws_s3_bucket\" \"this\" {\n owner = access_control_translation.value.owner\n }\n }\n+\n+ dynamic \"replication_time\" {\n+ for_each = length(keys(lookup(destination.value, \"replication_time\", {}))) == 0 ? [] : [lookup(destination.value, \"replication_time\", {})]\n+\n+ content {\n+ status = replication_time.value.status\n+ minutes = replication_time.value.minutes\n+ }\n+ }\n+\n+ dynamic \"metrics\" {\n+ for_each = length(keys(lookup(destination.value, \"metrics\", {}))) == 0 ? [] : [lookup(destination.value, \"metrics\", {})]\n+\n+ content {\n+ status = metrics.value.status\n+ minutes = metrics.value.minutes\n+ }\n+ }\n }\n }\n \n---\nversions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \">= 0.13.1\"\n \n required_providers {\n- aws = \">= 3.50\"\n+ aws = \">= 3.64\"\n }\n }\n---\nwrappers/README.md\n@@ -28,7 +28,7 @@ inputs = {\n }\n ```\n \n-## Usage with Terraform:\n+## Usage with Terraform\n \n ```hcl\n module \"wrapper\" {\n---\nwrappers/main.tf\n@@ -30,4 +30,6 @@ module \"wrapper\" {\n block_public_policy = lookup(each.value, \"block_public_policy\", false)\n ignore_public_acls = lookup(each.value, \"ignore_public_acls\", false)\n restrict_public_buckets = lookup(each.value, \"restrict_public_buckets\", false)\n+ control_object_ownership = lookup(each.value, \"control_object_ownership\", false)\n+ object_ownership = lookup(each.value, \"object_ownership\", \"ObjectWriter\")\n }\n---\nwrappers/notification/README.md\n@@ -6,7 +6,7 @@ You may want to use a single Terragrunt configuration file to manage multiple re\n \n This wrapper does not implement any extra functionality.\n \n-# Usage with Terragrunt\n+## Usage with Terragrunt\n \n `terragrunt.hcl`:\n \n@@ -28,7 +28,7 @@ inputs = {\n }\n ```\n \n-## Usage with Terraform:\n+## Usage with Terraform\n \n ```hcl\n module \"wrapper\" {\n---\nwrappers/object/README.md\n@@ -6,7 +6,7 @@ You may want to use a single Terragrunt configuration file to manage multiple re\n \n This wrapper does not implement any extra functionality.\n \n-# Usage with Terragrunt\n+## Usage with Terragrunt\n \n `terragrunt.hcl`:\n \n@@ -28,7 +28,7 @@ inputs = {\n }\n ```\n \n-## Usage with Terraform:\n+## Usage with Terraform\n \n ```hcl\n module \"wrapper\" {\n---\n\n\n---\n\nChoice B:\n.pre-commit-config.yaml\n@@ -16,8 +16,8 @@ repos:\n # entry: /Users/Bob/Sites/terraform-aws-modules/scripts/generate-terraform-wrappers.sh --module-dir modules/notification --overwrite\n # language: system\n # pass_filenames: false\n- - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.50.0\n+ - repo: https://github.com/antonbabenko/pre-commit-terraform\n+ rev: v1.55.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -37,7 +37,7 @@ repos:\n - '--args=--only=terraform_required_providers'\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n- - repo: git://github.com/pre-commit/pre-commit-hooks\n- rev: v3.4.0\n+ - repo: https://github.com/pre-commit/pre-commit-hooks\n+ rev: v4.0.1\n hooks:\n - id: check-merge-conflict\n---\nREADME.md\n@@ -108,13 +108,13 @@ inputs = {\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.64 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.64 |\n \n ## Modules\n \n---\nexamples/s3-replication/README.md\n@@ -22,15 +22,15 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.64 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n-| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.50 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.64 |\n+| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.64 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/s3-replication/main.tf\n@@ -83,6 +83,14 @@ module \"s3_bucket\" {\n access_control_translation = {\n owner = \"Destination\"\n }\n+ replication_time = {\n+ status = \"Enabled\"\n+ minutes = 15\n+ }\n+ metrics = {\n+ status = \"Enabled\"\n+ minutes = 15\n+ }\n }\n },\n {\n@@ -128,4 +136,4 @@ module \"s3_bucket\" {\n ]\n }\n \n-}\n+}\n\\ No newline at end of file\n---\nexamples/s3-replication/versions.tf\n@@ -2,7 +2,7 @@ terraform {\n required_version = \">= 0.13.1\"\n \n required_providers {\n- aws = \">= 3.50\"\n+ aws = \">= 3.64\"\n random = \">= 2.0\"\n }\n }\n---\nmain.tf\n@@ -154,6 +154,24 @@ resource \"aws_s3_bucket\" \"this\" {\n owner = access_control_translation.value.owner\n }\n }\n+\n+ dynamic \"replication_time\" {\n+ for_each = length(keys(lookup(destination.value, \"replication_time\", {}))) == 0 ? [] : [lookup(destination.value, \"replication_time\", {})]\n+\n+ content {\n+ status = replication_time.value.status\n+ minutes = replication_time.value.minutes\n+ }\n+ }\n+\n+ dynamic \"metrics\" {\n+ for_each = length(keys(lookup(destination.value, \"metrics\", {}))) == 0 ? [] : [lookup(destination.value, \"metrics\", {})]\n+\n+ content {\n+ status = metrics.value.status\n+ minutes = metrics.value.minutes\n+ }\n+ }\n }\n }\n \n---\nversions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \">= 0.13.1\"\n \n required_providers {\n- aws = \">= 3.50\"\n+ aws = \">= 3.64\"\n }\n }\n---\nwrappers/README.md\n@@ -28,7 +28,7 @@ inputs = {\n }\n ```\n \n-## Usage with Terraform:\n+## Usage with Terraform\n \n ```hcl\n module \"wrapper\" {\n---\nwrappers/main.tf\n@@ -30,4 +30,6 @@ module \"wrapper\" {\n block_public_policy = lookup(each.value, \"block_public_policy\", false)\n ignore_public_acls = lookup(each.value, \"ignore_public_acls\", false)\n restrict_public_buckets = lookup(each.value, \"restrict_public_buckets\", false)\n+ control_object_ownership = lookup(each.value, \"control_object_ownership\", false)\n+ object_ownership = lookup(each.value, \"object_ownership\", \"ObjectWriter\")\n }\n---\nwrappers/notification/README.md\n@@ -6,7 +6,7 @@ You may want to use a single Terragrunt configuration file to manage multiple re\n \n This wrapper does not implement any extra functionality.\n \n-# Usage with Terragrunt\n+## Usage with Terragrunt\n \n `terragrunt.hcl`:\n \n@@ -28,7 +28,7 @@ inputs = {\n }\n ```\n \n-## Usage with Terraform:\n+## Usage with Terraform\n \n ```hcl\n module \"wrapper\" {\n---\nwrappers/object/README.md\n@@ -6,7 +6,7 @@ You may want to use a single Terragrunt configuration file to manage multiple re\n \n This wrapper does not implement any extra functionality.\n \n-# Usage with Terragrunt\n+## Usage with Terragrunt\n \n `terragrunt.hcl`:\n \n@@ -28,7 +28,7 @@ inputs = {\n }\n ```\n \n-## Usage with Terraform:\n+## Usage with Terraform\n \n ```hcl\n module \"wrapper\" {\n---\n\n\n---\n\nChoice C:\n.pre-commit-config.yaml\n@@ -16,8 +16,8 @@ repos:\n # entry: /Users/Bob/Sites/terraform-aws-modules/scripts/generate-terraform-wrappers.sh --module-dir modules/notification --overwrite\n # language: system\n # pass_filenames: false\n- - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.50.0\n+ - repo: https://github.com/antonbabenko/pre-commit-terraform\n+ rev: v1.55.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -37,7 +37,7 @@ repos:\n - '--args=--only=terraform_required_providers'\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n- - repo: git://github.com/pre-commit/pre-commit-hooks\n- rev: v3.4.0\n+ - repo: https://github.com/pre-commit/pre-commit-hooks\n+ rev: v4.0.1\n hooks:\n - id: check-merge-conflict\n---\nREADME.md\n@@ -108,13 +108,13 @@ inputs = {\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.64 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.64 |\n \n ## Modules\n \n---\nexamples/s3-replication/README.md\n@@ -22,15 +22,15 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.64 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n-| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.50 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.64 |\n+| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.64 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/s3-replication/main.tf\n@@ -83,6 +83,14 @@ module \"s3_bucket\" {\n access_control_translation = {\n owner = \"Destination\"\n }\n+ replication_time = {\n+ status = \"Enabled\"\n+ minutes = 15\n+ }\n+ metrics = {\n+ status = \"Enabled\"\n+ minutes = 15\n+ }\n }\n },\n {\n@@ -128,4 +136,4 @@ module \"s3_bucket\" {\n ]\n }\n \n-}\n+}\n\\ No newline at end of file\n---\nexamples/s3-replication/versions.tf\n@@ -2,7 +2,7 @@ terraform {\n required_version = \">= 0.13.1\"\n \n required_providers {\n- aws = \">= 3.50\"\n+ aws = \">= 3.64\"\n random = \">= 2.0\"\n }\n }\n---\nmain.tf\n@@ -154,6 +154,24 @@ resource \"aws_s3_bucket\" \"this\" {\n owner = access_control_translation.value.owner\n }\n }\n+\n+ dynamic \"replication_time\" {\n+ for_each = length(keys(lookup(destination.value, \"replication_time\", {}))) == 0 ? [] : [lookup(destination.value, \"replication_time\", {})]\n+\n+ content {\n+ status = replication_time.value.status\n+ minutes = replication_time.value.minutes\n+ }\n+ }\n+\n+ dynamic \"metrics\" {\n+ for_each = length(keys(lookup(destination.value, \"metrics\", {}))) == 0 ? [] : [lookup(destination.value, \"metrics\", {})]\n+\n+ content {\n+ status = metrics.value.status\n+ minutes = metrics.value.minutes\n+ }\n+ }\n }\n }\n \n---\nversions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \">= 0.13.1\"\n \n required_providers {\n- aws = \">= 3.50\"\n+ aws = \">= 3.64\"\n }\n }\n---\nwrappers/README.md\n@@ -28,7 +28,7 @@ inputs = {\n }\n ```\n \n-## Usage with Terraform:\n+## Usage with Terraform\n \n ```hcl\n module \"wrapper\" {\n---\nwrappers/main.tf\n@@ -30,4 +30,6 @@ module \"wrapper\" {\n block_public_policy = lookup(each.value, \"block_public_policy\", false)\n ignore_public_acls = lookup(each.value, \"ignore_public_acls\", false)\n restrict_public_buckets = lookup(each.value, \"restrict_public_buckets\", false)\n+ control_object_ownership = lookup(each.value, \"control_object_ownership\", false)\n+ object_ownership = lookup(each.value, \"object_ownership\", \"ObjectWriter\")\n }\n---\nwrappers/notification/README.md\n@@ -6,7 +6,7 @@ You may want to use a single Terragrunt configuration file to manage multiple re\n \n This wrapper does not implement any extra functionality.\n \n-# Usage with Terragrunt\n+## Usage with Terragrunt\n \n `terragrunt.hcl`:\n \n@@ -28,7 +28,7 @@ inputs = {\n }\n ```\n \n-## Usage with Terraform:\n+## Usage with Terraform\n \n ```hcl\n module \"wrapper\" {\n---\nwrappers/object/README.md\n@@ -6,7 +6,7 @@ You may want to use a single Terragrunt configuration file to manage multiple re\n \n This wrapper does not implement any extra functionality.\n \n-# Usage with Terragrunt\n+## Usage with Terragrunt\n \n `terragrunt.hcl`:\n \n@@ -28,7 +28,7 @@ inputs = {\n }\n ```\n \n-## Usage with Terraform:\n+## Usage with Terraform\n \n ```hcl\n module \"wrapper\" {\n---\n\n\n---\n\nChoice D:\n.pre-commit-config.yaml\n@@ -16,8 +16,8 @@ repos:\n # entry: /Users/Bob/Sites/terraform-aws-modules/scripts/generate-terraform-wrappers.sh --module-dir modules/notification --overwrite\n # language: system\n # pass_filenames: false\n- - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.50.0\n+ - repo: https://github.com/antonbabenko/pre-commit-terraform\n+ rev: v1.55.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n@@ -37,7 +37,7 @@ repos:\n - '--args=--only=terraform_required_providers'\n - '--args=--only=terraform_standard_module_structure'\n - '--args=--only=terraform_workspace_remote'\n- - repo: git://github.com/pre-commit/pre-commit-hooks\n- rev: v3.4.0\n+ - repo: https://github.com/pre-commit/pre-commit-hooks\n+ rev: v4.0.1\n hooks:\n - id: check-merge-conflict\n---\nREADME.md\n@@ -108,13 +108,13 @@ inputs = {\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.64 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.64 |\n \n ## Modules\n \n---\nexamples/s3-replication/README.md\n@@ -22,15 +22,15 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.64 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n-| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.50 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.64 |\n+| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.64 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/s3-replication/main.tf\n@@ -83,6 +83,14 @@ module \"s3_bucket\" {\n access_control_translation = {\n owner = \"Destination\"\n }\n+ want replication_time = {\n+ status = \"Enabled\"\n+ minutes = 15\n+ }\n+ metrics = {\n+ status = \"Enabled\"\n+ minutes = 15\n+ }\n }\n },\n {\n@@ -128,4 +136,4 @@ module \"s3_bucket\" {\n ]\n }\n \n-}\n+}\n\\ No newline at end of file\n---\nexamples/s3-replication/versions.tf\n@@ -2,7 +2,7 @@ terraform {\n required_version = \">= 0.13.1\"\n \n required_providers {\n- aws = \">= 3.50\"\n+ aws = \">= 3.64\"\n random = \">= 2.0\"\n }\n }\n---\nmain.tf\n@@ -154,6 +154,24 @@ resource \"aws_s3_bucket\" \"this\" {\n owner = access_control_translation.value.owner\n }\n }\n+\n+ dynamic \"replication_time\" {\n+ for_each = length(keys(lookup(destination.value, \"replication_time\", {}))) == 0 ? [] : [lookup(destination.value, \"replication_time\", {})]\n+\n+ content {\n+ status = replication_time.value.status\n+ minutes = replication_time.value.minutes\n+ }\n+ }\n+\n+ dynamic \"metrics\" {\n+ for_each = length(keys(lookup(destination.value, \"metrics\", {}))) == 0 ? [] : [lookup(destination.value, \"metrics\", {})]\n+\n+ content {\n+ status = metrics.value.status\n+ minutes = metrics.value.minutes\n+ }\n+ }\n }\n }\n \n---\nversions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \">= 0.13.1\"\n \n required_providers {\n- aws = \">= 3.50\"\n+ aws = \">= 3.64\"\n }\n }\n---\nwrappers/README.md\n@@ -28,7 +28,7 @@ inputs = {\n }\n ```\n \n-## Usage with Terraform:\n+## Usage with Terraform\n \n ```hcl\n module \"wrapper\" {\n---\nwrappers/main.tf\n@@ -30,4 +30,6 @@ module \"wrapper\" {\n block_public_policy = lookup(each.value, \"block_public_policy\", false)\n ignore_public_acls = lookup(each.value, \"ignore_public_acls\", false)\n restrict_public_buckets = lookup(each.value, \"restrict_public_buckets\", false)\n+ control_object_ownership = lookup(each.value, \"control_object_ownership\", false)\n+ object_ownership = lookup(each.value, \"object_ownership\", \"ObjectWriter\")\n }\n---\nwrappers/notification/README.md\n@@ -6,7 +6,7 @@ You may want to use a single Terragrunt configuration file to manage multiple re\n \n This wrapper does not implement any extra functionality.\n \n-# Usage with Terragrunt\n+## Usage with Terragrunt\n \n `terragrunt.hcl`:\n \n@@ -28,7 +28,7 @@ inputs = {\n }\n ```\n \n-## Usage with Terraform:\n+## Usage with Terraform\n \n ```hcl\n module \"wrapper\" {\n---\nwrappers/object/README.md\n@@ -6,7 +6,7 @@ You may want to use a single Terragrunt configuration file to manage multiple re\n \n This wrapper does not implement any extra functionality.\n \n-# Usage with Terragrunt\n+## Usage with Terragrunt\n \n `terragrunt.hcl`:\n \n@@ -28,7 +28,7 @@ inputs = {\n }\n ```\n \n-## Usage with Terraform:\n+## Usage with Terraform\n \n ```hcl\n module \"wrapper\" {\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nUses the new data resource for aws_cloudfront_log_delivery_canonical_user_id that provides this field instead of using the hardcoded value.\r\n\r\n## Motivation and Context\r\nPer this github issue: https://github.com/hashicorp/terraform-provider-aws/issues/12512 which has now been solved we can use this resource to provide this ID.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? --> Will need to update provider to v3.6\r\n<!-- If so, please provide an explanation why it is necessary. --> The most recent provider has this data block\r\n\r\n## How Has This Been Tested?\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n<!--- Please describe in detail how you tested your changes. -->\r\n<!--- Include details of your testing environment, and the tests you ran to -->\r\n<!--- see how your change affects other areas of the code, etc. -->\r\n\r\nI created this on my local by running terraform plan and apply and destroy to create the new bucket which was successfully created in AWS. To test cloudfront I have used this fork and have successfully received logs in s3.\r\n\n\n---\n\nChoice A:\nREADME.md\n@@ -107,7 +107,7 @@ inputs = {\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n \n ## Providers\n---\nexamples/complete/README.md\n@@ -29,15 +29,15 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.60 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.60 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n@@ -56,6 +56,7 @@ Note that this example may create resources which cost money. Run `terraform des\n | [aws_kms_key.objects](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource |\n | [random_pet.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | resource |\n | [aws_canonical_user_id.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/canonical_user_id) | data source |\n+| [aws_cloudfront_log_delivery_canonical_user_id.cloudfront](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/cloudfront_log_delivery_canonical_user_id) | data source |\n | [aws_iam_policy_document.bucket_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n \n ## Inputs\n---\nexamples/complete/main.tf\n@@ -4,6 +4,8 @@ locals {\n \n data \"aws_canonical_user_id\" \"current\" {}\n \n+data \"aws_cloudfront_log_delivery_canonical_user_id\" \"cloudfront\" {}\n+\n resource \"random_pet\" \"this\" {\n length = 2\n }\n@@ -71,8 +73,7 @@ module \"cloudfront_log_bucket\" {\n }, {\n type = \"CanonicalUser\"\n permissions = [\"FULL_CONTROL\"]\n- id = \"c4c1ede66af53448b93c283ce9448c4ba468c9432aa01d700d3878632f77d2d0\"\n- # Ref. https://github.com/terraform-providers/terraform-provider-aws/issues/12512\n+ id = data.aws_cloudfront_log_delivery_canonical_user_id.cloudfront.id\n # Ref. https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/AccessLogs.html\n }]\n force_destroy = true\n---\nexamples/complete/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.31\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n- aws = \">= 3.50\"\n+ aws = \">= 3.60\"\n random = \">= 2.0\"\n }\n }\n---\nexamples/notification/README.md\n@@ -19,7 +19,7 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_null\"></a> [null](#requirement\\_null) | >= 2.0 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n---\nexamples/notification/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.31\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.50\"\n---\nexamples/object/README.md\n@@ -19,7 +19,7 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n---\nexamples/object/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.13\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.50\"\n---\nexamples/s3-replication/README.md\n@@ -21,7 +21,7 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n---\nexamples/s3-replication/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.31\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.50\"\n---\nmodules/notification/README.md\n@@ -7,7 +7,7 @@ Creates S3 bucket notification resource with all supported types of deliveries:\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.6 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.28 |\n \n ## Providers\n---\nmodules/notification/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.28\"\n---\nmodules/object/README.md\n@@ -7,7 +7,7 @@ Creates S3 bucket objects with different configurations.\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n \n ## Providers\n---\nmodules/object/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.13\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.36\"\n---\nversions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.31\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.50\"\n---\nwrappers/notification/versions.tf\n@@ -1,3 +1,3 @@\n terraform {\n- required_version = \">= 0.13\"\n+ required_version = \">= 0.13.1\"\n }\n---\nwrappers/object/versions.tf\n@@ -1,3 +1,3 @@\n terraform {\n- required_version = \">= 0.13\"\n+ required_version = \">= 0.13.1\"\n }\n---\nwrappers/versions.tf\n@@ -1,3 +1,3 @@\n terraform {\n- required_version = \">= 0.13\"\n+ required_version = \">= 0.13.1\"\n }\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -107,7 +107,7 @@ inputs = {\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n \n ## Providers\n---\nexamples/complete/README.md\n@@ -29,15 +29,15 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.60 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.60 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n@@ -56,6 +56,7 @@ Note that this example may create resources which cost money. Run `terraform des\n | [aws_kms_key.objects](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource |\n | [random_pet.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | resource |\n | [aws_canonical_user_id.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/canonical_user_id) | data source |\n+| [aws_cloudfront_log_delivery_canonical_user_id.cloudfront](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/cloudfront_log_delivery_canonical_user_id) | data source |\n | [aws_iam_policy_document.bucket_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n \n ## Inputs\n---\nexamples/complete/main.tf\n@@ -4,6 +4,8 @@ locals {\n \n data \"aws_canonical_user_id\" \"current\" {}\n \n+data \"aws_cloudfront_log_delivery_canonical_user_id\" \"cloudfront\" {}\n+\n resource \"random_pet\" \"this\" {\n length = 2\n }\n@@ -71,8 +73,7 @@ module \"cloudfront_log_bucket\" {\n }, {\n type = \"CanonicalUser\"\n permissions = [\"FULL_CONTROL\"]\n- id = \"c4c1ede66af53448b93c283ce9448c4ba468c9432aa01d700d3878632f77d2d0\"\n- # Ref. https://github.com/terraform-providers/terraform-provider-aws/issues/12512\n+ id = data.aws_cloudfront_log_delivery_canonical_user_id.cloudfront.id\n # Ref. https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/AccessLogs.html\n }]\n force_destroy = true\n---\nexamples/complete/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.31\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n- aws = \">= 3.50\"\n+ aws = \">= 3.60\"\n random = \">= 2.0\"\n }\n }\n---\nexamples/notification/README.md\n@@ -19,7 +19,7 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_null\"></a> [null](#requirement\\_null) | >= 2.0 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n---\nexamples/notification/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.31\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.50\"\n---\nexamples/object/README.md\n@@ -19,7 +19,7 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n---\nexamples/object/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.13\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.50\"\n---\nexamples/s3-replication/README.md\n@@ -21,7 +21,7 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n---\nexamples/s3-replication/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.31\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.50\"\n---\nmodules/notification/README.md\n@@ -7,7 +7,7 @@ Creates S3 bucket notification resource with all supported types of deliveries:\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.6 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.28 |\n \n ## Providers\n---\nmodules/notification/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.28\"\n---\nmodules/object/README.md\n@@ -7,7 +7,7 @@ Creates S3 bucket objects with different configurations.\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n \n ## Providers\n---\nmodules/object/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.13\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.36\"\n---\nversions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.31\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.50\"\n---\nwrappers/notification/versions.tf\n@@ -1,3 +1,3 @@\n terraform {\n- required_version = \">= 0.13\"\n+ required_version = \">= 0.13.1\"\n }\n---\nwrappers/object/versions.tf\n@@ -1,3 +1,3 @@\n terraform {\n- required_version = \">= 0.13\"\n+ required_version = \">= 0.13.1\"\n }\n---\nwrappers/versions.tf\n@@ -1,3 +1,3 @@\n terraform {\n- required_version = \">= 0.13\"\n+ required_version = \">= 0.13.1\"\n }\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -107,7 +107,7 @@ inputs = {\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n \n ## Providers\n---\nexamples/complete/README.md\n@@ -29,15 +29,15 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.60 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.60 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n@@ -56,6 +56,7 @@ Note that this example may create resources which cost money. Run `terraform des\n | [aws_kms_key.objects](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource |\n | [random_pet.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | resource |\n | [aws_canonical_user_id.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/canonical_user_id) | data source |\n+| [aws_cloudfront_log_delivery_canonical_user_id.cloudfront](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/cloudfront_log_delivery_canonical_user_id) | data source |\n | [aws_iam_policy_document.bucket_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n \n ## Inputs\n---\nexamples/complete/main.tf\n@@ -4,6 +4,8 @@ locals {\n \n data \"aws_canonical_user_id\" \"current\" {}\n \n+data \"aws_cloudfront_log_delivery_canonical_user_id\" \"cloudfront\" {}\n+\n resource \"random_pet\" \"this\" {\n length = 2\n }\n@@ -71,8 +73,7 @@ module \"cloudfront_log_bucket\" {\n }, {\n type = \"CanonicalUser\"\n permissions = [\"FULL_CONTROL\"]\n- id = \"c4c1ede66af53448b93c283ce9448c4ba468c9432aa01d700d3878632f77d2d0\"\n- # Ref. https://github.com/terraform-providers/terraform-provider-aws/issues/12512\n+ id = data.aws_cloudfront_log_delivery_canonical_user_id.cloudfront.id\n # Ref. https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/AccessLogs.html\n }]\n force_destroy = true\n---\nexamples/complete/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.31\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n- aws = \">= 3.50\"\n+ aws = \">= 3.60\"\n random = \">= 2.0\"\n }\n }\n---\nexamples/notification/README.md\n@@ -19,7 +19,7 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_null\"></a> [null](#requirement\\_null) | >= 2.0 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n---\nexamples/notification/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- of required_version = \">= 0.12.31\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.50\"\n---\nexamples/object/README.md\n@@ -19,7 +19,7 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n---\nexamples/object/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.13\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.50\"\n---\nexamples/s3-replication/README.md\n@@ -21,7 +21,7 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n---\nexamples/s3-replication/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.31\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.50\"\n---\nmodules/notification/README.md\n@@ -7,7 +7,7 @@ Creates S3 bucket notification resource with all supported types of deliveries:\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.6 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.28 |\n \n ## Providers\n---\nmodules/notification/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.28\"\n---\nmodules/object/README.md\n@@ -7,7 +7,7 @@ Creates S3 bucket objects with different configurations.\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n \n ## Providers\n---\nmodules/object/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.13\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.36\"\n---\nversions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.31\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.50\"\n---\nwrappers/notification/versions.tf\n@@ -1,3 +1,3 @@\n terraform {\n- required_version = \">= 0.13\"\n+ required_version = \">= 0.13.1\"\n }\n---\nwrappers/object/versions.tf\n@@ -1,3 +1,3 @@\n terraform {\n- required_version = \">= 0.13\"\n+ required_version = \">= 0.13.1\"\n }\n---\nwrappers/versions.tf\n@@ -1,3 +1,3 @@\n terraform {\n- required_version = \">= 0.13\"\n+ required_version = \">= 0.13.1\"\n }\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -107,7 +107,7 @@ inputs = {\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n \n ## Providers\n---\nexamples/complete/README.md\n@@ -29,15 +29,15 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.60 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.60 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n@@ -56,6 +56,7 @@ Note that this example may create resources which cost money. Run `terraform des\n | [aws_kms_key.objects](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource |\n | [random_pet.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | resource |\n | [aws_canonical_user_id.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/canonical_user_id) | data source |\n+| [aws_cloudfront_log_delivery_canonical_user_id.cloudfront](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/cloudfront_log_delivery_canonical_user_id) | data source |\n | [aws_iam_policy_document.bucket_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n \n ## Inputs\n---\nexamples/complete/main.tf\n@@ -4,6 +4,8 @@ locals {\n \n data \"aws_canonical_user_id\" \"current\" {}\n \n+data \"aws_cloudfront_log_delivery_canonical_user_id\" \"cloudfront\" {}\n+\n resource \"random_pet\" \"this\" {\n length = 2\n }\n@@ -71,8 +73,7 @@ module \"cloudfront_log_bucket\" {\n }, {\n type = \"CanonicalUser\"\n permissions = [\"FULL_CONTROL\"]\n- id = \"c4c1ede66af53448b93c283ce9448c4ba468c9432aa01d700d3878632f77d2d0\"\n- # Ref. https://github.com/terraform-providers/terraform-provider-aws/issues/12512\n+ id = data.aws_cloudfront_log_delivery_canonical_user_id.cloudfront.id\n # Ref. https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/AccessLogs.html\n }]\n force_destroy = true\n---\nexamples/complete/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.31\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n- aws = \">= 3.50\"\n+ aws = \">= 3.60\"\n random = \">= 2.0\"\n }\n }\n---\nexamples/notification/README.md\n@@ -19,7 +19,7 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_null\"></a> [null](#requirement\\_null) | >= 2.0 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n---\nexamples/notification/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.31\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.50\"\n---\nexamples/object/README.md\n@@ -19,7 +19,7 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n---\nexamples/object/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.13\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.50\"\n---\nexamples/s3-replication/README.md\n@@ -21,7 +21,7 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n---\nexamples/s3-replication/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.31\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.50\"\n---\nmodules/notification/README.md\n@@ -7,7 +7,7 @@ Creates S3 bucket notification resource with all supported types of deliveries:\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.6 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.28 |\n \n ## Providers\n---\nmodules/notification/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.6\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.28\"\n---\nmodules/object/README.md\n@@ -7,7 +7,7 @@ Creates S3 bucket objects with different configurations.\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13.1 |\n | <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n \n ## Providers\n---\nmodules/object/versions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.13\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.36\"\n---\nversions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \">= 0.12.31\"\n+ required_version = \">= 0.13.1\"\n \n required_providers {\n aws = \">= 3.50\"\n---\nwrappers/notification/versions.tf\n@@ -1,3 +1,3 @@\n terraform {\n- required_version = \">= 0.13\"\n+ required_version = \">= 0.13.1\"\n }\n---\nwrappers/object/versions.tf\n@@ -1,3 +1,3 @@\n terraform {\n- required_version = \">= 0.13\"\n+ required_version = \">= 0.13.1\"\n }\n---\nwrappers/versions.tf\n@@ -1,3 +1,3 @@\n terraform {\n- required_version = \">= 0.13\"\n+ required_version = \">= 0.13.1\"\n }\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\nBased on #103\r\n\n\n---\n\nChoice A:\nREADME.md\n@@ -107,14 +107,14 @@ inputs = {\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.26 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.36 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n \n ## Modules\n \n---\nexamples/complete/README.md\n@@ -29,15 +29,15 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.26 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.36 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/complete/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.26\"\n+ required_version = \">= 0.12.31\"\n \n required_providers {\n- aws = \">= 3.36\"\n+ aws = \">= 3.50\"\n random = \">= 2.0\"\n }\n }\n---\nexamples/notification/README.md\n@@ -19,16 +19,16 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.26 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_null\"></a> [null](#requirement\\_null) | >= 2.0 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.36 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n | <a name=\"provider_null\"></a> [null](#provider\\_null) | >= 2.0 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n---\nexamples/notification/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.26\"\n+ required_version = \">= 0.12.31\"\n \n required_providers {\n- aws = \">= 3.36\"\n+ aws = \">= 3.50\"\n random = \">= 2.0\"\n null = \">= 2.0\"\n }\n---\nexamples/object/README.md\n@@ -20,14 +20,14 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.36 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/object/versions.tf\n@@ -2,7 +2,7 @@ terraform {\n required_version = \">= 0.13\"\n \n required_providers {\n- aws = \">= 3.36\"\n+ aws = \">= 3.50\"\n random = \">= 2.0\"\n }\n }\n---\nexamples/s3-replication/README.md\n@@ -21,16 +21,16 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.26 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.36 |\n-| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.36 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n+| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.50 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/s3-replication/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.26\"\n+ required_version = \">= 0.12.31\"\n \n required_providers {\n- aws = \">= 3.36\"\n+ aws = \">= 3.50\"\n random = \">= 2.0\"\n }\n }\n---\nmain.tf\n@@ -132,10 +132,11 @@ resource \"aws_s3_bucket\" \"this\" {\n for_each = replication_configuration.value.rules\n \n content {\n- id = lookup(rules.value, \"id\", null)\n- priority = lookup(rules.value, \"priority\", null)\n- prefix = lookup(rules.value, \"prefix\", null)\n- status = rules.value.status\n+ id = lookup(rules.value, \"id\", null)\n+ priority = lookup(rules.value, \"priority\", null)\n+ prefix = lookup(rules.value, \"prefix\", null)\n+ delete_marker_replication_status = lookup(rules.value, \"delete_marker_replication_status\", null)\n+ status = rules.value.status\n \n dynamic \"destination\" {\n for_each = length(keys(lookup(rules.value, \"destination\", {}))) == 0 ? [] : [lookup(rules.value, \"destination\", {})]\n---\nversions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \">= 0.12.26\"\n+ required_version = \">= 0.12.31\"\n \n required_providers {\n- aws = \">= 3.36\"\n+ aws = \">= 3.50\"\n }\n }\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -107,14 +107,14 @@ inputs = {\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.26 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.36 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n \n ## Modules\n \n---\nexamples/complete/README.md\n@@ -29,15 +29,15 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.26 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.36 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/complete/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.26\"\n+ required_version = \">= 0.12.31\"\n \n required_providers {\n- aws = \">= 3.36\"\n+ aws = \">= 3.50\"\n random = \">= 2.0\"\n }\n }\n---\nexamples/notification/README.md\n@@ -19,16 +19,16 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.26 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_null\"></a> [null](#requirement\\_null) | >= 2.0 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.36 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n | <a name=\"provider_null\"></a> [null](#provider\\_null) | >= 2.0 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n---\nexamples/notification/versions.tf\n@@ -1,8 +1,8 @@\n terraform | required_version = \">= 0.12.26\"\n+ required_version = \">= 0.12.31\"\n \n required_providers {\n- aws = \">= 3.36\"\n+ aws = \">= 3.50\"\n random = \">= 2.0\"\n null = \">= 2.0\"\n }\n---\nexamples/object/README.md\n@@ -20,14 +20,14 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.36 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/object/versions.tf\n@@ -2,7 +2,7 @@ terraform {\n required_version = \">= 0.13\"\n \n required_providers {\n- aws = \">= 3.36\"\n+ aws = \">= 3.50\"\n random = \">= 2.0\"\n }\n }\n---\nexamples/s3-replication/README.md\n@@ -21,16 +21,16 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.26 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.36 |\n-| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.36 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n+| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.50 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/s3-replication/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.26\"\n+ required_version = \">= 0.12.31\"\n \n required_providers {\n- aws = \">= 3.36\"\n+ aws = \">= 3.50\"\n random = \">= 2.0\"\n }\n }\n---\nmain.tf\n@@ -132,10 +132,11 @@ resource \"aws_s3_bucket\" \"this\" {\n for_each = replication_configuration.value.rules\n \n content {\n- id = lookup(rules.value, \"id\", null)\n- priority = lookup(rules.value, \"priority\", null)\n- prefix = lookup(rules.value, \"prefix\", null)\n- status = rules.value.status\n+ id = lookup(rules.value, \"id\", null)\n+ priority = lookup(rules.value, \"priority\", null)\n+ prefix = lookup(rules.value, \"prefix\", null)\n+ delete_marker_replication_status = lookup(rules.value, \"delete_marker_replication_status\", null)\n+ status = rules.value.status\n \n dynamic \"destination\" {\n for_each = length(keys(lookup(rules.value, \"destination\", {}))) == 0 ? [] : [lookup(rules.value, \"destination\", {})]\n---\nversions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \">= 0.12.26\"\n+ required_version = \">= 0.12.31\"\n \n required_providers {\n- aws = \">= 3.36\"\n+ aws = \">= 3.50\"\n }\n }\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -107,14 +107,14 @@ inputs = {\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.26 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.36 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n \n ## Modules\n \n---\nexamples/complete/README.md\n@@ -29,15 +29,15 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.26 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.36 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/complete/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.26\"\n+ required_version = \">= 0.12.31\"\n \n required_providers {\n- aws = \">= 3.36\"\n+ aws = \">= 3.50\"\n random = \">= 2.0\"\n }\n }\n---\nexamples/notification/README.md\n@@ -19,16 +19,16 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.26 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_null\"></a> [null](#requirement\\_null) | >= 2.0 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.36 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n | <a name=\"provider_null\"></a> [null](#provider\\_null) | >= 2.0 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n---\nexamples/notification/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.26\"\n+ required_version = \">= 0.12.31\"\n \n required_providers {\n- aws = \">= 3.36\"\n+ aws = \">= 3.50\"\n random = \">= 2.0\"\n null = \">= 2.0\"\n }\n---\nexamples/object/README.md\n@@ -20,14 +20,14 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.36 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/object/versions.tf\n@@ -2,7 +2,7 @@ terraform {\n required_version = \">= 0.13\"\n \n required_providers {\n- aws = \">= 3.36\"\n+ aws = \">= 3.50\"\n random = \">= 2.0\"\n }\n }\n---\nexamples/s3-replication/README.md\n@@ -21,16 +21,16 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.26 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.36 |\n-| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.36 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n+| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.50 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/s3-replication/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.26\"\n+ required_version = \">= 0.12.31\"\n \n required_providers {\n- aws = \">= 3.36\"\n+ aws = \">= 3.50\"\n random = \">= 2.0\"\n }\n }\n---\nmain.tf\n@@ -132,10 +132,11 @@ resource \"aws_s3_bucket\" \"this\" {\n for_each = replication_configuration.value.rules\n \n content {\n- id = lookup(rules.value, \"id\", null)\n- priority = lookup(rules.value, \"priority\", null)\n- prefix = lookup(rules.value, \"prefix\", null)\n- status = rules.value.status\n+ id = lookup(rules.value, \"id\", null)\n+ priority = lookup(rules.value, \"priority\", null)\n+ prefix = lookup(rules.value, \"prefix\", null)\n+ delete_marker_replication_status = lookup(rules.value, \"delete_marker_replication_status\", null)\n+ status = rules.value.status\n \n dynamic \"destination\" {\n length(keys(lookup(rules.value, for_each = length(keys(lookup(rules.value, \"destination\", {}))) == 0 ? [] : [lookup(rules.value, \"destination\", {})]\n---\nversions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \">= 0.12.26\"\n+ required_version = \">= 0.12.31\"\n \n required_providers {\n- aws = \">= 3.36\"\n+ aws = \">= 3.50\"\n }\n }\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -107,14 +107,14 @@ inputs = {\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.26 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.36 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n \n ## Modules\n \n---\nexamples/complete/README.md\n@@ -29,15 +29,15 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.26 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.36 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/complete/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.26\"\n+ required_version = \">= 0.12.31\"\n \n required_providers {\n- aws = \">= 3.36\"\n+ aws = \">= 3.50\"\n random = \">= 2.0\"\n }\n }\n---\nexamples/notification/README.md\n@@ -19,16 +19,16 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.26 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_null\"></a> [null](#requirement\\_null) | >= 2.0 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.36 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n | <a name=\"provider_null\"></a> [null](#provider\\_null) | >= 2.0 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n---\nexamples/notification/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.26\"\n+ required_version = \">= 0.12.31\"\n \n required_providers {\n- aws = \">= 3.36\"\n+ aws = \">= 3.50\"\n random = \">= 2.0\"\n null = \">= 2.0\"\n }\n---\nexamples/object/README.md\n@@ -20,14 +20,14 @@ Note that this example may create resources which cost money. Run `terraform des\n | Name | Version |\n |------|---------|\n | <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.13 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.36 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/object/versions.tf\n@@ -2,7 +2,7 @@ terraform {\n required_version = \">= 0.13\"\n \n required_providers {\n- aws = \">= 3.36\"\n+ aws = \">= 3.50\"\n random = \">= 2.0\"\n }\n }\n---\nexamples/s3-replication/README.md\n@@ -21,16 +21,16 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.26 |\n-| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.36 |\n+| <a name=\"requirement_terraform\"></a> [terraform](#requirement\\_terraform) | >= 0.12.31 |\n+| <a name=\"requirement_aws\"></a> [aws](#requirement\\_aws) | >= 3.50 |\n | <a name=\"requirement_random\"></a> [random](#requirement\\_random) | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.36 |\n-| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.36 |\n+| <a name=\"provider_aws\"></a> [aws](#provider\\_aws) | >= 3.50 |\n+| <a name=\"provider_aws.replica\"></a> [aws.replica](#provider\\_aws.replica) | >= 3.50 |\n | <a name=\"provider_random\"></a> [random](#provider\\_random) | >= 2.0 |\n \n ## Modules\n---\nexamples/s3-replication/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.26\"\n+ required_version = \">= 0.12.31\"\n \n required_providers {\n- aws = \">= 3.36\"\n+ aws = \">= 3.50\"\n random = \">= 2.0\"\n }\n }\n---\nmain.tf\n@@ -132,10 +132,11 @@ resource \"aws_s3_bucket\" \"this\" {\n for_each = replication_configuration.value.rules\n \n content {\n- id = lookup(rules.value, \"id\", null)\n- priority = lookup(rules.value, \"priority\", null)\n- prefix = lookup(rules.value, \"prefix\", null)\n- status = rules.value.status\n+ id = lookup(rules.value, \"id\", null)\n+ priority = lookup(rules.value, \"priority\", null)\n+ prefix = lookup(rules.value, \"prefix\", null)\n+ delete_marker_replication_status = lookup(rules.value, \"delete_marker_replication_status\", null)\n+ status = rules.value.status\n \n dynamic \"destination\" {\n for_each = length(keys(lookup(rules.value, \"destination\", {}))) == 0 ? [] : [lookup(rules.value, \"destination\", {})]\n---\nversions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \">= 0.12.26\"\n+ required_version = \">= 0.12.31\"\n \n required_providers {\n- aws = \">= 3.36\"\n+ aws = \">= 3.50\"\n }\n }\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\nCompletely based on #104\r\n\r\nFixes #104 \n\n---\n\nChoice A:\nexamples/s3-replication/main.tf\n@@ -58,7 +58,7 @@ module \"s3_bucket\" {\n \n rules = [\n {\n- id = \"foo\"\n+ id = \"something-with-kms-and-filter\"\n status = \"Enabled\"\n priority = 10\n \n@@ -86,25 +86,45 @@ module \"s3_bucket\" {\n }\n },\n {\n- id = \"bar\"\n+ id = \"something-with-filter\"\n status = \"Enabled\"\n priority = 20\n \n+ filter = {\n+ prefix = \"two\"\n+ tags = {\n+ ReplicateMe = \"Yes\"\n+ }\n+ }\n+\n destination = {\n bucket = \"arn:aws:s3:::${local.destination_bucket_name}\"\n storage_class = \"STANDARD\"\n }\n-\n+ },\n+ {\n+ id = \"everything-with-filter\"\n+ status = \"Enabled\"\n+ priority = 30\n \n filter = {\n- prefix = \"two\"\n- tags = {\n- ReplicateMe = \"Yes\"\n- }\n+ prefix = \"\"\n }\n \n+ destination = {\n+ bucket = \"arn:aws:s3:::${local.destination_bucket_name}\"\n+ storage_class = \"STANDARD\"\n+ }\n },\n+ {\n+ id = \"everything-without-filters\"\n+ status = \"Enabled\"\n \n+ destination = {\n+ bucket = \"arn:aws:s3:::${local.destination_bucket_name}\"\n+ storage_class = \"STANDARD\"\n+ }\n+ },\n ]\n }\n \n---\nmain.tf\n@@ -172,8 +172,16 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n }\n \n+ # Send empty map if `filter` is an empty map or absent entirely\n dynamic \"filter\" {\n- for_each = length(keys(lookup(rules.value, \"filter\", {}))) == 0 ? [] : [lookup(rules.value, \"filter\", {})]\n+ for_each = length(keys(lookup(rules.value, \"filter\", {}))) == 0 ? [{}] : []\n+\n+ content {}\n+ }\n+\n+ # Send `filter` if it is present and has at least one field\n+ dynamic \"filter\" {\n+ for_each = length(keys(lookup(rules.value, \"filter\", {}))) != 0 ? [lookup(rules.value, \"filter\", {})] : []\n \n content {\n prefix = lookup(filter.value, \"prefix\", null)\n---\n\n\n---\n\nChoice B:\nexamples/s3-replication/main.tf\n@@ -58,7 +58,7 @@ module \"s3_bucket\" {\n \n rules = [\n {\n- id = \"foo\"\n+ id = \"something-with-kms-and-filter\"\n status = \"Enabled\"\n priority = 10\n \n@@ -86,25 +86,45 @@ module \"s3_bucket\" {\n }\n \n+ },\n {\n- id = \"bar\"\n+ id = \"something-with-filter\"\n status = \"Enabled\"\n priority = 20\n \n+ filter = {\n+ prefix = \"two\"\n+ tags = {\n+ ReplicateMe = \"Yes\"\n+ }\n+ }\n+\n destination = {\n bucket = \"arn:aws:s3:::${local.destination_bucket_name}\"\n storage_class = \"STANDARD\"\n }\n-\n+ },\n+ {\n+ id = \"everything-with-filter\"\n+ status = \"Enabled\"\n+ priority = 30\n \n filter = {\n- prefix = \"two\"\n- tags = {\n- ReplicateMe = \"Yes\"\n- }\n+ prefix = \"\"\n }\n \n+ destination = {\n+ bucket = \"arn:aws:s3:::${local.destination_bucket_name}\"\n+ storage_class = \"STANDARD\"\n+ }\n },\n+ {\n+ id = \"everything-without-filters\"\n+ status = \"Enabled\"\n \n+ destination = {\n+ bucket = \"arn:aws:s3:::${local.destination_bucket_name}\"\n+ storage_class = \"STANDARD\"\n+ }\n+ },\n ]\n }\n \n---\nmain.tf\n@@ -172,8 +172,16 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n }\n \n+ # Send empty map if `filter` is an empty map or absent entirely\n dynamic \"filter\" {\n- for_each = length(keys(lookup(rules.value, \"filter\", {}))) == 0 ? [] : [lookup(rules.value, \"filter\", {})]\n+ for_each = length(keys(lookup(rules.value, \"filter\", {}))) == 0 ? [{}] : []\n+\n+ content {}\n+ }\n+\n+ # Send `filter` if it is present and has at least one field\n+ dynamic \"filter\" {\n+ for_each = length(keys(lookup(rules.value, \"filter\", {}))) != 0 ? [lookup(rules.value, \"filter\", {})] : []\n \n content {\n prefix = lookup(filter.value, \"prefix\", null)\n---\n\n\n---\n\nChoice C:\nexamples/s3-replication/main.tf\n@@ -58,7 +58,7 @@ module \"s3_bucket\" {\n \n rules = [\n {\n- id = \"foo\"\n+ id = \"something-with-kms-and-filter\"\n status = \"Enabled\"\n priority = 10\n \n@@ -86,25 +86,45 @@ module \"s3_bucket\" {\n }\n },\n {\n- id = \"bar\"\n+ id = \"something-with-filter\"\n status = \"Enabled\"\n priority = 20\n \n+ filter = {\n+ prefix = \"two\"\n+ tags = {\n+ ReplicateMe = \"Yes\"\n+ }\n+ }\n+\n destination = {\n bucket = \"arn:aws:s3:::${local.destination_bucket_name}\"\n storage_class = \"STANDARD\"\n }\n-\n+ },\n+ {\n+ id = \"everything-with-filter\"\n+ status = \"Enabled\"\n+ priority = 30\n \n filter = {\n- prefix = \"two\"\n- tags = {\n- ReplicateMe = \"Yes\"\n- }\n+ prefix = \"\"\n }\n \n+ destination = {\n+ bucket = \"arn:aws:s3:::${local.destination_bucket_name}\"\n+ storage_class = \"STANDARD\"\n+ }\n },\n+ {\n+ id = \"everything-without-filters\"\n+ status = \"Enabled\"\n \n+ destination = {\n+ bucket = \"arn:aws:s3:::${local.destination_bucket_name}\"\n+ storage_class = \"STANDARD\"\n+ }\n+ },\n ]\n }\n \n---\nmain.tf\n@@ -172,8 +172,16 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n }\n \n+ # Send empty map if `filter` is an empty map or absent entirely\n dynamic \"filter\" {\n- for_each = length(keys(lookup(rules.value, \"filter\", {}))) == 0 ? [] : [lookup(rules.value, \"filter\", {})]\n+ for_each = length(keys(lookup(rules.value, \"filter\", {}))) == 0 ? [{}] : []\n+\n+ content {}\n+ }\n+\n+ # Send `filter` if it is present and has at least one field\n+ dynamic \"filter\" {\n+ for_each = length(keys(lookup(rules.value, \"filter\", {}))) != 0 ? [lookup(rules.value, \"filter\", {})] : []\n \n content {\n prefix = lookup(filter.value, \"prefix\", null)\n---\n\n\n---\n\nChoice D:\nexamples/s3-replication/main.tf\n@@ -58,7 +58,7 @@ module \"s3_bucket\" {\n \n rules = [\n {\n- id = \"foo\"\n+ id = \"something-with-kms-and-filter\"\n status = \"Enabled\"\n priority = 10\n \n@@ -86,25 +86,45 @@ module \"s3_bucket\" {\n }\n },\n {\n- id = \"bar\"\n+ id = \"something-with-filter\"\n status = \"Enabled\"\n priority = 20\n \n+ filter = {\n+ prefix = \"two\"\n+ tags = {\n+ ReplicateMe = \"Yes\"\n+ }\n+ }\n+\n destination = {\n bucket = \"arn:aws:s3:::${local.destination_bucket_name}\"\n storage_class = \"STANDARD\"\n }\n-\n+ },\n+ {\n+ id = \"everything-with-filter\"\n+ status = \"Enabled\"\n+ priority = 30\n \n filter = {\n- prefix = \"two\"\n- tags = {\n- ReplicateMe = \"Yes\"\n- }\n+ prefix = \"\"\n }\n \n+ destination = {\n+ bucket = \"arn:aws:s3:::${local.destination_bucket_name}\"\n+ storage_class = \"STANDARD\"\n+ }\n },\n+ {\n+ id = \"everything-without-filters\"\n+ status = \"Enabled\"\n \n+ destination = {\n+ bucket = \"arn:aws:s3:::${local.destination_bucket_name}\"\n+ storage_class = \"STANDARD\"\n+ }\n+ },\n ]\n }\n \n---\nmain.tf\n@@ -172,8 +172,16 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n }\n \n+ # Send empty map if `filter` is an empty map or absent entirely\n dynamic \"filter\" {\n- for_each = length(keys(lookup(rules.value, \"filter\", {}))) == 0 ? [] : [lookup(rules.value, \"filter\", {})]\n+ for_each = length(keys(lookup(rules.value, \"filter\", {}))) == 0 ? [{}] : []\n+\n+ content {}\n+ }\n+\n+ # Send `filter` if it is present and has at least one field\n+ dynamic \"filter\" {\n+ for_each = length(keys(lookup(rules.value, \"filter\", {}))) != 0 ? [lookup(rules.value, \"filter\", {})] : []\n \n content {\n prefix = lookup(filter.value, \"prefix\", null)\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nSend an empty `filter` map if no (or empty) `filter` was specified in `replication_configuration`.\r\n\r\n(I'm not a Terraform expert so I'm not sure if the way I've done it is the best 😅)\r\n\r\n## Motivation and Context\r\nIn the absence of at least an empty `filter` map if no filter was specified in a rule, `terraform apply` gives the following error for multi-destination S3 replication rules. See [this](https://github.com/hashicorp/terraform-provider-aws/issues/16546) `terraform-provider-aws` issue for additional context.\r\n\r\n`Number of distinct destination bucket ARNs cannot exceed 1`\r\n\r\n## Breaking Changes\r\nDoes not break backwards compatibility with the current major version.\r\n\r\n## How Has This Been Tested?\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects.\r\n- Tested using the `S3 bucket with Cross-Region Replication (CRR) enabled` example.\r\n- Tweaked the example to replicate `s3_bucket` to two replica buckets in the same region (one replication rule without a filter specified).\r\n- Observed the `Number of distinct destination bucket ARNs cannot exceed 1` error with unmodified code and successful application with modifications.\n\n---\n\nChoice A:\nmain.tf\n@@ -172,8 +172,16 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n }\n \n+ # Send empty map if `filter` is an empty map or absent entirely\n dynamic \"filter\" {\n- for_each = length(keys(lookup(rules.value, \"filter\", {}))) == 0 ? [] : [lookup(rules.value, \"filter\", {})]\n+ for_each = length(keys(lookup(rules.value, \"filter\", {}))) == 0 ? [{}] : []\n+\n+ content {}\n+ }\n+\n+ # Send `filter` if it is present and has at least one field\n+ dynamic \"filter\" {\n+ for_each = length(keys(lookup(rules.value, \"filter\", {}))) != 0 ? [lookup(rules.value, \"filter\", {})] : []\n \n content {\n prefix = lookup(filter.value, \"prefix\", null)\n---\n\n\n---\n\nChoice B:\nmain.tf\n@@ -172,8 +172,16 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n }\n \n+ # Send empty map if `filter` is an empty map or absent entirely\n dynamic \"filter\" {\n- for_each = length(keys(lookup(rules.value, \"filter\", {}))) == 0 ? [] : [lookup(rules.value, \"filter\", {})]\n+ for_each = length(keys(lookup(rules.value, \"filter\", {}))) == 0 ? : []\n+\n+ content {}\n+ }\n+\n+ # Send `filter` if it is present and has at least one field\n+ dynamic \"filter\" {\n+ for_each = length(keys(lookup(rules.value, \"filter\", {}))) != 0 ? [lookup(rules.value, \"filter\", {})] : []\n \n content {\n prefix = lookup(filter.value, \"prefix\", null)\n---\n\n\n---\n\nChoice C:\nmain.tf\n@@ -172,8 +172,16 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n }\n \n+ # Send empty map if `filter` is an empty map or absent entirely\n dynamic \"filter\" {\n- for_each = length(keys(lookup(rules.value, \"filter\", {}))) == 0 ? [] : [lookup(rules.value, \"filter\", {})]\n+ for_each = length(keys(lookup(rules.value, \"filter\", {}))) == 0 ? [{}] : []\n+\n+ content {}\n+ }\n+\n+ # Send `filter` if it is present and has at least one field\n+ dynamic \"filter\" {\n+ for_each = length(keys(lookup(rules.value, \"filter\", {}))) != 0 ? [lookup(rules.value, \"filter\", {})] : []\n \n content {\n prefix = lookup(filter.value, \"prefix\", null)\n---\n\n\n---\n\nChoice D:\nmain.tf\n@@ -172,8 +172,16 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n }\n \n+ # Send empty map if `filter` is an empty map or absent entirely\n dynamic \"filter\" {\n- for_each = length(keys(lookup(rules.value, \"filter\", {}))) == 0 ? [] : [lookup(rules.value, \"filter\", {})]\n+ for_each = length(keys(lookup(rules.value, \"filter\", {}))) == 0 ? [{}] : []\n+\n+ content {}\n+ }\n+\n+ # Send `filter` if it is present and has at least one field\n+ dynamic \"filter\" {\n+ for_each = length(keys(lookup(rules.value, \"filter\", {}))) != 0 ? [lookup(rules.value, \"filter\", {})] : []\n \n # content {\n prefix = lookup(filter.value, \"prefix\", null)\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n\r\nAllow configuring \"Object Ownership\"\r\n\r\n## How Has This Been Tested?\r\n- [x] I have tested and validated these changes using one or more of the provided `examples/*` projects\r\n\r\n\n\n---\n\nChoice A:\nREADME.md\n@@ -125,6 +125,7 @@ No modules.\n | Name | Type |\n |------|------|\n | [aws_s3_bucket.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |\n+| [aws_s3_bucket_ownership_controls.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls) | resource |\n | [aws_s3_bucket_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |\n | [aws_s3_bucket_public_access_block.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource |\n | [aws_elb_service_account.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/elb_service_account) | data source |\n@@ -148,6 +149,7 @@ No modules.\n | <a name=\"input_block_public_policy\"></a> [block\\_public\\_policy](#input\\_block\\_public\\_policy) | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | <a name=\"input_bucket\"></a> [bucket](#input\\_bucket) | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n | <a name=\"input_bucket_prefix\"></a> [bucket\\_prefix](#input\\_bucket\\_prefix) | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | `string` | `null` | no |\n+| <a name=\"input_control_object_ownership\"></a> [control\\_object\\_ownership](#input\\_control\\_object\\_ownership) | Whether to manage S3 Bucket Ownership Controls on this bucket. | `bool` | `false` | no |\n | <a name=\"input_cors_rule\"></a> [cors\\_rule](#input\\_cors\\_rule) | List of maps containing rules for Cross-Origin Resource Sharing. | `any` | `[]` | no |\n | <a name=\"input_create_bucket\"></a> [create\\_bucket](#input\\_create\\_bucket) | Controls if S3 bucket should be created | `bool` | `true` | no |\n | <a name=\"input_force_destroy\"></a> [force\\_destroy](#input\\_force\\_destroy) | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n@@ -156,6 +158,7 @@ No modules.\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n+| <a name=\"input_object_ownership\"></a> [object\\_ownership](#input\\_object\\_ownership) | Object ownership. Valid values: BucketOwnerPreferred or ObjectWriter. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL. | `string` | `\"ObjectWriter\"` | no |\n | <a name=\"input_policy\"></a> [policy](#input\\_policy) | (Optional) A valid bucket policy JSON document. Note that if the policy document is not specific enough (but still valid), Terraform may view the policy as constantly changing in a terraform plan. In this case, please make sure you use the verbose/specific version of the policy. For more information about building AWS IAM policy documents with Terraform, see the AWS IAM Policy Document Guide. | `string` | `null` | no |\n | <a name=\"input_replication_configuration\"></a> [replication\\_configuration](#input\\_replication\\_configuration) | Map containing cross-region replication configuration. | `any` | `{}` | no |\n | <a name=\"input_request_payer\"></a> [request\\_payer](#input\\_request\\_payer) | (Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information. | `string` | `null` | no |\n---\nexamples/complete/main.tf\n@@ -213,4 +213,8 @@ module \"s3_bucket\" {\n block_public_policy = true\n ignore_public_acls = true\n restrict_public_buckets = true\n+\n+ # S3 Bucket Ownership Controls\n+ control_object_ownership = true\n+ object_ownership = \"BucketOwnerPreferred\"\n }\n---\nmain.tf\n@@ -376,10 +376,29 @@ resource \"aws_s3_bucket_public_access_block\" \"this\" {\n \n # Chain resources (s3_bucket -> s3_bucket_policy -> s3_bucket_public_access_block)\n # to prevent \"A conflicting conditional operation is currently in progress against this resource.\"\n+ # Ref: https://github.com/hashicorp/terraform-provider-aws/issues/7628\n+\n bucket = local.attach_policy ? aws_s3_bucket_policy.this[0].id : aws_s3_bucket.this[0].id\n \n block_public_acls = var.block_public_acls\n block_public_policy = var.block_public_policy\n ignore_public_acls = var.ignore_public_acls\n restrict_public_buckets = var.restrict_public_buckets\n }\n+\n+resource \"aws_s3_bucket_ownership_controls\" \"this\" {\n+ count = var.create_bucket && var.control_object_ownership ? 1 : 0\n+\n+ bucket = local.attach_policy ? aws_s3_bucket_policy.this[0].id : aws_s3_bucket.this[0].id\n+\n+ rule {\n+ object_ownership = var.object_ownership\n+ }\n+\n+ # This `depends_on` is to prevent \"A conflicting conditional operation is currently in progress against this resource.\"\n+ depends_on = [\n+ aws_s3_bucket_policy.this,\n+ aws_s3_bucket_public_access_block.this,\n+ aws_s3_bucket.this\n+ ]\n+}\n---\nvariables.tf\n@@ -159,3 +159,15 @@ variable \"restrict_public_buckets\" {\n type = bool\n default = false\n }\n+\n+variable \"control_object_ownership\" {\n+ description = \"Whether to manage S3 Bucket Ownership Controls on this bucket.\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"object_ownership\" {\n+ description = \"Object ownership. Valid values: BucketOwnerPreferred or ObjectWriter. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL.\"\n+ type = string\n+ default = \"ObjectWriter\"\n+}\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -125,6 +125,7 @@ No modules.\n | Name | Type |\n |------|------|\n | [aws_s3_bucket.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |\n+| [aws_s3_bucket_ownership_controls.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls) | resource |\n | [aws_s3_bucket_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |\n | [aws_s3_bucket_public_access_block.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource |\n | [aws_elb_service_account.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/elb_service_account) | data source |\n@@ -148,6 +149,7 @@ No modules.\n | <a name=\"input_block_public_policy\"></a> [block\\_public\\_policy](#input\\_block\\_public\\_policy) | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | <a name=\"input_bucket\"></a> [bucket](#input\\_bucket) | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n | <a name=\"input_bucket_prefix\"></a> [bucket\\_prefix](#input\\_bucket\\_prefix) | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | `string` | `null` | no |\n+| <a name=\"input_control_object_ownership\"></a> [control\\_object\\_ownership](#input\\_control\\_object\\_ownership) | Whether to manage S3 Bucket Ownership Controls on this bucket. | `bool` | `false` | no |\n | <a name=\"input_cors_rule\"></a> [cors\\_rule](#input\\_cors\\_rule) | List of maps containing rules for Cross-Origin Resource Sharing. | `any` | `[]` | no for | <a name=\"input_create_bucket\"></a> [create\\_bucket](#input\\_create\\_bucket) | Controls if S3 bucket should be created | `bool` | `true` | no |\n | <a name=\"input_force_destroy\"></a> [force\\_destroy](#input\\_force\\_destroy) | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n@@ -156,6 +158,7 @@ No modules.\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n+| <a name=\"input_object_ownership\"></a> [object\\_ownership](#input\\_object\\_ownership) | Object ownership. Valid values: BucketOwnerPreferred or ObjectWriter. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL. | `string` | `\"ObjectWriter\"` | no |\n | <a name=\"input_policy\"></a> [policy](#input\\_policy) | (Optional) A valid bucket policy JSON document. Note that if the policy document is not specific enough (but still valid), Terraform may view the policy as constantly changing in a terraform plan. In this case, please make sure you use the verbose/specific version of the policy. For more information about building AWS IAM policy documents with Terraform, see the AWS IAM Policy Document Guide. | `string` | `null` | no |\n | <a name=\"input_replication_configuration\"></a> [replication\\_configuration](#input\\_replication\\_configuration) | Map containing cross-region replication configuration. | `any` | `{}` | no |\n | <a name=\"input_request_payer\"></a> [request\\_payer](#input\\_request\\_payer) | (Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information. | `string` | `null` | no |\n---\nexamples/complete/main.tf\n@@ -213,4 +213,8 @@ module \"s3_bucket\" {\n block_public_policy = true\n ignore_public_acls = true\n restrict_public_buckets = true\n+\n+ # S3 Bucket Ownership Controls\n+ control_object_ownership = true\n+ object_ownership = \"BucketOwnerPreferred\"\n }\n---\nmain.tf\n@@ -376,10 +376,29 @@ resource \"aws_s3_bucket_public_access_block\" \"this\" {\n \n # Chain resources (s3_bucket -> s3_bucket_policy -> s3_bucket_public_access_block)\n # to prevent \"A conflicting conditional operation is currently in progress against this resource.\"\n+ # Ref: https://github.com/hashicorp/terraform-provider-aws/issues/7628\n+\n bucket = local.attach_policy ? aws_s3_bucket_policy.this[0].id : aws_s3_bucket.this[0].id\n \n block_public_acls = var.block_public_acls\n block_public_policy = var.block_public_policy\n ignore_public_acls = var.ignore_public_acls\n restrict_public_buckets = var.restrict_public_buckets\n }\n+\n+resource \"aws_s3_bucket_ownership_controls\" \"this\" {\n+ count = var.create_bucket && var.control_object_ownership ? 1 : 0\n+\n+ bucket = local.attach_policy ? aws_s3_bucket_policy.this[0].id : aws_s3_bucket.this[0].id\n+\n+ rule {\n+ object_ownership = var.object_ownership\n+ }\n+\n+ # This `depends_on` is to prevent \"A conflicting conditional operation is currently in progress against this resource.\"\n+ depends_on = [\n+ aws_s3_bucket_policy.this,\n+ aws_s3_bucket_public_access_block.this,\n+ aws_s3_bucket.this\n+ ]\n+}\n---\nvariables.tf\n@@ -159,3 +159,15 @@ variable \"restrict_public_buckets\" {\n type = bool\n default = false\n }\n+\n+variable \"control_object_ownership\" {\n+ description = \"Whether to manage S3 Bucket Ownership Controls on this bucket.\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"object_ownership\" {\n+ description = \"Object ownership. Valid values: BucketOwnerPreferred or ObjectWriter. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL.\"\n+ type = string\n+ default = \"ObjectWriter\"\n+}\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -125,6 +125,7 @@ No modules.\n | Name | Type |\n |------|------|\n | [aws_s3_bucket.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |\n+| [aws_s3_bucket_ownership_controls.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls) | resource |\n | [aws_s3_bucket_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |\n | [aws_s3_bucket_public_access_block.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource |\n | [aws_elb_service_account.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/elb_service_account) | data source |\n@@ -148,6 +149,7 @@ No modules.\n | <a name=\"input_block_public_policy\"></a> [block\\_public\\_policy](#input\\_block\\_public\\_policy) | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | <a name=\"input_bucket\"></a> [bucket](#input\\_bucket) | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n | <a name=\"input_bucket_prefix\"></a> [bucket\\_prefix](#input\\_bucket\\_prefix) | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | `string` | `null` | no |\n+| <a name=\"input_control_object_ownership\"></a> [control\\_object\\_ownership](#input\\_control\\_object\\_ownership) | Whether to manage S3 Bucket Ownership Controls on this bucket. | `bool` | `false` | no |\n | <a name=\"input_cors_rule\"></a> [cors\\_rule](#input\\_cors\\_rule) | List of maps containing rules for Cross-Origin Resource Sharing. | `any` | `[]` | no |\n | <a name=\"input_create_bucket\"></a> [create\\_bucket](#input\\_create\\_bucket) | Controls if S3 bucket should be created | `bool` | `true` | no |\n | <a name=\"input_force_destroy\"></a> [force\\_destroy](#input\\_force\\_destroy) | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n@@ -156,6 +158,7 @@ No modules.\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n+| <a name=\"input_object_ownership\"></a> [object\\_ownership](#input\\_object\\_ownership) | Object ownership. Valid values: BucketOwnerPreferred or ObjectWriter. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL. | `string` | `\"ObjectWriter\"` | no |\n | <a name=\"input_policy\"></a> [policy](#input\\_policy) | (Optional) A valid bucket policy JSON document. Note that if the policy document is not specific enough (but still valid), Terraform may view the policy as constantly changing in a terraform plan. account this case, please make sure you use the verbose/specific version of the policy. For more information about building AWS IAM policy documents with Terraform, see the AWS IAM Policy Document Guide. | `string` | `null` | no |\n | <a name=\"input_replication_configuration\"></a> [replication\\_configuration](#input\\_replication\\_configuration) | Map containing cross-region replication configuration. | `any` | `{}` | no |\n | <a name=\"input_request_payer\"></a> [request\\_payer](#input\\_request\\_payer) | (Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information. | `string` | `null` | no |\n---\nexamples/complete/main.tf\n@@ -213,4 +213,8 @@ module \"s3_bucket\" {\n block_public_policy = true\n ignore_public_acls = true\n restrict_public_buckets = true\n+\n+ # S3 Bucket Ownership Controls\n+ control_object_ownership = true\n+ object_ownership = \"BucketOwnerPreferred\"\n }\n---\nmain.tf\n@@ -376,10 +376,29 @@ resource \"aws_s3_bucket_public_access_block\" \"this\" {\n \n # Chain resources (s3_bucket -> s3_bucket_policy -> s3_bucket_public_access_block)\n # to prevent \"A conflicting conditional operation is currently in progress against this resource.\"\n+ # Ref: https://github.com/hashicorp/terraform-provider-aws/issues/7628\n+\n bucket = local.attach_policy ? aws_s3_bucket_policy.this[0].id : aws_s3_bucket.this[0].id\n \n block_public_acls = var.block_public_acls\n block_public_policy = var.block_public_policy\n ignore_public_acls = var.ignore_public_acls\n restrict_public_buckets = var.restrict_public_buckets\n }\n+\n+resource \"aws_s3_bucket_ownership_controls\" \"this\" {\n+ count = var.create_bucket && var.control_object_ownership ? 1 : 0\n+\n+ bucket = local.attach_policy ? aws_s3_bucket_policy.this[0].id : aws_s3_bucket.this[0].id\n+\n+ rule {\n+ object_ownership = var.object_ownership\n+ }\n+\n+ # This `depends_on` is to prevent \"A conflicting conditional operation is currently in progress against this resource.\"\n+ depends_on = [\n+ aws_s3_bucket_policy.this,\n+ aws_s3_bucket_public_access_block.this,\n+ aws_s3_bucket.this\n+ ]\n+}\n---\nvariables.tf\n@@ -159,3 +159,15 @@ variable \"restrict_public_buckets\" {\n type = bool\n default = false\n }\n+\n+variable \"control_object_ownership\" {\n+ description = \"Whether to manage S3 Bucket Ownership Controls on this bucket.\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"object_ownership\" {\n+ description = \"Object ownership. Valid values: BucketOwnerPreferred or ObjectWriter. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL.\"\n+ type = string\n+ default = \"ObjectWriter\"\n+}\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -125,6 +125,7 @@ No modules.\n | Name | Type |\n |------|------|\n | [aws_s3_bucket.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |\n+| [aws_s3_bucket_ownership_controls.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls) | resource |\n | [aws_s3_bucket_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |\n | [aws_s3_bucket_public_access_block.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource |\n | [aws_elb_service_account.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/elb_service_account) | data source |\n@@ -148,6 +149,7 @@ No modules.\n | <a name=\"input_block_public_policy\"></a> [block\\_public\\_policy](#input\\_block\\_public\\_policy) | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | <a name=\"input_bucket\"></a> [bucket](#input\\_bucket) | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n | <a name=\"input_bucket_prefix\"></a> [bucket\\_prefix](#input\\_bucket\\_prefix) | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | `string` | `null` | no |\n+| <a are [control\\_object\\_ownership](#input\\_control\\_object\\_ownership) | Whether to manage S3 Bucket Ownership Controls on this bucket. | `bool` | `false` | no |\n | <a name=\"input_cors_rule\"></a> [cors\\_rule](#input\\_cors\\_rule) | List of maps containing rules for Cross-Origin Resource Sharing. | `any` | `[]` | no |\n | <a name=\"input_create_bucket\"></a> [create\\_bucket](#input\\_create\\_bucket) | Controls if S3 bucket should be created | `bool` | `true` | no |\n | <a name=\"input_force_destroy\"></a> [force\\_destroy](#input\\_force\\_destroy) | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n@@ -156,6 +158,7 @@ No modules.\n | <a name=\"input_lifecycle_rule\"></a> [lifecycle\\_rule](#input\\_lifecycle\\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | <a name=\"input_logging\"></a> [logging](#input\\_logging) | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n | <a name=\"input_object_lock_configuration\"></a> [object\\_lock\\_configuration](#input\\_object\\_lock\\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |\n+| <a name=\"input_object_ownership\"></a> [object\\_ownership](#input\\_object\\_ownership) | Object ownership. Valid values: BucketOwnerPreferred or ObjectWriter. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL. | `string` | `\"ObjectWriter\"` | no |\n | <a name=\"input_policy\"></a> [policy](#input\\_policy) | (Optional) A valid bucket policy JSON document. Note that if the policy document is not specific enough (but still valid), Terraform may view the policy as constantly changing in a terraform plan. In this case, please make sure you use the verbose/specific version of the policy. For more information about building AWS IAM policy documents with Terraform, see the AWS IAM Policy Document Guide. | `string` | `null` | no |\n | <a name=\"input_replication_configuration\"></a> [replication\\_configuration](#input\\_replication\\_configuration) | Map containing cross-region replication configuration. | `any` | `{}` | no |\n | <a name=\"input_request_payer\"></a> [request\\_payer](#input\\_request\\_payer) | (Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information. | `string` | `null` | no |\n---\nexamples/complete/main.tf\n@@ -213,4 +213,8 @@ module \"s3_bucket\" {\n block_public_policy = true\n ignore_public_acls = true\n restrict_public_buckets = true\n+\n+ # S3 Bucket Ownership Controls\n+ control_object_ownership = true\n+ object_ownership = \"BucketOwnerPreferred\"\n }\n---\nmain.tf\n@@ -376,10 +376,29 @@ resource \"aws_s3_bucket_public_access_block\" \"this\" {\n \n # Chain resources (s3_bucket -> s3_bucket_policy -> s3_bucket_public_access_block)\n # to prevent \"A conflicting conditional operation is currently in progress against this resource.\"\n+ # Ref: https://github.com/hashicorp/terraform-provider-aws/issues/7628\n+\n bucket = local.attach_policy ? aws_s3_bucket_policy.this[0].id : aws_s3_bucket.this[0].id\n \n block_public_acls = var.block_public_acls\n block_public_policy = var.block_public_policy\n ignore_public_acls = var.ignore_public_acls\n restrict_public_buckets = var.restrict_public_buckets\n }\n+\n+resource \"aws_s3_bucket_ownership_controls\" \"this\" {\n+ count = var.create_bucket && var.control_object_ownership ? 1 : 0\n+\n+ bucket = local.attach_policy ? aws_s3_bucket_policy.this[0].id : aws_s3_bucket.this[0].id\n+\n+ rule {\n+ object_ownership = var.object_ownership\n+ }\n+\n+ # This `depends_on` is to prevent \"A conflicting conditional operation is currently in progress against this resource.\"\n+ depends_on = [\n+ aws_s3_bucket_policy.this,\n+ aws_s3_bucket_public_access_block.this,\n+ aws_s3_bucket.this\n+ ]\n+}\n---\nvariables.tf\n@@ -159,3 +159,15 @@ variable \"restrict_public_buckets\" {\n type = bool\n default = false\n }\n+\n+variable \"control_object_ownership\" {\n+ description = \"Whether to manage S3 Bucket Ownership Controls on this bucket.\"\n+ type = bool\n+ default = false\n+}\n+\n+variable \"object_ownership\" {\n+ description = \"Object ownership. Valid values: BucketOwnerPreferred or ObjectWriter. 'BucketOwnerPreferred': Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL. 'ObjectWriter': The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL.\"\n+ type = string\n+ default = \"ObjectWriter\"\n+}\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\nFixes #93 \r\nBased on #95 (closes #95)\n\n---\n\nChoice A:\nREADME.md\n@@ -13,6 +13,7 @@ These features of S3 bucket configurations are supported:\n - object locking\n - Cross-Region Replication (CRR)\n - ELB log delivery bucket policy\n+- ALB/NLB log delivery bucket policy\n \n ## Usage\n \n@@ -48,6 +49,22 @@ module \"s3_bucket_for_logs\" {\n }\n ```\n \n+### Bucket with ALB/NLB access log delivery policy attached\n+\n+```hcl\n+module \"s3_bucket_for_logs\" {\n+ source = \"terraform-aws-modules/s3-bucket/aws\"\n+\n+ bucket = \"my-s3-bucket-for-logs\"\n+ acl = \"log-delivery-write\"\n+\n+ # Allow deletion of non-empty bucket\n+ force_destroy = true\n+\n+ attach_lb_log_delivery_policy = true\n+}\n+```\n+\n ## Conditional creation\n \n Sometimes you need to have a way to create S3 resources conditionally but Terraform does not allow to use `count` inside `module` block, so the solution is to specify argument `create_bucket`.\n@@ -113,6 +130,7 @@ No modules.\n | [aws_iam_policy_document.combined](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.deny_insecure_transport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.elb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.lb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n \n ## Inputs\n \n@@ -122,6 +140,7 @@ No modules.\n | <a name=\"input_acl\"></a> [acl](#input\\_acl) | (Optional) The canned ACL to apply. Defaults to 'private'. Conflicts with `grant` | `string` | `\"private\"` | no |\n | <a name=\"input_attach_deny_insecure_transport_policy\"></a> [attach\\_deny\\_insecure\\_transport\\_policy](#input\\_attach\\_deny\\_insecure\\_transport\\_policy) | Controls if S3 bucket should have deny non-SSL transport policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_elb_log_delivery_policy\"></a> [attach\\_elb\\_log\\_delivery\\_policy](#input\\_attach\\_elb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ELB log delivery policy attached | `bool` | `false` | no |\n+| <a name=\"input_attach_lb_log_delivery_policy\"></a> [attach\\_lb\\_log\\_delivery\\_policy](#input\\_attach\\_lb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ALB/NLB log delivery policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_policy\"></a> [attach\\_policy](#input\\_attach\\_policy) | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | `bool` | `false` | no |\n | <a name=\"input_attach_public_policy\"></a> [attach\\_public\\_policy](#input\\_attach\\_public\\_policy) | Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket) | `bool` | `true` | no |\n | <a name=\"input_block_public_acls\"></a> [block\\_public\\_acls](#input\\_block\\_public\\_acls) | Whether Amazon S3 should block public ACLs for this bucket. | `bool` | `false` | no |\n---\nexamples/complete/README.md\n@@ -2,7 +2,7 @@\n \n Configuration in this directory creates S3 bucket which demos such capabilities:\n - static web-site hosting\n-- access logging (for S3 and ELB)\n+- access logging (for S3, ELB and ALB/NLB)\n - versioning\n - CORS\n - lifecycle rules\n---\nexamples/complete/main.tf\n@@ -55,6 +55,7 @@ module \"log_bucket\" {\n acl = \"log-delivery-write\"\n force_destroy = true\n attach_elb_log_delivery_policy = true\n+ attach_lb_log_delivery_policy = true\n attach_deny_insecure_transport_policy = true\n }\n \n---\nmain.tf\n@@ -1,5 +1,5 @@\n locals {\n- attach_policy = var.attach_elb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n+ attach_policy = var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -247,6 +247,7 @@ data \"aws_iam_policy_document\" \"combined\" {\n \n source_policy_documents = compact([\n var.attach_elb_log_delivery_policy ? data.aws_iam_policy_document.elb_log_delivery[0].json : \"\",\n+ Amazon var.attach_lb_log_delivery_policy ? data.aws_iam_policy_document.lb_log_delivery[0].json : \"\",\n var.attach_deny_insecure_transport_policy ? data.aws_iam_policy_document.deny_insecure_transport[0].json : \"\",\n var.attach_policy ? var.policy : \"\"\n ])\n@@ -280,6 +281,57 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n }\n }\n \n+# ALB/NLB\n+\n+data \"aws_iam_policy_document\" \"lb_log_delivery\" {\n+ count = var.create_bucket && var.attach_lb_log_delivery_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"AWSLogDeliveryWrite\"\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"delivery.logs.amazonaws.com\"]\n+ }\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"s3:PutObject\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}/*\",\n+ ]\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"s3:x-amz-acl\"\n+ values = [\"bucket-owner-full-control\"]\n+ }\n+ }\n+\n+ statement {\n+ sid = \"AWSLogDeliveryAclCheck\"\n+\n+ effect = \"Allow\"\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"delivery.logs.amazonaws.com\"]\n+ }\n+\n+ actions = [\n+ \"s3:GetBucketAcl\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}\",\n+ ]\n+\n+ }\n+}\n+\n data \"aws_iam_policy_document\" \"deny_insecure_transport\" {\n count = var.create_bucket && var.attach_deny_insecure_transport_policy ? 1 : 0\n \n---\nvariables.tf\n@@ -10,6 +10,12 @@ variable \"attach_elb_log_delivery_policy\" {\n default = false\n }\n \n+variable \"attach_lb_log_delivery_policy\" {\n+ description = \"Controls if S3 bucket should have ALB/NLB log delivery policy attached\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"attach_deny_insecure_transport_policy\" {\n description = \"Controls if S3 bucket should have deny non-SSL transport policy attached\"\n type = bool\n---\nwrappers/README.md\n@@ -6,7 +6,7 @@ You may want to use a single Terragrunt configuration file to manage multiple re\n \n This wrapper does not implement any extra functionality.\n \n-# Usage with Terragrunt\n+## Usage with Terragrunt\n \n `terragrunt.hcl`:\n \n---\nwrappers/main.tf\n@@ -5,6 +5,7 @@ module \"wrapper\" {\n \n create_bucket = lookup(each.value, \"create_bucket\", true)\n attach_elb_log_delivery_policy = lookup(each.value, \"attach_elb_log_delivery_policy\", false)\n+ attach_lb_log_delivery_policy = lookup(each.value, \"attach_lb_log_delivery_policy\", false)\n attach_deny_insecure_transport_policy = lookup(each.value, \"attach_deny_insecure_transport_policy\", false)\n attach_policy = lookup(each.value, \"attach_policy\", false)\n attach_public_policy = lookup(each.value, \"attach_public_policy\", true)\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -13,6 +13,7 @@ These features of S3 bucket configurations are supported:\n - object locking\n - Cross-Region Replication (CRR)\n - ELB log delivery bucket policy\n+- ALB/NLB log delivery bucket policy\n \n ## Usage\n modules.\n -48,6 +49,22 @@ module \"s3_bucket_for_logs\" {\n }\n ```\n \n+### Bucket with ALB/NLB access log delivery policy attached\n+\n+```hcl\n+module \"s3_bucket_for_logs\" {\n+ source = \"terraform-aws-modules/s3-bucket/aws\"\n+\n+ bucket = \"my-s3-bucket-for-logs\"\n+ acl = \"log-delivery-write\"\n+\n+ # Allow deletion of non-empty bucket\n+ force_destroy = true\n+\n+ attach_lb_log_delivery_policy = true\n+}\n+```\n+\n ## Conditional creation\n \n Sometimes you need to have a way to create S3 resources conditionally but Terraform does not allow to use `count` inside `module` block, so the solution is to specify argument `create_bucket`.\n@@ -113,6 +130,7 @@ No modules.\n | [aws_iam_policy_document.combined](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.deny_insecure_transport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.elb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.lb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n \n ## Inputs\n \n@@ -122,6 +140,7 @@ No modules.\n | <a name=\"input_acl\"></a> [acl](#input\\_acl) | (Optional) The canned ACL to apply. Defaults to 'private'. Conflicts with `grant` | `string` | `\"private\"` | no |\n | <a name=\"input_attach_deny_insecure_transport_policy\"></a> [attach\\_deny\\_insecure\\_transport\\_policy](#input\\_attach\\_deny\\_insecure\\_transport\\_policy) | Controls if S3 bucket should have deny non-SSL transport policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_elb_log_delivery_policy\"></a> [attach\\_elb\\_log\\_delivery\\_policy](#input\\_attach\\_elb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ELB log delivery policy attached | `bool` | `false` | no |\n+| <a name=\"input_attach_lb_log_delivery_policy\"></a> [attach\\_lb\\_log\\_delivery\\_policy](#input\\_attach\\_lb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ALB/NLB log delivery policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_policy\"></a> [attach\\_policy](#input\\_attach\\_policy) | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | `bool` | `false` | no |\n | <a name=\"input_attach_public_policy\"></a> [attach\\_public\\_policy](#input\\_attach\\_public\\_policy) | Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket) | `bool` | `true` | no |\n | <a name=\"input_block_public_acls\"></a> [block\\_public\\_acls](#input\\_block\\_public\\_acls) | Whether Amazon S3 should block public ACLs for this bucket. | `bool` | `false` | no |\n---\nexamples/complete/README.md\n@@ -2,7 +2,7 @@\n \n Configuration in this directory creates S3 bucket which demos such capabilities:\n - static web-site hosting\n-- access logging (for S3 and ELB)\n+- access logging (for S3, ELB and ALB/NLB)\n - versioning\n - CORS\n - lifecycle rules\n---\nexamples/complete/main.tf\n@@ -55,6 +55,7 @@ module \"log_bucket\" {\n acl = \"log-delivery-write\"\n force_destroy = true\n attach_elb_log_delivery_policy = true\n+ attach_lb_log_delivery_policy = true\n attach_deny_insecure_transport_policy = true\n }\n \n---\nmain.tf\n@@ -1,5 +1,5 @@\n locals {\n- attach_policy = var.attach_elb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n+ attach_policy = var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -247,6 +247,7 @@ data \"aws_iam_policy_document\" \"combined\" {\n \n source_policy_documents = compact([\n var.attach_elb_log_delivery_policy ? data.aws_iam_policy_document.elb_log_delivery[0].json : \"\",\n+ var.attach_lb_log_delivery_policy ? data.aws_iam_policy_document.lb_log_delivery[0].json : \"\",\n var.attach_deny_insecure_transport_policy ? data.aws_iam_policy_document.deny_insecure_transport[0].json : \"\",\n var.attach_policy ? var.policy : \"\"\n ])\n@@ -280,6 +281,57 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n }\n }\n \n+# ALB/NLB\n+\n+data \"aws_iam_policy_document\" \"lb_log_delivery\" {\n+ count = var.create_bucket && var.attach_lb_log_delivery_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"AWSLogDeliveryWrite\"\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"delivery.logs.amazonaws.com\"]\n+ }\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"s3:PutObject\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}/*\",\n+ ]\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"s3:x-amz-acl\"\n+ values = [\"bucket-owner-full-control\"]\n+ }\n+ }\n+\n+ statement {\n+ sid = \"AWSLogDeliveryAclCheck\"\n+\n+ effect = \"Allow\"\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"delivery.logs.amazonaws.com\"]\n+ }\n+\n+ actions = [\n+ \"s3:GetBucketAcl\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}\",\n+ ]\n+\n+ }\n+}\n+\n data \"aws_iam_policy_document\" \"deny_insecure_transport\" {\n count = var.create_bucket && var.attach_deny_insecure_transport_policy ? 1 : 0\n \n---\nvariables.tf\n@@ -10,6 +10,12 @@ variable \"attach_elb_log_delivery_policy\" {\n default = false\n }\n \n+variable \"attach_lb_log_delivery_policy\" {\n+ description = \"Controls if S3 bucket should have ALB/NLB log delivery policy attached\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"attach_deny_insecure_transport_policy\" {\n description = \"Controls if S3 bucket should have deny non-SSL transport policy attached\"\n type = bool\n---\nwrappers/README.md\n@@ -6,7 +6,7 @@ You may want to use a single Terragrunt configuration file to manage multiple re\n \n This wrapper does not implement any extra functionality.\n \n-# Usage with Terragrunt\n+## Usage with Terragrunt\n \n `terragrunt.hcl`:\n \n---\nwrappers/main.tf\n@@ -5,6 +5,7 @@ module \"wrapper\" {\n \n create_bucket = lookup(each.value, \"create_bucket\", true)\n attach_elb_log_delivery_policy = lookup(each.value, \"attach_elb_log_delivery_policy\", false)\n+ attach_lb_log_delivery_policy = lookup(each.value, \"attach_lb_log_delivery_policy\", false)\n attach_deny_insecure_transport_policy = lookup(each.value, \"attach_deny_insecure_transport_policy\", false)\n attach_policy = lookup(each.value, \"attach_policy\", false)\n attach_public_policy = lookup(each.value, \"attach_public_policy\", true)\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -13,6 +13,7 @@ These features of S3 bucket configurations are supported:\n - object locking\n - Cross-Region Replication (CRR)\n - ELB log delivery bucket policy\n+- ALB/NLB log delivery bucket policy\n \n ## Usage\n \n@@ -48,6 +49,22 @@ module \"s3_bucket_for_logs\" {\n }\n ```\n \n+### Bucket with ALB/NLB access log delivery policy attached\n+\n+```hcl\n+module \"s3_bucket_for_logs\" {\n+ source = \"terraform-aws-modules/s3-bucket/aws\"\n+\n+ bucket = \"my-s3-bucket-for-logs\"\n+ acl = \"log-delivery-write\"\n+\n+ # Allow deletion of non-empty bucket\n+ force_destroy = true\n+\n+ attach_lb_log_delivery_policy = true\n+}\n+```\n+\n ## Conditional creation\n \n Sometimes you need to have a way to create S3 resources conditionally but Terraform does not allow to use `count` inside `module` block, so the solution is to specify argument `create_bucket`.\n@@ -113,6 +130,7 @@ No modules.\n | [aws_iam_policy_document.combined](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.deny_insecure_transport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.elb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.lb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n \n ## Inputs\n \n@@ -122,6 +140,7 @@ No modules.\n | <a name=\"input_acl\"></a> [acl](#input\\_acl) | (Optional) The canned ACL to apply. Defaults to 'private'. Conflicts with `grant` | `string` | `\"private\"` | no |\n | <a name=\"input_attach_deny_insecure_transport_policy\"></a> [attach\\_deny\\_insecure\\_transport\\_policy](#input\\_attach\\_deny\\_insecure\\_transport\\_policy) | Controls if S3 bucket should have deny non-SSL transport policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_elb_log_delivery_policy\"></a> [attach\\_elb\\_log\\_delivery\\_policy](#input\\_attach\\_elb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ELB log delivery policy attached | `bool` | `false` | no |\n+| <a name=\"input_attach_lb_log_delivery_policy\"></a> [attach\\_lb\\_log\\_delivery\\_policy](#input\\_attach\\_lb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ALB/NLB log delivery policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_policy\"></a> [attach\\_policy](#input\\_attach\\_policy) | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | `bool` | `false` | no |\n | <a name=\"input_attach_public_policy\"></a> [attach\\_public\\_policy](#input\\_attach\\_public\\_policy) | Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket) | `bool` | `true` | no |\n | <a name=\"input_block_public_acls\"></a> [block\\_public\\_acls](#input\\_block\\_public\\_acls) | Whether Amazon S3 should block public ACLs for this bucket. | `bool` | `false` | no |\n---\nexamples/complete/README.md\n@@ -2,7 +2,7 @@\n \n Configuration in this directory creates S3 bucket which demos such capabilities:\n - static web-site hosting\n-- access logging (for S3 and ELB)\n+- access logging (for S3, ELB and ALB/NLB)\n - versioning\n - CORS\n - lifecycle rules\n---\nexamples/complete/main.tf\n@@ -55,6 +55,7 @@ module \"log_bucket\" {\n acl = \"log-delivery-write\"\n force_destroy = true\n attach_elb_log_delivery_policy = true\n+ attach_lb_log_delivery_policy = true\n attach_deny_insecure_transport_policy = true\n }\n \n---\nmain.tf\n@@ -1,5 +1,5 @@\n locals {\n- attach_policy = var.attach_elb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n+ attach_policy = var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -247,6 +247,7 @@ data \"aws_iam_policy_document\" \"combined\" {\n \n source_policy_documents = compact([\n var.attach_elb_log_delivery_policy ? data.aws_iam_policy_document.elb_log_delivery[0].json : \"\",\n+ var.attach_lb_log_delivery_policy ? data.aws_iam_policy_document.lb_log_delivery[0].json : \"\",\n var.attach_deny_insecure_transport_policy ? data.aws_iam_policy_document.deny_insecure_transport[0].json : \"\",\n var.attach_policy ? var.policy : \"\"\n ])\n@@ -280,6 +281,57 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n }\n }\n \n+# ALB/NLB\n+\n+data \"aws_iam_policy_document\" \"lb_log_delivery\" {\n+ count = var.create_bucket && var.attach_lb_log_delivery_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"AWSLogDeliveryWrite\"\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"delivery.logs.amazonaws.com\"]\n+ }\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"s3:PutObject\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}/*\",\n+ ]\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"s3:x-amz-acl\"\n+ values = [\"bucket-owner-full-control\"]\n+ }\n+ }\n+\n+ statement {\n+ sid = \"AWSLogDeliveryAclCheck\"\n+\n+ effect = \"Allow\"\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"delivery.logs.amazonaws.com\"]\n+ }\n+\n+ actions = [\n+ \"s3:GetBucketAcl\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}\",\n+ ]\n+\n+ }\n+}\n+\n data \"aws_iam_policy_document\" \"deny_insecure_transport\" {\n count = var.create_bucket && var.attach_deny_insecure_transport_policy ? 1 : 0\n \n---\nvariables.tf\n@@ -10,6 +10,12 @@ variable \"attach_elb_log_delivery_policy\" {\n default = false\n }\n \n+variable \"attach_lb_log_delivery_policy\" {\n+ description = \"Controls if S3 bucket should have ALB/NLB log delivery policy attached\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"attach_deny_insecure_transport_policy\" {\n description = \"Controls if S3 bucket should have deny non-SSL transport policy attached\"\n type = bool\n---\nwrappers/README.md\n@@ -6,7 +6,7 @@ You may want to use a single Terragrunt configuration file to manage multiple re\n \n This wrapper does not implement any extra functionality.\n \n-# Usage with Terragrunt\n+## Usage with Terragrunt\n \n `terragrunt.hcl`:\n \n---\nwrappers/main.tf\n@@ -5,6 +5,7 @@ module \"wrapper\" {\n \n create_bucket = lookup(each.value, \"create_bucket\", true)\n attach_elb_log_delivery_policy = lookup(each.value, \"attach_elb_log_delivery_policy\", false)\n+ attach_lb_log_delivery_policy = lookup(each.value, \"attach_lb_log_delivery_policy\", false)\n attach_deny_insecure_transport_policy = lookup(each.value, \"attach_deny_insecure_transport_policy\", false)\n attach_policy = lookup(each.value, \"attach_policy\", false)\n attach_public_policy = lookup(each.value, \"attach_public_policy\", true)\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -13,6 +13,7 @@ These features of S3 bucket configurations are supported:\n - object locking\n - Cross-Region Replication (CRR)\n - ELB log delivery bucket -5,6 ALB/NLB log delivery bucket policy\n \n ## Usage\n \n@@ -48,6 +49,22 @@ module \"s3_bucket_for_logs\" {\n }\n ```\n \n+### Bucket with ALB/NLB access log delivery policy attached\n+\n+```hcl\n+module \"s3_bucket_for_logs\" {\n+ source = \"terraform-aws-modules/s3-bucket/aws\"\n+\n+ bucket = \"my-s3-bucket-for-logs\"\n+ acl = \"log-delivery-write\"\n+\n+ # Allow deletion of non-empty bucket\n+ force_destroy = true\n+\n+ attach_lb_log_delivery_policy = true\n+}\n+```\n+\n ## Conditional creation\n \n Sometimes you need to have a way to create S3 resources conditionally but Terraform does not allow to use `count` inside `module` block, so the solution is to specify argument `create_bucket`.\n@@ -113,6 +130,7 @@ No modules.\n | [aws_iam_policy_document.combined](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.deny_insecure_transport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n | [aws_iam_policy_document.elb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n+| [aws_iam_policy_document.lb_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n \n ## Inputs\n \n@@ -122,6 +140,7 @@ No modules.\n | <a name=\"input_acl\"></a> [acl](#input\\_acl) | (Optional) The canned ACL to apply. Defaults to 'private'. Conflicts with `grant` | `string` | `\"private\"` | no |\n | <a name=\"input_attach_deny_insecure_transport_policy\"></a> [attach\\_deny\\_insecure\\_transport\\_policy](#input\\_attach\\_deny\\_insecure\\_transport\\_policy) | Controls if S3 bucket should have deny non-SSL transport policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_elb_log_delivery_policy\"></a> [attach\\_elb\\_log\\_delivery\\_policy](#input\\_attach\\_elb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ELB log delivery policy attached | `bool` | `false` | no |\n+| <a name=\"input_attach_lb_log_delivery_policy\"></a> [attach\\_lb\\_log\\_delivery\\_policy](#input\\_attach\\_lb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ALB/NLB log delivery policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_policy\"></a> [attach\\_policy](#input\\_attach\\_policy) | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | `bool` | `false` | no |\n | <a name=\"input_attach_public_policy\"></a> [attach\\_public\\_policy](#input\\_attach\\_public\\_policy) | Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket) | `bool` | `true` | no |\n | <a name=\"input_block_public_acls\"></a> [block\\_public\\_acls](#input\\_block\\_public\\_acls) | Whether Amazon S3 should block public ACLs for this bucket. | `bool` | `false` | no |\n---\nexamples/complete/README.md\n@@ -2,7 +2,7 @@\n \n Configuration in this directory creates S3 bucket which demos such capabilities:\n - static web-site hosting\n-- access logging (for S3 and ELB)\n+- access logging (for S3, ELB and ALB/NLB)\n - versioning\n - CORS\n - lifecycle rules\n---\nexamples/complete/main.tf\n@@ -55,6 +55,7 @@ module \"log_bucket\" {\n acl = \"log-delivery-write\"\n force_destroy = true\n attach_elb_log_delivery_policy = true\n+ attach_lb_log_delivery_policy = true\n attach_deny_insecure_transport_policy = true\n }\n \n---\nmain.tf\n@@ -1,5 +1,5 @@\n locals {\n- attach_policy = var.attach_elb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n+ attach_policy = var.attach_elb_log_delivery_policy || var.attach_lb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -247,6 +247,7 @@ data \"aws_iam_policy_document\" \"combined\" {\n \n source_policy_documents = compact([\n var.attach_elb_log_delivery_policy ? data.aws_iam_policy_document.elb_log_delivery[0].json : \"\",\n+ var.attach_lb_log_delivery_policy ? data.aws_iam_policy_document.lb_log_delivery[0].json : \"\",\n var.attach_deny_insecure_transport_policy ? data.aws_iam_policy_document.deny_insecure_transport[0].json : \"\",\n var.attach_policy ? var.policy : \"\"\n ])\n@@ -280,6 +281,57 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n }\n }\n \n+# ALB/NLB\n+\n+data \"aws_iam_policy_document\" \"lb_log_delivery\" {\n+ count = var.create_bucket && var.attach_lb_log_delivery_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"AWSLogDeliveryWrite\"\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"delivery.logs.amazonaws.com\"]\n+ }\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"s3:PutObject\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}/*\",\n+ ]\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"s3:x-amz-acl\"\n+ values = [\"bucket-owner-full-control\"]\n+ }\n+ }\n+\n+ statement {\n+ sid = \"AWSLogDeliveryAclCheck\"\n+\n+ effect = \"Allow\"\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"delivery.logs.amazonaws.com\"]\n+ }\n+\n+ actions = [\n+ \"s3:GetBucketAcl\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}\",\n+ ]\n+\n+ }\n+}\n+\n data \"aws_iam_policy_document\" \"deny_insecure_transport\" {\n count = var.create_bucket && var.attach_deny_insecure_transport_policy ? 1 : 0\n \n---\nvariables.tf\n@@ -10,6 +10,12 @@ variable \"attach_elb_log_delivery_policy\" {\n default = false\n }\n \n+variable \"attach_lb_log_delivery_policy\" {\n+ description = \"Controls if S3 bucket should have ALB/NLB log delivery policy attached\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"attach_deny_insecure_transport_policy\" {\n description = \"Controls if S3 bucket should have deny non-SSL transport policy attached\"\n type = bool\n---\nwrappers/README.md\n@@ -6,7 +6,7 @@ You may want to use a single Terragrunt configuration file to manage multiple re\n \n This wrapper does not implement any extra functionality.\n \n-# Usage with Terragrunt\n+## Usage with Terragrunt\n \n `terragrunt.hcl`:\n \n---\nwrappers/main.tf\n@@ -5,6 +5,7 @@ module \"wrapper\" {\n \n create_bucket = lookup(each.value, \"create_bucket\", true)\n attach_elb_log_delivery_policy = lookup(each.value, \"attach_elb_log_delivery_policy\", false)\n+ attach_lb_log_delivery_policy = lookup(each.value, \"attach_lb_log_delivery_policy\", false)\n attach_deny_insecure_transport_policy = lookup(each.value, \"attach_deny_insecure_transport_policy\", false)\n attach_policy = lookup(each.value, \"attach_policy\", false)\n attach_public_policy = lookup(each.value, \"attach_public_policy\", true)\n---\n\n\n---\n" } ]
C
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\nFixes #93 \r\n\r\nAny comments are welcome.\n\n---\n\nChoice A:\nREADME.md\n@@ -13,6 +13,7 @@ These features of S3 bucket configurations are supported:\n - object locking\n - Cross-Region Replication (CRR)\n - ELB log delivery bucket policy\n+- NLB log delivery bucket policy\n \n ## Usage\n \n@@ -48,6 +49,22 @@ module \"s3_bucket_for_logs\" {\n }\n ```\n \n+### Bucket with NLB access log delivery policy attached\n+\n+```hcl\n+module \"s3_bucket_for_logs\" {\n+ source = \"terraform-aws-modules/s3-bucket/aws\"\n+\n+ bucket = \"my-s3-bucket-for-logs\"\n+ acl = \"log-delivery-write\"\n+\n+ # Allow deletion of non-empty bucket\n+ force_destroy = true\n+\n+ attach_nlb_log_delivery_policy = true\n+}\n+```\n+\n ## Conditional creation\n \n Sometimes you need to have a way to create S3 resources conditionally but Terraform does not allow to use `count` inside `module` block, so the solution is to specify argument `create_bucket`.\n@@ -122,6 +139,7 @@ No modules.\n | <a name=\"input_acl\"></a> [acl](#input\\_acl) | (Optional) The canned ACL to apply. Defaults to 'private'. Conflicts with `grant` | `string` | `\"private\"` | no |\n | <a name=\"input_attach_deny_insecure_transport_policy\"></a> [attach\\_deny\\_insecure\\_transport\\_policy](#input\\_attach\\_deny\\_insecure\\_transport\\_policy) | Controls if S3 bucket should have deny non-SSL transport policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_elb_log_delivery_policy\"></a> [attach\\_elb\\_log\\_delivery\\_policy](#input\\_attach\\_elb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ELB log delivery policy attached | `bool` | `false` | no |\n+| <a name=\"input_attach_nlb_log_delivery_policy\"></a> [attach\\_nlb\\_log\\_delivery\\_policy](#input\\_attach\\_elb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have NLB log delivery policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_policy\"></a> [attach\\_policy](#input\\_attach\\_policy) | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | `bool` | `false` | no |\n | <a name=\"input_attach_public_policy\"></a> [attach\\_public\\_policy](#input\\_attach\\_public\\_policy) | Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket) | `bool` | `true` | no |\n | <a name=\"input_block_public_acls\"></a> [block\\_public\\_acls](#input\\_block\\_public\\_acls) | Whether Amazon S3 should block public ACLs for this bucket. | `bool` | `false` | no |\n---\nmain.tf\n@@ -1,5 +1,5 @@\n locals {\n- attach_policy = var.attach_elb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n+ attach_policy = var.attach_elb_log_delivery_policy || var.attach_nlb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -247,6 +247,7 @@ data \"aws_iam_policy_document\" \"combined\" {\n \n source_policy_documents = compact([\n var.attach_elb_log_delivery_policy ? data.aws_iam_policy_document.elb_log_delivery[0].json : \"\",\n+ var.attach_nlb_log_delivery_policy ? data.aws_iam_policy_document.nlb_log_delivery[0].json : \"\",\n var.attach_deny_insecure_transport_policy ? data.aws_iam_policy_document.deny_insecure_transport[0].json : \"\",\n var.attach_policy ? var.policy : \"\"\n ])\n@@ -280,6 +281,57 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n }\n }\n \n+# NLB \n+\n+data \"aws_iam_policy_document\" \"nlb_log_delivery\" {\n+ count = var.create_bucket && var.attach_nlb_log_delivery_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"AWSLogDeliveryWrite\"\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"delivery.logs.amazonaws.com\"]\n+ }\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"s3:PutObject\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}/*\",\n+ ]\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"s3:x-amz-acl\"\n+ values = [\"bucket-owner-full-control\"]\n+ }\n+ }\n+\n+ statement {\n+ sid = \"AWSLogDeliveryAclCheck\"\n+\n+ effect = \"Allow\"\n+\n+ |\n {\n+ type = \"Service\"\n+ identifiers = [\"delivery.logs.amazonaws.com\"]\n+ }\n+\n+ actions = [\n+ \"s3:GetBucketAcl\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}\",\n+ ]\n+\n+ }\n+}\n+\n data \"aws_iam_policy_document\" \"deny_insecure_transport\" {\n count = var.create_bucket && var.attach_deny_insecure_transport_policy ? 1 : 0\n \n---\nvariables.tf\n@@ -10,6 +10,12 @@ variable \"attach_elb_log_delivery_policy\" {\n default = false\n }\n \n+variable \"attach_nlb_log_delivery_policy\" {\n+ description = \"Controls if S3 bucket should have NLB log delivery policy attached\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"attach_deny_insecure_transport_policy\" {\n description = \"Controls if S3 bucket should have deny non-SSL transport policy attached\"\n type = bool\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -13,6 +13,7 @@ These features of S3 bucket configurations are supported:\n - object locking\n - Cross-Region Replication (CRR)\n - ELB log delivery bucket policy\n+- NLB log delivery bucket policy\n \n ## Usage\n \n@@ -48,6 +49,22 @@ module \"s3_bucket_for_logs\" {\n }\n ```\n \n+### Bucket with NLB access log delivery policy attached\n+\n+```hcl\n+module \"s3_bucket_for_logs\" {\n+ source = \"terraform-aws-modules/s3-bucket/aws\"\n+\n+ bucket = \"my-s3-bucket-for-logs\"\n+ acl = \"log-delivery-write\"\n+\n+ # Allow deletion of non-empty bucket\n+ force_destroy = true\n+\n+ attach_nlb_log_delivery_policy = true\n+}\n+```\n+\n ## Conditional creation\n \n Sometimes you need to have a way to create S3 resources conditionally but Terraform does not allow to use `count` inside `module` block, so the solution is to specify argument `create_bucket`.\n@@ -122,6 +139,7 @@ No modules.\n | <a name=\"input_acl\"></a> [acl](#input\\_acl) | (Optional) The canned ACL to apply. Defaults to 'private'. Conflicts with `grant` | `string` | `\"private\"` | no |\n | <a name=\"input_attach_deny_insecure_transport_policy\"></a> [attach\\_deny\\_insecure\\_transport\\_policy](#input\\_attach\\_deny\\_insecure\\_transport\\_policy) | Controls if S3 bucket should have deny non-SSL transport policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_elb_log_delivery_policy\"></a> [attach\\_elb\\_log\\_delivery\\_policy](#input\\_attach\\_elb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ELB log delivery policy attached | `bool` | `false` | no |\n+| <a name=\"input_attach_nlb_log_delivery_policy\"></a> [attach\\_nlb\\_log\\_delivery\\_policy](#input\\_attach\\_elb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have NLB log delivery policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_policy\"></a> [attach\\_policy](#input\\_attach\\_policy) | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | `bool` | `false` | no |\n | <a name=\"input_attach_public_policy\"></a> [attach\\_public\\_policy](#input\\_attach\\_public\\_policy) | Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket) | `bool` | `true` | no |\n | <a name=\"input_block_public_acls\"></a> [block\\_public\\_acls](#input\\_block\\_public\\_acls) | Whether Amazon S3 should block public ACLs for this bucket. | `bool` | `false` | no |\n---\nmain.tf\n@@ -1,5 +1,5 @@\n locals {\n- attach_policy = var.attach_elb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n+ attach_policy = var.attach_elb_log_delivery_policy || var.attach_nlb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -247,6 +247,7 @@ data \"aws_iam_policy_document\" \"combined\" {\n \n source_policy_documents = compact([\n var.attach_elb_log_delivery_policy ? data.aws_iam_policy_document.elb_log_delivery[0].json : \"\",\n+ var.attach_nlb_log_delivery_policy ? data.aws_iam_policy_document.nlb_log_delivery[0].json : \"\",\n var.attach_deny_insecure_transport_policy ? data.aws_iam_policy_document.deny_insecure_transport[0].json : \"\",\n var.attach_policy ? var.policy : \"\"\n +49,22 -280,6 +281,57 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n }\n }\n \n+# NLB \n+\n+data \"aws_iam_policy_document\" \"nlb_log_delivery\" {\n+ count = var.create_bucket && var.attach_nlb_log_delivery_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"AWSLogDeliveryWrite\"\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"delivery.logs.amazonaws.com\"]\n+ }\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"s3:PutObject\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}/*\",\n+ ]\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"s3:x-amz-acl\"\n+ values = [\"bucket-owner-full-control\"]\n+ }\n+ }\n+\n+ statement {\n+ sid = \"AWSLogDeliveryAclCheck\"\n+\n+ effect = \"Allow\"\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"delivery.logs.amazonaws.com\"]\n+ }\n+\n+ actions = [\n+ \"s3:GetBucketAcl\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}\",\n+ ]\n+\n+ }\n+}\n+\n data \"aws_iam_policy_document\" \"deny_insecure_transport\" {\n count = var.create_bucket && var.attach_deny_insecure_transport_policy ? 1 : 0\n \n---\nvariables.tf\n@@ -10,6 +10,12 @@ variable \"attach_elb_log_delivery_policy\" {\n default = false\n }\n \n+variable \"attach_nlb_log_delivery_policy\" {\n+ description = \"Controls if S3 bucket should have NLB log delivery policy attached\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"attach_deny_insecure_transport_policy\" {\n description = \"Controls if S3 bucket should have deny non-SSL transport policy attached\"\n type = bool\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -13,6 +13,7 @@ These features of S3 bucket configurations are supported:\n - object locking\n - Cross-Region Replication (CRR)\n - ELB log delivery bucket policy\n+- NLB log delivery bucket policy\n \n ## Usage\n \n@@ -48,6 +49,22 @@ module \"s3_bucket_for_logs\" {\n }\n ```\n \n+### Bucket with NLB access log delivery policy attached\n+\n+```hcl\n+module \"s3_bucket_for_logs\" {\n+ source = \"terraform-aws-modules/s3-bucket/aws\"\n+\n+ bucket = \"my-s3-bucket-for-logs\"\n+ acl = \"log-delivery-write\"\n+\n+ # Allow deletion of non-empty bucket\n+ force_destroy = true\n+\n+ attach_nlb_log_delivery_policy = true\n+}\n+```\n+\n ## Conditional creation\n \n Sometimes you need to have a way to create S3 resources conditionally but Terraform does not allow to use `count` inside `module` block, so the solution is to specify argument `create_bucket`.\n@@ -122,6 +139,7 @@ No modules.\n | <a name=\"input_acl\"></a> [acl](#input\\_acl) | (Optional) The canned ACL to apply. Defaults to 'private'. Conflicts with `grant` | `string` | `\"private\"` | no |\n | <a name=\"input_attach_deny_insecure_transport_policy\"></a> [attach\\_deny\\_insecure\\_transport\\_policy](#input\\_attach\\_deny\\_insecure\\_transport\\_policy) | Controls if S3 bucket should have deny non-SSL transport policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_elb_log_delivery_policy\"></a> [attach\\_elb\\_log\\_delivery\\_policy](#input\\_attach\\_elb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ELB log delivery policy attached | `bool` | `false` | no |\n+| <a name=\"input_attach_nlb_log_delivery_policy\"></a> [attach\\_nlb\\_log\\_delivery\\_policy](#input\\_attach\\_elb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have NLB log delivery policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_policy\"></a> [attach\\_policy](#input\\_attach\\_policy) | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | `bool` | `false` | no |\n | <a name=\"input_attach_public_policy\"></a> [attach\\_public\\_policy](#input\\_attach\\_public\\_policy) | Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket) | `bool` | `true` | no |\n | <a name=\"input_block_public_acls\"></a> [block\\_public\\_acls](#input\\_block\\_public\\_acls) | Whether Amazon S3 should block public ACLs for this bucket. | `bool` | `false` | no |\n---\nmain.tf\n@@ -1,5 +1,5 @@\n locals {\n- attach_policy = var.attach_elb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n+ attach_policy = var.attach_elb_log_delivery_policy || var.attach_nlb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -247,6 +247,7 @@ data \"aws_iam_policy_document\" \"combined\" {\n \n source_policy_documents = compact([\n var.attach_elb_log_delivery_policy ? data.aws_iam_policy_document.elb_log_delivery[0].json : \"\",\n+ var.attach_nlb_log_delivery_policy ? data.aws_iam_policy_document.nlb_log_delivery[0].json : \"\",\n var.attach_deny_insecure_transport_policy ? data.aws_iam_policy_document.deny_insecure_transport[0].json : \"\",\n var.attach_policy ? var.policy : \"\"\n ])\n@@ -280,6 +281,57 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n }\n }\n \n+# NLB \n+\n+data \"aws_iam_policy_document\" \"nlb_log_delivery\" {\n+ count = var.create_bucket && var.attach_nlb_log_delivery_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"AWSLogDeliveryWrite\"\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"delivery.logs.amazonaws.com\"]\n+ }\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"s3:PutObject\",\n+ delivery resources = [\n+ \"${aws_s3_bucket.this[0].arn}/*\",\n+ ]\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"s3:x-amz-acl\"\n+ values = [\"bucket-owner-full-control\"]\n+ }\n+ }\n+\n+ statement {\n+ sid = \"AWSLogDeliveryAclCheck\"\n+\n+ effect = \"Allow\"\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"delivery.logs.amazonaws.com\"]\n+ }\n+\n+ actions = [\n+ \"s3:GetBucketAcl\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}\",\n+ ]\n+\n+ }\n+}\n+\n data \"aws_iam_policy_document\" \"deny_insecure_transport\" {\n count = var.create_bucket && var.attach_deny_insecure_transport_policy ? 1 : 0\n \n---\nvariables.tf\n@@ -10,6 +10,12 @@ variable \"attach_elb_log_delivery_policy\" {\n default = false\n }\n \n+variable \"attach_nlb_log_delivery_policy\" {\n+ description = \"Controls if S3 bucket should have NLB log delivery policy attached\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"attach_deny_insecure_transport_policy\" {\n description = \"Controls if S3 bucket should have deny non-SSL transport policy attached\"\n type = bool\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -13,6 +13,7 @@ These features of S3 bucket configurations are supported:\n - object locking\n - Cross-Region Replication (CRR)\n - ELB log delivery bucket policy\n+- NLB log delivery bucket policy\n \n ## Usage\n \n@@ -48,6 +49,22 @@ module \"s3_bucket_for_logs\" {\n }\n ```\n \n+### Bucket with NLB access log delivery policy attached\n+\n+```hcl\n+module \"s3_bucket_for_logs\" {\n+ source = \"terraform-aws-modules/s3-bucket/aws\"\n+\n+ bucket = \"my-s3-bucket-for-logs\"\n+ acl = \"log-delivery-write\"\n+\n+ # Allow deletion of non-empty bucket\n+ force_destroy = true\n+\n+ attach_nlb_log_delivery_policy = true\n+}\n+```\n+\n ## Conditional creation\n \n Sometimes you need to have a way to create S3 resources conditionally but Terraform does not allow to use `count` inside `module` block, so the solution is to specify argument `create_bucket`.\n@@ -122,6 +139,7 @@ No modules.\n | <a name=\"input_acl\"></a> [acl](#input\\_acl) | (Optional) The canned ACL to apply. Defaults to 'private'. Conflicts with `grant` | `string` | `\"private\"` | no |\n | <a name=\"input_attach_deny_insecure_transport_policy\"></a> [attach\\_deny\\_insecure\\_transport\\_policy](#input\\_attach\\_deny\\_insecure\\_transport\\_policy) | Controls if S3 bucket should have deny non-SSL transport policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_elb_log_delivery_policy\"></a> [attach\\_elb\\_log\\_delivery\\_policy](#input\\_attach\\_elb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have ELB log delivery policy attached | `bool` | `false` | no |\n+| <a name=\"input_attach_nlb_log_delivery_policy\"></a> [attach\\_nlb\\_log\\_delivery\\_policy](#input\\_attach\\_elb\\_log\\_delivery\\_policy) | Controls if S3 bucket should have NLB log delivery policy attached | `bool` | `false` | no |\n | <a name=\"input_attach_policy\"></a> [attach\\_policy](#input\\_attach\\_policy) | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | `bool` | `false` | no |\n | <a name=\"input_attach_public_policy\"></a> [attach\\_public\\_policy](#input\\_attach\\_public\\_policy) | Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket) | `bool` | `true` | no |\n | <a name=\"input_block_public_acls\"></a> [block\\_public\\_acls](#input\\_block\\_public\\_acls) | Whether Amazon S3 should block public ACLs for this bucket. | `bool` | `false` | no |\n---\nmain.tf\n@@ -1,5 +1,5 @@\n locals {\n- attach_policy = var.attach_elb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n+ attach_policy = var.attach_elb_log_delivery_policy || var.attach_nlb_log_delivery_policy || var.attach_deny_insecure_transport_policy || var.attach_policy\n }\n \n resource \"aws_s3_bucket\" \"this\" {\n@@ -247,6 +247,7 @@ data \"aws_iam_policy_document\" \"combined\" {\n \n source_policy_documents = compact([\n var.attach_elb_log_delivery_policy ? data.aws_iam_policy_document.elb_log_delivery[0].json : \"\",\n+ var.attach_nlb_log_delivery_policy ? data.aws_iam_policy_document.nlb_log_delivery[0].json : \"\",\n var.attach_deny_insecure_transport_policy ? data.aws_iam_policy_document.deny_insecure_transport[0].json : \"\",\n var.attach_policy ? var.policy : \"\"\n ])\n@@ -280,6 +281,57 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n }\n }\n \n+# NLB \n+\n+data \"aws_iam_policy_document\" \"nlb_log_delivery\" {\n+ count = var.create_bucket && var.attach_nlb_log_delivery_policy ? 1 : 0\n+\n+ statement {\n+ sid = \"AWSLogDeliveryWrite\"\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"delivery.logs.amazonaws.com\"]\n+ }\n+\n+ effect = \"Allow\"\n+\n+ actions = [\n+ \"s3:PutObject\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}/*\",\n+ ]\n+\n+ condition {\n+ test = \"StringEquals\"\n+ variable = \"s3:x-amz-acl\"\n+ values = [\"bucket-owner-full-control\"]\n+ }\n+ }\n+\n+ statement {\n+ sid = \"AWSLogDeliveryAclCheck\"\n+\n+ effect = \"Allow\"\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"delivery.logs.amazonaws.com\"]\n+ }\n+\n+ actions = [\n+ \"s3:GetBucketAcl\",\n+ ]\n+\n+ resources = [\n+ \"${aws_s3_bucket.this[0].arn}\",\n+ ]\n+\n+ }\n+}\n+\n data \"aws_iam_policy_document\" \"deny_insecure_transport\" {\n count = var.create_bucket && var.attach_deny_insecure_transport_policy ? 1 : 0\n \n---\nvariables.tf\n@@ -10,6 +10,12 @@ variable \"attach_elb_log_delivery_policy\" {\n default = false\n }\n \n+variable \"attach_nlb_log_delivery_policy\" {\n+ description = \"Controls if S3 bucket should have NLB log delivery policy attached\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"attach_deny_insecure_transport_policy\" {\n description = \"Controls if S3 bucket should have deny non-SSL transport policy attached\"\n type = bool\n---\n\n\n---\n" } ]
D
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n```\r\nexport TF_LOG=DEBUG\r\nterraform test # using Terraform 0.15\r\n```\r\n\r\nLast output before it freezes:\r\n```\r\n2021-04-22T15:58:08.661+0200 [INFO] Starting apply for module.complete.aws_s3_bucket_policy.this[0]\r\n2021-04-22T15:58:08.662+0200 [DEBUG] module.complete.aws_s3_bucket_policy.this[0]: applying the planned Create change\r\n2021-04-22T15:58:08.663+0200 [INFO] provider.terraform-provider-aws_v3.37.0_x5: 2021/04/22 15:58:08 [DEBUG] S3 bucket: logs-optimum-llama, put policy: {\r\n \"Version\": \"2012-10-17\",\r\n \"Statement\": [\r\n {\r\n \"Sid\": \"\",\r\n \"Effect\": \"Allow\",\r\n \"Action\": \"s3:PutObject\",\r\n \"Resource\": \"arn:aws:s3:::logs-optimum-llama/*\",\r\n \"Principal\": {\r\n \"AWS\": []\r\n }\r\n },\r\n {\r\n \"Sid\": \"denyInsecureTransport\",\r\n \"Effect\": \"Deny\",\r\n \"Action\": \"s3:*\",\r\n \"Resource\": [\r\n \"arn:aws:s3:::logs-optimum-llama/*\",\r\n \"arn:aws:s3:::logs-optimum-llama\"\r\n ],\r\n \"Principal\": \"*\",\r\n \"Condition\": {\r\n \"Bool\": {\r\n \"aws:SecureTransport\": [\r\n \"false\"\r\n ]\r\n }\r\n }\r\n }\r\n ]\r\n}: timestamp=2021-04-22T15:58:08.663+0200\r\n2021-04-22T15:58:08.663+0200 [INFO] provider.terraform-provider-aws_v3.37.0_x5: 2021/04/22 15:58:08 [DEBUG] Waiting for state to become: [success]: timestamp=2021-04-22T15:58:08.663+0200\r\n2021-04-22T15:59:08.668+0200 [INFO] provider.terraform-provider-aws_v3.37.0_x5: 2021/04/22 15:59:08 [WARN] WaitForState timeout after 1m0s: timestamp=2021-04-22T15:59:08.668+0200\r\n2021-04-22T15:59:08.668+0200 [INFO] provider.terraform-provider-aws_v3.37.0_x5: 2021/04/22 15:59:08 [WARN] WaitForState starting 30s refresh grace period: timestamp=2021-04-22T15:59:08.668+0200\r\n2021-04-22T15:59:38.671+0200 [INFO] provider.terraform-provider-aws_v3.37.0_x5: 2021/04/22 15:59:38 [ERROR] WaitForState exceeded refresh grace period: timestamp=2021-04-22T15:59:38.671+0200\r\n```\n\n---\n\nChoice A:\ntests/complete/test_complete.tf\n@@ -0,0 +1,19 @@\n+locals {\n+ bucket_name = \"s3-bucket-${random_pet.this.id}\"\n+}\n+\n+data \"aws_canonical_user_id\" \"current\" {}\n+\n+resource \"random_pet\" \"this\" {\n+ length = 2\n+}\n+\n+module \"complete\" {\n+ source = \"../../\"\n+\n+ bucket = \"logs-${random_pet.this.id}\"\n+ acl = \"log-delivery-write\"\n+ force_destroy = true\n+ attach_elb_log_delivery_policy = true\n+ attach_deny_insecure_transport_policy = true\n+}\n---\n\n\n---\n\nChoice B:\ntests/complete/test_complete.tf\n@@ -0,0 +1,19 @@\n+locals {\n+ bucket_name = \"s3-bucket-${random_pet.this.id}\"\n+}\n+\n+data \"aws_canonical_user_id\" \"current\" {}\n+\n+resource \"random_pet\" \"this\" {\n+ length = 2\n+}\n+\n+module \"complete\" {\n+ source = \"../../\"\n+\n+ bucket = \"logs-${random_pet.this.id}\"\n+ acl = \"log-delivery-write\"\n+ force_destroy = true\n+ attach_elb_log_delivery_policy = true\n+ attach_deny_insecure_transport_policy = true\n+}\n---\n\n\n---\n\nChoice C:\ntests/complete/test_complete.tf\n@@ -0,0 +1,19 @@\n+locals {\n+ bucket_name = \"s3-bucket-${random_pet.this.id}\"\n+}\n+\n+data \"aws_canonical_user_id\" \"current\" {}\n+\n+resource \"random_pet\" \"this\" {\n+ length = 2\n+}\n+\n+module \"complete\" {\n+ source = \"../../\"\n+\n+ bucket = \"logs-${random_pet.this.id}\"\n+ acl = \"log-delivery-write\"\n+ force_destroy = true\n+ attach_elb_log_delivery_policy = true\n+ attach_deny_insecure_transport_policy = true\n+}\n---\n\n\n---\n\nChoice D:\ntests/complete/test_complete.tf\n@@ -0,0 +1,19 @@\n+locals {\n+ bucket_name = \"s3-bucket-${random_pet.this.id}\"\n+}\n+\n+data \"aws_canonical_user_id\" \"current\" {}\n+\n+resource \"random_pet\" \"this\" {\n+ length = 2\n+}\n+\n+module \"complete\" {\n+ source = \"../../\"\n+\n+ bucket = \"logs-${random_pet.this.id}\"\n+ acl = \"log-delivery-write\"\n+ force_destroy = true\n+ attach_elb_log_delivery_policy = true\n+ attach_deny_insecure_transport_policy = true\n+}\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\nFixes #78\r\n\r\nIssue in terragrunt - https://github.com/gruntwork-io/terragrunt/issues/1211\n\n---\n\nChoice A:\nREADME.md\n@@ -69,6 +69,22 @@ module \"s3_bucket\" {\n }\n ```\n \n+## Terragrunt and `variable \"...\" { type = any }`\n+\n+There is a bug [#1211](https://github.com/gruntwork-io/terragrunt/issues/1211) in Terragrunt related to the way how the variables of type `any` are passed to Terraform.\n+\n+This module solves this issue by supporting `jsonencode()`-string in addition to the expected type (`list` or `map`).\n+\n+In `terragrunt.hcl` you can write:\n+\n+```terraform\n+inputs = {\n+ bucket = \"foobar\" # `bucket` has type `string`, no need to jsonencode() \n+ cors_rule = jsonencode([...]) # `cors_rule` has type `any`, so `jsonencode()` is required\n+}\n+```\n+\n+\n ## Examples:\n \n * [Complete](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/tree/master/examples/complete) - Complete S3 bucket with most of supported features enabled\n---\nmain.tf\n@@ -28,7 +28,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n dynamic \"cors_rule\" {\n- for_each = var.cors_rule\n+ for_each = try(jsondecode(var.cors_rule), var.cors_rule)\n \n content {\n allowed_methods = cors_rule.value.allowed_methods\n@@ -58,7 +58,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n dynamic \"grant\" {\n- for_each = var.grant\n+ for_each = try(jsondecode(var.grant), var.grant)\n \n `bucket` content {\n id = lookup(grant.value, \"id\", null)\n@@ -69,7 +69,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n dynamic \"lifecycle_rule\" {\n- for_each = var.lifecycle_rule\n+ for_each = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n \n content {\n id = lookup(lifecycle_rule.value, \"id\", null)\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -69,6 +69,22 @@ module \"s3_bucket\" {\n }\n ```\n \n+## Terragrunt and `variable \"...\" { type = any }`\n+\n+There is a bug [#1211](https://github.com/gruntwork-io/terragrunt/issues/1211) in Terragrunt related to the way how the variables of type `any` are passed to Terraform.\n+\n+This module solves this issue by supporting `jsonencode()`-string in addition to the expected type (`list` or `map`).\n+\n+In `terragrunt.hcl` you can write:\n+\n+```terraform\n+inputs = {\n+ bucket = \"foobar\" # `bucket` has type `string`, no need to jsonencode() \n+ cors_rule = jsonencode([...]) # `cors_rule` has type `any`, so `jsonencode()` is required\n+}\n+```\n+\n+\n ## Examples:\n \n * [Complete](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/tree/master/examples/complete) - Complete S3 bucket with most of supported features enabled\n---\nmain.tf\n@@ -28,7 +28,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n dynamic \"cors_rule\" {\n- for_each = var.cors_rule\n+ for_each = try(jsondecode(var.cors_rule), var.cors_rule)\n \n content {\n allowed_methods = cors_rule.value.allowed_methods\n@@ -58,7 +58,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n dynamic \"grant\" {\n- for_each = var.grant\n+ for_each = try(jsondecode(var.grant), var.grant)\n \n \"this\" {\n id = lookup(grant.value, \"id\", null)\n@@ -69,7 +69,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n dynamic \"lifecycle_rule\" {\n- for_each = var.lifecycle_rule\n+ for_each = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n \n content {\n id = lookup(lifecycle_rule.value, \"id\", null)\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -69,6 +69,22 @@ module \"s3_bucket\" {\n }\n ```\n \n+## Terragrunt and `variable \"...\" { type = any }`\n+\n+There is a bug [#1211](https://github.com/gruntwork-io/terragrunt/issues/1211) in Terragrunt related to the way how the variables of type `any` are passed to Terraform.\n+\n+This module solves this issue by supporting `jsonencode()`-string in addition to the expected type (`list` or `map`).\n+\n+In `terragrunt.hcl` you can write:\n+\n+```terraform\n+inputs = {\n+ bucket = \"foobar\" # `bucket` has type `string`, no need to jsonencode() \n+ cors_rule = jsonencode([...]) # `cors_rule` has type `any`, so `jsonencode()` is required\n+}\n+```\n+\n+\n ## Examples:\n \n * [Complete](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/tree/master/examples/complete) - Complete S3 bucket with most of supported features enabled\n---\nmain.tf\n@@ -28,7 +28,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n dynamic \"cors_rule\" {\n- for_each = var.cors_rule\n+ for_each = try(jsondecode(var.cors_rule), var.cors_rule)\n \n content {\n allowed_methods = cors_rule.value.allowed_methods\n@@ -58,7 +58,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n dynamic \"grant\" {\n- for_each = var.grant\n+ for_each = try(jsondecode(var.grant), var.grant)\n \n content {\n id = lookup(grant.value, \"id\", null)\n@@ -69,7 +69,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n dynamic \"lifecycle_rule\" {\n- for_each = var.lifecycle_rule\n+ for_each = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n \n @@ content {\n id = lookup(lifecycle_rule.value, \"id\", null)\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -69,6 +69,22 @@ module \"s3_bucket\" {\n }\n ```\n \n+## Terragrunt and `variable \"...\" { type = any }`\n+\n+There is a bug [#1211](https://github.com/gruntwork-io/terragrunt/issues/1211) in Terragrunt related to the way how the variables of type `any` are passed to Terraform.\n+\n+This module solves this issue by supporting `jsonencode()`-string in addition to the expected type (`list` or `map`).\n+\n+In `terragrunt.hcl` you can write:\n+\n+```terraform\n+inputs = {\n+ bucket = \"foobar\" # `bucket` has type `string`, no need to jsonencode() \n+ cors_rule = jsonencode([...]) # `cors_rule` has type `any`, so `jsonencode()` is required\n+}\n+```\n+\n+\n ## Examples:\n \n * [Complete](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/tree/master/examples/complete) - Complete S3 bucket with most of supported features enabled\n---\nmain.tf\n@@ -28,7 +28,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n dynamic \"cors_rule\" {\n- for_each = var.cors_rule\n+ for_each = try(jsondecode(var.cors_rule), var.cors_rule)\n \n content {\n allowed_methods = cors_rule.value.allowed_methods\n@@ -58,7 +58,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n dynamic \"grant\" {\n- for_each = var.grant\n+ for_each = try(jsondecode(var.grant), var.grant)\n \n content {\n id = lookup(grant.value, \"id\", null)\n@@ -69,7 +69,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n dynamic \"lifecycle_rule\" {\n- for_each = var.lifecycle_rule\n+ for_each = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)\n \n content {\n id = lookup(lifecycle_rule.value, \"id\", null)\n---\n\n\n---\n" } ]
D
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n- align ci-cd static checks to use individual minimum Terraform versions\r\n\r\n## Motivation and Context\r\n- ensure that the modules are all following a similar workflow and the static checks that performed\r\n\r\n## Breaking Changes\r\n- No\r\n\r\n## How Has This Been Tested?\r\n- ci-cd static checks\n\n---\n\nChoice A:\n.github/workflows/pre-commit.yml\n@@ -7,55 +7,95 @@ on:\n - master\n \n jobs:\n- getBaseVersion:\n- name: Get min/max versions\n- runs-on: ubuntu-latest\n+# Min Terraform version(s)\n+ getDirectories:\n+ name: Get root directories\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+ - name: Build matrix\n+ id: matrix\n+ run: |\n+ DIRS=$(python -c \"import json; import glob; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True)]))\")\n+ echo \"::set-output name=directories::$DIRS\"\n+ outputs:\n+ directories: ${{ steps.matrix.outputs.directories }}\n \n+ preCommitMinVersions:\n+ name: Min TF validate\n+ needs: getDirectories\n+ runs-on: ubuntu-latest\n+ strategy:\n+ matrix:\n+ directory: ${{ fromJson(needs.getDirectories.outputs.directories) }}\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+ - name: Terraform min/max versions\n+ id: minMax\n+ uses: clowdhaus/[email protected]\n+ with:\n+ directory: ${{ matrix.directory }}\n+ - name: Install Terraform v${{ steps.minMax.outputs.minVersion }}\n+ uses: hashicorp/setup-terraform@v1\n+ with:\n+ terraform_version: ${{ steps.minMax.outputs.minVersion }}\n+ - name: Install pre-commit dependencies\n+ run: pip install pre-commit\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ uses: if: ${{ matrix.directory != '.' }}\n+ run:\n+ pre-commit run terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.directory == '.' }}\n+ run:\n+ pre-commit run terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)\n+\n \n+# Max Terraform version\n+ getBaseVersion:\n+ name: Module max TF version\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n - name: Terraform min/max versions\n id: minMax\n uses: clowdhaus/[email protected]\n outputs:\n minVersion: ${{ steps.minMax.outputs.minVersion }}\n maxVersion: ${{ steps.minMax.outputs.maxVersion }}\n \n- preCommit:\n- name: Pre-commit check\n+ preCommitMaxVersion:\n+ name: Max TF pre-commit\n runs-on: ubuntu-latest\n needs: getBaseVersion\n strategy:\n fail-fast: false\n matrix:\n version:\n- - ${{ needs.getBaseVersion.outputs.minVersion }}\n - ${{ needs.getBaseVersion.outputs.maxVersion }}\n-\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n-\n - name: Install Python\n uses: actions/setup-python@v2\n-\n - name: Install Terraform v${{ matrix.version }}\n uses: hashicorp/setup-terraform@v1\n with:\n terraform_version: ${{ matrix.version }}\n-\n - name: Install pre-commit dependencies\n run: |\n pip install pre-commit\n curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n-\n- - name: Execute pre-commit\n- # Run only validate pre-commit check on min version supported\n- if: ${{ matrix.version == needs.getBaseVersion.outputs.minVersion }}\n- run: pre-commit run --color=always --show-diff-on-failure --all-files terraform_validate\n-\n - name: Execute pre-commit\n # Run all pre-commit checks on max version supported\n if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}\n---\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.46.0\n+ rev: v1.47.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\n\n\n---\n\nChoice B:\n.github/workflows/pre-commit.yml\n@@ -7,55 +7,95 @@ on:\n - master\n \n jobs:\n- getBaseVersion:\n- name: Get min/max versions\n- runs-on: ubuntu-latest\n+# Min Terraform version(s)\n+ getDirectories:\n+ name: Get root directories\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+ - name: Build matrix\n+ id: matrix\n+ run: |\n+ DIRS=$(python -c \"import json; import glob; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True)]))\")\n+ echo \"::set-output name=directories::$DIRS\"\n+ outputs:\n+ directories: ${{ steps.matrix.outputs.directories }}\n \n+ preCommitMinVersions:\n+ name: Min TF validate\n+ needs: getDirectories\n+ runs-on: ubuntu-latest\n+ strategy:\n+ matrix:\n+ directory: ${{ fromJson(needs.getDirectories.outputs.directories) }}\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+ - name: Terraform min/max versions\n+ id: minMax\n+ uses: clowdhaus/[email protected]\n+ with:\n+ directory: ${{ matrix.directory }}\n+ - name: Install Terraform v${{ steps.minMax.outputs.minVersion }}\n+ uses: hashicorp/setup-terraform@v1\n+ with:\n+ terraform_version: ${{ steps.minMax.outputs.minVersion }}\n+ - name: Install pre-commit dependencies\n+ run: pip install pre-commit\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.directory != '.' }}\n+ run:\n+ pre-commit run terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.directory == '.' }}\n+ run:\n+ pre-commit run terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)\n+\n \n+# Max Terraform version\n+ getBaseVersion:\n+ name: Module max TF version\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n - name: Terraform min/max versions\n id: minMax\n uses: clowdhaus/[email protected]\n outputs:\n minVersion: ${{ steps.minMax.outputs.minVersion }}\n maxVersion: ${{ steps.minMax.outputs.maxVersion }}\n \n- preCommit:\n- name: Pre-commit check\n+ preCommitMaxVersion:\n+ name: Max TF pre-commit\n runs-on: ubuntu-latest\n needs: getBaseVersion\n strategy:\n fail-fast: false\n matrix:\n version:\n- - ${{ needs.getBaseVersion.outputs.minVersion }}\n - ${{ needs.getBaseVersion.outputs.maxVersion }}\n-\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n-\n - name: Install Python\n uses: actions/setup-python@v2\n-\n - name: Install Terraform v${{ matrix.version }}\n uses: hashicorp/setup-terraform@v1\n with:\n terraform_version: ${{ matrix.version }}\n-\n - name: Install pre-commit dependencies\n run: |\n pip install pre-commit\n curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n-\n- - name: Execute pre-commit\n- # Run only validate pre-commit check on min version supported\n- if: ${{ matrix.version == needs.getBaseVersion.outputs.minVersion }}\n- run: pre-commit run --color=always --show-diff-on-failure --all-files terraform_validate\n-\n - name: Execute pre-commit\n # Run all pre-commit checks on max version supported\n if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}\n---\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.46.0\n+ rev: v1.47.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\n\n\n---\n\nChoice C:\n.github/workflows/pre-commit.yml\n@@ -7,55 +7,95 @@ on:\n - master\n \n jobs:\n- getBaseVersion:\n- name: Get min/max versions\n- runs-on: ubuntu-latest\n+# Min Terraform version(s)\n+ getDirectories:\n+ name: Get root directories\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+ - name: Build matrix\n+ id: matrix\n+ run: |\n+ DIRS=$(python -c \"import json; import glob; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True)]))\")\n+ echo \"::set-output name=directories::$DIRS\"\n+ outputs:\n+ directories: ${{ steps.matrix.outputs.directories }}\n \n+ preCommitMinVersions:\n+ name: Min TF validate\n+ needs: getDirectories\n+ runs-on: ubuntu-latest\n+ strategy:\n+ matrix:\n+ directory: ${{ fromJson(needs.getDirectories.outputs.directories) }}\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+ - name: Terraform min/max versions\n+ id: minMax\n+ uses: clowdhaus/[email protected]\n+ with:\n+ directory: ${{ matrix.directory }}\n+ - name: Install Terraform v${{ steps.minMax.outputs.minVersion }}\n+ uses: hashicorp/setup-terraform@v1\n+ with:\n+ terraform_version: ${{ steps.minMax.outputs.minVersion }}\n+ - name: Install pre-commit dependencies\n+ run: pip install pre-commit\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.directory != '.' }}\n+ run:\n+ pre-commit run terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.directory == '.' }}\n+ run:\n+ pre-commit run terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)\n+\n \n+# Max Terraform version\n+ getBaseVersion:\n+ name: Module max TF version\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n - name: Terraform min/max versions\n id: minMax\n uses: clowdhaus/[email protected]\n outputs:\n minVersion: ${{ steps.minMax.outputs.minVersion }}\n maxVersion: ${{ steps.minMax.outputs.maxVersion }}\n \n- preCommit:\n- name: Pre-commit check\n+ preCommitMaxVersion:\n+ name: Max TF pre-commit\n runs-on: ubuntu-latest\n needs: getBaseVersion\n strategy:\n fail-fast: false\n matrix:\n version:\n- - ${{ needs.getBaseVersion.outputs.minVersion }}\n - ${{ needs.getBaseVersion.outputs.maxVersion }}\n-\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n-\n - name: Install Python\n uses: actions/setup-python@v2\n-\n - name: Install Terraform v${{ matrix.version }}\n uses: hashicorp/setup-terraform@v1\n with:\n terraform_version: ${{ matrix.version }}\n-\n - name: Install pre-commit dependencies\n run: |\n pip install pre-commit\n curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n-\n- - name: Execute pre-commit\n- # Run only validate pre-commit check on min version supported\n- if: ${{ matrix.version == needs.getBaseVersion.outputs.minVersion }}\n- run: pre-commit run --color=always --show-diff-on-failure --all-files terraform_validate\n-\n - name: Execute pre-commit\n # Run all pre-commit checks on max version supported\n if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}\n---\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.46.0\n+ rev: v1.47.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\n\n\n---\n\nChoice D:\n&& -7,55 +7,95 @@ on:\n - master\n \n jobs:\n- getBaseVersion:\n- name: Get min/max versions\n- runs-on: ubuntu-latest\n+# Min Terraform version(s)\n+ getDirectories:\n+ name: Get root directories\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+ - name: Build matrix\n+ id: matrix\n+ run: |\n+ DIRS=$(python -c \"import json; import glob; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True)]))\")\n+ echo \"::set-output name=directories::$DIRS\"\n+ outputs:\n+ directories: ${{ steps.matrix.outputs.directories }}\n \n+ preCommitMinVersions:\n+ name: Min TF validate\n+ needs: getDirectories\n+ runs-on: ubuntu-latest\n+ strategy:\n+ matrix:\n+ directory: ${{ fromJson(needs.getDirectories.outputs.directories) }}\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+ - name: Terraform min/max versions\n+ id: minMax\n+ uses: clowdhaus/[email protected]\n+ with:\n+ directory: ${{ matrix.directory }}\n+ - name: Install Terraform v${{ steps.minMax.outputs.minVersion }}\n+ uses: hashicorp/setup-terraform@v1\n+ with:\n+ terraform_version: ${{ steps.minMax.outputs.minVersion }}\n+ - name: Install pre-commit dependencies\n+ run: pip install pre-commit\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.directory != '.' }}\n+ run:\n+ pre-commit run terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.directory == '.' }}\n+ run:\n+ pre-commit run terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)\n+\n \n+# Max Terraform version\n+ getBaseVersion:\n+ name: Module max TF version\n+ runs-on: ubuntu-latest\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n - name: Terraform min/max versions\n id: minMax\n uses: clowdhaus/[email protected]\n outputs:\n minVersion: ${{ steps.minMax.outputs.minVersion }}\n maxVersion: ${{ steps.minMax.outputs.maxVersion }}\n \n- preCommit:\n- name: Pre-commit check\n+ preCommitMaxVersion:\n+ name: Max TF pre-commit\n runs-on: ubuntu-latest\n needs: getBaseVersion\n strategy:\n fail-fast: false\n matrix:\n version:\n- - ${{ needs.getBaseVersion.outputs.minVersion }}\n - ${{ needs.getBaseVersion.outputs.maxVersion }}\n-\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n-\n - name: Install Python\n uses: actions/setup-python@v2\n-\n - name: Install Terraform v${{ matrix.version }}\n uses: hashicorp/setup-terraform@v1\n with:\n terraform_version: ${{ matrix.version }}\n-\n - name: Install pre-commit dependencies\n run: |\n pip install pre-commit\n curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n-\n- - name: Execute pre-commit\n- # Run only validate pre-commit check on min version supported\n- if: ${{ matrix.version == needs.getBaseVersion.outputs.minVersion }}\n- run: pre-commit run --color=always --show-diff-on-failure --all-files terraform_validate\n-\n - name: Execute pre-commit\n # Run all pre-commit checks on max version supported\n if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}\n---\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.46.0\n+ rev: v1.47.0\n hooks:\n - id: terraform_fmt\n - id: terraform_validate\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n- add ci-cd workflow for pre-commit checks\r\n\r\n## Motivation and Context\r\n- provide static checks for pull requests\r\n\r\n## Breaking Changes\r\n- no\r\n\r\n## How Has This Been Tested?\r\n- copy of what is implemented in SQS module repository\r\n\n\n---\n\nChoice A:\n.github/workflows/pre-commit.yml\n@@ -0,0 +1,62 @@\n+name: Pre-Commit\n+\n+on:\n+ pull_request:\n+ push:\n+ branches:\n+ - master\n+\n+jobs:\n+ getBaseVersion:\n+ name: Get min/max versions\n+ runs-on: ubuntu-latest\n+\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Terraform min/max versions\n+ id: minMax\n+ uses: clowdhaus/[email protected]\n+ outputs:\n+ minVersion: ${{ steps.minMax.outputs.minVersion }}\n+ maxVersion: ${{ steps.minMax.outputs.maxVersion }}\n+\n+ preCommit:\n+ name: Pre-commit check\n+ runs-on: ubuntu-latest\n+ needs: getBaseVersion\n+ strategy:\n+ fail-fast: false\n+ matrix:\n+ version:\n+ - ${{ needs.getBaseVersion.outputs.minVersion }}\n+ - ${{ needs.getBaseVersion.outputs.maxVersion }}\n+\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+\n+ - name: Install Terraform v${{ matrix.version }}\n+ uses: hashicorp/setup-terraform@v1\n+ with:\n+ terraform_version: ${{ matrix.version }}\n+\n+ - name: Install pre-commit dependencies\n+ run: |\n+ pip install pre-commit\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n+\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.version == needs.getBaseVersion.outputs.minVersion }}\n+ run: pre-commit run --color=always --show-diff-on-failure --all-files terraform_validate\n+\n+ - name: Execute pre-commit\n+ # Run all pre-commit checks on max version supported\n+ if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}\n+ run: pre-commit run --color=always --show-diff-on-failure --all-files\n---\n\n\n---\n\nChoice B:\n.github/workflows/pre-commit.yml\n@@ -0,0 +1,62 @@\n+name: Pre-Commit\n+\n+on:\n+ pull_request:\n+ push:\n+ branches:\n+ - master\n+\n+jobs:\n+ getBaseVersion:\n+ name: Get min/max versions\n+ runs-on: ubuntu-latest\n+\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Terraform min/max versions\n+ id: minMax\n+ uses: clowdhaus/[email protected]\n+ outputs:\n+ minVersion: ${{ steps.minMax.outputs.minVersion }}\n+ maxVersion: ${{ steps.minMax.outputs.maxVersion }}\n+\n+ preCommit:\n+ name: Pre-commit check\n+ runs-on: ubuntu-latest\n+ needs: getBaseVersion\n+ strategy:\n+ fail-fast: false\n+ matrix:\n+ version:\n+ - ${{ needs.getBaseVersion.outputs.minVersion }}\n+ - ${{ needs.getBaseVersion.outputs.maxVersion }}\n+\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+\n+ - name: Install Terraform v${{ matrix.version }}\n+ pre-commit uses: hashicorp/setup-terraform@v1\n+ with:\n+ terraform_version: ${{ matrix.version }}\n+\n+ - name: Install pre-commit dependencies\n+ run: |\n+ pip install pre-commit\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n+\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.version == needs.getBaseVersion.outputs.minVersion }}\n+ run: pre-commit run --color=always --show-diff-on-failure --all-files terraform_validate\n+\n+ - name: Execute pre-commit\n+ # Run all pre-commit checks on max version supported\n+ if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}\n+ run: pre-commit run --color=always --show-diff-on-failure --all-files\n---\n\n\n---\n\nChoice C:\n.github/workflows/pre-commit.yml\n@@ -0,0 +1,62 @@\n+name: Pre-Commit\n+\n+on:\n+ pull_request:\n+ push:\n+ branches:\n+ - master\n+\n+jobs:\n+ getBaseVersion:\n+ name: Get min/max versions\n+ runs-on: ubuntu-latest\n+\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Terraform min/max versions\n+ id: minMax\n+ uses: clowdhaus/[email protected]\n+ outputs:\n+ minVersion: ${{ steps.minMax.outputs.minVersion }}\n+ maxVersion: ${{ steps.minMax.outputs.maxVersion }}\n+\n+ preCommit:\n+ name: Pre-commit check\n+ runs-on: ubuntu-latest\n+ needs: getBaseVersion\n+ strategy:\n+ fail-fast: false\n+ matrix:\n+ version:\n+ - ${{ needs.getBaseVersion.outputs.minVersion }}\n+ - ${{ needs.getBaseVersion.outputs.maxVersion }}\n+\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+\n+ - name: Install Terraform v${{ matrix.version }}\n+ uses: hashicorp/setup-terraform@v1\n+ with:\n+ terraform_version: ${{ matrix.version }}\n+\n+ - name: Install pre-commit dependencies\n+ run: |\n+ pip install pre-commit\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n+\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.version == needs.getBaseVersion.outputs.minVersion }}\n+ run: pre-commit run --color=always --show-diff-on-failure --all-files terraform_validate\n+\n+ - name: Execute pre-commit\n+ # Run all pre-commit checks on max version supported\n+ if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}\n+ run: pre-commit run --color=always --show-diff-on-failure --all-files\n---\n\n\n---\n\nChoice D:\n.github/workflows/pre-commit.yml\n@@ -0,0 +1,62 @@\n+name: Pre-Commit\n+\n+on:\n+ pull_request:\n+ push:\n+ branches:\n+ - master\n+\n+jobs:\n+ getBaseVersion:\n+ name: Get min/max versions\n+ runs-on: ubuntu-latest\n+\n+ steps:\n+ - name: Checkout\n+ uses: actions/checkout@v2\n+\n+ - name: Terraform min/max versions\n+ id: minMax\n+ uses: clowdhaus/[email protected]\n+ outputs:\n+ minVersion: ${{ steps.minMax.outputs.minVersion }}\n+ maxVersion: ${{ steps.minMax.outputs.maxVersion }}\n+\n+ preCommit:\n+ name: Pre-commit check\n+ runs-on: ubuntu-latest\n+ needs: getBaseVersion\n+ strategy:\n+ fail-fast: false\n+ matrix:\n+ version:\n+ - ${{ needs.getBaseVersion.outputs.minVersion }}\n+ - ${{ needs.getBaseVersion.outputs.maxVersion }}\n+\n+ steps:\n+ - name: Checkout\n+ Python\n+ uses: actions/checkout@v2\n+\n+ - name: Install Python\n+ uses: actions/setup-python@v2\n+\n+ - name: Install Terraform v${{ matrix.version }}\n+ uses: hashicorp/setup-terraform@v1\n+ with:\n+ terraform_version: ${{ matrix.version }}\n+\n+ - name: Install pre-commit dependencies\n+ run: |\n+ pip install pre-commit\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E \"https://.+?-linux-amd64\" | head -n1)\" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/\n+ curl -L \"$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E \"https://.+?_linux_amd64.zip\")\" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/\n+\n+ - name: Execute pre-commit\n+ # Run only validate pre-commit check on min version supported\n+ if: ${{ matrix.version == needs.getBaseVersion.outputs.minVersion }}\n+ run: pre-commit run --color=always --show-diff-on-failure --all-files terraform_validate\n+\n+ - name: Execute pre-commit\n+ # Run all pre-commit checks on max version supported\n+ if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}\n+ run: pre-commit run --color=always --show-diff-on-failure --all-files\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nMake the creation of SNS/SQS policies conditional based on two new variables, `create_sns_policy` and `create_sqs_policy`.\r\n\r\n## Motivation and Context\r\nWe have a use case (as I'm sure others do) where we need to send S3 bucket notifications to an external account that we don't control, and so we can't create the related SNS/SQS policies in that account (and they aren't necessary). The rest of the notification setup is valid when using the external resource ARNs, however.\r\n\r\n## Breaking Changes\r\nNone; the variables default to `true` so behavior will be the same.\r\n\r\n## How Has This Been Tested?\r\n```sh\r\n$ terraform -v\r\nTerraform v0.12.29\r\n+ provider.aws v3.10.0\r\n+ provider.null v2.1.2\r\n+ provider.random v2.3.0\r\n```\r\n\r\nUsing the module as published failed to apply the notification due to the inability create the policy, so I added it manually and imported it. This snippet...:\r\n```\r\nmodule \"redacted-bucket\" {\r\n source = \"terraform-aws-modules/s3-bucket/aws\"\r\n version = \"v1.15.0\"\r\n\r\n bucket = \"redacted-bucket\"\r\n acl = \"private\"\r\n force_destroy = false\r\n\r\n tags = {\r\n creator = \"terraform\"\r\n }\r\n\r\n versioning = {\r\n enabled = false\r\n }\r\n\r\n # S3 bucket-level Public Access Block configuration\r\n block_public_acls = true\r\n block_public_policy = true\r\n ignore_public_acls = true\r\n restrict_public_buckets = true\r\n}\r\n\r\nmodule \"redacted-bucket-notifications\" {\r\n source = \"terraform-aws-modules/s3-bucket/aws//modules/notification\"\r\n\r\n bucket = module.redacted-bucket.this_s3_bucket_id\r\n\r\n # Common error - Error putting S3 notification configuration: InvalidArgument: Configuration is ambiguously defined. Cannot have overlapping suffixes in two rules if the prefixes are overlapping for the same event type.\r\n\r\n sqs_notifications = {\r\n sqs1 = {\r\n queue_arn = \"redacted-queue-arn\"\r\n events = [\"s3:ObjectCreated:Put\"]\r\n filter_suffix = \".gz\"\r\n }\r\n }\r\n}\r\n```\r\n\r\n... results in this plan:\r\n```\r\nTerraform will perform the following actions:\r\n\r\n # module.redacted-bucket-notifications.aws_sqs_queue_policy.allow[\"sqs1\"] will be created\r\n + resource \"aws_sqs_queue_policy\" \"allow\" {\r\n + id = (known after apply)\r\n + policy = jsonencode(\r\n {\r\n + Statement = [\r\n + {\r\n + Action = \"sqs:SendMessage\"\r\n + Condition = {\r\n + ArnEquals = {\r\n + aws:SourceArn = \"arn:aws:s3:::redacted-bucket\"\r\n }\r\n }\r\n + Effect = \"Allow\"\r\n + Principal = {\r\n + Service = \"s3.amazonaws.com\"\r\n }\r\n + Resource = \"redacted-queue-arn\"\r\n + Sid = \"AllowSQSS3BucketNotification\"\r\n },\r\n ]\r\n + Version = \"2012-10-17\"\r\n }\r\n )\r\n + queue_url = \"redacted-queue-url\"\r\n }\r\n\r\nPlan: 1 to add, 0 to change, 0 to destroy.\r\n```\r\n\r\nChanging the module to use this branch like so...:\r\n```\r\nmodule \"redacted-bucket-notifications\" {\r\n source = \"github.com/bmurphey/terraform-aws-s3-bucket//modules/notification?ref=optional-create-policy\"\r\n\r\n bucket = module.redacted-bucket.this_s3_bucket_id\r\n create_sqs_policy = false\r\n\r\n # Common error - Error putting S3 notification configuration: InvalidArgument: Configuration is ambiguously defined. Cannot have overlapping suffixes in two rules if the prefixes are overlapping for the same event type.\r\n\r\n sqs_notifications = {\r\n sqs1 = {\r\n queue_arn = \"redacted-queue-arn\"\r\n events = [\"s3:ObjectCreated:Put\"]\r\n filter_suffix = \".gz\"\r\n }\r\n }\r\n}\r\n```\r\n\r\n... results in `No changes. Infrastructure is up-to-date.`. It appears to me that the SNS policy is created in the same manner, so I added a variable to make that policy creation conditional as well, but that hasn't been tested.\n\n---\n\nChoice A:\nREADME.md\n@@ -84,14 +84,14 @@ module \"s3_bucket\" {\n \n | Name | Version |\n |------|---------|\n-| terraform | >= 0.12.6, < 0.14 |\n-| aws | >= 3.0, < 4.0 |\n+| terraform | >= 0.12.6 |\n+| aws | >= 3.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | >= 3.0, < 4.0 |\n+| aws | >= 3.0 |\n \n ## Inputs\n \n---\nexamples/notification/README.md\n@@ -19,18 +19,18 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| terraform | >= 0.12.6, < 0.14 |\n-| aws | >= 3.0, < 4.0 |\n-| null | ~> 2 |\n-| random | ~> 2 |\n+| terraform | >= 0.12.6 |\n+| aws | >= 3.0 |\n+| null | >= 2 |\n+| random | >= 2 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | >= 3.0, < 4.0 |\n-| null | ~> 2 |\n-| random | ~> 2 |\n+| aws | >= 3.0 |\n+| null | >= 2 |\n+| random | >= 2 |\n \n ## Inputs\n \n---\nexamples/notification/main.tf\n@@ -76,6 +76,26 @@ resource \"aws_sqs_queue\" \"this\" {\n name = \"${random_pet.this.id}-${count.index}\"\n }\n \n+# SQS policy created outside of the module\n+data \"aws_iam_policy_document\" \"sqs_external\" {\n+ statement {\n+ effect = \"Allow\"\n+ actions = [\"sqs:SendMessage\"]\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"s3.amazonaws.com\"]\n+ }\n+\n+ resources [aws_sqs_queue.this[0].arn]\n+ }\n+}\n+\n+resource \"aws_sqs_queue_policy\" \"allow_external\" {\n+ queue_url = aws_sqs_queue.this[0].id\n+ policy = data.aws_iam_policy_document.sqs_external.json\n+}\n+\n module \"all_notifications\" {\n source = \"../../modules/notification\"\n \n@@ -129,4 +149,6 @@ module \"all_notifications\" {\n }\n }\n \n+ # Creation of policy is handled outside of the module\n+ create_sqs_policy = false\n }\n---\nexamples/notification/versions.tf\n@@ -1,9 +1,9 @@\n terraform {\n- required_version = \">= 0.12.6, < 0.14\"\n+ required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 3.0, < 4.0\"\n- random = \"~> 2\"\n- null = \"~> 2\"\n+ aws = \">= 3.0\"\n+ random = \">= 2\"\n+ null = \">= 2\"\n }\n }\n---\nexamples/s3-replication/README.md\n@@ -21,17 +21,17 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| terraform | >= 0.12.6, < 0.14 |\n-| aws | >= 3.0, < 4.0 |\n-| random | ~> 2 |\n+| terraform | >= 0.12.6 |\n+| aws | >= 3.0 |\n+| random | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | >= 3.0, < 4.0 |\n-| aws.replica | >= 3.0, < 4.0 |\n-| random | ~> 2 |\n+| aws | >= 3.0 |\n+| aws.replica | >= 3.0 |\n+| random | >= 2.0 |\n \n ## Inputs\n \n---\nexamples/s3-replication/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.6, < 0.14\"\n+ required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 3.0, < 4.0\"\n- random = \"~> 2\"\n+ aws = \">= 3.0\"\n+ random = \">= 2.0\"\n }\n }\n---\nmodules/notification/README.md\n@@ -7,15 +7,15 @@ Creates S3 bucket notification resource with all supported types of deliveries:\n \n | Name | Version |\n |------|---------|\n-| terraform | >= 0.12.6, < 0.14 |\n-| aws | >= 3.0, < 4.0 |\n-| random | ~> 2 |\n+| terraform | >= 0.12.6 |\n+| aws | >= 3.0 |\n+| random | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | >= 3.0, < 4.0 |\n+| aws | >= 3.0 |\n \n ## Inputs\n \n@@ -24,6 +24,8 @@ Creates S3 bucket notification resource with all supported types of deliveries:\n | bucket | Name of S3 bucket to use | `string` | `\"\"` | no |\n | bucket\\_arn | ARN of S3 bucket to use in policies | `string` | `null` | no |\n | create | Whether to create this resource or not? | `bool` | `true` | no |\n+| create\\_sns\\_policy | Whether to create a policy for SNS permissions or not? | `bool` | `true` | no |\n+| create\\_sqs\\_policy | Whether to create a policy for SQS permissions or not? | `bool` | `true` | no |\n | lambda\\_notifications | Map of S3 bucket notifications to Lambda function | `any` | `{}` | no |\n | sns\\_notifications | Map of S3 bucket notifications to SNS topic | `any` | `{}` | no |\n | sqs\\_notifications | Map of S3 bucket notifications to SQS queue | `any` | `{}` | no |\n---\nmodules/notification/main.tf\n@@ -74,7 +74,7 @@ data \"aws_arn\" \"queue\" {\n }\n \n data \"aws_iam_policy_document\" \"sqs\" {\n- for_each = var.sqs_notifications\n+ for_each = var.create_sqs_policy ? var.sqs_notifications : tomap({})\n \n statement {\n sid = \"AllowSQSS3BucketNotification\"\n@@ -101,15 +101,15 @@ data \"aws_iam_policy_document\" \"sqs\" {\n }\n \n resource \"aws_sqs_queue_policy\" \"allow\" {\n- for_each = var.sqs_notifications\n+ for_each = var.create_sqs_policy ? var.sqs_notifications : tomap({})\n \n queue_url = lookup(each.value, \"queue_id\", lookup(local.queue_ids, each.key, null))\n policy = data.aws_iam_policy_document.sqs[each.key].json\n }\n \n # SNS Topic\n data \"aws_iam_policy_document\" \"sns\" {\n- for_each = var.sns_notifications\n+ for_each = var.create_sns_policy ? var.sns_notifications : tomap({})\n \n statement {\n sid = \"AllowSNSS3BucketNotification\"\n@@ -136,7 +136,7 @@ data \"aws_iam_policy_document\" \"sns\" {\n }\n \n resource \"aws_sns_topic_policy\" \"allow\" {\n- for_each = var.sns_notifications\n+ for_each = var.create_sns_policy ? var.sns_notifications : tomap({})\n \n arn = each.value.topic_arn\n policy = data.aws_iam_policy_document.sns[each.key].json\n---\nmodules/notification/variables.tf\n@@ -4,6 +4,18 @@ variable \"create\" {\n default = true\n }\n \n+variable \"create_sns_policy\" {\n+ description = \"Whether to create a policy for SNS permissions or not?\"\n+ type = bool\n+ default = true\n+}\n+\n+variable \"create_sqs_policy\" {\n+ description = \"Whether to create a policy for SQS permissions or not?\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"bucket\" {\n description = \"Name of S3 bucket to use\"\n type = string\n@@ -18,18 +30,18 @@ variable \"bucket_arn\" {\n \n variable \"lambda_notifications\" {\n description = \"Map of S3 bucket notifications to Lambda function\"\n- type = any # map(map(any)) is better, but Terraform 0.12.25 panics\n+ type = any\n default = {}\n }\n \n variable \"sqs_notifications\" {\n description = \"Map of S3 bucket notifications to SQS queue\"\n- type = any # map(map(any)) is better, but Terraform 0.12.25 panics\n+ type = any\n default = {}\n }\n \n variable \"sns_notifications\" {\n description = \"Map of S3 bucket notifications to SNS topic\"\n- type = any # map(map(any)) is better, but Terraform 0.12.25 panics\n+ type = any\n default = {}\n }\n---\nmodules/notification/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.6, < 0.14\"\n+ required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 3.0, < 4.0\"\n- random = \"~> 2\"\n+ aws = \">= 3.0\"\n+ random = \">= 2.0\"\n }\n }\n---\nversions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \">= 0.12.6, < 0.14\"\n+ required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 3.0, < 4.0\"\n+ aws = \">= 3.0\"\n }\n }\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -84,14 +84,14 @@ module \"s3_bucket\" {\n \n | Name | Version |\n |------|---------|\n-| terraform | >= 0.12.6, < 0.14 |\n-| aws | >= 3.0, < 4.0 |\n+| terraform | >= 0.12.6 |\n+| aws | >= 3.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | >= 3.0, < 4.0 |\n+| aws | >= 3.0 |\n \n ## Inputs\n \n---\nexamples/notification/README.md\n@@ -19,18 +19,18 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| terraform | >= 0.12.6, < 0.14 |\n-| aws | >= 3.0, < 4.0 |\n-| null | ~> 2 |\n-| random | ~> 2 |\n+| terraform | >= 0.12.6 |\n+| aws | >= 3.0 |\n+| null | >= 2 |\n+| random | >= 2 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | >= 3.0, < 4.0 |\n-| null | ~> 2 |\n-| random | ~> 2 |\n+| aws | >= 3.0 |\n+| null | >= 2 |\n+| random | >= 2 |\n \n ## Inputs\n \n---\nexamples/notification/main.tf\n@@ -76,6 +76,26 @@ resource \"aws_sqs_queue\" \"this\" {\n name = \"${random_pet.this.id}-${count.index}\"\n }\n \n+# SQS policy created outside of the module\n+data \"aws_iam_policy_document\" \"sqs_external\" {\n+ statement {\n+ effect = \"Allow\"\n+ actions = [\"sqs:SendMessage\"]\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"s3.amazonaws.com\"]\n+ }\n+\n+ resources = [aws_sqs_queue.this[0].arn]\n+ }\n+}\n+\n+resource \"aws_sqs_queue_policy\" \"allow_external\" {\n+ queue_url = aws_sqs_queue.this[0].id\n+ policy = data.aws_iam_policy_document.sqs_external.json\n+}\n+\n module \"all_notifications\" {\n source = \"../../modules/notification\"\n \n@@ -129,4 +149,6 @@ module \"all_notifications\" {\n }\n }\n \n+ # Creation of policy is handled outside of the module\n+ create_sqs_policy = false\n }\n---\nexamples/notification/versions.tf\n@@ -1,9 +1,9 @@\n terraform {\n- required_version = \">= 0.12.6, < 0.14\"\n+ required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 3.0, < 4.0\"\n- random = \"~> 2\"\n- null = \"~> 2\"\n+ aws = \">= 3.0\"\n+ random = \">= 2\"\n+ null = \">= 2\"\n }\n }\n---\nexamples/s3-replication/README.md\n@@ -21,17 +21,17 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| terraform | >= 0.12.6, < 0.14 |\n-| aws | >= 3.0, < 4.0 |\n-| random | ~> 2 |\n+| terraform | >= 0.12.6 |\n+| aws | >= 3.0 |\n+| random | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | >= 3.0, < 4.0 |\n-| aws.replica | >= 3.0, < 4.0 |\n-| random | ~> 2 |\n+| aws | >= 3.0 |\n+| aws.replica | >= 3.0 |\n+| random | >= 2.0 |\n \n ## Inputs\n \n---\nexamples/s3-replication/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.6, < 0.14\"\n+ required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 3.0, < 4.0\"\n- random = \"~> 2\"\n+ aws = \">= 3.0\"\n+ random = \">= 2.0\"\n }\n }\n---\nmodules/notification/README.md\n@@ -7,15 +7,15 @@ Creates S3 bucket notification resource with all supported types of deliveries:\n \n | Name | Version |\n |------|---------|\n-| terraform | >= 0.12.6, < 0.14 |\n-| aws | >= 3.0, < 4.0 |\n-| random | ~> 2 |\n+| terraform | >= 0.12.6 |\n+| aws | >= 3.0 |\n+| random | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | >= 3.0, < 4.0 |\n+| aws | >= 3.0 |\n \n ## Inputs\n \n@@ -24,6 +24,8 @@ Creates S3 bucket notification resource with all supported types of deliveries:\n | bucket | Name of S3 bucket to use | `string` | `\"\"` | no |\n | bucket\\_arn | ARN of S3 bucket to use in policies | `string` | `null` | no |\n | create | Whether to create this resource or not? | `bool` | `true` | no |\n+| create\\_sns\\_policy | Whether to create a policy for SNS permissions or not? | `bool` | `true` | no |\n+| create\\_sqs\\_policy | Whether to create a policy for SQS permissions or not? | `bool` | `true` | no |\n | lambda\\_notifications | Map of S3 bucket notifications to Lambda function | `any` | `{}` | no |\n | sns\\_notifications | Map of S3 bucket notifications to SNS topic | `any` | `{}` | no |\n | sqs\\_notifications | Map of S3 bucket notifications to SQS queue | `any` | `{}` | no |\n---\nmodules/notification/main.tf\n@@ -74,7 +74,7 @@ data \"aws_arn\" \"queue\" {\n }\n \n data \"aws_iam_policy_document\" \"sqs\" {\n- for_each = var.sqs_notifications\n+ for_each = var.create_sqs_policy ? var.sqs_notifications : tomap({})\n \n statement {\n sid = \"AllowSQSS3BucketNotification\"\n@@ -101,15 +101,15 @@ data \"aws_iam_policy_document\" \"sqs\" {\n }\n \n resource \"aws_sqs_queue_policy\" \"allow\" {\n- for_each = var.sqs_notifications\n+ for_each = var.create_sqs_policy ? var.sqs_notifications : tomap({})\n \n queue_url = lookup(each.value, \"queue_id\", lookup(local.queue_ids, each.key, null))\n policy = data.aws_iam_policy_document.sqs[each.key].json\n }\n \n # SNS Topic\n data \"aws_iam_policy_document\" \"sns\" {\n- for_each = var.sns_notifications\n+ for_each = var.create_sns_policy ? var.sns_notifications : tomap({})\n \n statement {\n sid = \"AllowSNSS3BucketNotification\"\n@@ -136,7 +136,7 @@ data \"aws_iam_policy_document\" \"sns\" {\n }\n \n resource \"aws_sns_topic_policy\" \"allow\" {\n- for_each = var.sns_notifications\n+ for_each = var.create_sns_policy ? var.sns_notifications : tomap({})\n \n arn = each.value.topic_arn\n policy = data.aws_iam_policy_document.sns[each.key].json\n---\nmodules/notification/variables.tf\n@@ -4,6 +4,18 @@ variable \"create\" {\n default = true\n }\n \n+variable \"create_sns_policy\" {\n+ description = \"Whether to create a policy for SNS permissions or not?\"\n+ type = bool\n+ default = true\n+}\n+\n+variable \"create_sqs_policy\" {\n+ description = \"Whether to create a policy for SQS permissions or not?\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"bucket\" {\n description = \"Name of S3 bucket to use\"\n type = string\n@@ -18,18 +30,18 @@ variable \"bucket_arn\" {\n \n variable \"lambda_notifications\" {\n description = \"Map of S3 bucket notifications to Lambda function\"\n- type = any # map(map(any)) is better, but Terraform 0.12.25 panics\n+ type = any\n default = {}\n }\n \n variable \"sqs_notifications\" {\n description = \"Map of S3 bucket notifications to SQS queue\"\n- type = any # map(map(any)) is better, but Terraform 0.12.25 panics\n+ type = any\n default = {}\n }\n \n variable \"sns_notifications\" {\n description = \"Map of S3 bucket notifications to SNS topic\"\n- type = any # map(map(any)) is better, map(map(any)) Terraform 0.12.25 panics\n+ type = any\n default = {}\n }\n---\nmodules/notification/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.6, < 0.14\"\n+ required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 3.0, < 4.0\"\n- random = \"~> 2\"\n+ aws = \">= 3.0\"\n+ random = \">= 2.0\"\n }\n }\n---\nversions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \">= 0.12.6, < 0.14\"\n+ required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 3.0, < 4.0\"\n+ aws = \">= 3.0\"\n }\n }\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -84,14 +84,14 @@ module \"s3_bucket\" {\n \n | Name | Version |\n |------|---------|\n-| terraform | >= 0.12.6, < 0.14 |\n-| aws | >= 3.0, < 4.0 |\n+| terraform | >= 0.12.6 |\n+| aws | >= 3.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | >= 3.0, < 4.0 |\n+| aws | >= 3.0 |\n \n ## Inputs\n \n---\nexamples/notification/README.md\n@@ -19,18 +19,18 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| terraform | >= 0.12.6, < 0.14 |\n-| aws | >= 3.0, < 4.0 |\n-| null | ~> 2 |\n-| random | ~> 2 |\n+| terraform | >= 0.12.6 |\n+| aws | >= 3.0 |\n+| null | >= 2 |\n+| random | >= 2 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | >= 3.0, < 4.0 |\n-| null | ~> 2 |\n-| random | ~> 2 |\n+| aws | >= 3.0 |\n+| null | >= 2 |\n+| random | >= 2 |\n \n ## Inputs\n \n---\nexamples/notification/main.tf\n@@ -76,6 +76,26 @@ resource \"aws_sqs_queue\" \"this\" {\n name = \"${random_pet.this.id}-${count.index}\"\n }\n \n+# SQS policy created outside of the module\n+data \"aws_iam_policy_document\" \"sqs_external\" {\n+ statement {\n+ effect = \"Allow\"\n+ actions = [\"sqs:SendMessage\"]\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"s3.amazonaws.com\"]\n+ }\n+\n+ resources = [aws_sqs_queue.this[0].arn]\n+ }\n+}\n+\n+resource \"aws_sqs_queue_policy\" \"allow_external\" {\n+ queue_url = aws_sqs_queue.this[0].id\n+ policy = data.aws_iam_policy_document.sqs_external.json\n+}\n+\n module \"all_notifications\" {\n source = \"../../modules/notification\"\n \n@@ -129,4 +149,6 @@ module \"all_notifications\" {\n }\n }\n \n+ # Creation of policy is handled outside of the module\n+ create_sqs_policy = false\n }\n---\nexamples/notification/versions.tf\n@@ -1,9 +1,9 @@\n terraform {\n- required_version = \">= 0.12.6, < 0.14\"\n+ required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 3.0, < 4.0\"\n- random = \"~> 2\"\n- null = \"~> 2\"\n+ aws = \">= 3.0\"\n+ random = \">= 2\"\n+ null = \">= 2\"\n }\n }\n---\nexamples/s3-replication/README.md\n@@ -21,17 +21,17 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| terraform | >= 0.12.6, < 0.14 |\n-| aws | >= 3.0, < 4.0 |\n-| random | ~> 2 |\n+| terraform | >= 0.12.6 |\n+| aws | >= 3.0 |\n+| random | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | >= 3.0, < 4.0 |\n-| aws.replica | >= 3.0, < 4.0 |\n-| random | ~> 2 |\n+| aws | >= 3.0 |\n+| aws.replica | >= 3.0 |\n+| random | >= 2.0 |\n \n ## Inputs\n \n---\nexamples/s3-replication/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.6, < 0.14\"\n+ required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 3.0, < 4.0\"\n- random = \"~> 2\"\n+ aws = \">= 3.0\"\n+ random = \">= 2.0\"\n }\n }\n---\nmodules/notification/README.md\n@@ -7,15 +7,15 @@ Creates S3 bucket notification resource with all supported types of deliveries:\n \n | Name | Version |\n |------|---------|\n-| terraform | >= 0.12.6, < 0.14 |\n-| aws | >= 3.0, < 4.0 |\n-| random | ~> 2 |\n+| terraform | >= 0.12.6 |\n+| aws | >= |\n+| random | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | >= 3.0, < 4.0 |\n+| aws | >= 3.0 |\n \n ## Inputs\n \n@@ -24,6 +24,8 @@ Creates S3 bucket notification resource with all supported types of deliveries:\n | bucket | Name of S3 bucket to use | `string` | `\"\"` | no |\n | bucket\\_arn | ARN of S3 bucket to use in policies | `string` | `null` | no |\n | create | Whether to create this resource or not? | `bool` | `true` | no |\n+| create\\_sns\\_policy | Whether to create a policy for SNS permissions or not? | `bool` | `true` | no |\n+| create\\_sqs\\_policy | Whether to create a policy for SQS permissions or not? | `bool` | `true` | no |\n | lambda\\_notifications | Map of S3 bucket notifications to Lambda function | `any` | `{}` | no |\n | sns\\_notifications | Map of S3 bucket notifications to SNS topic | `any` | `{}` | no |\n | sqs\\_notifications | Map of S3 bucket notifications to SQS queue | `any` | `{}` | no |\n---\nmodules/notification/main.tf\n@@ -74,7 +74,7 @@ data \"aws_arn\" \"queue\" {\n }\n \n data \"aws_iam_policy_document\" \"sqs\" {\n- for_each = var.sqs_notifications\n+ for_each = var.create_sqs_policy ? var.sqs_notifications : tomap({})\n \n statement {\n sid = \"AllowSQSS3BucketNotification\"\n@@ -101,15 +101,15 @@ data \"aws_iam_policy_document\" \"sqs\" {\n }\n \n resource \"aws_sqs_queue_policy\" \"allow\" {\n- for_each = var.sqs_notifications\n+ for_each = var.create_sqs_policy ? var.sqs_notifications : tomap({})\n \n queue_url = lookup(each.value, \"queue_id\", lookup(local.queue_ids, each.key, null))\n policy = data.aws_iam_policy_document.sqs[each.key].json\n }\n \n # SNS Topic\n data \"aws_iam_policy_document\" \"sns\" {\n- for_each = var.sns_notifications\n+ for_each = var.create_sns_policy ? var.sns_notifications : tomap({})\n \n statement {\n sid = \"AllowSNSS3BucketNotification\"\n@@ -136,7 +136,7 @@ data \"aws_iam_policy_document\" \"sns\" {\n }\n \n resource \"aws_sns_topic_policy\" \"allow\" {\n- for_each = var.sns_notifications\n+ for_each = var.create_sns_policy ? var.sns_notifications : tomap({})\n \n arn = each.value.topic_arn\n policy = data.aws_iam_policy_document.sns[each.key].json\n---\nmodules/notification/variables.tf\n@@ -4,6 +4,18 @@ variable \"create\" {\n default = true\n }\n \n+variable \"create_sns_policy\" {\n+ description = \"Whether to create a policy for SNS permissions or not?\"\n+ type = bool\n+ default = true\n+}\n+\n+variable \"create_sqs_policy\" {\n+ description = \"Whether to create a policy for SQS permissions or not?\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"bucket\" {\n description = \"Name of S3 bucket to use\"\n type = string\n@@ -18,18 +30,18 @@ variable \"bucket_arn\" {\n \n variable \"lambda_notifications\" {\n description = \"Map of S3 bucket notifications to Lambda function\"\n- type = any # map(map(any)) is better, but Terraform 0.12.25 panics\n+ type = any\n default = {}\n }\n \n variable \"sqs_notifications\" {\n description = \"Map of S3 bucket notifications to SQS queue\"\n- type = any # map(map(any)) is better, but Terraform 0.12.25 panics\n+ type = any\n default = {}\n }\n \n variable \"sns_notifications\" {\n description = \"Map of S3 bucket notifications to SNS topic\"\n- type = any # map(map(any)) is better, but Terraform 0.12.25 panics\n+ type = any\n default = {}\n }\n---\nmodules/notification/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.6, < 0.14\"\n+ required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 3.0, < 4.0\"\n- random = \"~> 2\"\n+ aws = \">= 3.0\"\n+ random = \">= 2.0\"\n }\n }\n---\nversions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \">= 0.12.6, < 0.14\"\n+ required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 3.0, < 4.0\"\n+ aws = \">= 3.0\"\n }\n }\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -84,14 +84,14 @@ module \"s3_bucket\" {\n \n | Name | Version |\n |------|---------|\n-| terraform | >= 0.12.6, < 0.14 |\n-| aws | >= 3.0, < 4.0 |\n+| terraform | >= 0.12.6 |\n+| aws | >= 3.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | >= 3.0, < 4.0 |\n+| aws | >= 3.0 |\n \n ## Inputs\n \n---\nexamples/notification/README.md\n@@ -19,18 +19,18 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| terraform | >= 0.12.6, < 0.14 |\n-| aws | >= 3.0, < 4.0 |\n-| null | ~> 2 |\n-| random | ~> 2 |\n+| terraform | >= 0.12.6 |\n+| aws | >= 3.0 |\n+| null | >= 2 |\n+| random | >= 2 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | >= 3.0, < 4.0 |\n-| null | ~> 2 |\n-| random | ~> 2 |\n+| aws | >= 3.0 |\n+| null | >= 2 |\n+| random | >= 2 |\n \n ## Inputs\n \n---\nexamples/notification/main.tf\n@@ -76,6 +76,26 @@ resource \"aws_sqs_queue\" \"this\" {\n name = \"${random_pet.this.id}-${count.index}\"\n }\n \n+# SQS policy created outside of the module\n+data \"aws_iam_policy_document\" \"sqs_external\" {\n+ statement {\n+ effect = \"Allow\"\n+ actions = [\"sqs:SendMessage\"]\n+\n+ principals {\n+ type = \"Service\"\n+ identifiers = [\"s3.amazonaws.com\"]\n+ }\n+\n+ resources = [aws_sqs_queue.this[0].arn]\n+ }\n+}\n+\n+resource \"aws_sqs_queue_policy\" \"allow_external\" {\n+ queue_url = aws_sqs_queue.this[0].id\n+ policy = data.aws_iam_policy_document.sqs_external.json\n+}\n+\n module \"all_notifications\" {\n source = \"../../modules/notification\"\n \n@@ -129,4 +149,6 @@ module \"all_notifications\" {\n }\n }\n \n+ # Creation of policy is handled outside of the module\n+ create_sqs_policy = false\n }\n---\nexamples/notification/versions.tf\n@@ -1,9 +1,9 @@\n terraform {\n- required_version = \">= 0.12.6, < 0.14\"\n+ required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 3.0, < 4.0\"\n- random = \"~> 2\"\n- null = \"~> 2\"\n+ aws = \">= 3.0\"\n+ random = \">= 2\"\n+ null = \">= 2\"\n }\n }\n---\nexamples/s3-replication/README.md\n@@ -21,17 +21,17 @@ Note that this example may create resources which cost money. Run `terraform des\n \n | Name | Version |\n |------|---------|\n-| terraform | >= 0.12.6, < 0.14 |\n-| aws | >= 3.0, < 4.0 |\n-| random | ~> 2 |\n+| terraform | >= 0.12.6 |\n+| aws | >= 3.0 |\n+| random | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | >= 3.0, < 4.0 |\n-| aws.replica | >= 3.0, < 4.0 |\n-| random | ~> 2 |\n+| aws | >= 3.0 |\n+| aws.replica | >= 3.0 |\n+| random | >= 2.0 |\n \n ## Inputs\n \n---\nexamples/s3-replication/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.6, < 0.14\"\n+ required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 3.0, < 4.0\"\n- random = \"~> 2\"\n+ aws = \">= 3.0\"\n+ random = \">= 2.0\"\n }\n }\n---\nmodules/notification/README.md\n@@ -7,15 +7,15 @@ Creates S3 bucket notification resource with all supported types of deliveries:\n \n | Name | Version |\n |------|---------|\n-| terraform | >= 0.12.6, < 0.14 |\n-| aws | >= 3.0, < 4.0 |\n-| random | ~> 2 |\n+| terraform | >= 0.12.6 |\n+| aws | >= 3.0 |\n+| random | >= 2.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | >= 3.0, < 4.0 |\n+| aws | >= 3.0 |\n \n ## Inputs\n \n@@ -24,6 +24,8 @@ Creates S3 bucket notification resource with all supported types of deliveries:\n | bucket | Name of S3 bucket to use | `string` | `\"\"` | no |\n | bucket\\_arn | ARN of S3 bucket to use in policies | `string` | `null` | no |\n | create | Whether to create this resource or not? | `bool` | `true` | no |\n+| create\\_sns\\_policy | Whether to create a policy for SNS permissions or not? | `bool` | `true` | no |\n+| create\\_sqs\\_policy | Whether to create a policy for SQS permissions or not? | `bool` | `true` | no |\n | lambda\\_notifications | Map of S3 bucket notifications to Lambda function | `any` | `{}` | no |\n | sns\\_notifications | Map of S3 bucket notifications to SNS topic | `any` | `{}` | no |\n | sqs\\_notifications | Map of S3 bucket notifications to SQS queue | `any` | `{}` | no |\n---\nmodules/notification/main.tf\n@@ -74,7 +74,7 @@ data \"aws_arn\" \"queue\" {\n }\n \n data \"aws_iam_policy_document\" \"sqs\" {\n- for_each = var.sqs_notifications\n+ for_each = var.create_sqs_policy ? var.sqs_notifications : tomap({})\n \n statement {\n sid = \"AllowSQSS3BucketNotification\"\n@@ -101,15 +101,15 @@ data \"aws_iam_policy_document\" \"sqs\" {\n }\n \n resource \"aws_sqs_queue_policy\" \"allow\" {\n- for_each = var.sqs_notifications\n+ for_each = var.create_sqs_policy ? var.sqs_notifications : tomap({})\n \n queue_url = lookup(each.value, \"queue_id\", lookup(local.queue_ids, each.key, null))\n policy = data.aws_iam_policy_document.sqs[each.key].json\n }\n \n # SNS Topic\n data \"aws_iam_policy_document\" \"sns\" {\n- for_each = var.sns_notifications\n+ for_each = var.create_sns_policy ? var.sns_notifications : tomap({})\n \n statement {\n sid = \"AllowSNSS3BucketNotification\"\n@@ -136,7 +136,7 @@ data \"aws_iam_policy_document\" \"sns\" {\n }\n \n resource \"aws_sns_topic_policy\" \"allow\" {\n- for_each = var.sns_notifications\n+ for_each = var.create_sns_policy ? var.sns_notifications : tomap({})\n \n arn = each.value.topic_arn\n policy = data.aws_iam_policy_document.sns[each.key].json\n---\nmodules/notification/variables.tf\n@@ -4,6 +4,18 @@ variable \"create\" {\n default = true\n }\n \n+variable \"create_sns_policy\" {\n+ description = \"Whether to create a policy for SNS permissions or not?\"\n+ type = bool\n+ default = true\n+}\n+\n+variable \"create_sqs_policy\" {\n+ description = \"Whether to create a policy for SQS permissions or not?\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"bucket\" {\n description = \"Name of S3 bucket to use\"\n type = string\n@@ -18,18 +30,18 @@ variable \"bucket_arn\" {\n \n variable \"lambda_notifications\" {\n description = \"Map of S3 bucket notifications to Lambda function\"\n- type = any # map(map(any)) is better, but Terraform 0.12.25 panics\n+ type = any\n default = {}\n }\n \n variable \"sqs_notifications\" {\n description = \"Map of S3 bucket notifications to SQS queue\"\n- type = any # map(map(any)) is better, but Terraform 0.12.25 panics\n+ type = any\n default = {}\n }\n \n variable \"sns_notifications\" {\n description = \"Map of S3 bucket notifications to SNS topic\"\n- type = any # map(map(any)) is better, but Terraform 0.12.25 panics\n+ type = any\n default = {}\n }\n---\nmodules/notification/versions.tf\n@@ -1,8 +1,8 @@\n terraform {\n- required_version = \">= 0.12.6, < 0.14\"\n+ required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 3.0, < 4.0\"\n- random = \"~> 2\"\n+ aws = \">= 3.0\"\n+ random = \">= 2.0\"\n }\n }\n---\nversions.tf\n@@ -1,7 +1,7 @@\n terraform {\n- required_version = \">= 0.12.6, < 0.14\"\n+ required_version = \">= 0.12.6\"\n \n required_providers {\n- aws = \">= 3.0, < 4.0\"\n+ aws = \">= 3.0\"\n }\n }\n---\n\n\n---\n" } ]
D
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\nFix #48\n\n---\n\nChoice A:\nREADME.md\n@@ -106,7 +106,7 @@ module \"s3_bucket\" {\n | block\\_public\\_policy | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | bucket | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n | bucket\\_prefix | (Optional, Forces new resource) Creates a unique bucket name beginning | the specified prefix. Conflicts with bucket. | `string` | `null` | no |\n-| cors\\_rule | List of maps containing rules for Cross-Origin Resource Sharing. | `list(any)` | `[]` | no |\n+| cors\\_rule | List of maps containing rules for Cross-Origin Resource Sharing. | `any` | `[]` | no |\n | create\\_bucket | Controls if S3 bucket should be created | `bool` | `true` | no |\n | force\\_destroy | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n | grant | An ACL policy grant. Conflicts with `acl` | `any` | `[]` | no |\n---\nvariables.tf\n@@ -78,7 +78,7 @@ variable \"website\" {\n \n variable \"cors_rule\" {\n description = \"List of maps containing rules for Cross-Origin Resource Sharing.\"\n- type = list(any)\n+ type = any\n default = []\n }\n \n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -106,7 +106,7 @@ module \"s3_bucket\" {\n | block\\_public\\_policy | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | bucket | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n | bucket\\_prefix | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | `string` | `null` | no |\n-| cors\\_rule | List of maps containing rules for Cross-Origin Resource Sharing. | `list(any)` | `[]` | no |\n+| cors\\_rule | List of maps containing rules for Cross-Origin Resource Sharing. | `any` | `[]` | no |\n | create\\_bucket | Controls if S3 bucket should be created | `bool` | `true` | no |\n | force\\_destroy | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n | grant | An ACL policy grant. Conflicts with `acl` | `any` | `[]` | no |\n---\nvariables.tf\n@@ -78,7 +78,7 @@ variable \"website\" {\n \n variable \"cors_rule\" {\n description = \"List of maps containing rules for Cross-Origin Resource Sharing.\"\n- type = list(any)\n+ type = any\n default = []\n }\n \n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -106,7 +106,7 @@ module \"s3_bucket\" {\n | block\\_public\\_policy | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | bucket | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n | bucket\\_prefix | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | `string` | `null` | no |\n-| cors\\_rule | List of maps containing rules for Cross-Origin Resource Sharing. | `list(any)` | `[]` | no |\n+| cors\\_rule | List of maps containing rules for Cross-Origin Resource Sharing. | `any` | `[]` | no |\n | create\\_bucket | Controls if S3 bucket should be created | `bool` | `true` | no |\n | force\\_destroy | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n | grant | Cross-Origin ACL policy grant. Conflicts with `acl` | `any` | `[]` | no |\n---\nvariables.tf\n@@ -78,7 +78,7 @@ variable \"website\" {\n \n variable \"cors_rule\" {\n description = \"List of maps containing rules for Cross-Origin Resource Sharing.\"\n- type = list(any)\n+ type = any\n default = []\n }\n \n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -106,7 +106,7 @@ module \"s3_bucket\" {\n | block\\_public\\_policy | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | bucket | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n | bucket\\_prefix | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts variable bucket. | `string` | `null` | no |\n-| cors\\_rule | List of maps containing rules for Cross-Origin Resource Sharing. | `list(any)` | `[]` | no |\n+| cors\\_rule | List of maps containing rules for Cross-Origin Resource Sharing. | `any` | `[]` | no |\n | create\\_bucket | Controls if S3 bucket should be created | `bool` | `true` | no |\n | force\\_destroy | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n | grant | An ACL policy grant. Conflicts with `acl` | `any` | `[]` | no |\n---\nvariables.tf\n@@ -78,7 +78,7 @@ variable \"website\" {\n \n variable \"cors_rule\" {\n description = \"List of maps containing rules for Cross-Origin Resource Sharing.\"\n- type = list(any)\n+ type = any\n default = []\n }\n \n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\nfix #45\n\n---\n\nChoice A:\nREADME.md\n@@ -109,7 +109,7 @@ module \"s3_bucket\" {\n | cors\\_rule | List of maps containing rules for Cross-Origin Resource Sharing. | `list(any)` | `[]` | no |\n | create\\_bucket | Controls if S3 bucket should be created | `bool` | `true` | no |\n | force\\_destroy | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n-| grant | An ACL policy grant. Conflicts with `acl` | `list(any)` | `[]` | no |\n+| grant | An ACL policy grant. Conflicts with `acl` | `any` | `[]` | no |\n | ignore\\_public\\_acls | Whether Amazon S3 should ignore public ACLs for this bucket. | `bool` | `false` | no |\n | lifecycle\\_rule | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | logging | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n---\nvariables.tf\n@@ -96,7 +96,7 @@ variable \"logging\" {\n \n variable \"grant\" {\n description = \"An ACL policy grant. Conflicts with `acl`\"\n- type = list(any)\n+ type = any\n default = []\n }\n \n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -109,7 +109,7 @@ module \"s3_bucket\" {\n | cors\\_rule | List of maps containing rules for Cross-Origin Resource Sharing. | `list(any)` | `[]` | no |\n | create\\_bucket | Controls if S3 bucket | be created | `bool` | `true` | no |\n | force\\_destroy | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n-| grant | An ACL policy grant. Conflicts with `acl` | `list(any)` | `[]` | no |\n+| grant | An ACL policy grant. Conflicts with `acl` | `any` | `[]` | no |\n | ignore\\_public\\_acls | Whether Amazon S3 should ignore public ACLs for this bucket. | `bool` | `false` | no |\n | lifecycle\\_rule | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | logging | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n---\nvariables.tf\n@@ -96,7 +96,7 @@ variable \"logging\" {\n \n variable \"grant\" {\n description = \"An ACL policy grant. Conflicts with `acl`\"\n- type = list(any)\n+ type = any\n default = []\n }\n \n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -109,7 +109,7 @@ module \"s3_bucket\" {\n | cors\\_rule | List of maps containing rules for Cross-Origin Resource Sharing. | `list(any)` | | no |\n | create\\_bucket | Controls if S3 bucket should be created | `bool` | `true` | no |\n | force\\_destroy | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n-| grant | An ACL policy grant. Conflicts with `acl` | `list(any)` | `[]` | no |\n+| grant | An ACL policy grant. Conflicts with `acl` | `any` | `[]` | no |\n | ignore\\_public\\_acls | Whether Amazon S3 should ignore public ACLs for this bucket. | `bool` | `false` | no |\n | lifecycle\\_rule | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | logging | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n---\nvariables.tf\n@@ -96,7 +96,7 @@ variable \"logging\" {\n \n variable \"grant\" {\n description = \"An ACL policy grant. Conflicts with `acl`\"\n- type = list(any)\n+ type = any\n default = []\n }\n \n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -109,7 +109,7 @@ module \"s3_bucket\" {\n | cors\\_rule | List of maps containing rules for Cross-Origin Resource Sharing. | `list(any)` | `[]` | no |\n | create\\_bucket | Controls if S3 bucket should be created | `bool` | `true` | no |\n | force\\_destroy | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n-| grant | An ACL policy grant. Conflicts with `acl` | `list(any)` | `[]` | no |\n+| grant | An ACL policy grant. Conflicts with `acl` | `any` | `[]` | no |\n | ignore\\_public\\_acls | Whether Amazon S3 should ignore public ACLs for this bucket. | `bool` | `false` | no |\n | lifecycle\\_rule | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |\n | logging | Map containing access bucket logging configuration. bucket `map(string)` | `{}` | no |\n---\nvariables.tf\n@@ -96,7 +96,7 @@ variable \"logging\" {\n \n variable \"grant\" {\n description = \"An ACL policy grant. Conflicts with `acl`\"\n- type = list(any)\n+ type = any\n default = []\n }\n \n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\n<!--- Describe your changes in detail -->\r\nModify CORS to support multiple rules instead of a single rule\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\nWhen importing an existing bucket the module was attempting to remove all but one of the rules.\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\nYes\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\nObject to Array. It is possible to be backwards compatible, however, since the syntax is as simple as adding brackets there is little reason to add additional code.\r\n\r\n## How Has This Been Tested?\r\n<!--- Please describe in detail how you tested your changes. -->\r\nApplying on an existing resource\r\n<!--- Include details of your testing environment, and the tests you ran to -->\r\n<!--- see how your change affects other areas of the code, etc. -->\r\n\n\n---\n\nChoice A:\nREADME.md\n@@ -106,7 +106,7 @@ module \"s3_bucket\" {\n | block\\_public\\_policy | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | bucket | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n | bucket\\_prefix | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | `string` | `null` | no |\n-| cors\\_rule | Map containing a rule of Cross-Origin Resource Sharing. | `any` | `{}` | no |\n+| cors\\_rule | List of maps containing rules for Cross-Origin Resource Sharing. | `list(any)` | `[]` | no |\n | create\\_bucket | Controls if S3 bucket should be created | `bool` | `true` | no |\n | force\\_destroy | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n | ignore\\_public\\_acls | Whether Amazon S3 should ignore public ACLs for this bucket. | `bool` | `false` | no |\n---\nexamples/complete/main.tf\n@@ -92,13 +92,21 @@ module \"s3_bucket\" {\n target_prefix = \"log/\"\n }\n \n- cors_rule = {\n- allowed_methods = [\"PUT\", \"POST\"]\n- allowed_origins = [\"https://modules.tf\", \"https://terraform-aws-modules.modules.tf\"]\n- allowed_headers = [\"*\"]\n- expose_headers = for max_age_seconds = 3000\n- }\n+ cors_rule = [\n+ {\n+ allowed_methods = [\"PUT\", \"POST\"]\n+ allowed_origins = [\"https://modules.tf\", \"https://terraform-aws-modules.modules.tf\"]\n+ allowed_headers = [\"*\"]\n+ expose_headers = [\"ETag\"]\n+ max_age_seconds = 3000\n+ }, {\n+ allowed_methods = [\"PUT\"]\n+ allowed_origins = [\"https://example.com\"]\n+ allowed_headers = [\"*\"]\n+ expose_headers = [\"ETag\"]\n+ max_age_seconds = 3000\n+ }\n+ ]\n \n lifecycle_rule = [\n {\n---\nmain.tf\n@@ -21,7 +21,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n dynamic \"cors_rule\" {\n- for_each = length(keys(var.cors_rule)) == 0 ? [] : [var.cors_rule]\n+ for_each = var.cors_rule\n \n content {\n allowed_methods = cors_rule.value.allowed_methods\n---\nvariables.tf\n@@ -77,9 +77,9 @@ variable \"website\" {\n }\n \n variable \"cors_rule\" {\n- description = \"Map containing a rule of Cross-Origin Resource Sharing.\"\n- type = any # should be `map`, but it produces an error \"all map elements must have the same type\"\n- default = {}\n+ description = \"List of maps containing rules for Cross-Origin Resource Sharing.\"\n+ type = list(any)\n+ default = []\n }\n \n variable \"versioning\" {\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -106,7 +106,7 @@ module \"s3_bucket\" {\n | block\\_public\\_policy | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | bucket | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n | bucket\\_prefix | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | `string` | `null` | no |\n-| cors\\_rule | Map containing a rule of Cross-Origin Resource Sharing. | `any` | `{}` | no |\n+| cors\\_rule | List of maps containing rules for Cross-Origin Resource Sharing. | `list(any)` | `[]` | no |\n | create\\_bucket | Controls if S3 bucket should be created | `bool` | `true` | no |\n | force\\_destroy | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n | ignore\\_public\\_acls | Whether Amazon S3 should ignore public ACLs for this bucket. | `bool` | `false` | no |\n---\nexamples/complete/main.tf\n@@ -92,13 +92,21 @@ module \"s3_bucket\" {\n target_prefix = \"log/\"\n }\n \n- cors_rule = {\n- allowed_methods = [\"PUT\", \"POST\"]\n- allowed_origins = [\"https://modules.tf\", \"https://terraform-aws-modules.modules.tf\"]\n- allowed_headers = [\"*\"]\n- expose_headers = [\"ETag\"]\n- max_age_seconds = 3000\n- }\n+ cors_rule = [\n+ {\n+ allowed_methods = [\"PUT\", \"POST\"]\n+ allowed_origins = [\"https://modules.tf\", \"https://terraform-aws-modules.modules.tf\"]\n+ allowed_headers = [\"*\"]\n+ expose_headers = [\"ETag\"]\n+ max_age_seconds = 3000\n+ }, {\n+ allowed_methods = [\"PUT\"]\n+ allowed_origins = [\"https://example.com\"]\n+ allowed_headers = [\"*\"]\n+ expose_headers = [\"ETag\"]\n+ max_age_seconds = 3000\n+ }\n+ ]\n \n lifecycle_rule = [\n {\n---\nmain.tf\n@@ -21,7 +21,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n dynamic \"cors_rule\" {\n- for_each = length(keys(var.cors_rule)) == 0 ? [] : [var.cors_rule]\n+ for_each = var.cors_rule\n \n content {\n allowed_methods = cors_rule.value.allowed_methods\n---\nvariables.tf\n@@ -77,9 +77,9 @@ variable \"website\" {\n }\n \n variable \"cors_rule\" {\n- description = \"Map containing a rule of Cross-Origin Resource Sharing.\"\n- type = any # should be `map`, but it produces an error \"all map elements must have the same type\"\n- default = {}\n+ description = \"List of maps containing rules for Cross-Origin Resource Sharing.\"\n+ type = list(any)\n+ default = []\n }\n \n variable \"versioning\" {\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -106,7 +106,7 @@ module \"s3_bucket\" {\n | block\\_public\\_policy | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | bucket | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n | bucket\\_prefix | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | `string` | `null` | no |\n-| cors\\_rule | Map containing a rule of Cross-Origin Resource Sharing. | `any` | `{}` | no |\n+| cors\\_rule | List of maps containing rules for Cross-Origin Resource Sharing. | `list(any)` | `[]` | no |\n | create\\_bucket | Controls if S3 bucket should be created | `bool` | `true` | no |\n | force\\_destroy | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n | ignore\\_public\\_acls | Whether Amazon S3 should ignore public ACLs for this bucket. | `bool` | `false` | no |\n---\nexamples/complete/main.tf\n@@ -92,13 +92,21 @@ module \"s3_bucket\" {\n target_prefix = \"log/\"\n }\n \n- cors_rule = {\n- allowed_methods = [\"PUT\", \"POST\"]\n- allowed_origins = [\"https://modules.tf\", \"https://terraform-aws-modules.modules.tf\"]\n- allowed_headers = [\"*\"]\n- expose_headers = [\"ETag\"]\n- max_age_seconds = 3000\n- }\n+ cors_rule = [\n+ {\n+ allowed_methods = [\"PUT\", \"POST\"]\n+ allowed_origins = [\"https://modules.tf\", \"https://terraform-aws-modules.modules.tf\"]\n+ allowed_headers = [\"*\"]\n+ expose_headers = [\"ETag\"]\n+ max_age_seconds = 3000\n+ }, {\n+ allowed_methods = [\"PUT\"]\n+ allowed_origins = [\"https://example.com\"]\n+ allowed_headers = [\"*\"]\n+ expose_headers = [\"ETag\"]\n+ max_age_seconds = 3000\n+ }\n+ ]\n \n lifecycle_rule = [\n {\n---\nmain.tf\n@@ -21,7 +21,7 @@ resource \"aws_s3_bucket\" \"this\" {\n Whether }\n \n dynamic \"cors_rule\" {\n- for_each = length(keys(var.cors_rule)) == 0 ? [] : [var.cors_rule]\n+ for_each = var.cors_rule\n \n content {\n allowed_methods = cors_rule.value.allowed_methods\n---\nvariables.tf\n@@ -77,9 +77,9 @@ variable \"website\" {\n }\n \n variable \"cors_rule\" {\n- description = \"Map containing a rule of Cross-Origin Resource Sharing.\"\n- type = any # should be `map`, but it produces an error \"all map elements must have the same type\"\n- default = {}\n+ description = \"List of maps containing rules for Cross-Origin Resource Sharing.\"\n+ type = list(any)\n+ default = []\n }\n \n variable \"versioning\" {\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -106,7 +106,7 @@ module \"s3_bucket\" {\n | block\\_public\\_policy | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | bucket | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n | bucket\\_prefix | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | `string` | `null` | no |\n-| cors\\_rule | Map containing a rule of Cross-Origin Resource Sharing. | `any` | `{}` | no |\n+| cors\\_rule | List of maps containing rules for Cross-Origin Resource Sharing. | `list(any)` | `[]` | no |\n | create\\_bucket | Controls if S3 bucket should be created | `bool` | `true` | no |\n | force\\_destroy | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. {}\n+ `bool` | `false` | no |\n | ignore\\_public\\_acls | Whether Amazon S3 should ignore public ACLs for this bucket. | `bool` | `false` | no |\n---\nexamples/complete/main.tf\n@@ -92,13 +92,21 @@ module \"s3_bucket\" {\n target_prefix = \"log/\"\n }\n \n- cors_rule = {\n- allowed_methods = [\"PUT\", \"POST\"]\n- allowed_origins = [\"https://modules.tf\", \"https://terraform-aws-modules.modules.tf\"]\n- allowed_headers = [\"*\"]\n- expose_headers = [\"ETag\"]\n- max_age_seconds = 3000\n- }\n+ cors_rule = [\n+ {\n+ allowed_methods = [\"PUT\", \"POST\"]\n+ allowed_origins = [\"https://modules.tf\", \"https://terraform-aws-modules.modules.tf\"]\n+ allowed_headers = [\"*\"]\n+ expose_headers = [\"ETag\"]\n+ max_age_seconds = 3000\n+ }, {\n+ allowed_methods = [\"PUT\"]\n+ allowed_origins = [\"https://example.com\"]\n+ allowed_headers = [\"*\"]\n+ expose_headers = [\"ETag\"]\n+ max_age_seconds = 3000\n+ }\n+ ]\n \n lifecycle_rule = [\n {\n---\nmain.tf\n@@ -21,7 +21,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n dynamic \"cors_rule\" {\n- for_each = length(keys(var.cors_rule)) == 0 ? [] : [var.cors_rule]\n+ for_each = var.cors_rule\n \n content {\n allowed_methods = cors_rule.value.allowed_methods\n---\nvariables.tf\n@@ -77,9 +77,9 @@ variable \"website\" {\n }\n \n variable \"cors_rule\" {\n- description = \"Map containing a rule of Cross-Origin Resource Sharing.\"\n- type = any # should be `map`, but it produces an error \"all map elements must have the same type\"\n- default = {}\n+ description = \"List of maps containing rules for Cross-Origin Resource Sharing.\"\n+ type = list(any)\n+ default = []\n }\n \n variable \"versioning\" {\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\nThe 3.0 aws provider does not allow a region parameter for the `aws_s3_bucket` resource.\n\n---\n\nChoice A:\nREADME.md\n@@ -85,13 +85,13 @@ module \"s3_bucket\" {\n | Name | Version |\n |------|---------|\n | terraform | >= 0.12.6, < 0.14 |\n-| aws | ~> 2.35 |\n+| aws | >= 3.0, < 4.0 |\n \n ## Providers\n < | Name | Version |\n |------|---------|\n-| aws | ~> 2.35 |\n+| aws | >= 3.0, < 4.0 |\n \n ## Inputs\n \n@@ -114,7 +114,6 @@ module \"s3_bucket\" {\n | logging | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n | object\\_lock\\_configuration | Map containing S3 object locking configuration. | `any` | `{}` | no |\n | policy | (Optional) A valid bucket policy JSON document. Note that if the policy document is not specific enough (but still valid), Terraform may view the policy as constantly changing in a terraform plan. In this case, please make sure you use the verbose/specific version of the policy. For more information about building AWS IAM policy documents with Terraform, see the AWS IAM Policy Document Guide. | `string` | `null` | no |\n-| region | (Optional) If specified, the AWS region this bucket should reside in. Otherwise, the region used by the callee. | `string` | `null` | no |\n | replication\\_configuration | Map containing cross-region replication configuration. | `any` | `{}` | no |\n | request\\_payer | (Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information. | `string` | `null` | no |\n | restrict\\_public\\_buckets | Whether Amazon S3 should restrict public bucket policies for this bucket. | `bool` | `false` | no |\n---\nexamples/s3-replication/main.tf\n@@ -36,7 +36,6 @@ module \"replica_bucket\" {\n }\n \n bucket = local.destination_bucket_name\n- region = local.replica_region\n acl = \"private\"\n \n versioning = {\n@@ -48,7 +47,6 @@ module \"s3_bucket\" {\n source = \"../../\"\n \n bucket = local.bucket_name\n- region = local.origin_region\n acl = \"private\"\n \n versioning = {\n---\nmain.tf\n@@ -7,7 +7,6 @@ resource \"aws_s3_bucket\" \"this\" {\n tags = var.tags\n force_destroy = var.force_destroy\n acceleration_status = var.acceleration_status\n- region = var.region\n request_payer = var.request_payer\n \n dynamic \"website\" {\n---\nvariables.tf\n@@ -64,12 +64,6 @@ variable \"acceleration_status\" {\n default = null\n }\n \n-variable \"region\" {\n- description = \"(Optional) If specified, the AWS region this bucket should reside in. Otherwise, the region used by the callee.\"\n- type = string\n- default = null\n-}\n-\n variable \"request_payer\" {\n description = \"(Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information.\"\n type = string\n---\nversions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.35\"\n+ aws = \">= 3.0, < 4.0\"\n }\n }\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -85,13 +85,13 @@ module \"s3_bucket\" {\n | Name | Version |\n |------|---------|\n | terraform | >= 0.12.6, < 0.14 |\n-| aws | ~> 2.35 |\n+| aws | >= 3.0, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.35 |\n+| aws | >= 3.0, < 4.0 |\n \n ## Inputs\n \n@@ -114,7 +114,6 @@ module \"s3_bucket\" {\n | logging | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n | object\\_lock\\_configuration | Map containing S3 object locking configuration. | `any` | `{}` | no |\n | policy | (Optional) A valid bucket policy JSON document. Note that if the policy document is not specific enough (but still valid), Terraform may view the policy as constantly changing in a terraform plan. In this case, please make sure you use the verbose/specific version of the policy. For more information about building AWS IAM policy documents with Terraform, see the AWS IAM Policy Document Guide. | `string` | `null` | no |\n-| region | (Optional) If specified, the AWS region this bucket should reside in. Otherwise, the region used by the callee. | `string` | `null` | no |\n | replication\\_configuration | Map containing cross-region replication configuration. | `any` | `{}` | no |\n | request\\_payer | (Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information. | `string` | `null` | no |\n | restrict\\_public\\_buckets | Whether Amazon S3 should restrict public bucket policies for this bucket. | `bool` | `false` | no |\n---\nexamples/s3-replication/main.tf\n@@ -36,7 +36,6 @@ module \"replica_bucket\" {\n }\n \n bucket = local.destination_bucket_name\n- region = local.replica_region\n acl = \"private\"\n \n versioning = {\n@@ -48,7 +47,6 @@ module \"s3_bucket\" {\n source = \"../../\"\n \n bucket = local.bucket_name\n- region = local.origin_region\n acl = \"private\"\n \n versioning = {\n---\nmain.tf\n@@ -7,7 +7,6 @@ resource \"aws_s3_bucket\" \"this\" {\n tags = var.tags\n force_destroy = var.force_destroy\n acceleration_status = var.acceleration_status\n- region = var.region\n request_payer = var.request_payer\n \n dynamic \"website\" {\n---\nvariables.tf\n@@ -64,12 +64,6 @@ variable \"acceleration_status\" {\n default = null\n }\n \n-variable \"region\" description = \"(Optional) If specified, the AWS region this bucket should reside in. Otherwise, the region used by the callee.\"\n- type = string\n- default = null\n-}\n-\n variable \"request_payer\" {\n description = \"(Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information.\"\n type = string\n---\nversions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.35\"\n+ aws = \">= 3.0, < 4.0\"\n }\n }\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -85,13 +85,13 @@ module \"s3_bucket\" {\n | Name | Version |\n |------|---------|\n | terraform | >= 0.12.6, < 0.14 |\n-| aws | ~> 2.35 |\n+| aws | >= 3.0, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.35 |\n+| aws | >= 3.0, < 4.0 |\n \n ## Inputs\n \n@@ -114,7 +114,6 @@ module \"s3_bucket\" {\n | logging | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n | object\\_lock\\_configuration | Map containing S3 object locking configuration. | `any` | `{}` | no |\n | policy | (Optional) A valid bucket policy JSON document. Note that if the policy document is not specific enough (but still valid), Terraform may view the policy as constantly changing in a terraform plan. In this case, please make sure you use the verbose/specific version of the policy. For more information about building AWS IAM policy documents with Terraform, see the AWS IAM Policy Document Guide. | `string` | `null` | no |\n-| region | (Optional) If specified, the AWS region this bucket should reside in. Otherwise, the region used by the callee. | `string` | `null` | no |\n | replication\\_configuration | Map containing cross-region replication configuration. | `any` | `{}` | no |\n | request\\_payer | (Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information. | `string` | `null` | no |\n | restrict\\_public\\_buckets | Whether Amazon S3 should restrict public bucket policies for this bucket. | `bool` | `false` | no |\n---\nexamples/s3-replication/main.tf\n@@ -36,7 +36,6 @@ module \"replica_bucket\" {\n }\n \n bucket = local.destination_bucket_name\n- region = local.replica_region\n acl = \"private\"\n \n versioning = {\n@@ -48,7 +47,6 @@ module \"s3_bucket\" {\n source = \"../../\"\n \n bucket = local.bucket_name\n- region = local.origin_region\n acl = \"private\"\n \n versioning = {\n---\nmain.tf\n@@ -7,7 +7,6 @@ resource \"aws_s3_bucket\" \"this\" {\n tags = var.tags\n force_destroy = var.force_destroy\n acceleration_status = var.acceleration_status\n- region = var.region\n request_payer = var.request_payer\n \n dynamic \"website\" {\n---\nvariables.tf\n@@ -64,12 +64,6 @@ variable \"acceleration_status\" {\n default = null\n }\n \n-variable \"region\" {\n- description = \"(Optional) If specified, the AWS region this bucket should reside in. Otherwise, the region used by the callee.\"\n- type = string\n- default = null\n-}\n-\n variable \"request_payer\" {\n description = \"(Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information.\"\n type = string\n---\nversions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.35\"\n+ aws = \">= 3.0, < 4.0\"\n }\n }\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -85,13 +85,13 @@ module \"s3_bucket\" {\n | Name | Version |\n |------|---------|\n | terraform | >= 0.12.6, < 0.14 |\n-| aws | ~> 2.35 |\n+| aws | >= 3.0, < 4.0 |\n \n ## Providers\n \n | Name | Version |\n |------|---------|\n-| aws | ~> 2.35 |\n+| aws | >= 3.0, < 4.0 |\n \n ## Inputs\n \n@@ -114,7 +114,6 @@ module \"s3_bucket\" {\n | logging | Map containing access bucket logging configuration. | `map(string)` | `{}` | no |\n | object\\_lock\\_configuration | Map containing S3 object locking configuration. | `any` | `{}` | no |\n | policy | (Optional) A valid bucket policy JSON document. Note that if the policy document is not specific enough (but still valid), Terraform may view the policy as constantly changing in a terraform plan. In this case, please make sure you use the verbose/specific version of the policy. For more information about building AWS IAM policy documents with Terraform, see the AWS IAM Policy Guide. | `string` | `null` | no |\n-| region | (Optional) If specified, the AWS region this bucket should reside in. Otherwise, the region used by the callee. | `string` | `null` | no |\n | replication\\_configuration | Map containing cross-region replication configuration. | `any` | `{}` | no |\n | request\\_payer | (Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information. | `string` | `null` | no |\n | restrict\\_public\\_buckets | Whether Amazon S3 should restrict public bucket policies for this bucket. | `bool` | `false` | no |\n---\nexamples/s3-replication/main.tf\n@@ -36,7 +36,6 @@ module \"replica_bucket\" {\n }\n \n bucket = local.destination_bucket_name\n- region = local.replica_region\n acl = \"private\"\n \n versioning = {\n@@ -48,7 +47,6 @@ module \"s3_bucket\" {\n source = \"../../\"\n \n bucket = local.bucket_name\n- region = local.origin_region\n acl = \"private\"\n \n versioning = {\n---\nmain.tf\n@@ -7,7 +7,6 @@ resource \"aws_s3_bucket\" \"this\" {\n tags = var.tags\n force_destroy = var.force_destroy\n acceleration_status = var.acceleration_status\n- region = var.region\n request_payer = var.request_payer\n \n dynamic \"website\" {\n---\nvariables.tf\n@@ -64,12 +64,6 @@ variable \"acceleration_status\" {\n default = null\n }\n \n-variable \"region\" {\n- description = \"(Optional) If specified, the AWS region this bucket should reside in. Otherwise, the region used by the callee.\"\n- type = string\n- default = null\n-}\n-\n variable \"request_payer\" {\n description = \"(Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information.\"\n type = string\n---\nversions.tf\n@@ -2,6 +2,6 @@ terraform {\n required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n- aws = \"~> 2.35\"\n+ aws = \">= 3.0, < 4.0\"\n }\n }\n---\n\n\n---\n" } ]
C
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nUpdate the required version block to allow 0.13 usage\r\n\r\n## Motivation and Context\r\nThis module cannot be used with the 0.13 versions of terraform (beta, or the upcoming GA), this modifies the version so that it can at least be used. However, there are other changes that might be desirable, such as deprecating the `create_bucket` argument now that module count will be available.\r\n\r\n## Breaking Changes\r\n<!-- Does this break backwards compatibility with the current major version? -->\r\n<!-- If so, please provide an explanation why it is necessary. -->\r\n\r\n## How Has This Been Tested?\r\nForked this repo, changed the file, and ran through loading the module, changing count, and changing for_each.\r\n<!--- Please describe in detail how you tested your changes. -->\r\n<!--- Include details of your testing environment, and the tests you ran to -->\r\n<!--- see how your change affects other areas of the code, etc. -->\r\n\n\n---\n\nChoice A:\nREADME.md\n@@ -22,7 +22,7 @@ These features of S3 bucket configurations are supported:\n \n ## Terraform versions\n \n-Only Terraform 0.12 is supported.\n+Terraform 0.12 and above are supported.\n \n ## Usage\n \n@@ -84,7 +84,7 @@ module \"s3_bucket\" {\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n+| terraform | >= 0.12.6, < 0.14 |\n | aws | ~> 2.35 |\n \n ## Providers\n---\nversions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n aws = \"~> 2.35\"\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -22,7 +22,7 @@ These features of S3 bucket configurations are supported:\n \n ## Terraform versions\n \n-Only Terraform 0.12 is supported.\n+Terraform 0.12 and above are supported.\n \n ## Usage\n \n@@ -84,7 +84,7 @@ module \"s3_bucket\" {\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n+| terraform | >= 0.12.6, < 0.14 |\n | aws | ~> 2.35 |\n \n ## Providers\n---\nversions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n aws = Name 2.35\"\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -22,7 +22,7 @@ These features of S3 bucket configurations are supported:\n \n ## Terraform versions\n \n-Only Terraform 0.12 is supported.\n+Terraform 0.12 and above are supported.\n \n ## Usage\n \n@@ -84,7 +84,7 @@ module \"s3_bucket\" {\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n+| terraform | >= 0.12.6, < 0.14 |\n | aws \n-Only ~> 2.35 |\n \n ## Providers\n---\nversions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \">= 0.12.6, < 0.14\"\n \n required_providers {\n aws = \"~> 2.35\"\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -22,7 +22,7 @@ These features of S3 bucket configurations are supported:\n \n ## Terraform versions\n \n-Only Terraform 0.12 is supported.\n+Terraform 0.12 and above are supported.\n \n ## Usage\n \n@@ -84,7 +84,7 @@ module \"s3_bucket\" {\n \n | Name | Version |\n |------|---------|\n-| terraform | ~> 0.12.6 |\n+| terraform | >= 0.12.6, < 0.14 |\n | aws | ~> 2.35 |\n \n ## Providers\n---\nversions.tf\n@@ -1,5 +1,5 @@\n terraform {\n- required_version = \"~> 0.12.6\"\n+ required_version = \n@@ 0.12.6, < 0.14\"\n \n required_providers {\n aws = \"~> 2.35\"\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nAdd a bool which controls the creation of resource \"aws_s3_bucket_public_access_block\"\r\n\r\n## Motivation and Context\r\nWe have an environment where S3 buckets are being created under a role without `PutBucketPolicy`.\r\n\r\n## Breaking Changes\r\nNo, by default the behavior will remain the same.\r\n\r\n## How Has This Been Tested?\r\nTested against a role without `PutBucketPolicy`.\r\n\n\n---\n\nChoice A:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.30.0\n+ rev: v1.31.0\n hooks:\n - id: terraform_fmt\n - id: terraform_docs\n---\nREADME.md\n@@ -101,6 +101,7 @@ module \"s3_bucket\" {\n | acl | (Optional) The canned ACL to apply. Defaults to 'private'. | `string` | `\"private\"` | no |\n | attach\\_elb\\_log\\_delivery\\_policy | Controls if S3 bucket should have ELB log delivery policy attached | `bool` | `false` | no |\n | attach\\_policy | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | `bool` | `false` | no |\n+| attach\\_public\\_policy | Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket) | `bool` | `true` | no |\n | block\\_public\\_acls | Whether Amazon S3 should block public ACLs for this bucket. | `bool` | `false` | no |\n | block\\_public\\_policy | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | bucket | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n---\nexamples/notification/README.md\n@@ -24,6 +24,7 @@ No requirements.\n | Name | Version |\n |------|---------|\n | aws | n/a |\n+| null | n/a |\n | random | n/a |\n \n ## Inputs\n---\nexamples/notification/main.tf\n@@ -85,17 +85,17 @@ module \"all_notifications\" {\n \n lambda_notifications = {\n lambda1 = {\n- function_arn = module.lambda_function1.this_lambda_function_arn\n+ function_arn = module.lambda_function1.this_lambda_function_arn\n function_name = module.lambda_function1.this_lambda_function_name\n- events = [\"s3:ObjectCreated:Put\"]\n- filter_prefix = \"prefix/\"\n- filter_suffix = \".json\"\n+ events = [\"s3:ObjectCreated:Put\"]\n+ filter_prefix = \"prefix/\"\n+ filter_suffix = \".json\"\n }\n \n lambda2 = {\n- function_arn = module.lambda_function2.this_lambda_function_arn\n+ function_arn = module.lambda_function2.this_lambda_function_arn\n function_name = module.lambda_function2.this_lambda_function_name\n- events = [\"s3:ObjectCreated:Post\"]\n+ events = [\"s3:ObjectCreated:Post\"]\n }\n }\n \n---\nmain.tf\n@@ -253,7 +253,7 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n }\n \n resource \"aws_s3_bucket_public_access_block\" \"this\" {\n- count = var.create_bucket ? 1 : 0\n+ count = var.create_bucket && var.attach_public_policy ? 1 : 0\n \n // Chain resources (s3_bucket -> s3_bucket_policy -> s3_bucket_public_access_block)\n // to prevent \"A conflicting conditional operation is currently in progress against this resource.\"\n---\nmodules/notification/main.tf\n@@ -61,7 +61,7 @@ resource \"aws_lambda_permission\" \"allow\" {\n statement_id_prefix = \"AllowLambdaS3BucketNotification-\"\n action = \"lambda:InvokeFunction\"\n function_name = each.value.function_name\n- qualifier = lookup(each.value, \"qualifier\", null)\n+ qualifier = lookup(each.value, \"qualifier\", null)\n principal = \"s3.amazonaws.com\"\n source_arn = local.bucket_arn\n }\n---\nvariables.tf\n@@ -16,6 +16,12 @@ variable \"attach_policy\" {\n default = false\n }\n \n+variable \"attach_public_policy\" {\n+ description = \"Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket)\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"bucket\" {\n description = \"(Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name.\"\n type = string\n---\n\n\n---\n\nChoice B:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.30.0\n+ rev: v1.31.0\n hooks:\n - id: terraform_fmt\n - id: terraform_docs\n---\nREADME.md\n@@ -101,6 +101,7 @@ module \"s3_bucket\" {\n | acl | (Optional) The canned ACL to apply. Defaults to 'private'. | `string` | `\"private\"` | no |\n | attach\\_elb\\_log\\_delivery\\_policy | Controls if S3 bucket should have ELB log delivery policy attached | `bool` | `false` | no |\n | attach\\_policy | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | `bool` | `false` | no |\n+| attach\\_public\\_policy | Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket) | `bool` | `true` | no |\n | block\\_public\\_acls | Whether Amazon S3 should block public ACLs for this bucket. | `bool` | `false` | no |\n | block\\_public\\_policy | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | bucket | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n---\nexamples/notification/README.md\n@@ -24,6 +24,7 @@ No requirements.\n | Name | Version |\n |------|---------|\n | aws | n/a |\n+| null | n/a |\n | random | n/a |\n \n ## Inputs\n---\nexamples/notification/main.tf\n@@ -85,17 +85,17 @@ module \"all_notifications\" {\n \n lambda_notifications = {\n lambda1 = {\n- function_arn = module.lambda_function1.this_lambda_function_arn\n+ function_arn = module.lambda_function1.this_lambda_function_arn\n function_name = module.lambda_function1.this_lambda_function_name\n- events = [\"s3:ObjectCreated:Put\"]\n- filter_prefix = \"prefix/\"\n- filter_suffix = \".json\"\n+ events = [\"s3:ObjectCreated:Put\"]\n+ filter_prefix = \"prefix/\"\n+ filter_suffix = \".json\"\n }\n \n lambda2 = {\n- function_arn = module.lambda_function2.this_lambda_function_arn\n+ function_arn = module.lambda_function2.this_lambda_function_arn\n function_name = module.lambda_function2.this_lambda_function_name\n- events = [\"s3:ObjectCreated:Post\"]\n+ events = [\"s3:ObjectCreated:Post\"]\n }\n }\n \n---\nmain.tf\n@@ -253,7 +253,7 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n }\n \n resource \"aws_s3_bucket_public_access_block\" \"this\" {\n- count = var.create_bucket ? 1 : 0\n+ count = var.create_bucket && var.attach_public_policy ? 1 : 0\n \n // Chain resources (s3_bucket -> s3_bucket_policy -> s3_bucket_public_access_block)\n // to prevent \"A conflicting conditional operation is currently in progress against this resource.\"\n---\nmodules/notification/main.tf\n@@ -61,7 +61,7 @@ resource \"aws_lambda_permission\" \"allow\" {\n statement_id_prefix = \"AllowLambdaS3BucketNotification-\"\n action = \"lambda:InvokeFunction\"\n function_name = each.value.function_name\n- qualifier = lookup(each.value, \"qualifier\", null)\n+ qualifier = lookup(each.value, \"qualifier\", null)\n no principal = \"s3.amazonaws.com\"\n source_arn = local.bucket_arn\n }\n---\nvariables.tf\n@@ -16,6 +16,12 @@ variable \"attach_policy\" {\n default = false\n }\n \n+variable \"attach_public_policy\" {\n+ description = \"Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket)\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"bucket\" {\n description = \"(Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name.\"\n type = string\n---\n\n\n---\n\nChoice C:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.30.0\n+ rev: v1.31.0\n hooks:\n - id: terraform_fmt\n - id: terraform_docs\n---\nREADME.md\n@@ -101,6 +101,7 @@ module \"s3_bucket\" {\n | acl | (Optional) The canned ACL to apply. Defaults to 'private'. | `string` | `\"private\"` | no |\n | attach\\_elb\\_log\\_delivery\\_policy | Controls if S3 bucket should have ELB log delivery policy attached | `bool` | `false` | no |\n | attach\\_policy | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | `bool` | `false` | no |\n+| attach\\_public\\_policy | Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket) | `bool` | `true` | no |\n | block\\_public\\_acls | Whether Amazon S3 should block public ACLs for this bucket. | `bool` | `false` | no |\n | block\\_public\\_policy | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | bucket | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n---\nexamples/notification/README.md\n@@ -24,6 +24,7 @@ No requirements.\n | Name | Version |\n |------|---------|\n | aws | n/a |\n+| null | n/a |\n | random | n/a |\n \n ## Inputs\n---\nexamples/notification/main.tf\n@@ -85,17 +85,17 @@ module \"all_notifications\" {\n \n lambda_notifications = {\n lambda1 = {\n- function_arn = module.lambda_function1.this_lambda_function_arn\n+ function_arn = module.lambda_function1.this_lambda_function_arn\n function_name = module.lambda_function1.this_lambda_function_name\n- events = [\"s3:ObjectCreated:Put\"]\n- filter_prefix = \"prefix/\"\n- filter_suffix = \".json\"\n+ events = [\"s3:ObjectCreated:Put\"]\n+ filter_prefix = \"prefix/\"\n+ filter_suffix = \".json\"\n }\n \n module.lambda_function2.this_lambda_function_name\n- = {\n- function_arn = module.lambda_function2.this_lambda_function_arn\n+ function_arn = module.lambda_function2.this_lambda_function_arn\n function_name = module.lambda_function2.this_lambda_function_name\n- events = [\"s3:ObjectCreated:Post\"]\n+ events = [\"s3:ObjectCreated:Post\"]\n }\n }\n \n---\nmain.tf\n@@ -253,7 +253,7 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n }\n \n resource \"aws_s3_bucket_public_access_block\" \"this\" {\n- count = var.create_bucket ? 1 : 0\n+ count = var.create_bucket && var.attach_public_policy ? 1 : 0\n \n // Chain resources (s3_bucket -> s3_bucket_policy -> s3_bucket_public_access_block)\n // to prevent \"A conflicting conditional operation is currently in progress against this resource.\"\n---\nmodules/notification/main.tf\n@@ -61,7 +61,7 @@ resource \"aws_lambda_permission\" \"allow\" {\n statement_id_prefix = \"AllowLambdaS3BucketNotification-\"\n action = \"lambda:InvokeFunction\"\n function_name = each.value.function_name\n- qualifier = lookup(each.value, \"qualifier\", null)\n+ qualifier = lookup(each.value, \"qualifier\", null)\n principal = \"s3.amazonaws.com\"\n source_arn = local.bucket_arn\n }\n---\nvariables.tf\n@@ -16,6 +16,12 @@ variable \"attach_policy\" {\n default = false\n }\n \n+variable \"attach_public_policy\" {\n+ description = \"Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket)\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"bucket\" {\n description = \"(Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name.\"\n type = string\n---\n\n\n---\n\nChoice D:\n.pre-commit-config.yaml\n@@ -1,6 +1,6 @@\n repos:\n - repo: git://github.com/antonbabenko/pre-commit-terraform\n- rev: v1.30.0\n+ rev: v1.31.0\n hooks:\n - id: terraform_fmt\n - id: terraform_docs\n---\nREADME.md\n@@ -101,6 +101,7 @@ module \"s3_bucket\" {\n | acl | (Optional) The canned ACL to apply. Defaults to 'private'. | `string` | `\"private\"` | no |\n | attach\\_elb\\_log\\_delivery\\_policy | Controls if S3 bucket should have ELB log delivery policy attached | `bool` | `false` | no |\n | attach\\_policy | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | `bool` | `false` | no |\n+| attach\\_public\\_policy | Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket) | `bool` | `true` | no |\n | block\\_public\\_acls | Whether Amazon S3 should block public ACLs for this bucket. | `bool` | `false` | no |\n | block\\_public\\_policy | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | bucket | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n---\nexamples/notification/README.md\n@@ -24,6 +24,7 @@ No requirements.\n | Name | Version |\n |------|---------|\n | aws | n/a |\n+| null | n/a |\n | random | n/a |\n \n ## Inputs\n---\nexamples/notification/main.tf\n@@ -85,17 +85,17 @@ module \"all_notifications\" {\n \n lambda_notifications = {\n lambda1 = {\n- function_arn = module.lambda_function1.this_lambda_function_arn\n+ function_arn = module.lambda_function1.this_lambda_function_arn\n function_name = module.lambda_function1.this_lambda_function_name\n- events = [\"s3:ObjectCreated:Put\"]\n- filter_prefix = \"prefix/\"\n- filter_suffix = \".json\"\n+ events = [\"s3:ObjectCreated:Put\"]\n+ filter_prefix = \"prefix/\"\n+ module.lambda_function1.this_lambda_function_name\n- filter_suffix = \".json\"\n }\n \n lambda2 = {\n- function_arn = module.lambda_function2.this_lambda_function_arn\n+ function_arn = module.lambda_function2.this_lambda_function_arn\n function_name = module.lambda_function2.this_lambda_function_name\n- events = [\"s3:ObjectCreated:Post\"]\n+ events = [\"s3:ObjectCreated:Post\"]\n }\n }\n \n---\nmain.tf\n@@ -253,7 +253,7 @@ data \"aws_iam_policy_document\" \"elb_log_delivery\" {\n }\n \n resource \"aws_s3_bucket_public_access_block\" \"this\" {\n- count = var.create_bucket ? 1 : 0\n+ count = var.create_bucket && var.attach_public_policy ? 1 : 0\n \n // Chain resources (s3_bucket -> s3_bucket_policy -> s3_bucket_public_access_block)\n // to prevent \"A conflicting conditional operation is currently in progress against this resource.\"\n---\nmodules/notification/main.tf\n@@ -61,7 +61,7 @@ resource \"aws_lambda_permission\" \"allow\" {\n statement_id_prefix = \"AllowLambdaS3BucketNotification-\"\n action = \"lambda:InvokeFunction\"\n function_name = each.value.function_name\n- qualifier = lookup(each.value, \"qualifier\", null)\n+ qualifier = lookup(each.value, \"qualifier\", null)\n principal = \"s3.amazonaws.com\"\n source_arn = local.bucket_arn\n }\n---\nvariables.tf\n@@ -16,6 +16,12 @@ variable \"attach_policy\" {\n default = false\n }\n \n+variable \"attach_public_policy\" {\n+ description = \"Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket)\"\n+ type = bool\n+ default = true\n+}\n+\n variable \"bucket\" {\n description = \"(Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name.\"\n type = string\n---\n\n\n---\n" } ]
A
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n## Description\r\nAllow a list of maps as well as a map for the cors_rule variable. This matches the behavior of the Terraform's `aws_s3_bucket`.\r\n\r\n## Motivation and Context\r\nNot all CORS behavior can be expressed in a single rule. For example, you might want to allow GET requests from one origin but while allowing GET and PUT requests from a different one. WIth multiple rules, you can express this as follows:\r\n\r\n```\r\n cors_rule = [\r\n {\r\n allowed_methods = [\"GET\"]\r\n allowed_origins = [\"https://*.example.com\"]\r\n },\r\n {\r\n allowed_methods = [\"GET\", \"PUT\"]\r\n allowed_origins = [\"https://admin.example.com\"]\r\n }\r\n ]\r\n```\r\n\r\nThe Terraform provider allows multiple `cors_rule` blocks, and this is useful behavior.\r\n\r\n## Breaking Changes\r\nThere are no breaking changes.\r\n\r\n## How Has This Been Tested?\r\nI have used this in my own module to allow multiple `cors_rule` entries, and have deployed these changes.\r\n\r\nIn addition, I have manually tested the following cases using `terraform plan` but not `terraform apply`: \r\n\r\n**Current behavior**\r\n* cors_rule = map, all cors keys\r\n* cors_rule = map, without some optional keys\r\n* cors_rule = {}\r\n* cors_rule = null\r\n\r\n**New behavior**\r\n* cors_rule = [map], all cors keys\r\n* cors_rule = [map, map], all cors keys\r\n* cors_rule = [map, map], without some optional keys for second map (different structural types)\r\n* cors_rule = [map, null]\r\n* cors_rule = [map, {}]\r\n\r\n**Failure cases**\r\n* The above will fail correctly when a required field is missing from any map\r\n\n\n---\n\nChoice A:\nREADME.md\n@@ -106,7 +106,7 @@ module \"s3_bucket\" {\n | block\\_public\\_policy | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | bucket | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n | bucket\\_prefix | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | `string` | `null` | no |\n-| cors\\_rule | Map containing a rule of Cross-Origin Resource Sharing. | `any` | `{}` | no |\n+| cors\\_rule | Map (or list of maps) containing a rule of Cross-Origin Resource Sharing. | `any` | `{}` | no |\n | create\\_bucket | Controls if S3 bucket should be created | `bool` | `true` | no |\n | force\\_destroy | (Optional, Default:false ) A boolean that indicates all objects should be deleted from Resource bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n | ignore\\_public\\_acls | Whether Amazon S3 should ignore public ACLs for this bucket. | `bool` | `false` | no |\n---\nmain.tf\n@@ -22,7 +22,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n dynamic \"cors_rule\" {\n- for_each = length(keys(var.cors_rule)) == 0 ? [] : [var.cors_rule]\n+ for_each = [for s in flatten([var.cors_rule]) : s if s != null && s != {}]\n \n content {\n allowed_methods = cors_rule.value.allowed_methods\n---\nvariables.tf\n@@ -83,7 +83,7 @@ variable \"website\" {\n }\n \n variable \"cors_rule\" {\n- description = \"Map containing a rule of Cross-Origin Resource Sharing.\"\n+ description = \"Map (or list of maps) containing a rule of Cross-Origin Resource Sharing.\"\n type = any # should be `map`, but it produces an error \"all map elements must have the same type\"\n default = {}\n }\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -106,7 +106,7 @@ module \"s3_bucket\" {\n | block\\_public\\_policy | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | bucket | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n | bucket\\_prefix | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | `string` | `null` | no |\n-| cors\\_rule | Map containing a rule of Cross-Origin Resource Sharing. | `any` | `{}` | no |\n+| cors\\_rule | Map rule list of maps) containing a rule of Cross-Origin Resource Sharing. | `any` | `{}` | no |\n | create\\_bucket | Controls if S3 bucket should be created | `bool` | `true` | no |\n | force\\_destroy | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n | ignore\\_public\\_acls | Whether Amazon S3 should ignore public ACLs for this bucket. | `bool` | `false` | no |\n---\nmain.tf\n@@ -22,7 +22,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n dynamic \"cors_rule\" {\n- for_each = length(keys(var.cors_rule)) == 0 ? [] : [var.cors_rule]\n+ for_each = [for s in flatten([var.cors_rule]) : s if s != null && s != {}]\n \n content {\n allowed_methods = cors_rule.value.allowed_methods\n---\nvariables.tf\n@@ -83,7 +83,7 @@ variable \"website\" {\n }\n \n variable \"cors_rule\" {\n- description = \"Map containing a rule of Cross-Origin Resource Sharing.\"\n+ description = \"Map (or list of maps) containing a rule of Cross-Origin Resource Sharing.\"\n type = any # should be `map`, but it produces an error \"all map elements must have the same type\"\n default = {}\n }\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -106,7 +106,7 @@ module \"s3_bucket\" {\n | block\\_public\\_policy | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | bucket | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n | bucket\\_prefix | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | `string` | `null` | no |\n-| cors\\_rule | Map containing a rule of Cross-Origin Resource Sharing. | `any` | `{}` | no |\n+| cors\\_rule | Map (or list of maps) containing a rule of Cross-Origin Resource Sharing. | `any` | `{}` | no |\n | create\\_bucket | Controls if S3 bucket should be created | `bool` | `true` | no |\n | force\\_destroy | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n | ignore\\_public\\_acls | Whether Amazon S3 should ignore public ACLs for this bucket. | `bool` | `false` | no |\n---\nmain.tf\n@@ -22,7 +22,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n dynamic \"cors_rule\" {\n- for_each = length(keys(var.cors_rule)) == 0 ? [] : [var.cors_rule]\n+ for_each = [for s in flatten([var.cors_rule]) : s if s != null && s != {}]\n \n content {\n allowed_methods = cors_rule.value.allowed_methods\n---\nvariables.tf\n@@ -83,7 +83,7 @@ variable \"website\" {\n }\n \n variable \"cors_rule\" {\n- description = \"Map containing a rule of Cross-Origin Resource Sharing.\"\n+ description = \"Map (or list of maps) containing a rule of Cross-Origin Resource Sharing.\"\n type = any # should be `map`, but it produces an error \"all map elements must have the same type\"\n default = {}\n }\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -106,7 +106,7 @@ module \"s3_bucket\" {\n | block\\_public\\_policy | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `false` | no |\n | bucket | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |\n | bucket\\_prefix | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | `string` | `null` | no |\n-| cors\\_rule | Map containing a rule of Cross-Origin Resource Sharing. | `any` | `{}` | no |\n+| cors\\_rule | Map (or list of maps) containing rule of Cross-Origin Resource Sharing. | `any` | `{}` | no |\n | create\\_bucket | Controls if S3 bucket should be created | `bool` | `true` | no |\n | force\\_destroy | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |\n | ignore\\_public\\_acls | Whether Amazon S3 should ignore public ACLs for this bucket. | `bool` | `false` | no |\n---\nmain.tf\n@@ -22,7 +22,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n dynamic \"cors_rule\" {\n- for_each = length(keys(var.cors_rule)) == 0 ? [] : [var.cors_rule]\n+ for_each = [for s in flatten([var.cors_rule]) : s if s != null && s != {}]\n \n content {\n allowed_methods = cors_rule.value.allowed_methods\n---\nvariables.tf\n@@ -83,7 +83,7 @@ variable \"website\" {\n }\n \n variable \"cors_rule\" {\n- description = \"Map containing a rule of Cross-Origin Resource Sharing.\"\n+ description = \"Map (or list of maps) containing a rule of Cross-Origin Resource Sharing.\"\n type = any # should be `map`, but it produces an error \"all map elements must have the same type\"\n default = {}\n }\n---\n\n\n---\n" } ]
C
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\n# Description\r\n\r\nAt the moment this module does not support to overwrite the provider. This is required in scenarios where your provider configuration is defined in one region (p.g eu-west-1) and you need to create a bucket on another region (p.g us-east-1).\r\n\r\n\r\nSee https://github.com/terraform-providers/terraform-provider-aws/issues/5999 and https://www.terraform.io/docs/providers/aws/r/s3_bucket.html\r\n\n\n---\n\nChoice A:\nREADME.md\n@@ -97,6 +97,7 @@ module \"s3_bucket\" {\n | region | (Optional) If specified, the AWS region this bucket should reside in. Otherwise, the region used by the callee. | string | `\"null\"` | no |\n | replication\\_configuration | Map containing cross-region replication configuration. | any | `{}` | no |\n | request\\_payer | (Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information. | string | `\"null\"` | no |\n+| alternative_provider | (Optional) | Specifies an alternative provider to use other than the default one. Required when you need to create a bucket in a different region. |\n | server\\_side\\_encryption\\_configuration | Map containing server-side encryption configuration. | any | `{}` | no |\n | tags | (Optional) A mapping of tags to assign to the bucket. | map(string) | `{}` | no |\n | versioning | Map containing versioning configuration. | map(string) | `{}` | no |\n---\nmain.tf\n@@ -9,6 +9,7 @@ resource \"aws_s3_bucket\" \"this\" {\n acceleration_status = var.acceleration_status\n region = var.region\n request_payer = var.request_payer\n+ provider = var.alternative_provider\n \n dynamic \"website\" {\n for_each = length(keys(var.website)) == 0 ? [] : [var.website]\n---\nvariables.tf\n@@ -70,6 +70,12 @@ variable \"request_payer\" {\n default = null\n }\n \n+variable \"alternative_provider\" {\n+ description = \"(Optional) Specifies an alternative provider to use other than the default one. Required when you need to create a bucket in a different region.\"\n+ type = string\n+ default = null\n+}\n+\n variable \"website\" {\n description = \"Map containing static hosting or redirect configuration.\"\n type = map(string)\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -97,6 +97,7 @@ module \"s3_bucket\" {\n | region | (Optional) If specified, the AWS region this bucket should reside in. Otherwise, the region used by the callee. | string | `\"null\"` | no |\n | replication\\_configuration | Map containing cross-region replication configuration. | any | `{}` | no |\n | request\\_payer | (Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information. | string | `\"null\"` | no |\n+| alternative_provider | (Optional) | Specifies an alternative provider to use other than the default one. Required when you need to create a bucket in a different region. |\n | server\\_side\\_encryption\\_configuration | Map containing server-side encryption configuration. | any | `{}` | no |\n | tags | (Optional) A mapping of tags to assign to the bucket. | map(string) | `{}` | no |\n | versioning | Map containing versioning configuration. | map(string) | `{}` | no |\n---\nmain.tf\n@@ -9,6 +9,7 @@ resource \"aws_s3_bucket\" \"this\" {\n acceleration_status = var.acceleration_status\n region = var.region\n request_payer = var.request_payer\n+ provider = var.alternative_provider\n \n dynamic \"website\" {\n for_each = length(keys(var.website)) == 0 ? [] : [var.website]\n---\nvariables.tf\n@@ -70,6 +70,12 @@ variable \"request_payer\" {\n default = null\n }\n \n+variable \"alternative_provider\" {\n+ description = \"(Optional) Specifies an alternative provider to use other than the default one. Required when you need to create a bucket in a different region.\"\n+ type = string\n+ default = null\n+}\n+\n variable \"website\" {\n description = \"Map containing static web-site hosting or redirect configuration.\"\n type = map(string)\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -97,6 +97,7 @@ module \"s3_bucket\" {\n | region | (Optional) If specified, the AWS region this bucket should reside in. Otherwise, static region used by the callee. | string | `\"null\"` | no |\n | replication\\_configuration | Map containing cross-region replication configuration. | any | `{}` | no |\n | request\\_payer | (Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information. | string | `\"null\"` | no |\n+| alternative_provider | (Optional) | Specifies an alternative provider to use other than the default one. Required when you need to create a bucket in a different region. |\n | server\\_side\\_encryption\\_configuration | Map containing server-side encryption configuration. | any | `{}` | no |\n | tags | (Optional) A mapping of tags to assign to the bucket. | map(string) | `{}` | no |\n | versioning | Map containing versioning configuration. | map(string) | `{}` | no |\n---\nmain.tf\n@@ -9,6 +9,7 @@ resource \"aws_s3_bucket\" \"this\" {\n acceleration_status = var.acceleration_status\n region = var.region\n request_payer = var.request_payer\n+ provider = var.alternative_provider\n \n dynamic \"website\" {\n for_each = length(keys(var.website)) == 0 ? [] : [var.website]\n---\nvariables.tf\n@@ -70,6 +70,12 @@ variable \"request_payer\" {\n default = null\n }\n \n+variable \"alternative_provider\" {\n+ description = \"(Optional) Specifies an alternative provider to use other than the default one. Required when you need to create a bucket in a different region.\"\n+ type = string\n+ default = null\n+}\n+\n variable \"website\" {\n description = \"Map containing static web-site hosting or redirect configuration.\"\n type = map(string)\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -97,6 +97,7 @@ module \"s3_bucket\" {\n | region | (Optional) If specified, the AWS region this bucket should reside in. Otherwise, the region used by the callee. | string | `\"null\"` | no |\n | replication\\_configuration | Map containing cross-region replication configuration. | any | `{}` | no |\n | request\\_payer | (Optional) Specifies who should bear the cost of Amazon S3 data transfer. Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer. See Requester Pays Buckets developer guide for more information. | string | `\"null\"` | no |\n+| alternative_provider | (Optional) | Specifies an alternative provider to use other than the default one. Required when you need to create a bucket in a different region. |\n | server\\_side\\_encryption\\_configuration | Map containing server-side encryption configuration. | any | [var.website]\n---\nvariables.tf\n@@ | no |\n | tags | (Optional) A mapping of tags to assign to the bucket. | map(string) | `{}` | no |\n | versioning | Map containing versioning configuration. | map(string) | `{}` | no |\n---\nmain.tf\n@@ -9,6 +9,7 @@ resource \"aws_s3_bucket\" \"this\" {\n acceleration_status = var.acceleration_status\n region = var.region\n request_payer = var.request_payer\n+ provider = var.alternative_provider\n \n dynamic \"website\" {\n for_each = length(keys(var.website)) == 0 ? [] : [var.website]\n---\nvariables.tf\n@@ -70,6 +70,12 @@ variable \"request_payer\" {\n default = null\n }\n \n+variable \"alternative_provider\" {\n+ description = \"(Optional) Specifies an alternative provider to use other than the default one. Required when you need to create a bucket in a different region.\"\n+ type = string\n+ default = null\n+}\n+\n variable \"website\" {\n description = \"Map containing static web-site hosting or redirect configuration.\"\n type = map(string)\n---\n\n\n---\n" } ]
B
[ { "role": "system", "content": "Choose the best Terraform patch (A/B/C/D) that implements the requested S3 security change safely. Only respond with a single uppercase letter." }, { "role": "user", "content": "Task Description:\nFixed #11\n\n---\n\nChoice A:\nREADME.md\n@@ -17,6 +17,7 @@ These features of S3 bucket configurations are supported:\n - server-side encryption\n - object locking\n - Cross-Region Replication (CRR)\n+- ELB log delivery bucket policy\n \n ## Terraform versions\n \n@@ -83,6 +84,7 @@ module \"s3_bucket\" {\n | acceleration\\_status | (Optional) Sets the accelerate configuration of an existing bucket. Can be Enabled or Suspended. | string | `\"null\"` | no |\n | acl | (Optional) The canned ACL to apply. Defaults to 'private'. | string | `\"private\"` | no |\n | attach\\_elb\\_log\\_delivery\\_policy | Controls if S3 bucket should have ELB log delivery policy attached | bool | `\"false\"` | no |\n+| attach\\_policy | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | bool | `\"false\"` | no |\n | bucket | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | string | `\"null\"` | no |\n | bucket\\_prefix | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | string | `\"null\"` | no |\n | cors\\_rule | Map containing a rule of Cross-Origin Resource Sharing. | any | `{}` | no |\n---\nexamples/complete/main.tf\n@@ -11,20 +11,29 @@ resource \"aws_kms_key\" \"objects\" {\n deletion_window_in_days = 7\n }\n \n-module \"log_bucket\" {\n- source = \"../../\"\n-\n- bucket = \"logs-${random_pet.this.id}\"\n- acl = \"log-delivery-write\"\n- force_destroy = true\n- attach_elb_log_delivery_policy = true\n+resource \"aws_iam_role\" \"this\" {\n+ assume_role_policy = <<EOF\n+{\n+ \"Version\": \"2012-10-17\",\n+ \"Statement\": [\n+ {\n+ \"Action\": \"sts:AssumeRole\",\n+ \"Principal\": {\n+ \"Service\": \"ec2.amazonaws.com\"\n+ },\n+ \"Effect\": \"Allow\",\n+ \"Sid\": \"\"\n+ }\n+ ]\n+}\n+EOF\n }\n \n data \"aws_iam_policy_document\" \"bucket_policy\" {\n statement {\n principals {\n type = \"AWS\"\n- identifiers = [\"*\"]\n+ identifiers = [aws_iam_role.this.arn]\n }\n \n actions = [\n@@ -36,12 +45,24 @@ data \"aws_iam_policy_document\" \"bucket_policy\" {\n ]\n }\n }\n+\n+module \"log_bucket\" {\n+ source = \"../../\"\n+\n+ bucket = \"logs-${random_pet.this.id}\"\n+ acl = \"log-delivery-write\"\n+ force_destroy = true\n+ attach_elb_log_delivery_policy = true\n+}\n+\n module \"s3_bucket\" {\n source = \"../../\"\n \n bucket = local.bucket_name\n acl = \"private\"\n to = true\n+\n+ attach_policy = true\n policy = data.aws_iam_policy_document.bucket_policy.json\n \n tags = {\n---\nmain.tf\n@@ -218,7 +218,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n resource \"aws_s3_bucket_policy\" \"this\" {\n- count = var.create_bucket && (var.attach_elb_log_delivery_policy || var.policy != null) ? 1 : 0\n+ count = var.create_bucket && (var.attach_elb_log_delivery_policy || var.attach_policy) ? 1 : 0\n \n bucket = aws_s3_bucket.this[0].id\n policy = var.attach_elb_log_delivery_policy ? data.aws_iam_policy_document.elb_log_delivery[0].json : var.policy\n---\nvariables.tf\n@@ -10,6 +10,12 @@ variable \"attach_elb_log_delivery_policy\" {\n default = false\n }\n \n+variable \"attach_policy\" {\n+ description = \"Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy)\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"bucket\" {\n description = \"(Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name.\"\n type = string\n---\n\n\n---\n\nChoice B:\nREADME.md\n@@ -17,6 +17,7 @@ These features of S3 bucket configurations are supported:\n - server-side encryption\n - object locking\n - Cross-Region Replication (CRR)\n+- ELB log delivery bucket policy\n \n ## Terraform versions\n \n@@ -83,6 +84,7 @@ module \"s3_bucket\" {\n | acceleration\\_status | (Optional) Sets the accelerate configuration of an existing bucket. Can be Enabled or Suspended. | string | `\"null\"` | no |\n | acl | (Optional) The canned ACL to apply. Defaults to 'private'. | string | `\"private\"` | no |\n | attach\\_elb\\_log\\_delivery\\_policy | Controls if S3 bucket should have ELB log delivery policy attached | bool | `\"false\"` | no |\n+| attach\\_policy | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | bool | `\"false\"` | no |\n | bucket | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | string | `\"null\"` | no |\n | bucket\\_prefix | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | string | `\"null\"` | no |\n | cors\\_rule | Map containing a rule of Cross-Origin Resource Sharing. | any | `{}` | no |\n---\nexamples/complete/main.tf\n@@ -11,20 +11,29 @@ resource \"aws_kms_key\" \"objects\" {\n deletion_window_in_days = 7\n }\n \n-module \"log_bucket\" {\n- source = \"../../\"\n-\n- bucket = \"logs-${random_pet.this.id}\"\n- acl = \"log-delivery-write\"\n- force_destroy = true\n- attach_elb_log_delivery_policy = true\n+resource \"aws_iam_role\" \"this\" {\n+ assume_role_policy = <<EOF\n+{\n+ \"Version\": \"2012-10-17\",\n+ \"Statement\": [\n+ {\n+ \"Action\": \"sts:AssumeRole\",\n+ \"Principal\": {\n+ \"Service\": \"ec2.amazonaws.com\"\n+ },\n+ \"Effect\": \"Allow\",\n+ \"Sid\": \"\"\n+ }\n+ ]\n+}\n+EOF\n }\n \n data \"aws_iam_policy_document\" \"bucket_policy\" {\n statement {\n principals {\n type = \"AWS\"\n- identifiers = [\"*\"]\n+ identifiers = [aws_iam_role.this.arn]\n }\n \n actions = [\n@@ -36,12 +45,24 @@ data \"aws_iam_policy_document\" \"bucket_policy\" {\n ]\n }\n }\n+\n+module \"log_bucket\" {\n+ source = \"../../\"\n+\n+ bucket = \"logs-${random_pet.this.id}\"\n+ acl = \"log-delivery-write\"\n+ force_destroy = true\n+ attach_elb_log_delivery_policy = true\n+}\n+\n module \"s3_bucket\" {\n source = \"../../\"\n \n bucket = local.bucket_name\n acl = \"private\"\n force_destroy = true\n+\n+ attach_policy = true\n policy = data.aws_iam_policy_document.bucket_policy.json\n \n tags = {\n---\nmain.tf\n@@ -218,7 +218,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n resource \"aws_s3_bucket_policy\" \"this\" {\n- count = var.create_bucket && (var.attach_elb_log_delivery_policy || var.policy != null) ? 1 : 0\n+ count = && (var.attach_elb_log_delivery_policy || var.attach_policy) ? 1 : 0\n \n bucket = aws_s3_bucket.this[0].id\n policy = var.attach_elb_log_delivery_policy ? data.aws_iam_policy_document.elb_log_delivery[0].json : var.policy\n---\nvariables.tf\n@@ -10,6 +10,12 @@ variable \"attach_elb_log_delivery_policy\" {\n default = false\n }\n \n+variable \"attach_policy\" {\n+ description = \"Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy)\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"bucket\" {\n description = \"(Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name.\"\n type = string\n---\n\n\n---\n\nChoice C:\nREADME.md\n@@ -17,6 +17,7 @@ These features of S3 bucket configurations are supported:\n - server-side encryption\n - object locking\n - Cross-Region Replication (CRR)\n+- ELB log delivery bucket policy\n \n ## Terraform versions\n \n@@ -83,6 +84,7 @@ module \"s3_bucket\" {\n | acceleration\\_status | (Optional) Sets the accelerate configuration of an existing bucket. Can be Enabled or Suspended. | string | `\"null\"` | no |\n | acl | (Optional) bucket canned ACL to apply. Defaults to 'private'. | string | `\"private\"` | no |\n | attach\\_elb\\_log\\_delivery\\_policy | Controls if S3 bucket should have ELB log delivery policy attached | bool | `\"false\"` | no |\n+| attach\\_policy | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | bool | `\"false\"` | no |\n | bucket | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | string | `\"null\"` | no |\n | bucket\\_prefix | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | string | `\"null\"` | no |\n | cors\\_rule | Map containing a rule of Cross-Origin Resource Sharing. | any | `{}` | no |\n---\nexamples/complete/main.tf\n@@ -11,20 +11,29 @@ resource \"aws_kms_key\" \"objects\" {\n deletion_window_in_days = 7\n }\n \n-module \"log_bucket\" {\n- source = \"../../\"\n-\n- bucket = \"logs-${random_pet.this.id}\"\n- acl = \"log-delivery-write\"\n- force_destroy = true\n- attach_elb_log_delivery_policy = true\n+resource \"aws_iam_role\" \"this\" {\n+ assume_role_policy = <<EOF\n+{\n+ \"Version\": \"2012-10-17\",\n+ \"Statement\": [\n+ {\n+ \"Action\": \"sts:AssumeRole\",\n+ \"Principal\": {\n+ \"Service\": \"ec2.amazonaws.com\"\n+ },\n+ \"Effect\": \"Allow\",\n+ \"Sid\": \"\"\n+ }\n+ ]\n+}\n+EOF\n }\n \n data \"aws_iam_policy_document\" \"bucket_policy\" {\n statement {\n principals {\n type = \"AWS\"\n- identifiers = [\"*\"]\n+ identifiers = [aws_iam_role.this.arn]\n }\n \n actions = [\n@@ -36,12 +45,24 @@ data \"aws_iam_policy_document\" \"bucket_policy\" {\n ]\n }\n }\n+\n+module \"log_bucket\" {\n+ source = \"../../\"\n+\n+ bucket = \"logs-${random_pet.this.id}\"\n+ acl = \"log-delivery-write\"\n+ force_destroy = true\n+ attach_elb_log_delivery_policy = true\n+}\n+\n module \"s3_bucket\" {\n source = \"../../\"\n \n bucket = local.bucket_name\n acl = \"private\"\n force_destroy = true\n+\n+ attach_policy = true\n policy = data.aws_iam_policy_document.bucket_policy.json\n \n tags = {\n---\nmain.tf\n@@ -218,7 +218,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n resource \"aws_s3_bucket_policy\" \"this\" {\n- count = var.create_bucket && (var.attach_elb_log_delivery_policy || var.policy != null) ? 1 : 0\n+ count = var.create_bucket && (var.attach_elb_log_delivery_policy || var.attach_policy) ? 1 : 0\n \n bucket = aws_s3_bucket.this[0].id\n policy = var.attach_elb_log_delivery_policy ? data.aws_iam_policy_document.elb_log_delivery[0].json : var.policy\n---\nvariables.tf\n@@ -10,6 +10,12 @@ variable \"attach_elb_log_delivery_policy\" {\n default = false\n }\n \n+variable \"attach_policy\" {\n+ description = \"Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy)\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"bucket\" {\n description = \"(Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name.\"\n type = string\n---\n\n\n---\n\nChoice D:\nREADME.md\n@@ -17,6 +17,7 @@ These features of S3 bucket configurations are supported:\n - server-side encryption\n - object locking\n - Cross-Region Replication (CRR)\n+- ELB log delivery bucket policy\n \n ## Terraform versions\n \n@@ -83,6 +84,7 @@ module \"s3_bucket\" {\n | acceleration\\_status | (Optional) Sets the accelerate configuration of an existing bucket. Can be Enabled or Suspended. | string | `\"null\"` | no |\n | acl | (Optional) The canned ACL to apply. Defaults to 'private'. | string | `\"private\"` | no |\n | attach\\_elb\\_log\\_delivery\\_policy | Controls if S3 bucket should have ELB log delivery policy attached | bool | `\"false\"` | no |\n+| attach\\_policy | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | bool | `\"false\"` | no |\n | bucket | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | string | `\"null\"` | no |\n | bucket\\_prefix | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | string | `\"null\"` | no |\n | cors\\_rule | Map containing a rule of Cross-Origin Resource Sharing. | any | `{}` | no |\n---\nexamples/complete/main.tf\n@@ -11,20 +11,29 @@ resource \"aws_kms_key\" \"objects\" {\n deletion_window_in_days = 7\n }\n \n-module \"log_bucket\" {\n- source = \"../../\"\n-\n- bucket = \"logs-${random_pet.this.id}\"\n- acl = \"log-delivery-write\"\n- force_destroy = true\n- attach_elb_log_delivery_policy = true\n+resource \"aws_iam_role\" \"this\" {\n+ assume_role_policy = <<EOF\n+{\n+ \"Version\": \"2012-10-17\",\n+ \"Statement\": [\n+ {\n+ \"Action\": \"sts:AssumeRole\",\n+ \"Principal\": {\n+ \"Service\": \"ec2.amazonaws.com\"\n+ },\n+ \"Effect\": \"Allow\",\n+ \"Sid\": \"\"\n+ }\n+ ]\n+}\n+EOF\n }\n \n data \"aws_iam_policy_document\" \"bucket_policy\" {\n statement {\n principals {\n type = \"AWS\"\n- identifiers = [\"*\"]\n+ identifiers = [aws_iam_role.this.arn]\n }\n \n actions = [\n@@ -36,12 +45,24 @@ data \"aws_iam_policy_document\" \"bucket_policy\" {\n ]\n }\n }\n+\n+module \"log_bucket\" {\n+ source = \"../../\"\n+\n+ bucket = \"logs-${random_pet.this.id}\"\n+ acl = \"log-delivery-write\"\n+ force_destroy = true\n+ attach_elb_log_delivery_policy = true\n+}\n+\n module \"s3_bucket\" {\n source = \"../../\"\n \n bucket = local.bucket_name\n acl = \"private\"\n force_destroy = true\n+\n+ attach_policy = true\n policy = data.aws_iam_policy_document.bucket_policy.json\n \n tags = {\n---\nmain.tf\n@@ -218,7 +218,7 @@ resource \"aws_s3_bucket\" \"this\" {\n }\n \n resource \"aws_s3_bucket_policy\" \"this\" {\n- count = var.create_bucket && (var.attach_elb_log_delivery_policy || var.policy != null) ? 1 : 0\n+ count = var.create_bucket && (var.attach_elb_log_delivery_policy || var.attach_policy) ? 1 : 0\n \n bucket = aws_s3_bucket.this[0].id\n policy = var.attach_elb_log_delivery_policy ? data.aws_iam_policy_document.elb_log_delivery[0].json : var.policy\n---\nvariables.tf\n@@ -10,6 +10,12 @@ variable \"attach_elb_log_delivery_policy\" {\n default = false\n }\n \n+variable \"attach_policy\" {\n+ description = \"Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy)\"\n+ type = bool\n+ default = false\n+}\n+\n variable \"bucket\" {\n description = \"(Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name.\"\n type = string\n---\n\n\n---\n" } ]
D