diff --git a/datasources.tf b/datasources.tf index 414b2c2..2609614 100644 --- a/datasources.tf +++ b/datasources.tf @@ -1,4 +1,4 @@ -# AWS Academy Vocareum AWS Learner Lab +# AWS Academy Vocareum AWS Learner Lab data "aws_iam_role" "lab_role" { name = "LabRole" } diff --git a/lb.tf b/lb.tf index 9a76bd2..045145f 100644 --- a/lb.tf +++ b/lb.tf @@ -24,7 +24,7 @@ resource "aws_lb_listener" "main" { fixed_response { content_type = "text/plain" status_code = "418" - message_body = "SOAT Tech Challenge - Invalid destination" + message_body = "SOAT Tech Challenge - ALB Invalid destination" } } diff --git a/lb_outputs.tf b/lb_outputs.tf new file mode 100644 index 0000000..b59b139 --- /dev/null +++ b/lb_outputs.tf @@ -0,0 +1,82 @@ +output "lb_lb" { + description = "ALB" + value = { + "arn" : aws_lb.main.arn + "arn_suffix" : aws_lb.main.arn_suffix + "dns_name" : aws_lb.main.dns_name + "id" : aws_lb.main.id + "internal" : aws_lb.main.internal + "ip_address_type" : aws_lb.main.ip_address_type + "load_balancer_type" : aws_lb.main.load_balancer_type + "name" : aws_lb.main.name + "security_groups" : aws_lb.main.security_groups + "subnet_mapping" : aws_lb.main.subnet_mapping + "subnets" : aws_lb.main.subnets + "tags" : aws_lb.main.tags + "vpc_id" : aws_lb.main.vpc_id + "zone_id" : aws_lb.main.zone_id + } +} + +output "lb_tgs" { + description = "ALB Target Groups" + value = { + "ecs_identification_svc_tg" : { + "arn" : aws_lb_target_group.ecs_identification_svc_tg.arn + "arn_suffix" : aws_lb_target_group.ecs_identification_svc_tg.arn_suffix + "health_check" : aws_lb_target_group.ecs_identification_svc_tg.health_check + "id" : aws_lb_target_group.ecs_identification_svc_tg.id + "ip_address_type" : aws_lb_target_group.ecs_identification_svc_tg.ip_address_type + "name" : aws_lb_target_group.ecs_identification_svc_tg.name + "name_prefix" : aws_lb_target_group.ecs_identification_svc_tg.name_prefix + "port" : aws_lb_target_group.ecs_identification_svc_tg.port + "protocol_version" : aws_lb_target_group.ecs_identification_svc_tg.protocol_version + "tags" : aws_lb_target_group.ecs_identification_svc_tg.tags + "target_type" : aws_lb_target_group.ecs_identification_svc_tg.target_type + "vpc_id" : aws_lb_target_group.ecs_identification_svc_tg.vpc_id + } + "ecs_order_svc_tg" : { + "arn" : aws_lb_target_group.ecs_order_svc_tg.arn + "arn_suffix" : aws_lb_target_group.ecs_order_svc_tg.arn_suffix + "health_check" : aws_lb_target_group.ecs_order_svc_tg.health_check + "id" : aws_lb_target_group.ecs_order_svc_tg.id + "ip_address_type" : aws_lb_target_group.ecs_order_svc_tg.ip_address_type + "name" : aws_lb_target_group.ecs_order_svc_tg.name + "name_prefix" : aws_lb_target_group.ecs_order_svc_tg.name_prefix + "port" : aws_lb_target_group.ecs_order_svc_tg.port + "protocol_version" : aws_lb_target_group.ecs_order_svc_tg.protocol_version + "tags" : aws_lb_target_group.ecs_order_svc_tg.tags + "target_type" : aws_lb_target_group.ecs_order_svc_tg.target_type + "vpc_id" : aws_lb_target_group.ecs_order_svc_tg.vpc_id + } + "ecs_payment_svc_tg" : { + "arn" : aws_lb_target_group.ecs_payment_svc_tg.arn + "arn_suffix" : aws_lb_target_group.ecs_payment_svc_tg.arn_suffix + "health_check" : aws_lb_target_group.ecs_payment_svc_tg.health_check + "id" : aws_lb_target_group.ecs_payment_svc_tg.id + "ip_address_type" : aws_lb_target_group.ecs_payment_svc_tg.ip_address_type + "name" : aws_lb_target_group.ecs_payment_svc_tg.name + "name_prefix" : aws_lb_target_group.ecs_payment_svc_tg.name_prefix + "port" : aws_lb_target_group.ecs_payment_svc_tg.port + "protocol_version" : aws_lb_target_group.ecs_payment_svc_tg.protocol_version + "tags" : aws_lb_target_group.ecs_payment_svc_tg.tags + "target_type" : aws_lb_target_group.ecs_payment_svc_tg.target_type + "vpc_id" : aws_lb_target_group.ecs_payment_svc_tg.vpc_id + } + "ecs_production_svc_tg" : { + "arn" : aws_lb_target_group.ecs_production_svc_tg.arn + "arn_suffix" : aws_lb_target_group.ecs_production_svc_tg.arn_suffix + "health_check" : aws_lb_target_group.ecs_production_svc_tg.health_check + "id" : aws_lb_target_group.ecs_production_svc_tg.id + "ip_address_type" : aws_lb_target_group.ecs_production_svc_tg.ip_address_type + "name" : aws_lb_target_group.ecs_production_svc_tg.name + "name_prefix" : aws_lb_target_group.ecs_production_svc_tg.name_prefix + "port" : aws_lb_target_group.ecs_production_svc_tg.port + "protocol_version" : aws_lb_target_group.ecs_production_svc_tg.protocol_version + "tags" : aws_lb_target_group.ecs_production_svc_tg.tags + "target_type" : aws_lb_target_group.ecs_production_svc_tg.target_type + "vpc_id" : aws_lb_target_group.ecs_production_svc_tg.vpc_id + } + } +} + diff --git a/lb_target_groups.tf b/lb_target_groups.tf index 66fd740..acf78e3 100644 --- a/lb_target_groups.tf +++ b/lb_target_groups.tf @@ -8,6 +8,11 @@ resource "aws_lb_target_group" "ecs_identification_svc_tg" { target_type = "ip" vpc_id = aws_vpc.main.id + health_check { + interval = 10 + path = "/identification/actuator/health" + } + tags = { Name : "SOAT-TC ALB Identification Service Target Group" } @@ -20,6 +25,11 @@ resource "aws_lb_target_group" "ecs_order_svc_tg" { target_type = "ip" vpc_id = aws_vpc.main.id + health_check { + interval = 10 + path = "/order/actuator/health" + } + tags = { Name : "SOAT-TC ALB Order Service Target Group" } @@ -32,6 +42,12 @@ resource "aws_lb_target_group" "ecs_payment_svc_tg" { target_type = "ip" vpc_id = aws_vpc.main.id + health_check { + interval = 10 + path = "/payment/actuator/health" + } + + tags = { Name : "SOAT-TC ALB Payment Service Target Group" } @@ -45,6 +61,12 @@ resource "aws_lb_target_group" "ecs_production_svc_tg" { target_type = "ip" vpc_id = aws_vpc.main.id + health_check { + interval = 10 + path = "/production/actuator/health" + } + + tags = { Name : "SOAT-TC ALB Production Service Target Group" } diff --git a/variables.tf b/variables.tf index 4add535..23c2083 100644 --- a/variables.tf +++ b/variables.tf @@ -9,14 +9,17 @@ variable "aws_region" { variable "aws_access_key" { description = "AWS Access Key" type = string + sensitive = true } variable "aws_secret_key" { description = "AWS Secret Key" type = string + sensitive = true } variable "aws_session_token" { - description = "AWS Secret Key" + description = "AWS Session Token" type = string + sensitive = true }