Skip to content

Commit 2784aba

Browse files
Nurumax-lobur
andauthored
Add grants input (#93)
Co-authored-by: Max Lobur <[email protected]>
1 parent 7cda5e2 commit 2784aba

File tree

6 files changed

+32
-8
lines changed

6 files changed

+32
-8
lines changed

Diff for: README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ Available targets:
218218
| <a name="input_abort_incomplete_multipart_upload_days"></a> [abort\_incomplete\_multipart\_upload\_days](#input\_abort\_incomplete\_multipart\_upload\_days) | (Deprecated, use `lifecycle_configuration_rules` instead)<br>Maximum time (in days) that you want to allow multipart uploads to remain in progress | `number` | `null` | no |
219219
| <a name="input_access_log_bucket_name"></a> [access\_log\_bucket\_name](#input\_access\_log\_bucket\_name) | Name of the S3 bucket where S3 access logs will be sent to | `string` | `""` | no |
220220
| <a name="input_access_log_bucket_prefix"></a> [access\_log\_bucket\_prefix](#input\_access\_log\_bucket\_prefix) | Prefix to prepend to the current S3 bucket name, where S3 access logs will be sent to | `string` | `"logs/"` | no |
221-
| <a name="input_acl"></a> [acl](#input\_acl) | The canned ACL to apply. We recommend log-delivery-write for compatibility with AWS services | `string` | `"log-delivery-write"` | no |
221+
| <a name="input_acl"></a> [acl](#input\_acl) | The [canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl) to apply.<br>Deprecated by AWS in favor of bucket policies.<br>Automatically disabled if `s3_object_ownership` is set to "BucketOwnerEnforced".<br>Defaults to "private" for backwards compatibility, but we recommend setting `s3_object_ownership` to "BucketOwnerEnforced" instead. | `string` | `"log-delivery-write"` | no |
222222
| <a name="input_additional_tag_map"></a> [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.<br>This is for some rare cases where resources want additional configuration of tags<br>and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
223223
| <a name="input_allow_encrypted_uploads_only"></a> [allow\_encrypted\_uploads\_only](#input\_allow\_encrypted\_uploads\_only) | Set to `true` to prevent uploads of unencrypted objects to S3 bucket | `bool` | `false` | no |
224224
| <a name="input_allow_ssl_requests_only"></a> [allow\_ssl\_requests\_only](#input\_allow\_ssl\_requests\_only) | Set to `true` to require requests to use Secure Socket Layer (HTTPS/SSL). This will explicitly deny access to HTTP requests | `bool` | `true` | no |
@@ -240,6 +240,7 @@ Available targets:
240240
| <a name="input_expiration_days"></a> [expiration\_days](#input\_expiration\_days) | (Deprecated, use `lifecycle_configuration_rules` instead)<br>Number of days after which to expunge the objects | `number` | `null` | no |
241241
| <a name="input_force_destroy"></a> [force\_destroy](#input\_force\_destroy) | When `true`, permits a non-empty S3 bucket to be deleted by first deleting all objects in the bucket.<br>THESE OBJECTS ARE NOT RECOVERABLE even if they were versioned and stored in Glacier.<br>Must be set `false` unless `force_destroy_enabled` is also `true`. | `bool` | `false` | no |
242242
| <a name="input_glacier_transition_days"></a> [glacier\_transition\_days](#input\_glacier\_transition\_days) | (Deprecated, use `lifecycle_configuration_rules` instead)<br>Number of days after which to move the data to the Glacier Flexible Retrieval storage tier | `number` | `null` | no |
243+
| <a name="input_grants"></a> [grants](#input\_grants) | A list of policy grants for the bucket, taking a list of permissions.<br>Conflicts with `acl`. Set `acl` to `null` to use this.<br>Deprecated by AWS in favor of bucket policies, but still required for some log delivery services.<br>Automatically disabled if `s3_object_ownership` is set to "BucketOwnerEnforced". | <pre>list(object({<br> id = string<br> type = string<br> permissions = list(string)<br> uri = string<br> }))</pre> | `[]` | no |
243244
| <a name="input_id_length_limit"></a> [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for keep the existing setting, which defaults to `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
244245
| <a name="input_ignore_public_acls"></a> [ignore\_public\_acls](#input\_ignore\_public\_acls) | Set to `false` to disable the ignoring of public access lists on the bucket | `bool` | `true` | no |
245246
| <a name="input_kms_master_key_arn"></a> [kms\_master\_key\_arn](#input\_kms\_master\_key\_arn) | The AWS KMS master key ARN used for the SSE-KMS encryption. This can only be used when you set the value of sse\_algorithm as aws:kms. The default aws/s3 AWS KMS master key is used if this element is absent while the sse\_algorithm is aws:kms | `string` | `""` | no |

Diff for: docs/terraform.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
| <a name="input_abort_incomplete_multipart_upload_days"></a> [abort\_incomplete\_multipart\_upload\_days](#input\_abort\_incomplete\_multipart\_upload\_days) | (Deprecated, use `lifecycle_configuration_rules` instead)<br>Maximum time (in days) that you want to allow multipart uploads to remain in progress | `number` | `null` | no |
3939
| <a name="input_access_log_bucket_name"></a> [access\_log\_bucket\_name](#input\_access\_log\_bucket\_name) | Name of the S3 bucket where S3 access logs will be sent to | `string` | `""` | no |
4040
| <a name="input_access_log_bucket_prefix"></a> [access\_log\_bucket\_prefix](#input\_access\_log\_bucket\_prefix) | Prefix to prepend to the current S3 bucket name, where S3 access logs will be sent to | `string` | `"logs/"` | no |
41-
| <a name="input_acl"></a> [acl](#input\_acl) | The canned ACL to apply. We recommend log-delivery-write for compatibility with AWS services | `string` | `"log-delivery-write"` | no |
41+
| <a name="input_acl"></a> [acl](#input\_acl) | The [canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl) to apply.<br>Deprecated by AWS in favor of bucket policies.<br>Automatically disabled if `s3_object_ownership` is set to "BucketOwnerEnforced".<br>Defaults to "private" for backwards compatibility, but we recommend setting `s3_object_ownership` to "BucketOwnerEnforced" instead. | `string` | `"log-delivery-write"` | no |
4242
| <a name="input_additional_tag_map"></a> [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.<br>This is for some rare cases where resources want additional configuration of tags<br>and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
4343
| <a name="input_allow_encrypted_uploads_only"></a> [allow\_encrypted\_uploads\_only](#input\_allow\_encrypted\_uploads\_only) | Set to `true` to prevent uploads of unencrypted objects to S3 bucket | `bool` | `false` | no |
4444
| <a name="input_allow_ssl_requests_only"></a> [allow\_ssl\_requests\_only](#input\_allow\_ssl\_requests\_only) | Set to `true` to require requests to use Secure Socket Layer (HTTPS/SSL). This will explicitly deny access to HTTP requests | `bool` | `true` | no |
@@ -60,6 +60,7 @@
6060
| <a name="input_expiration_days"></a> [expiration\_days](#input\_expiration\_days) | (Deprecated, use `lifecycle_configuration_rules` instead)<br>Number of days after which to expunge the objects | `number` | `null` | no |
6161
| <a name="input_force_destroy"></a> [force\_destroy](#input\_force\_destroy) | When `true`, permits a non-empty S3 bucket to be deleted by first deleting all objects in the bucket.<br>THESE OBJECTS ARE NOT RECOVERABLE even if they were versioned and stored in Glacier.<br>Must be set `false` unless `force_destroy_enabled` is also `true`. | `bool` | `false` | no |
6262
| <a name="input_glacier_transition_days"></a> [glacier\_transition\_days](#input\_glacier\_transition\_days) | (Deprecated, use `lifecycle_configuration_rules` instead)<br>Number of days after which to move the data to the Glacier Flexible Retrieval storage tier | `number` | `null` | no |
63+
| <a name="input_grants"></a> [grants](#input\_grants) | A list of policy grants for the bucket, taking a list of permissions.<br>Conflicts with `acl`. Set `acl` to `null` to use this.<br>Deprecated by AWS in favor of bucket policies, but still required for some log delivery services.<br>Automatically disabled if `s3_object_ownership` is set to "BucketOwnerEnforced". | <pre>list(object({<br> id = string<br> type = string<br> permissions = list(string)<br> uri = string<br> }))</pre> | `[]` | no |
6364
| <a name="input_id_length_limit"></a> [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for keep the existing setting, which defaults to `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
6465
| <a name="input_ignore_public_acls"></a> [ignore\_public\_acls](#input\_ignore\_public\_acls) | Set to `false` to disable the ignoring of public access lists on the bucket | `bool` | `true` | no |
6566
| <a name="input_kms_master_key_arn"></a> [kms\_master\_key\_arn](#input\_kms\_master\_key\_arn) | The AWS KMS master key ARN used for the SSE-KMS encryption. This can only be used when you set the value of sse\_algorithm as aws:kms. The default aws/s3 AWS KMS master key is used if this element is absent while the sse\_algorithm is aws:kms | `string` | `""` | no |

Diff for: main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module "aws_s3_bucket" {
2121

2222
bucket_name = local.bucket_name
2323
acl = var.acl
24+
grants = var.grants
2425
force_destroy = var.force_destroy
2526
versioning_enabled = var.versioning_enabled
2627

Diff for: outputs.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ output "prefix" {
1919
}
2020

2121
output "bucket_notifications_sqs_queue_arn" {
22-
value = join("", aws_sqs_queue.notifications.*.arn)
22+
value = join("", aws_sqs_queue.notifications[*].arn)
2323
description = "Notifications SQS queue ARN"
2424
}
2525

Diff for: sqs_notifications.tf

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ locals {
22
enabled = module.this.enabled
33
sqs_notifications_enabled = local.enabled && var.bucket_notifications_enabled && var.bucket_notifications_type == "SQS"
44
sqs_queue_name = module.this.id
5-
partition = join("", data.aws_partition.current.*.partition)
5+
partition = join("", data.aws_partition.current[*].partition)
66
}
77

88
data "aws_caller_identity" "current" { count = local.enabled ? 1 : 0 }
@@ -12,7 +12,7 @@ resource "aws_sqs_queue" "notifications" {
1212
#bridgecrew:skip=BC_AWS_GENERAL_16:Skipping `AWS SQS server side encryption is not enabled` check because this queue does not have sensitive data. Enabling the encryption for S3 publisher requires the new CMK which is extra here.
1313
count = local.sqs_notifications_enabled ? 1 : 0
1414
name = local.sqs_queue_name
15-
policy = join("", data.aws_iam_policy_document.sqs_policy.*.json)
15+
policy = join("", data.aws_iam_policy_document.sqs_policy[*].json)
1616
tags = module.this.tags
1717
}
1818

@@ -39,7 +39,7 @@ data "aws_iam_policy_document" "sqs_policy" {
3939
test = "StringEquals"
4040
variable = "aws:SourceAccount"
4141
values = [
42-
join("", data.aws_caller_identity.current.*.account_id)]
42+
join("", data.aws_caller_identity.current[*].account_id)]
4343
}
4444
}
4545
}
@@ -49,7 +49,7 @@ resource "aws_s3_bucket_notification" "bucket_notification" {
4949
bucket = join("", module.aws_s3_bucket.bucket_id)
5050

5151
queue {
52-
queue_arn = join("", aws_sqs_queue.notifications.*.arn)
52+
queue_arn = join("", aws_sqs_queue.notifications[*].arn)
5353
events = [
5454
"s3:ObjectCreated:*"
5555
]

Diff for: variables.tf

+22-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,29 @@ variable "object_lock_configuration" {
2020

2121
variable "acl" {
2222
type = string
23-
description = "The canned ACL to apply. We recommend log-delivery-write for compatibility with AWS services"
23+
description = <<-EOT
24+
The [canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl) to apply.
25+
Deprecated by AWS in favor of bucket policies.
26+
Automatically disabled if `s3_object_ownership` is set to "BucketOwnerEnforced".
27+
Defaults to "private" for backwards compatibility, but we recommend setting `s3_object_ownership` to "BucketOwnerEnforced" instead.
28+
EOT
2429
default = "log-delivery-write"
30+
}
31+
32+
variable "grants" {
33+
type = list(object({
34+
id = string
35+
type = string
36+
permissions = list(string)
37+
uri = string
38+
}))
39+
description = <<-EOT
40+
A list of policy grants for the bucket, taking a list of permissions.
41+
Conflicts with `acl`. Set `acl` to `null` to use this.
42+
Deprecated by AWS in favor of bucket policies, but still required for some log delivery services.
43+
Automatically disabled if `s3_object_ownership` is set to "BucketOwnerEnforced".
44+
EOT
45+
default = []
2546
nullable = false
2647
}
2748

0 commit comments

Comments
 (0)