Skip to content

Commit ae98be0

Browse files
authored
feat: Added redoer service. (#33)
1 parent 10082ca commit ae98be0

File tree

9 files changed

+102
-4
lines changed

9 files changed

+102
-4
lines changed

.github/actions/setup-opentofu/action.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ runs:
3636
"database_skip_final_snapshot" "deletion_protection"
3737
"deployment_environments" "environment" "export_expiration"
3838
"image_tags_mutable" "key_recovery_period" "log_level" "program"
39-
"project" "region" "repository"
39+
"project" "redoer_container_count" "redoer_cpu" "redoer_memory"
40+
"region" "repository"
4041
)
4142
for var in ${variables[@]}; do
4243
name="TF_VAR_$(echo $var | tr '[:lower:]' '[:upper:]')"

.github/workflows/deploy.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ jobs:
5454
TF_VAR_LOG_LEVEL: ${{ secrets.TF_VAR_LOG_LEVEL }}
5555
TF_VAR_PROGRAM: ${{ secrets.TF_VAR_PROGRAM }}
5656
TF_VAR_PROJECT: ${{ secrets.TF_VAR_PROJECT }}
57+
TF_VAR_REDOER_CONTAINER_COUNT: ${{ secrets.TF_VAR_REDOER_CONTAINER_COUNT }}
58+
TF_VAR_REDOER_CPU: ${{ secrets.TF_VAR_REDOER_CPU }}
59+
TF_VAR_REDOER_MEMORY: ${{ secrets.TF_VAR_REDOER_MEMORY }}
5760
TF_VAR_REPO_OIDC_ARN: ${{ secrets.TF_VAR_REPO_OIDC_ARN }}
5861
TF_VAR_REPOSITORY: ${{ secrets.TF_VAR_REPOSITORY }}
5962
TF_VAR_VPC_CIDR: ${{ secrets.TF_VAR_VPC_CIDR }}
@@ -105,6 +108,9 @@ jobs:
105108
TF_VAR_LOG_LEVEL: ${{ secrets.TF_VAR_LOG_LEVEL }}
106109
TF_VAR_PROJECT: ${{ secrets.TF_VAR_PROJECT }}
107110
TF_VAR_PROGRAM: ${{ secrets.TF_VAR_PROGRAM }}
111+
TF_VAR_REDOER_CONTAINER_COUNT: ${{ secrets.TF_VAR_REDOER_CONTAINER_COUNT }}
112+
TF_VAR_REDOER_CPU: ${{ secrets.TF_VAR_REDOER_CPU }}
113+
TF_VAR_REDOER_MEMORY: ${{ secrets.TF_VAR_REDOER_MEMORY }}
108114
TF_VAR_REPO_OIDC_ARN: ${{ secrets.TF_VAR_REPO_OIDC_ARN }}
109115
TF_VAR_REPOSITORY: ${{ secrets.TF_VAR_REPOSITORY }}
110116
TF_VAR_VPC_CIDR: ${{ secrets.TF_VAR_VPC_CIDR }}

.github/workflows/plan.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ on:
5454
required: false
5555
TF_VAR_PROJECT:
5656
required: false
57+
TF_VAR_REDOER_CONTAINER_COUNT:
58+
required: false
59+
TF_VAR_REDOER_CPU:
60+
required: false
61+
TF_VAR_REDOER_MEMORY:
62+
required: false
5763
TF_VAR_REPOSITORY:
5864
required: false
5965
workflow_dispatch:
@@ -120,6 +126,9 @@ jobs:
120126
TF_VAR_LOG_LEVEL: ${{ secrets.TF_VAR_LOG_LEVEL }}
121127
TF_VAR_PROJECT: ${{ secrets.TF_VAR_PROJECT }}
122128
TF_VAR_PROGRAM: ${{ secrets.TF_VAR_PROGRAM }}
129+
TF_VAR_REDOER_CONTAINER_COUNT: ${{ secrets.TF_VAR_REDOER_CONTAINER_COUNT }}
130+
TF_VAR_REDOER_CPU: ${{ secrets.TF_VAR_REDOER_CPU }}
131+
TF_VAR_REDOER_MEMORY: ${{ secrets.TF_VAR_REDOER_MEMORY }}
123132
TF_VAR_REPO_OIDC_ARN: ${{ secrets.TF_VAR_REPO_OIDC_ARN }}
124133
TF_VAR_REPOSITORY: ${{ secrets.TF_VAR_REPOSITORY }}
125134
TF_VAR_VPC_CIDR: ${{ secrets.TF_VAR_VPC_CIDR }}

.github/workflows/pull-request.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ jobs:
7777
TF_VAR_KEY_RECOVERY_PERIOD: ${{ secrets.TF_VAR_KEY_RECOVERY_PERIOD }}
7878
TF_VAR_LOG_LEVEL: ${{ secrets.TF_VAR_LOG_LEVEL }}
7979
TF_VAR_PROGRAM: ${{ secrets.TF_VAR_PROGRAM }}
80+
TF_VAR_REDOER_CONTAINER_COUNT: ${{ secrets.TF_VAR_REDOER_CONTAINER_COUNT }}
81+
TF_VAR_REDOER_CPU: ${{ secrets.TF_VAR_REDOER_CPU }}
82+
TF_VAR_REDOER_MEMORY: ${{ secrets.TF_VAR_REDOER_MEMORY }}
8083
TF_VAR_REPO_OIDC_ARN: ${{ secrets.TF_VAR_REPO_OIDC_ARN }}
8184
TF_VAR_REPOSITORY: ${{ secrets.TF_VAR_REPOSITORY }}
8285
TF_VAR_VPC_CIDR: ${{ secrets.TF_VAR_VPC_CIDR }}

Dockerfile.redoer

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ ENV PYTHONPATH=/opt/senzing/er/sdk/python:/app
2121
# Flush buffer - helps with print statements.
2222
ENV PYTHONUNBUFFERED=1
2323

24+
# Define volumes necessary to support a read-only root filesystem on ECS
25+
# Fargate.
26+
VOLUME ["/home/senzing", "/var/lib/amazon", "/var/log"]
27+
2428
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD ./healthcheck.sh redoer.py || exit 1
2529

2630
CMD ["python3", "redoer.py"]

tofu/config/service/main.tf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,23 @@ module "system" {
2424
key_recovery_period = var.key_recovery_period
2525
logging_bucket = module.inputs.values["logging/bucket"]
2626
logging_key_arn = module.inputs.values["logging/key"]
27+
log_level = var.log_level
2728
tags = merge({ awsApplication : module.inputs.values["application/tag"] }, var.tags)
2829
vpc_id = module.inputs.values["vpc/id"]
29-
database_subnets = split(",", module.inputs.values["vpc/private_subnets"])
30-
container_subnets = split(",", module.inputs.values["vpc/private_subnets"])
3130

31+
database_subnets = split(",", module.inputs.values["vpc/private_subnets"])
3232
apply_database_updates_immediately = var.apply_database_updates_immediately
3333
database_instance_count = var.database_instance_count
3434
database_skip_final_snapshot = var.database_skip_final_snapshot
3535
deletion_protection = var.deletion_protection
3636
image_tag = local.image_tag
3737
image_tags_mutable = var.image_tags_mutable
38-
log_level = var.log_level
3938

39+
container_subnets = split(",", module.inputs.values["vpc/private_subnets"])
4040
consumer_container_count = var.consumer_container_count
4141
consumer_cpu = var.consumer_cpu
4242
consumer_memory = var.consumer_memory
43+
redoer_container_count = var.redoer_container_count
44+
redoer_cpu = var.redoer_cpu
45+
redoer_memory = var.redoer_memory
4346
}

tofu/config/service/variables.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,24 @@ variable "project" {
103103
default = "sqs-senzing"
104104
}
105105

106+
variable "redoer_container_count" {
107+
type = number
108+
description = "Desired number of redoer containers to run."
109+
default = 1
110+
}
111+
112+
variable "redoer_cpu" {
113+
type = number
114+
description = "Number of virtual CPUs to allocate to each redoer container."
115+
default = 1
116+
}
117+
118+
variable "redoer_memory" {
119+
type = number
120+
description = "Amount of memory (in MiB) to allocate to each redoer container."
121+
default = 4096
122+
}
123+
106124
variable "region" {
107125
type = string
108126
description = "AWS region where resources should be deployed."

tofu/modules/system/ecs.tf

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,42 @@ module "consumer" {
121121
tags = var.tags
122122
}
123123

124+
module "redoer" {
125+
source = "../persistent_service"
126+
depends_on = [aws_iam_policy.secrets]
127+
128+
project = var.project
129+
environment = var.environment
130+
service = "redoer"
131+
image_tag = var.image_tag
132+
image_tags_mutable = var.image_tags_mutable
133+
force_delete = !var.deletion_protection
134+
container_key_arn = aws_kms_key.container.arn
135+
logging_key_id = var.logging_key_arn
136+
otel_ssm_parameter_arn = module.otel_config.ssm_parameter_arn
137+
execution_policies = [aws_iam_policy.secrets.arn]
138+
task_policies = [aws_iam_policy.queue.arn]
139+
security_groups = [module.task_security_group.security_group_id]
140+
cluster_arn = module.ecs.arn
141+
container_subnets = var.container_subnets
142+
desired_containers = var.redoer_container_count
143+
cpu = var.redoer_cpu
144+
memory = var.redoer_memory
145+
dockerfile = "Dockerfile.redoer"
146+
docker_context = "${path.module}/../../../"
147+
148+
environment_variables = {
149+
LOG_LEVEL : var.log_level
150+
Q_URL : module.sqs.queue_url
151+
}
152+
153+
environment_secrets = {
154+
SENZING_ENGINE_CONFIGURATION_JSON = module.senzing_config.ssm_parameter_arn
155+
}
156+
157+
tags = var.tags
158+
}
159+
124160
module "exporter" {
125161
source = "../ephemeral_service"
126162
depends_on = [aws_iam_policy.exports, aws_iam_policy.secrets]

tofu/modules/system/variables.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,24 @@ variable "project" {
157157
default = "sqs-senzing"
158158
}
159159

160+
variable "redoer_container_count" {
161+
type = number
162+
description = "Desired number of redoer containers to run."
163+
default = 1
164+
}
165+
166+
variable "redoer_cpu" {
167+
type = number
168+
description = "Number of virtual CPUs to allocate to each redoer container."
169+
default = 1
170+
}
171+
172+
variable "redoer_memory" {
173+
type = number
174+
description = "Amount of memory (in MiB) to allocate to each redoer container."
175+
default = 4096
176+
}
177+
160178
variable "tags" {
161179
type = map(string)
162180
description = "Tags to apply to resources."

0 commit comments

Comments
 (0)