Skip to content

Commit 44fec9c

Browse files
committed
feat: add ability to deny non-SSL transport on log forwarder S3 bucket
1 parent f21e89c commit 44fec9c

File tree

8 files changed

+31
-13
lines changed

8 files changed

+31
-13
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Examples codified under the [`examples`](./examples) are intended to give users
105105
| <a name="input_api_vpce_security_group_ids"></a> [api\_vpce\_security\_group\_ids](#input\_api\_vpce\_security\_group\_ids) | IDs of security groups to attach to API endpoint | `list(string)` | `[]` | no |
106106
| <a name="input_api_vpce_subnet_ids"></a> [api\_vpce\_subnet\_ids](#input\_api\_vpce\_subnet\_ids) | IDs of subnets to associate with API endpoint | `list(string)` | `[]` | no |
107107
| <a name="input_api_vpce_tags"></a> [api\_vpce\_tags](#input\_api\_vpce\_tags) | A map of tags to apply to the API endpoint | `map(string)` | `{}` | no |
108+
| <a name="input_bucket_attach_deny_insecure_transport_policy"></a> [bucket\_attach\_deny\_insecure\_transport\_policy](#input\_bucket\_attach\_deny\_insecure\_transport\_policy) | Controls if S3 bucket should have deny non-SSL transport policy attacheds | `bool` | `false` | no |
108109
| <a name="input_bucket_name"></a> [bucket\_name](#input\_bucket\_name) | Lambda artifact S3 bucket name | `string` | `""` | no |
109110
| <a name="input_create_agent_vpce"></a> [create\_agent\_vpce](#input\_create\_agent\_vpce) | Controls whether an agent endpoint should be created | `bool` | `false` | no |
110111
| <a name="input_create_api_vpce"></a> [create\_api\_vpce](#input\_create\_api\_vpce) | Controls whether a API endpoint should be created | `bool` | `false` | no |

examples/complete/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ Note that this example may create resources which will incur monetary charges on
3030

3131
| Name | Version |
3232
|------|---------|
33-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.25.0 |
34-
| <a name="provider_random"></a> [random](#provider\_random) | 3.0.1 |
33+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.50.0 |
34+
| <a name="provider_random"></a> [random](#provider\_random) | 3.1.0 |
3535

3636
## Modules
3737

main.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ module "log_forwarder" {
2626
lambda_tags = var.log_forwarder_lambda_tags
2727
log_retention_days = var.log_forwarder_log_retention_days
2828

29-
create_bucket = var.create_bucket
30-
bucket_name = var.bucket_name
31-
bucket_prefix = var.log_forwarder_bucket_prefix
29+
create_bucket = var.create_bucket
30+
bucket_name = var.bucket_name
31+
bucket_prefix = var.log_forwarder_bucket_prefix
32+
bucket_attach_deny_insecure_transport_policy = var.bucket_attach_deny_insecure_transport_policy
33+
3234
s3_zip_storage_class = var.log_forwarder_s3_zip_storage_class
3335
s3_zip_server_side_encryption = var.log_forwarder_s3_zip_server_side_encryption
3436
s3_zip_kms_key_id = var.log_forwarder_s3_zip_kms_key_id

modules/log_forwarder/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ module "datadog_log_forwarder" {
5555

5656
| Name | Source | Version |
5757
|------|--------|---------|
58-
| <a name="module_this_s3_bucket"></a> [this\_s3\_bucket](#module\_this\_s3\_bucket) | terraform-aws-modules/s3-bucket/aws | v1.25.0 |
58+
| <a name="module_this_s3_bucket"></a> [this\_s3\_bucket](#module\_this\_s3\_bucket) | terraform-aws-modules/s3-bucket/aws | v2.6.0 |
5959

6060
## Resources
6161

@@ -78,6 +78,7 @@ module "datadog_log_forwarder" {
7878

7979
| Name | Description | Type | Default | Required |
8080
|------|-------------|------|---------|:--------:|
81+
| <a name="input_bucket_attach_deny_insecure_transport_policy"></a> [bucket\_attach\_deny\_insecure\_transport\_policy](#input\_bucket\_attach\_deny\_insecure\_transport\_policy) | Controls if S3 bucket should have deny non-SSL transport policy attacheds | `bool` | `false` | no |
8182
| <a name="input_bucket_name"></a> [bucket\_name](#input\_bucket\_name) | Forwarder S3 bucket name | `string` | `""` | no |
8283
| <a name="input_bucket_prefix"></a> [bucket\_prefix](#input\_bucket\_prefix) | S3 object key prefix to prepend to zip archive name | `string` | `""` | no |
8384
| <a name="input_create"></a> [create](#input\_create) | Controls whether the forwarder resources should be created | `bool` | `true` | no |

modules/log_forwarder/main.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ data "aws_region" "current" {}
2424

2525
module "this_s3_bucket" {
2626
source = "terraform-aws-modules/s3-bucket/aws"
27-
version = "v1.25.0"
27+
version = "v2.6.0"
2828

2929
create_bucket = var.create && var.create_bucket
3030
bucket = local.bucket_name
3131
force_destroy = true
3232

33+
attach_deny_insecure_transport_policy = var.bucket_attach_deny_insecure_transport_policy
34+
3335
block_public_acls = true
3436
block_public_policy = true
3537
ignore_public_acls = true
@@ -129,7 +131,7 @@ resource "null_resource" "this" {
129131
resource "aws_s3_bucket_object" "this" {
130132
count = var.create ? 1 : 0
131133

132-
bucket = var.create_bucket ? module.this_s3_bucket.this_s3_bucket_id : var.bucket_name
134+
bucket = var.create_bucket ? module.this_s3_bucket.s3_bucket_id : var.bucket_name
133135
key = join("/", compact([var.bucket_prefix, local.zip_name]))
134136
source = local.forwarder_zip
135137

@@ -150,7 +152,7 @@ resource "aws_s3_bucket_object" "this" {
150152
resource "aws_lambda_function" "this" {
151153
count = var.create ? 1 : 0
152154

153-
s3_bucket = var.create_bucket ? module.this_s3_bucket.this_s3_bucket_id : var.bucket_name
155+
s3_bucket = var.create_bucket ? module.this_s3_bucket.s3_bucket_id : var.bucket_name
154156
s3_key = aws_s3_bucket_object.this[0].key
155157
s3_object_version = aws_s3_bucket_object.this[0].version_id
156158
function_name = var.name

modules/log_forwarder/outputs.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
# Forwarder bucket
22
output "s3_bucket_id" {
33
description = "The name of the bucket"
4-
value = module.this_s3_bucket.this_s3_bucket_id
4+
value = module.this_s3_bucket.s3_bucket_id
55
}
66

77
output "s3_bucket_arn" {
88
description = "The ARN of the bucket. Will be of format arn:aws:s3:::bucketname"
9-
value = module.this_s3_bucket.this_s3_bucket_arn
9+
value = module.this_s3_bucket.s3_bucket_arn
1010
}
1111

1212
output "s3_bucket_domain_name" {
1313
description = "The bucket domain name. Will be of format bucketname.s3.amazonaws.com"
14-
value = module.this_s3_bucket.this_s3_bucket_bucket_domain_name
14+
value = module.this_s3_bucket.s3_bucket_bucket_domain_name
1515
}
1616

1717
output "s3_bucket_regional_domain_name" {
1818
description = "The bucket region-specific domain name. The bucket domain name including the region name"
19-
value = module.this_s3_bucket.this_s3_bucket_bucket_regional_domain_name
19+
value = module.this_s3_bucket.s3_bucket_bucket_regional_domain_name
2020
}
2121

2222
# Forwarder role

modules/log_forwarder/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ variable "bucket_name" {
4242
default = ""
4343
}
4444

45+
variable "bucket_attach_deny_insecure_transport_policy" {
46+
description = "Controls if S3 bucket should have deny non-SSL transport policy attacheds"
47+
type = bool
48+
default = false
49+
}
50+
4551
# Forwarder S3 Zip Objcet
4652
variable "bucket_prefix" {
4753
description = "S3 object key prefix to prepend to zip archive name"

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ variable "bucket_name" {
4747
default = ""
4848
}
4949

50+
variable "bucket_attach_deny_insecure_transport_policy" {
51+
description = "Controls if S3 bucket should have deny non-SSL transport policy attacheds"
52+
type = bool
53+
default = false
54+
}
55+
5056
# Log Forwarder S3 Objcet
5157
variable "log_forwarder_bucket_prefix" {
5258
description = "S3 object key prefix to prepend to zip archive name"

0 commit comments

Comments
 (0)