Skip to content

Commit 8c3b083

Browse files
committed
Adding variables to ELB module
1 parent 851a34b commit 8c3b083

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

aws/elb/elb.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,14 @@ resource "aws_sns_topic_subscription" "subscription" {
137137
resource "aws_serverlessapplicationrepository_cloudformation_stack" "auto_enable_access_logs" {
138138
for_each = toset(local.auto_enable_access_logs ? ["auto_enable_access_logs"] : [])
139139

140-
name = "Auto-Enable-Access-Logs-Elb-${random_string.aws_random.id}"
140+
name = "Auto-Enable-Access-Logs-${var.auto_enable_access_logs_options.auto_enable_logging}-${random_string.aws_random.id}"
141141
application_id = "arn:aws:serverlessrepo:us-east-1:956882708938:applications/sumologic-s3-logging-auto-enable"
142-
semantic_version = "1.0.2"
142+
semantic_version = var.app_semantic_version
143143
capabilities = data.aws_serverlessapplicationrepository_application.app.required_capabilities
144144
parameters = {
145145
BucketName = local.bucket_name
146-
BucketPrefix = "elasticloadbalancing"
147-
AutoEnableLogging = "ALB"
146+
BucketPrefix = var.auto_enable_access_logs_options.bucket_prefix
147+
AutoEnableLogging = var.auto_enable_access_logs_options.auto_enable_logging
148148
AutoEnableResourceOptions = var.auto_enable_access_logs
149149
FilterExpression = var.auto_enable_access_logs_options.filter
150150
RemoveOnDeleteStack = var.auto_enable_access_logs_options.remove_on_delete_stack

aws/elb/locals.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ locals {
1414
auto_enable_access_logs = var.auto_enable_access_logs != "None" ? true : false
1515

1616
# If we create the bucket, then get the default PATH expression.
17-
logs_path_expression = var.source_details.bucket_details.create_bucket ? "*AWSLogs/${local.aws_account_id}/elasticloadbalancing/${local.aws_region}/*" : var.source_details.bucket_details.path_expression
17+
logs_path_expression = var.source_details.bucket_details.create_bucket ? "*${var.auto_enable_access_logs_options.bucket_prefix}/AWSLogs/${local.aws_account_id}/elasticloadbalancing/${local.aws_region}/*" : var.source_details.bucket_details.path_expression
1818

1919
region_to_elb_account_id = {
2020
"us-east-1" = "127311923021",

aws/elb/variables.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,16 @@ variable "auto_enable_access_logs" {
108108
default = "Both"
109109
}
110110

111+
variable "app_semantic_version" {
112+
type = string
113+
description = "Provide the latest version of Serverless Application Repository 'sumologic-s3-logging-auto-enable'."
114+
default = "1.0.4"
115+
}
116+
111117
variable "auto_enable_access_logs_options" {
112118
type = object({
119+
bucket_prefix = string
120+
auto_enable_logging = string
113121
filter = string
114122
remove_on_delete_stack = bool
115123
})
@@ -120,9 +128,15 @@ variable "auto_enable_access_logs_options" {
120128
EOT
121129

122130
default = {
131+
bucket_prefix = ""
132+
auto_enable_logging = ""
123133
filter = ""
124134
remove_on_delete_stack = true
125135
}
136+
validation {
137+
condition = contains(["ALB", "ELB"], var.auto_enable_access_logs_options.auto_enable_logging)
138+
error_message = "The value must be one of ALB or ELB."
139+
}
126140
}
127141

128142
variable "wait_for_seconds" {

0 commit comments

Comments
 (0)