Skip to content

Commit

Permalink
try using serverless
Browse files Browse the repository at this point in the history
  • Loading branch information
rhyek committed Apr 1, 2024
1 parent 34603f5 commit d417f80
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 36 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,13 @@ jobs:
- name: Set deploy params
run: |
echo "LAMBDA_ROLE_ARN=${{ needs.terraform.outputs.iam_lambda_role_arn }}" >> $GITHUB_ENV
- name: Deploy
- name: Install Serverless
run: |
curl -o- -L https://slss.io/install | bash
echo "$HOME/.serverless/bin" >> $GITHUB_PATH
- name: Deploy with Serverless
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: make deploy
run: |
cd ./deploy
serverless deploy
2 changes: 1 addition & 1 deletion projects/update-ynab/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
bootstrap
bin/
update-ynab.zip
7 changes: 1 addition & 6 deletions projects/update-ynab/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
zipfile = update-ynab.zip

test:
go test ./...
build: # https://docs.aws.amazon.com/lambda/latest/dg/golang-package.html
GOOS=linux GOARCH=arm64 go build -tags lambda.norpc -o bootstrap main.go
zip ${zipfile} bootstrap
deploy:
ZIPFILE=${zipfile} ./scripts/deploy.sh
GOOS=linux GOARCH=arm64 go build -tags lambda.norpc -o bin/bootstrap main.go
29 changes: 29 additions & 0 deletions projects/update-ynab/deploy/serverless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
service: update-ynab-lambda
frameworkVersion: '3'

provider:
name: aws
runtime: provided.al2023
architecture: arm64

package:
individually: true

functions:
cronHandler:
handler: bootstrap
memorySize: 128
timeout: 30 # 30 seconds
environment:
DATABASE_URL: ${env:DATABASE_URL}
role: ${env:LAMBDA_ROLE_ARN}
events:
# Invoke Lambda function every day at 7:30am Guatemala time
- schedule:
method: scheduler # use AWS::Scheduler::Schedule (EventBridge rule) instead of AWS::Events::Rule (CloudWatch Events rule)
rate: cron(30 7 * * ? *)
timezone: America/Guatemala # possible with AWS::Scheduler::Schedule
package:
patterns:
- '!**/**'
- './bin/bootstrap'
27 changes: 0 additions & 27 deletions projects/update-ynab/scripts/deploy.sh

This file was deleted.

0 comments on commit d417f80

Please sign in to comment.