Skip to content

Commit 66f073c

Browse files
committed
Pass alb variables to alb module from root module
1 parent 2484c79 commit 66f073c

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

modules/alb/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ No modules.
3838
| <a name="input_enable_access_logs"></a> [enable\_access\_logs](#input\_enable\_access\_logs) | Enable or disable ALB access logs. If set to true, logs will be stored in an S3 bucket. | `bool` | `false` | no |
3939
| <a name="input_enable_connection_logs"></a> [enable\_connection\_logs](#input\_enable\_connection\_logs) | Enable or disable ALB connection logs. If set to true, logs will be stored in an S3 bucket. | `bool` | `false` | no |
4040
| <a name="input_name"></a> [name](#input\_name) | Name for this load balancer | `string` | n/a | yes |
41-
| <a name="input_s3_bucket_name"></a> [s3\_bucket\_name](#input\_s3\_bucket\_name) | Optional S3 bucket name for storing ALB access logs. If not provided, a new bucket will be created. | `string` | `""` | no |
41+
| <a name="input_s3_logs_bucket_name"></a> [s3\_bucket\_name](#input\_s3\_bucket\_name) | Optional S3 bucket name for storing ALB access logs. If not provided, a new bucket will be created. | `string` | `""` | no |
4242
| <a name="input_security_group_name"></a> [security\_group\_name](#input\_security\_group\_name) | Name for the load balancer security group; defaults to name | `string` | `null` | no |
4343
| <a name="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids) | Subnets for this load balancer | `list(string)` | n/a | yes |
4444
| <a name="input_tags"></a> [tags](#input\_tags) | Tags to apply to created resources | `map(string)` | `{}` | no |

modules/alb/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ resource "aws_alb" "this" {
55
dynamic "connection_logs" {
66
for_each = var.enable_connection_logs ? [1] : []
77
content {
8-
bucket = var.s3_bucket_name != "" ? var.s3_bucket_name : aws_s3_bucket.lb_logs[0].id
8+
bucket = var.s3_logs_bucket_name != "" ? var.s3_logs_bucket_name : aws_s3_bucket.lb_logs[0].id
99
prefix = "connectionlogs"
1010
enabled = true
1111
}
@@ -14,7 +14,7 @@ resource "aws_alb" "this" {
1414
dynamic "access_logs" {
1515
for_each = var.enable_access_logs ? [1] : []
1616
content {
17-
bucket = var.s3_bucket_name != "" ? var.s3_bucket_name : aws_s3_bucket.lb_logs[0].id
17+
bucket = var.s3_logs_bucket_name != "" ? var.s3_logs_bucket_name : aws_s3_bucket.lb_logs[0].id
1818
prefix = "accesslogs"
1919
enabled = true
2020
}
@@ -24,8 +24,8 @@ resource "aws_alb" "this" {
2424
}
2525

2626
resource "aws_s3_bucket" "lb_logs" {
27-
count = var.s3_bucket_name == "" ? 1 : 0
28-
bucket = var.s3_bucket_name == "" ? "${var.name}-alb-logs-${random_id.suffix.hex}" : var.s3_bucket_name
27+
count = var.s3_logs_bucket_name == "" ? 1 : 0
28+
bucket = var.s3_logs_bucket_name == "" ? "${var.name}-alb-logs-${random_id.suffix.hex}" : var.s3_logs_bucket_name
2929
}
3030

3131
resource "random_id" "suffix" {

modules/alb/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ variable "name" {
2020
type = string
2121
}
2222

23-
variable "s3_bucket_name" {
23+
variable "s3_logs_bucket_name" {
2424
type = string
2525
default = ""
2626
description = "Optional S3 bucket name for storing ALB access logs. If not provided, a new bucket will be created."

variables.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ variable "description" {
3838
type = string
3939
}
4040

41+
variable "enable_access_logs" {
42+
type = bool
43+
default = false
44+
description = "Enable or disable ALB access logs. If set to true, logs will be stored in an S3 bucket."
45+
}
46+
47+
variable "enable_connection_logs" {
48+
type = bool
49+
default = false
50+
description = "Enable or disable ALB connection logs. If set to true, logs will be stored in an S3 bucket."
51+
}
4152
variable "enable_stickiness" {
4253
type = bool
4354
description = "Set to true to use a cookie for load balancer stickiness"
@@ -78,6 +89,12 @@ variable "primary_certificate_domain" {
7889
type = string
7990
}
8091

92+
variable "s3_logs_bucket_name" {
93+
type = string
94+
default = ""
95+
description = "Optional S3 bucket name for storing ALB access logs. If not provided, a new bucket will be created."
96+
}
97+
8198
variable "security_group_name" {
8299
type = string
83100
description = "Name for the load balancer security group; defaults to name"

0 commit comments

Comments
 (0)