Skip to content
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

Add components for cache invalidator lambda #1820

Merged
merged 3 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/lambda-zip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,38 @@ jobs:
with:
args: zip -qq -r -j bans-and-prohibitions-monitor.zip lambda/bans-and-prohibitions-monitor/bans-and-prohibitions


- uses: montudor/action-zip@v1
with:
args: zip -qq -r -j evacuation-orders-monitor.zip lambda/evacuation-orders-monitor/evacuation-orders

- uses: actions/setup-node@v4
with:
node-version: 14

- name: run npm install for cache invalidator
run: |
cd lambda/cache-invalidator/wfnews-cache-invalidator
npm install

- uses: montudor/action-zip@v1
with:
args: zip -qq -r -j wfnews-cache-invalidator.zip lambda/cache-invalidator/wfnews-cache-invalidator

- name: Make staging directory, copy files
run: |
mkdir staging
echo ${{hashFiles('**/active-fire-monitor.zip')}} >> staging/active-fire-monitor-hash.txt
echo ${{hashFiles('**/area-restrictions-monitor.zip')}} >> staging/area-restrictions-monitor-hash.txt
echo ${{hashFiles('**/bans-and-prohibitions-monitor.zip')}} >> staging/bans-and-prohibitions-monitor-hash.txt
echo ${{hashFiles('**/evacuation-orders-monitor.zip')}} >> staging/evacuation-orders-monitor-hash.txt
echo ${{hashFiles('**/wfnews-cache-invalidator.zip')}} >> staging/wfnews-cache-invalidator-hash.txt
echo ${{hashFiles('**/python.zip')}} >> staging/python-hash
cp active-fire-monitor.zip staging/active-fire-monitor.zip
cp area-restrictions-monitor.zip staging/area-restrictions-monitor.zip
cp bans-and-prohibitions-monitor.zip staging/bans-and-prohibitions-monitor.zip
cp evacuation-orders-monitor.zip staging/evacuation-orders-monitor.zip
cp wfnews-cache-invalidator.zip staging/wfnews-cache-invalidator.zip
cp lambda/lambda-layer/python.zip staging/python.zip

- name: Configure AWS Credentials
Expand Down
9 changes: 7 additions & 2 deletions terraform/lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ data "aws_s3_object" "evacuation_orders_monitor_hash" {
key = "evacuation-orders-monitor-hash.txt"
}

data "aws_s3_object" "wfnews_cache_invalidator_hash" {
bucket = data.aws_s3_bucket.wfnews_lambda.bucket
key = "wfnews-cache-invalidator-hash.txt"
}

resource "aws_lambda_function" "monitor-bans-prohibitions" {
function_name = "wfnews-monitor-bans-${var.target_env}"
s3_bucket = data.aws_s3_bucket.wfnews_lambda.bucket
Expand Down Expand Up @@ -129,7 +134,7 @@ resource "aws_lambda_function" "wfnews-cache-invalidator" {
function_name = "wfnews-cache-invalidator-${var.target_env}"
s3_bucket = data.aws_s3_bucket.wfnews_lambda.bucket
s3_key = "wfnews-cache-invalidator.zip"
source_code_hash = data.aws_s3_object.wfnews-cache-invalidator_hash.body
source_code_hash = data.aws_s3_object.wfnews_cache_invalidator_hash.body
role = aws_iam_role.lambda_iam_role.arn
handler = "app.lambda_handler"
runtime = "nodejs18.x"
Expand All @@ -138,7 +143,7 @@ resource "aws_lambda_function" "wfnews-cache-invalidator" {
variables = {
S3_BUCKET = aws_s3_bucket.wfnews-monitor-queue-bucket.id
SECRET_NAME = var.SECRET_NAME
DISTRIBUTION_IDS = "${aws_cloudfront_distribution.wfnews_openmaps_cache.id},${aws_cloudfront_distribution.wfnews_services6_cache.id}"
DISTRIBUTION_IDS = "${aws_cloudfront_distribution.wfnews_openmaps_cache[0].id},${aws_cloudfront_distribution.wfnews_services6_cache[0].id}"
}
}
vpc_config {
Expand Down
Loading