Skip to content

Commit e6569a9

Browse files
committed
update count logic
1 parent 8d55c49 commit e6569a9

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

infrastructure/buckets.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
locals {
2-
access_logs_bucket_id = local.is_production ? aws_s3_bucket.access_logs[0].id : null
2+
access_logs_bucket_id = local.is_production ? aws_s3_bucket.access_logs[0].id : ""
33
access_logs_count = local.is_production ? 1 : 0
44
}
55

@@ -330,8 +330,8 @@ resource "aws_s3_bucket_policy" "logs_bucket_policy" {
330330
}
331331

332332
resource "aws_s3_bucket_logging" "logs_bucket_logging" {
333-
count = local.access_logs_count > 0 ? 1 : 0
333+
count = local.access_logs_count
334334
bucket = aws_s3_bucket.logs_bucket.id
335-
target_bucket = aws_s3_bucket.access_logs[0].id
335+
target_bucket = local.access_logs_bucket_id
336336
target_prefix = "${aws_s3_bucket.logs_bucket.id}/"
337337
}

infrastructure/modules/s3/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ No modules.
3636

3737
| Name | Description | Type | Default | Required |
3838
|------|-------------|------|---------|:--------:|
39-
| <a name="input_access_logs_bucket_id"></a> [access\_logs\_bucket\_id](#input\_access\_logs\_bucket\_id) | Enables access logs on the module's bucket | `string` | `null` | no |
39+
| <a name="input_access_logs_bucket_id"></a> [access\_logs\_bucket\_id](#input\_access\_logs\_bucket\_id) | Enables access logs on the module's bucket | `string` | n/a | yes |
4040
| <a name="input_access_logs_enabled"></a> [access\_logs\_enabled](#input\_access\_logs\_enabled) | n/a | `bool` | `false` | no |
4141
| <a name="input_bucket_name"></a> [bucket\_name](#input\_bucket\_name) | the name of the bucket | `string` | n/a | yes |
4242
| <a name="input_cloudfront_arn"></a> [cloudfront\_arn](#input\_cloudfront\_arn) | CloudFront Distribution ARN association and policy toggles | `string` | `"null"` | no |

infrastructure/modules/s3/variable.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,5 @@ variable "access_logs_enabled" {
5050

5151
variable "access_logs_bucket_id" {
5252
type = string
53-
default = null
5453
description = "Enables access logs on the module's bucket"
5554
}

0 commit comments

Comments
 (0)