Skip to content

Commit

Permalink
Terraform 6 (#121)
Browse files Browse the repository at this point in the history
* changes

* addding wfprev_db_subnet

* update listener
  • Loading branch information
yzlucas authored Oct 1, 2024
1 parent 7e9c811 commit 33e4513
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/terragrunt-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jobs:
WFPREV_API_PORT: ${{vars.WFPREV_API_PORT}}
TARGET_AWS_ACCOUNT_ID: ${{secrets.TARGET_AWS_ACCOUNT_ID}}
# WFPREV UI
CLIENT_IMAGE: ${{ vars.REPOSITORY }}/${{ github.repository }}-wfprev-ui:${{ inputs.IMAGE_TAG }}
CLIENT_IMAGE: ${{ vars.REPOSITORY }}/${{ github.repository }}-wfprev-war:${{ inputs.IMAGE_TAG }}
WEBADE_OAUTH2_WFPREV_UI_CLIENT_SECRET: ${{ secrets.WEBADE_OAUTH2_WFPREV_UI_CLIENT_SECRET }}
WFPREV_CLIENT_MEMORY: ${{vars.WFPREV_CLIENT_MEMORY}}
WFPREV_CLIENT_CPU_UNITS : ${{vars.WFPREV_CLIENT_CPU_UNITS}}
Expand Down
34 changes: 34 additions & 0 deletions terraform/alb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,40 @@ resource "aws_lb_listener" "wfprev_main" {
}
}

/// LISTENER RULES////

resource "aws_lb_listener_rule" "wfprev-api" {
listener_arn = aws_lb_listener.wfprev_main.arn

action {
type = "forward"
target_group_arn = aws_alb_target_group.wfprev_api.arn
}

condition {
path_pattern {
values = [for sn in var.PREVENTION_API_NAMES : "/${aws_apigatewayv2_stage.wfprev_stage.name}/${sn}"]
}
}
}

resource "aws_lb_listener_rule" "wfprev-ui" {
listener_arn = aws_lb_listener.wfprev_main.arn

action {
type = "forward"
target_group_arn = aws_alb_target_group.wfprev_ui.arn
}

condition {
path_pattern {
values = [for sn in var.PREVENTION_WAR_NAMES : "/${aws_apigatewayv2_stage.wfprev_stage.name}/${sn}"]
}
}
}




//////////////////////////////
/// TARGET GROUP RESOURCES ///
Expand Down
2 changes: 1 addition & 1 deletion terraform/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ resource "aws_ecs_task_definition" "wfprev_server" {
essential = true
readonlyRootFilesystem = true
name = var.server_container_name
image = var.server_image
image = var.WFPREV_API_IMAGE
repositoryCredentials = {
credentialsParameter = aws_secretsmanager_secret.githubCredentials.arn
}
Expand Down
21 changes: 20 additions & 1 deletion terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ variable "CLIENT_IMAGE" {
type = string
default = ""
}
variable "server_image" {
variable "SERVER_IMAGE" {
description = "Docker image to run in the ECS cluster. _Note_: there is a blank default value, which will cause service and task resource creation to be supressed unless an image is specified."
type = string
default = ""
}

variable "WFPREV_API_IMAGE" {
description = "Docker image to run in the ECS cluster. _Note_: there is a blank default value, which will cause service and task resource creation to be supressed unless an image is specified."
type = string
default = ""
Expand Down Expand Up @@ -201,3 +207,16 @@ variable "DB_SIZE" {
type = number
default = 10
}


variable "PREVENTION_WAR_NAMES" {
type = list(string)
description = "List of paths to point at payroll API"
default = ["wfprev-ui", "wfprev-ui/*"]
}

variable "PREVENTION_API_NAMES" {
type = list(string)
description = "List of paths to point at payroll API"
default = ["wfprev-api", "wfprev-api/*"]
}

0 comments on commit 33e4513

Please sign in to comment.