Skip to content

Commit

Permalink
[Issue #2548] Swap analytics to new step function pattern (#2546)
Browse files Browse the repository at this point in the history
## Summary

Relates to #2548

### Time to review: __2 mins__

## Changes proposed

Swaps the analytics application to the new step functions pattern that I
originally merged in
#2506. The size of the red
diff and the simplicity of the new configuration show have valuable the
new pattern is.

## Context for reviewers

The step function is now running, but the CLI itself is currently
broken. eg. the CLI is currently broken everywhere, even locally. Fixing
that is someone else's job though!
  • Loading branch information
coilysiren authored Oct 30, 2024
1 parent a12f926 commit cd1844c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 113 deletions.
10 changes: 7 additions & 3 deletions infra/analytics/app-config/env-config/environment-variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ locals {
# This is a map rather than a list so that variables can be easily
# overridden per environment using terraform's `merge` function
default_extra_environment_variables = {
MB_DB_TYPE = "postgres"
MB_DB_USER = "metabaseuser"
MB_DB_DBNAME = "metabase"
MB_DB_TYPE = "postgres"
MB_DB_USER = "metabaseuser"
MB_DB_DBNAME = "metabase"
PY_RUN_APPROACH = "local"
SPRINT_FILE = "/tmp/sprint-data.json"
ISSUE_FILE = "/tmp/issue-data.json"
OUTPUT_DIR = "/tmp/"
}

# Configuration for secrets
Expand Down
4 changes: 4 additions & 0 deletions infra/analytics/app-config/env-config/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ output "service_config" {
}
}

output "scheduled_jobs" {
value = local.scheduled_jobs
}

output "domain" {
value = var.domain
}
15 changes: 15 additions & 0 deletions infra/analytics/app-config/env-config/scheduled_jobs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
locals {
# The `task_command` is what you want your scheduled job to run, for example: ["poetry", "run", "flask"].
# Schedule expression defines the frequency at which the job should run.
# The syntax for `schedule_expression` is explained in the following documentation:
# https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-scheduled-rule-pattern.html
# The `state` is the state of the scheduled job. It can be either "ENABLED" or "DISABLED".

scheduled_jobs = {
sprint-reports = {
task_command = ["make", "gh-data-export", "sprint-reports"]
schedule_expression = "rate(1 days)"
state = "ENABLED"
}
}
}
4 changes: 4 additions & 0 deletions infra/analytics/service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ module "service" {
cpu = 1024
memory = 2048

readonly_root_filesystem = false

# This is a task based service, not a web server, so we don't need to run any instances of the service at rest.
desired_instance_count = 0

Expand All @@ -123,6 +125,8 @@ module "service" {
app_access_policy_arn = data.aws_iam_policy.app_db_access_policy[0].arn
migrator_access_policy_arn = data.aws_iam_policy.migrator_db_access_policy[0].arn

scheduled_jobs = local.environment_config.scheduled_jobs

db_vars = {
security_group_ids = data.aws_rds_cluster.db_cluster[0].vpc_security_group_ids
connection_info = {
Expand Down
110 changes: 0 additions & 110 deletions infra/analytics/service/sfn_sprint_reports.tf

This file was deleted.

0 comments on commit cd1844c

Please sign in to comment.