-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* nlb integration * nlb integration code review * nlb integration code review * security group * security group * security group * nlb * nlb * workaround logic * docs * tf docs * tf docs * example * example modified * example modified * nlb integration * nlb integration * nlb integration --------- Co-authored-by: Matt Love <[email protected]>
- Loading branch information
Showing
10 changed files
with
614 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
data "aws_subnet" "main" { | ||
id = var.subnet_ids[0] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
terraform { | ||
required_version = ">= 1.3.0" | ||
|
||
required_providers { | ||
aws = ">= 5.0.0" | ||
} | ||
} | ||
|
||
provider "aws" { | ||
region = "eu-west-2" | ||
} | ||
|
||
data "aws_vpc" "default" { | ||
id = "<example>" | ||
} | ||
|
||
data "aws_subnets" "all" { | ||
filter { | ||
name = "vpc-id" | ||
values = [data.aws_vpc.default.id] | ||
} | ||
|
||
filter { | ||
name = "tag:Name" | ||
values = ["*private*"] | ||
} | ||
} | ||
|
||
locals { | ||
mq_admin_user = "adminUsername" | ||
mq_admin_password = "adminPassword" | ||
} | ||
|
||
module "active_mq" { | ||
source = "../../" | ||
|
||
broker_name = "my-active-mq-broker" | ||
|
||
subnet_ids = [data.aws_subnets.all.ids[0], data.aws_subnets.all.ids[1]] | ||
|
||
security_groups = ["<example>"] | ||
|
||
engine_type = "ActiveMQ" | ||
engine_version = "5.17.2" | ||
host_instance_type = "mq.t3.micro" | ||
|
||
apply_immediately = true | ||
|
||
deployment_mode = "ACTIVE_STANDBY_MULTI_AZ" | ||
|
||
encryption_enabled = false | ||
|
||
username = local.mq_admin_user | ||
password = local.mq_admin_password | ||
|
||
general_log_enabled = true | ||
audit_log_enabled = true | ||
|
||
configuration_data = <<DATA | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<broker xmlns="http://activemq.apache.org/schema/core"> | ||
<plugins> | ||
<forcePersistencyModeBrokerPlugin persistenceFlag="true"/> | ||
<statisticsBrokerPlugin/> | ||
<timeStampingBrokerPlugin ttlCeiling="86400000" zeroExpirationOverride="86400000"/> | ||
</plugins> | ||
</broker> | ||
DATA | ||
|
||
nlb_enabled = true | ||
nlb_certificate_arn = "<example>" | ||
|
||
create_security_group = true | ||
security_group_name = "<example>" | ||
security_group_description = "example" | ||
cidr_blocks_8883 = [data.aws_vpc.default.cidr_block] | ||
prefix_lists_8883 = [data.aws_ec2_managed_prefix_list.default.id] | ||
} | ||
|
||
data "aws_ec2_managed_prefix_list" "default" { | ||
name = "<example>" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ terraform { | |
required_version = ">= 1.3.0" | ||
|
||
required_providers { | ||
aws = ">= 4.0.0" | ||
aws = ">= 5.0.0" | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ terraform { | |
required_version = ">= 1.3.0" | ||
|
||
required_providers { | ||
aws = ">= 4.0.0" | ||
aws = ">= 5.0.0" | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
resource "aws_lb" "main" { | ||
count = var.nlb_enabled && var.deployment_mode == "ACTIVE_STANDBY_MULTI_AZ" ? 1 : 0 | ||
|
||
name = var.nlb_name == null ? "${var.broker_name}-nlb" : var.nlb_name | ||
internal = var.nlb_internal | ||
load_balancer_type = "network" | ||
subnets = var.subnet_ids | ||
|
||
enable_cross_zone_load_balancing = var.enable_cross_zone_load_balancing | ||
enable_deletion_protection = var.enable_deletion_protection | ||
|
||
tags = merge(var.nlb_tags, var.tags) | ||
|
||
depends_on = [ | ||
aws_mq_broker.main, | ||
] | ||
} | ||
|
||
resource "aws_lb_target_group" "main" { | ||
count = var.nlb_enabled && var.deployment_mode == "ACTIVE_STANDBY_MULTI_AZ" ? 1 : 0 | ||
|
||
name = aws_lb.main[0].name | ||
port = var.nlb_tg_port | ||
protocol = var.nlb_tg_protocol | ||
target_type = "ip" | ||
vpc_id = data.aws_subnet.main.vpc_id | ||
|
||
health_check { | ||
enabled = true | ||
port = 8162 | ||
protocol = "TCP" | ||
interval = 10 | ||
healthy_threshold = 3 | ||
} | ||
|
||
depends_on = [ | ||
aws_lb.main, | ||
] | ||
} | ||
|
||
resource "aws_lb_target_group_attachment" "main" { | ||
count = (var.nlb_enabled && var.deployment_mode == "ACTIVE_STANDBY_MULTI_AZ") ? length(var.subnet_ids) : 0 | ||
|
||
target_group_arn = aws_lb_target_group.main[0].arn | ||
target_id = aws_mq_broker.main.instances[count.index]["ip_address"] | ||
port = 8883 | ||
|
||
depends_on = [ | ||
aws_mq_broker.main, | ||
] | ||
} | ||
|
||
resource "aws_lb_listener" "main" { | ||
count = var.nlb_enabled && var.deployment_mode == "ACTIVE_STANDBY_MULTI_AZ" ? 1 : 0 | ||
|
||
load_balancer_arn = aws_lb.main[0].arn | ||
port = "8883" | ||
protocol = "TLS" | ||
certificate_arn = var.nlb_certificate_arn | ||
alpn_policy = "HTTP2Preferred" | ||
ssl_policy = "ELBSecurityPolicy-TLS-1-2-2017-01" | ||
|
||
default_action { | ||
type = "forward" | ||
target_group_arn = aws_lb_target_group.main[0].arn | ||
} | ||
|
||
depends_on = [ | ||
aws_lb.main, | ||
] | ||
} |
Oops, something went wrong.