Skip to content

Commit

Permalink
make janitor run on hal
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspervdj committed Dec 12, 2023
1 parent 9051230 commit e6baa12
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ build/zureg-%-lambda/bootstrap: build/image.txt $(SOURCES)
touch $@

# Put all code and dependencies in a zip file we can run on AWS Lambda.
build/zureg-%-lambda/config.json: deploy/env.json
cp $^ $@
build/zureg-%-lambda.zip: build/zureg-%-lambda/bootstrap build/zureg-%-lambda/config.json
build/zureg-%-lambda.zip: build/zureg-%-lambda/bootstrap
zip $@ -j build/zureg-$*-lambda/*
ls -lh $@

Expand Down Expand Up @@ -72,7 +70,13 @@ deploy: build/zureg-janitor-lambda.txt build/bucket.txt
--parameter-overrides \
LambdaBucket=$(shell cat build/bucket.txt) \
JanitorLambdaKey=$(shell cat build/zureg-janitor-lambda.txt) \
EmailAddress=$(shell jq -r '.ZUREG_EMAIL' deploy/env.json)
Hackathon=$(shell jq -r '.ZUREG_HACKATHON' deploy/env.json) \
Email=$(shell jq -r '.ZUREG_EMAIL' deploy/env.json) \
ScannerSecret=$(shell jq -r '.ZUREG_SCANNER_SECRET' deploy/env.json) \
HCaptchaSiteKey=$(shell jq -r '.ZUREG_HCAPTCHA_SITEKEY' deploy/env.json) \
HCaptchaSecret=$(shell jq -r '.ZUREG_HCAPTCHA_SECRET' deploy/env.json) \
DiscordGuildID=$(shell jq -r '.ZUREG_DISCORD_GUILD_ID' deploy/env.json) \
DiscordAccessToken=$(shell jq -r '.ZUREG_DISCORD_ACCESS_TOKEN' deploy/env.json)

# Undo the deployment.
teardown:
Expand Down
40 changes: 38 additions & 2 deletions deploy/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,27 @@ Parameters:
JanitorLambdaKey:
Type: 'String'
Description: 'S3 Key of the janitor lambda.'
EmailAddress:
Hackathon:
Type: 'String'
Description: 'Configuration discriminator, deprecated.'
Email:
Type: 'String'
Description: 'Email address that the registration bot sends email from.'
ScannerSecret:
Type: 'String'
Description: 'Secret for accessing the scanner page.'
HCaptchaSiteKey:
Type: 'String'
Description: 'SiteKey for HCaptcha.'
HCaptchaSecret:
Type: 'String'
Description: 'Secret for HCaptcha.'
DiscordGuildID:
Type: 'String'
Description: 'Guild ID for Discord.'
DiscordAccessToken:
Type: 'String'
Description: 'Access Token for Discord.'

Resources:
# This table stores participant registration using event sourcing: we only
Expand Down Expand Up @@ -85,6 +103,15 @@ Resources:
Code:
S3Bucket: {'Ref': 'LambdaBucket'}
S3Key: {'Ref': 'JanitorLambdaKey'}
Environment:
Variables:
ZUREG_HACKATHON: {'Ref': 'Hackathon'}
ZUREG_EMAIL: {'Ref': 'Email'}
ZUREG_SCANNER_SECRET: {'Ref': 'ScannerSecret'}
ZUREG_HCAPTCHA_SITEKEY: {'Ref': 'HCaptchaSiteKey'}
ZUREG_HCAPTCHA_SECRET: {'Ref': 'HCaptchaSecret'}
ZUREG_DISCORD_GUILD_ID: {'Ref': 'DiscordGuildID'}
ZUREG_DISCORD_ACCESS_TOKEN: {'Ref': 'DiscordAccessToken'}

# This is the role of the lambda: the permissions it needs. We need access to
# logs, and to the database.
Expand Down Expand Up @@ -119,7 +146,7 @@ Resources:
Resource: {'Fn::GetAtt': ['SummariesDatabase', 'Arn']}
- Effect: 'Allow'
Action: ['ses:SendEmail']
Resource: {'Fn::Sub': 'arn:aws:ses:${AWS::Region}:${AWS::AccountId}:identity/${EmailAddress}'}
Resource: {'Fn::Sub': 'arn:aws:ses:${AWS::Region}:${AWS::AccountId}:identity/${Email}'}

# Allow ApiGateway to invoke the function.
#
Expand Down Expand Up @@ -176,6 +203,15 @@ Resources:
Code:
S3Bucket: {'Ref': 'LambdaBucket'}
S3Key: {'Ref': 'JanitorLambdaKey'}
Environment:
Variables:
ZUREG_HACKATHON: {'Ref': 'Hackathon'}
ZUREG_EMAIL: {'Ref': 'Email'}
ZUREG_SCANNER_SECRET: {'Ref': 'ScannerSecret'}
ZUREG_HCAPTCHA_SITEKEY: {'Ref': 'HCaptchaSiteKey'}
ZUREG_HCAPTCHA_SECRET: {'Ref': 'HCaptchaSecret'}
ZUREG_DISCORD_GUILD_ID: {'Ref': 'DiscordGuildID'}
ZUREG_DISCORD_ACCESS_TOKEN: {'Ref': 'DiscordAccessToken'}

JanitorRule:
Type: 'AWS::Events::Rule'
Expand Down

0 comments on commit e6baa12

Please sign in to comment.