Skip to content

Commit

Permalink
Merge pull request #6 from unity-sds/431-lockdown-mc-alb-allow-ecs
Browse files Browse the repository at this point in the history
Add implicit ingress rule creation for venue-services proxy connection to the management console
  • Loading branch information
jpl-btlunsfo authored Sep 5, 2024
2 parents 9c3214d + 7dc9dba commit 4b75729
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
19 changes: 19 additions & 0 deletions terraform-unity/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,22 @@ resource "aws_ecs_service" "httpd_service" {
aws_ssm_parameter.managementproxy_config
]
}

# Find the MC's ALB's security group (created before unity-proxy)
data "aws_security_group" "mc_alb_sg" {
tags = {
Name = "Unity Management Console Load Balancer SG"
Venue = var.venue
ServiceArea = "cs"
Proj = var.project
}
}

# Add a new ingress rule to the MC ALB's security group, allowing the ECS instance to connect
resource "aws_vpc_security_group_ingress_rule" "ecs_mc_alb_ingress_sg_rule" {
security_group_id = data.aws_security_group.mc_alb_sg.id
to_port = 8080
from_port = 8080
ip_protocol = "tcp"
referenced_security_group_id = aws_security_group.ecs_sg.id
}
1 change: 1 addition & 0 deletions terraform-unity/lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ resource "aws_lambda_function" "httpdlambda" {
Service = "U-CS"
}
}

resource "aws_security_group" "lambda_sg" {
name = "${var.project}-${var.venue}-httpd_lambda_sg"
description = "Security group for httpd lambda service"
Expand Down
14 changes: 7 additions & 7 deletions terraform-unity/networking.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ resource "aws_lb_listener" "httpd_listener" {
}
}
# Unity shared serive account ID
data "aws_ssm_parameter" "shared_service_account_id"{
data "aws_ssm_parameter" "shared_service_account_id" {
name = var.ssm_account_id
}

#Unity shared serive account region
data "aws_ssm_parameter" "shared_service_region"{
data "aws_ssm_parameter" "shared_service_region" {
name = var.ssm_region
}

Expand All @@ -71,11 +71,11 @@ resource "aws_ssm_parameter" "mgmt_endpoint" {

# New SSM parameter for management console
resource "aws_ssm_parameter" "management_console_url" {
name = "/unity/${var.project}/${var.venue}/component/management-console"
type = "String"
name = "/unity/${var.project}/${var.venue}/component/management-console"
type = "String"
value = jsonencode({
healthCheckUrl = "https://www.${data.aws_ssm_parameter.shared-service-domain.value}:4443/${var.project}/${var.venue}/management/api/health_checks"
landingPageUrl = "https://www.${data.aws_ssm_parameter.shared-service-domain.value}:4443/${var.project}/${var.venue}/management/ui/landing"
componentName = "Management Console"
healthCheckUrl = "https://www.${data.aws_ssm_parameter.shared-service-domain.value}:4443/${var.project}/${var.venue}/management/api/health_checks"
landingPageUrl = "https://www.${data.aws_ssm_parameter.shared-service-domain.value}:4443/${var.project}/${var.venue}/management/ui/landing"
componentName = "Management Console"
})
}
6 changes: 3 additions & 3 deletions terraform-unity/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ variable "httpd_proxy_version" {
default = "0.16.0"
}

variable "ssm_account_id"{
variable "ssm_account_id" {
description = "Name of the SSM paramter for shared service account ID"
type = string
default = "/unity/shared-services/aws/account"
type = string
default = "/unity/shared-services/aws/account"
}

variable "ssm_region" {
Expand Down

0 comments on commit 4b75729

Please sign in to comment.