Skip to content

Commit

Permalink
fix-log-enable (#44)
Browse files Browse the repository at this point in the history
Fix Log enabling

Signed-off-by: Kyle Nguyen <nvietthu@gmail.com>
  • Loading branch information
kylewin authored Nov 19, 2024
1 parent 67649c5 commit e7f3476
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ resource "aws_ec2_client_vpn_endpoint" "default" {
}

connection_log_options {
enabled = var.Connection_logging
enabled = var.connection_logging
cloudwatch_log_group = join("", aws_cloudwatch_log_group.vpn[*].name)
cloudwatch_log_stream = join("", aws_cloudwatch_log_stream.vpn[*].name)
}
Expand Down Expand Up @@ -242,7 +242,7 @@ resource "aws_ec2_client_vpn_network_association" "default" {
##-----------------------------------------------------------------------------
#tfsec:ignore:aws-cloudwatch-log-group-customer-key
resource "aws_cloudwatch_log_group" "vpn" {
count = var.enabled ? 1 : 0
count = var.enabled && var.connection_logging ? 1 : 0
name = format("/aws/vpn/%s/logs", module.labels.id)
retention_in_days = var.logs_retention
tags = module.labels.tags
Expand All @@ -252,7 +252,7 @@ resource "aws_cloudwatch_log_group" "vpn" {
## A log stream is a sequence of log events that share the same source. Each separate source of logs in CloudWatch Logs makes up a separate log stream.
##-----------------------------------------------------------------------------
resource "aws_cloudwatch_log_stream" "vpn" {
count = var.enabled ? 1 : 0
count = var.enabled && var.connection_logging ? 1 : 0
name = format("%s-usage", module.labels.id)
log_group_name = join("", aws_cloudwatch_log_group.vpn[*].name)
}
Expand Down
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ variable "certificate_enabled" {
default = true
}

variable "Connection_logging" {
variable "connection_logging" {
type = bool
default = true
description = "Connection logging is a feature of AWS client VPN that enables you to capture connection logs for your client VPN endpoint. Before you enable, you must have a CloudWatch Logs log group in your account."
Expand Down

0 comments on commit e7f3476

Please sign in to comment.