Skip to content

Commit f9b406f

Browse files
committed
add auth manager service components
1 parent 49433be commit f9b406f

File tree

12 files changed

+600
-14
lines changed

12 files changed

+600
-14
lines changed

auth-manager/alb.tf

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
resource "aws_lb_target_group" "auth_manager_private_tg" {
2+
#ts:skip=AC_AWS_0492
3+
name = "auth-manager-private"
4+
port = 8000
5+
protocol = "HTTP"
6+
target_type = "ip"
7+
vpc_id = var.vpc_id
8+
9+
lifecycle {
10+
create_before_destroy = true
11+
}
12+
13+
health_check {
14+
enabled = true
15+
path = "${var.root_path}/health"
16+
protocol = "HTTP"
17+
}
18+
19+
tags = var.auth_manager_svc_tags
20+
}
21+
22+
resource "aws_lb_listener_rule" "auth_manager_private_listener_rule" {
23+
listener_arn = var.private_alb_listener_arn
24+
priority = 610
25+
26+
action {
27+
type = "forward"
28+
target_group_arn = aws_lb_target_group.auth_manager_private_tg.arn
29+
}
30+
31+
condition {
32+
path_pattern {
33+
values = ["${var.root_path}*"]
34+
}
35+
}
36+
37+
condition {
38+
source_ip {
39+
values = var.allowed_source_ip_cidr_blocks
40+
}
41+
}
42+
tags = var.auth_manager_svc_tags
43+
}

auth-manager/dashboard.tf

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
locals {
2+
clustername = "auth_manager_ecs_cluster"
3+
servicename = "auth_manager_ecs_service"
4+
}
5+
6+
resource "aws_cloudwatch_dashboard" "main" {
7+
dashboard_name = "auth_manager"
8+
9+
dashboard_body = jsonencode({
10+
widgets = [
11+
{
12+
type = "metric"
13+
x = 0
14+
y = 0
15+
width = 12
16+
height = 6
17+
18+
properties = {
19+
metrics = [
20+
["AWS/ECS",
21+
"CPUUtilization",
22+
"ClusterName", local.clustername,
23+
"ServiceName", local.servicename,
24+
{ "stat" : "Average",
25+
"region" : var.aws_region }]
26+
]
27+
view = "timeSeries"
28+
stacked = false
29+
region = var.aws_region
30+
title = "CPUUtilization: Average"
31+
period = 300
32+
}
33+
},
34+
{
35+
type = "metric"
36+
x = 12
37+
y = 0
38+
width = 12
39+
height = 6
40+
41+
properties = {
42+
metrics = [
43+
["AWS/ECS",
44+
"MemoryUtilization",
45+
"ClusterName", local.clustername,
46+
"ServiceName", local.servicename,
47+
{ "stat" : "Average", "region" : var.aws_region }]
48+
]
49+
view = "timeSeries"
50+
stacked = false
51+
region = var.aws_region
52+
title = "MemoryUtilization: Average"
53+
period = 300
54+
}
55+
}
56+
]
57+
})
58+
}

auth-manager/db.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
resource "aws_db_subnet_group" "auth_manager_db_cluster_subnet_group" {
22
name = "auth-manager-db-cluster-group"
33
subnet_ids = [aws_subnet.auth_manager_db_a.id, aws_subnet.auth_manager_db_b.id]
4+
5+
tags = var.auth_manager_svc_tags
46
}
57

68
data "aws_secretsmanager_secret_version" "auth_manager_database_password" {

auth-manager/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "private_lb_rule_suffix" {
2+
description = "auth manager Private Loadbalancer Rule Suffix"
3+
value = aws_lb_target_group.auth_manager_private_tg.arn_suffix
4+
}

auth-manager/policies.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
resource "aws_iam_policy" "auth_manager_secrets_access" {
2+
name = "auth_manager-secrets-access-policy"
3+
description = "Policy that gives access to the auth_manager service secrets"
4+
5+
policy = <<-EOT
6+
{
7+
"Version": "2012-10-17",
8+
"Statement": [
9+
{
10+
"Effect": "Allow",
11+
"Action": [
12+
"ssm:GetParameters",
13+
"secretsmanager:GetSecretValue"
14+
],
15+
"Resource": [
16+
"${var.auth_manager_secrets_arn}"
17+
]
18+
}
19+
]
20+
}
21+
EOT
22+
}
23+
24+

auth-manager/security-groups.tf

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
resource "aws_security_group" "auth_manager_sg" {
2+
vpc_id = var.vpc_id
3+
4+
name = "main_auth_manager_sg"
5+
description = "main security group for auth manager database"
6+
7+
ingress {
8+
description = "Allow Postgres access from the VPC"
9+
from_port = 5432
10+
to_port = 5432
11+
protocol = "tcp"
12+
cidr_blocks = var.allowed_source_ip_cidr_blocks
13+
}
14+
15+
tags = var.auth_manager_svc_tags
16+
}
17+
18+
resource "aws_vpc_security_group_ingress_rule" "main_subnet_ingress" {
19+
security_group_id = aws_security_group.acc_sg.id
20+
description = "Allow everything incoming from the VPC"
21+
ip_protocol = -1
22+
cidr_ipv4 = data.aws_vpc.main.cidr_block
23+
from_port = -1
24+
to_port = -1
25+
}
26+
27+
resource "aws_vpc_security_group_egress_rule" "main_subnet_egress" {
28+
security_group_id = aws_security_group.acc_sg.id
29+
description = "Allow everything outgoing"
30+
ip_protocol = -1
31+
cidr_ipv4 = "0.0.0.0/0"
32+
from_port = -1
33+
to_port = -1
34+
}

0 commit comments

Comments
 (0)