Skip to content

Commit

Permalink
Dynamic logs block (#28)
Browse files Browse the repository at this point in the history
Co-authored-by: cloudpossebot <11232728+cloudpossebot@users.noreply.github.com>
  • Loading branch information
heathsnow and cloudpossebot committed Apr 11, 2021
1 parent 3d2c4aa commit bf29e34
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -64,6 +64,7 @@ We literally have [*hundreds of terraform modules*][terraform_modules] that are

This module provisions the following resources:
- ActiveMQ broker
- RabbitMQ broker
- Security group rules to allow access to the broker

Admin and application users are created and credentials written to SSM if not passed in as variables.
Expand Down
1 change: 1 addition & 0 deletions README.yaml
Expand Up @@ -53,6 +53,7 @@ description: |-
introduction: |-
This module provisions the following resources:
- ActiveMQ broker
- RabbitMQ broker
- Security group rules to allow access to the broker
Admin and application users are created and credentials written to SSM if not passed in as variables.
Expand Down
15 changes: 12 additions & 3 deletions main.tf
Expand Up @@ -13,6 +13,7 @@ locals {

mq_application_password_is_set = var.mq_application_password != null && var.mq_application_password != ""
mq_application_password = local.mq_application_password_is_set ? var.mq_application_password : join("", random_password.mq_application_password.*.result)
mq_logs = { logs = { "general_log_enabled" : var.general_log_enabled, "audit_log_enabled" : var.audit_log_enabled } }
}

resource "random_string" "mq_admin_user" {
Expand Down Expand Up @@ -105,9 +106,17 @@ resource "aws_mq_broker" "default" {
}
}

logs {
general = var.general_log_enabled
audit = var.audit_log_enabled
# NOTE: Omit logs block if both general and audit logs disabled:
# https://github.com/hashicorp/terraform-provider-aws/issues/18067
dynamic "logs" {
for_each = {
for logs, type in local.mq_logs : logs => type
if type.general_log_enabled || type.audit_log_enabled
}
content {
general = logs.value["general_log_enabled"]
audit = logs.value["audit_log_enabled"]
}
}

maintenance_window_start_time {
Expand Down

0 comments on commit bf29e34

Please sign in to comment.