Skip to content

Commit

Permalink
Schedule dist-alerts sync for 1pm PST every day
Browse files Browse the repository at this point in the history
New data from UMD should only be available on Saturday morning, so
should only do a full run generating a new version once a week on
Saturday/Sunday
  • Loading branch information
danscales committed Nov 21, 2024
1 parent b55f67a commit 87cd05c
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion terraform/modules/datapump/cloudwatch.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Note: when it says est/EST here, it really means PST (Pacific Standard time)
# The hours in the cron() expression are in UTC.

resource "aws_cloudwatch_event_rule" "everyday-11-pm-est" {
name = substr("everyday-11-pm-est${local.name_suffix}", 0, 64)
description = "Run everyday at 11 pm EST"
Expand Down Expand Up @@ -26,6 +29,15 @@ resource "aws_cloudwatch_event_rule" "everyday-3-am-est" {
tags = local.tags
}

resource "aws_cloudwatch_event_rule" "everyday-1-pm-est" {
name = substr("everyday-1-pm-est${local.name_suffix}", 0, 64)
description = "Run everyday at 1 pm EST"
schedule_expression = "cron(0 21 ? * * *)"
tags = local.tags
}

# The count condition in each of the resources below ensures that the CloudWatch
# events only happen in production.
resource "aws_cloudwatch_event_target" "sync-areas" {
rule = aws_cloudwatch_event_rule.everyday-7-pm-est.name
target_id = substr("${local.project}-sync-areas${local.name_suffix}", 0, 64)
Expand Down Expand Up @@ -78,4 +90,15 @@ resource "aws_cloudwatch_event_target" "sync-integrated-alerts" {
input = "{\"command\": \"sync\", \"parameters\": {\"types\": [\"integrated_alerts\"]}}"
role_arn = aws_iam_role.datapump_states.arn
count = var.environment == "production" ? 1 : 0
}
}

# Run every day at 1pm PST, but new data from UMD should only be available on Saturday morning,
# so should only do a full run generating a new version once a week on Saturday/Sunday.
resource "aws_cloudwatch_event_target" "sync-dist-alerts" {
rule = aws_cloudwatch_event_rule.everyday-1-pm-est.name
target_id = substr("${local.project}-sync-integrated-alerts${local.name_suffix}", 0, 64)
arn = aws_sfn_state_machine.datapump.id
input = "{\"command\": \"sync\", \"parameters\": {\"types\": [\"integrated_alerts\"]}}"
role_arn = aws_iam_role.datapump_states.arn
count = var.environment == "production" ? 1 : 0
}

0 comments on commit 87cd05c

Please sign in to comment.