Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic logs block #28

Merged
merged 5 commits into from Apr 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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