-
Couldn't load subscription status.
- Fork 0
feat: add auth manager service #671
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
Open
bilalesi
wants to merge
7
commits into
staging
Choose a base branch
from
feat/add-db-for-auth-manager
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5522692
add auth manager service db
bilalesi 4845c91
add auth manager service components
bilalesi 6b0ae98
Set actual keycloak client uuids values
danifr 55971df
fix ci
bilalesi 96affa8
Merge branch 'staging' into feat/add-db-for-auth-manager
bilalesi 5d62a7c
Merge branch 'staging' into feat/add-db-for-auth-manager
bilalesi 53c95bd
fix ci
bilalesi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,43 @@ | ||
| resource "aws_lb_target_group" "auth_manager_private_tg" { | ||
| #ts:skip=AC_AWS_0492 | ||
| name = "auth-manager-private" | ||
| port = 8000 | ||
| protocol = "HTTP" | ||
| target_type = "ip" | ||
| vpc_id = var.vpc_id | ||
|
|
||
| lifecycle { | ||
| create_before_destroy = true | ||
| } | ||
|
|
||
| health_check { | ||
| enabled = true | ||
| path = "${var.root_path}/health" | ||
| protocol = "HTTP" | ||
| } | ||
|
|
||
| tags = var.auth_manager_svc_tags | ||
| } | ||
|
|
||
| resource "aws_lb_listener_rule" "auth_manager_private_listener_rule" { | ||
| listener_arn = var.private_alb_listener_arn | ||
| priority = 612 | ||
|
|
||
| action { | ||
| type = "forward" | ||
| target_group_arn = aws_lb_target_group.auth_manager_private_tg.arn | ||
| } | ||
|
|
||
| condition { | ||
| path_pattern { | ||
| values = ["${var.root_path}*"] | ||
| } | ||
| } | ||
|
|
||
| condition { | ||
| source_ip { | ||
| values = var.allowed_source_ip_cidr_blocks | ||
| } | ||
| } | ||
| tags = var.auth_manager_svc_tags | ||
| } |
This file contains hidden or 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,58 @@ | ||
| locals { | ||
| clustername = "auth_manager_ecs_cluster" | ||
| servicename = "auth_manager_ecs_service" | ||
| } | ||
|
|
||
| resource "aws_cloudwatch_dashboard" "main" { | ||
| dashboard_name = "auth_manager" | ||
|
|
||
| dashboard_body = jsonencode({ | ||
| widgets = [ | ||
| { | ||
| type = "metric" | ||
| x = 0 | ||
| y = 0 | ||
| width = 12 | ||
| height = 6 | ||
|
|
||
| properties = { | ||
| metrics = [ | ||
| ["AWS/ECS", | ||
| "CPUUtilization", | ||
| "ClusterName", local.clustername, | ||
| "ServiceName", local.servicename, | ||
| { "stat" : "Average", | ||
| "region" : var.aws_region }] | ||
| ] | ||
| view = "timeSeries" | ||
| stacked = false | ||
| region = var.aws_region | ||
| title = "CPUUtilization: Average" | ||
| period = 300 | ||
| } | ||
| }, | ||
| { | ||
| type = "metric" | ||
| x = 12 | ||
| y = 0 | ||
| width = 12 | ||
| height = 6 | ||
|
|
||
| properties = { | ||
| metrics = [ | ||
| ["AWS/ECS", | ||
| "MemoryUtilization", | ||
| "ClusterName", local.clustername, | ||
| "ServiceName", local.servicename, | ||
| { "stat" : "Average", "region" : var.aws_region }] | ||
| ] | ||
| view = "timeSeries" | ||
| stacked = false | ||
| region = var.aws_region | ||
| title = "MemoryUtilization: Average" | ||
| period = 300 | ||
| } | ||
| } | ||
| ] | ||
| }) | ||
| } |
This file contains hidden or 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,52 @@ | ||
| resource "aws_db_subnet_group" "auth_manager_db_cluster_subnet_group" { | ||
| name = "auth-manager-db-cluster-group" | ||
| subnet_ids = [aws_subnet.auth_manager_db_a.id, aws_subnet.auth_manager_db_b.id] | ||
|
|
||
| tags = var.auth_manager_svc_tags | ||
| } | ||
|
|
||
| data "aws_secretsmanager_secret_version" "auth_manager_database_password" { | ||
| secret_id = var.auth_manager_secrets_arn | ||
| } | ||
|
|
||
| # tfsec:ignore:aws-rds-enable-performance-insights-encryption | ||
| resource "aws_db_instance" "auth_manager" { | ||
| #ts:skip=AC_AWS_0053 | ||
| #ts:skip=AC_AWS_0454 | ||
| #ts:skip=AC_AWS_0058 | ||
|
|
||
| engine = "postgres" | ||
| engine_version = "17" | ||
| allow_major_version_upgrade = true | ||
| multi_az = true | ||
| instance_class = "db.t3.small" | ||
|
|
||
| deletion_protection = true #tfsec:ignore:AVD-AWS-0177 | ||
| allocated_storage = 10 # in gigabytes | ||
|
|
||
| backup_retention_period = 14 # in days | ||
| backup_window = "01:00-02:00" | ||
| maintenance_window = "sun:05:00-sun:06:00" | ||
|
|
||
| db_subnet_group_name = aws_db_subnet_group.auth_manager_db_cluster_subnet_group.name | ||
|
|
||
| identifier = "auth-manager" | ||
| db_name = var.db_name | ||
| username = var.db_username | ||
| password = jsondecode(data.aws_secretsmanager_secret_version.auth_manager_database_password.secret_string)["DATABASE_PASSWORD"] | ||
|
|
||
| publicly_accessible = false | ||
| performance_insights_enabled = true | ||
| storage_encrypted = false #tfsec:ignore:aws-rds-encrypt-instance-storage-data | ||
|
|
||
| vpc_security_group_ids = [aws_security_group.auth_manager_sg.id] | ||
|
|
||
| iam_database_authentication_enabled = false | ||
|
|
||
| copy_tags_to_snapshot = true | ||
|
|
||
| tags = { | ||
| Name = "auth-manager-db" | ||
| obi_backup_plan = "obi_plan" | ||
| } | ||
| } | ||
This file contains hidden or 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,4 @@ | ||
| output "private_lb_rule_suffix" { | ||
| description = "auth manager Private Loadbalancer Rule Suffix" | ||
| value = aws_lb_target_group.auth_manager_private_tg.arn_suffix | ||
| } |
This file contains hidden or 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,24 @@ | ||
| resource "aws_iam_policy" "auth_manager_secrets_access" { | ||
| name = "auth_manager-secrets-access-policy" | ||
| description = "Policy that gives access to the auth_manager service secrets" | ||
|
|
||
| policy = <<-EOT | ||
| { | ||
| "Version": "2012-10-17", | ||
| "Statement": [ | ||
| { | ||
| "Effect": "Allow", | ||
| "Action": [ | ||
| "ssm:GetParameters", | ||
| "secretsmanager:GetSecretValue" | ||
| ], | ||
| "Resource": [ | ||
| "${var.auth_manager_secrets_arn}" | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| EOT | ||
| } | ||
|
|
||
|
|
This file contains hidden or 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,34 @@ | ||
| resource "aws_security_group" "auth_manager_sg" { | ||
| vpc_id = var.vpc_id | ||
|
|
||
| name = "main_auth_manager_sg" | ||
| description = "main security group for auth manager database" | ||
|
|
||
| ingress { | ||
| description = "Allow Postgres access from the VPC" | ||
| from_port = 5432 | ||
| to_port = 5432 | ||
| protocol = "tcp" | ||
| cidr_blocks = var.allowed_source_ip_cidr_blocks | ||
| } | ||
|
|
||
| tags = var.auth_manager_svc_tags | ||
| } | ||
|
|
||
| resource "aws_vpc_security_group_ingress_rule" "main_subnet_ingress" { | ||
| security_group_id = aws_security_group.auth_manager_sg.id | ||
| description = "Allow everything incoming from the VPC" | ||
| ip_protocol = -1 | ||
| cidr_ipv4 = data.aws_vpc.main.cidr_block | ||
| from_port = -1 | ||
| to_port = -1 | ||
| } | ||
|
|
||
| resource "aws_vpc_security_group_egress_rule" "main_subnet_egress" { | ||
| security_group_id = aws_security_group.auth_manager_sg.id | ||
| description = "Allow everything outgoing" | ||
| ip_protocol = -1 | ||
| cidr_ipv4 = "0.0.0.0/0" | ||
| from_port = -1 | ||
| to_port = -1 | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.