-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat: adds infra required to support digest emails #2023
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2d4842e
feat: adds infra required to support digest emails
as1729 ba08fd0
fix: lint
as1729 852f23f
fix: adds consumer_task_efs_volume_mounts
as1729 7e768c9
chore: add placeholder scripts
as1729 cee8e3b
fix: applying changes from feedback #2023
dysmento ff41673
fix: fix naming and formatting for terraform
dysmento 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 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,7 @@ | ||
async function run() { | ||
console.log('getGrantsAndUsers.run() is called'); | ||
} | ||
|
||
module.exports = { | ||
run, | ||
}; |
This file contains 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,7 @@ | ||
function main() { | ||
console.log('sendEmail.main() is called'); | ||
} | ||
|
||
if (require.main === module) { | ||
main().then(() => process.exit()); | ||
} |
This file contains 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,19 @@ | ||
async function run() { | ||
console.log('grants-digest-cron run() is called'); | ||
|
||
/* | ||
The cron is responsible for: | ||
1. Identifying all unique criteria from grants_saved_searches | ||
2. Constructing a JSON object with the following for each criteria: | ||
{ | ||
criteria: <criteria>, | ||
user_ids: [<user_id>, ...], | ||
email_date: <email_date>, | ||
} | ||
3. Publish each object created above as a new message in an SQS queue. | ||
*/ | ||
} | ||
|
||
module.exports = { | ||
run, | ||
}; |
This file contains 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,25 @@ | ||
function main() { | ||
console.log('getGrants.js.main() is called'); | ||
/* | ||
The getGrants.js script is responsible for: | ||
1. Receiving messages from an SQS queue | ||
2. Parse the message body into an object with the following shape: | ||
{ | ||
criteria: <criteria>, | ||
user_ids: [<user_id>, ...], | ||
email_date: <email_date>, | ||
} | ||
3. For each object, query the grants table for grants that match the criteria | ||
4. For each user in user_ids, create a JSON object with the following shape: | ||
{ | ||
user_id: <user_id>, | ||
grant_ids: [<grant_id>, ...], | ||
email_date: <email_date>, | ||
} | ||
5. Publish each object created above as a new message in an SQS queue. | ||
*/ | ||
} | ||
|
||
if (require.main === module) { | ||
main().then(() => process.exit()); | ||
} |
This file contains 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,7 @@ | ||
function main() { | ||
console.log('sendEmail.main() is called'); | ||
} | ||
|
||
if (require.main === module) { | ||
main().then(() => process.exit()); | ||
} |
This file contains 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,7 @@ | ||
function main() { | ||
console.log('getGrantsAndUsers.js.main() is called'); | ||
} | ||
|
||
if (require.main === module) { | ||
main().then(() => process.exit()); | ||
} |
This file contains 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
This file contains 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,62 @@ | ||
module "digest_email_kickoff_cron" { | ||
source = "../scheduled_ecs_task" | ||
enabled = var.enabled && var.enable_digest_email_criteria_cron | ||
|
||
name_prefix = "${var.namespace}-digest-cron-" | ||
description = "Executes an ECS task that kicks-off the grants email digest send daily, between 9am - 10am ET." | ||
|
||
// Schedule | ||
schedule_expression = "cron(0 9 * * ? *)" | ||
schedule_expression_timezone = "America/New_York" | ||
flexible_time_window = { hours = 1 } | ||
retry_policy_max_attempts = 10 | ||
retry_policy_max_event_age = { hours = 4 } | ||
|
||
// Permissions | ||
task_role_arn = join("", aws_ecs_task_definition.default.*.task_role_arn) | ||
task_execution_role_arn = join("", aws_ecs_task_definition.default.*.execution_role_arn) | ||
permissions_boundary_arn = var.permissions_boundary_arn | ||
|
||
// Task settings | ||
cluster_arn = join("", data.aws_ecs_cluster.default.*.arn) | ||
task_definition_arn = join("", aws_ecs_task_definition.default.*.arn) | ||
task_revision = "LATEST" | ||
launch_type = "FARGATE" | ||
enable_ecs_managed_tags = true | ||
enable_execute_command = false | ||
|
||
task_override = jsonencode({ | ||
containerOverrides = [ | ||
{ | ||
name = "api" | ||
command = [ | ||
"node", | ||
"-e", | ||
"require('./src/lib/grants-digest').run().then(() => { process.exit(0); }).catch((err) => { console.log(err); process.exit(1); });" | ||
] | ||
environment = [ | ||
{ | ||
name = "ENABLE_DIGEST_EMAIL_CRITERIA_CRON", | ||
value = "true" | ||
}, | ||
] | ||
}, | ||
] | ||
}) | ||
|
||
network_configuration = { | ||
assign_public_ip = false | ||
security_groups = [module.digest_email_kickoff_cron_security_group.id] | ||
subnets = var.subnet_ids | ||
} | ||
} | ||
|
||
module "digest_email_kickoff_cron_security_group" { | ||
source = "cloudposse/security-group/aws" | ||
version = "2.2.0" | ||
|
||
namespace = var.namespace | ||
vpc_id = var.vpc_id | ||
attributes = ["digest_email_kickoff"] | ||
allow_all_egress = true | ||
} |
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏