Skip to content

Commit 68407bd

Browse files
authored
Initial commit
0 parents  commit 68407bd

25 files changed

+1990
-0
lines changed

.github/workflows/release.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
env:
8+
UPLOAD_LAMBDA: false
9+
10+
jobs:
11+
test:
12+
name: Test lambda function
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- name: Install dependencies
19+
run: yarn install
20+
21+
- name: Test
22+
run: yarn test
23+
24+
build-and-upload:
25+
name: Build GitHub action and AWS lambda function
26+
needs: test
27+
if: "false" # To be removed
28+
runs-on: ubuntu-latest
29+
30+
steps:
31+
- uses: actions/checkout@v2
32+
33+
- name: Install dependencies
34+
run: yarn install
35+
36+
- name: Build lambda distribution
37+
run: yarn dist
38+
39+
- name: Configure AWS credentials
40+
uses: aws-actions/configure-aws-credentials@v1
41+
with:
42+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
43+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
44+
aws-region: ${{ secrets.AWS_REGION }}
45+
46+
- name: Upload new build to AWS lambda
47+
run: |
48+
aws lambda update-function-code --function-name "$FUNCTION_ARN" --zip-file "fileb://$(pwd)/out/lambda.zip"
49+
env:
50+
FUNCTION_ARN: ${{ secrets.LAMBDA_FUNCTION_ARN }}
51+
52+
test-new-version:
53+
name: Test uploaded lambda
54+
needs: build-and-upload
55+
if: "false" # To be removed
56+
runs-on: ubuntu-latest
57+
58+
steps:
59+
- uses: actions/checkout@v2
60+
61+
- name: Install dependencies
62+
run: yarn install
63+
64+
- name: Integration tests
65+
run: yarn test
66+
env:
67+
LAMBDA_URL: ${{ secrets.LAMBDA_URL }}

.github/workflows/tests.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
terraform:
11+
name: Validate Terraform code
12+
runs-on: ubuntu-latest
13+
14+
env:
15+
TERRAFORM_VERSION: 0.13.5
16+
TERRAFORM_WORK_DIR: ./terraform
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
22+
- name: Setup Terraform
23+
uses: hashicorp/setup-terraform@v1
24+
with:
25+
terraform_version: ${{ env.TERRAFORM_VERSION }}
26+
27+
- name: Terraform Init
28+
working-directory: ${{ env.TERRAFORM_WORK_DIR }}
29+
run: terraform init
30+
31+
- name: Terraform Validate
32+
working-directory: ${{ env.TERRAFORM_WORK_DIR }}
33+
run: terraform validate
34+
env:
35+
AWS_DEFAULT_REGION: ca-central-1 # https://github.com/hashicorp/terraform/issues/21408#issuecomment-495746582
36+
37+
test:
38+
name: Test lambda function
39+
runs-on: ubuntu-latest
40+
41+
steps:
42+
- uses: actions/checkout@v2
43+
44+
- name: Install dependencies
45+
run: yarn install
46+
47+
- name: Test
48+
run: yarn test
49+
50+
build:
51+
name: Build lambda function
52+
runs-on: ubuntu-latest
53+
54+
steps:
55+
- uses: actions/checkout@v2
56+
57+
- name: Install dependencies
58+
run: yarn install
59+
60+
- name: Build lambda distribution
61+
run: yarn dist

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
/dist
3+
/out
4+
.terraform
5+
yarn-error.log

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"arrowParens": "avoid",
3+
"printWidth": 120,
4+
"singleQuote": false,
5+
"quoteProps": "consistent"
6+
}

.vscode/extensions.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["esbenp.prettier-vscode", "hashicorp.terraform", "annsk.alignment"]
3+
}

.vscode/launch.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Mocha Current File",
11+
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
12+
"args": ["--no-timeouts", "--colors", "${file}", "--require", "ts-node/register"],
13+
"console": "integratedTerminal",
14+
"sourceMaps": true,
15+
"internalConsoleOptions": "neverOpen"
16+
},
17+
{
18+
"type": "node",
19+
"request": "launch",
20+
"name": "Debug File",
21+
"program": "${workspaceFolder}/node_modules/.bin/ts-node",
22+
"args": ["${file}"]
23+
}
24+
]
25+
}

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.tabSize": 2,
4+
"editor.trimAutoWhitespace": true
5+
}

CONTRIBUTING.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Contributing
2+
3+
## Testing
4+
5+
```bash
6+
yarn install
7+
yarn test
8+
```
9+
10+
## Publish a new release
11+
12+
- Bump [`package.json`](./package.json) version (ie.: 1.0.0)
13+
- Create a new release (ie.: v1.0.0)
14+
- A GitHub workflow will automatically run, build and upload the new code to AWS Lambda.
15+
16+
## Note about `aws-sdk`
17+
18+
`aws-sdk` is placed as a devDependency in the projet in order to build smaller zip file for the distribution.
19+
20+
From the [Building Lambda functions with Node.js](https://docs.aws.amazon.com/lambda/latest/dg/lambda-nodejs.html) documentation:
21+
22+
> Your code runs in an environment that includes the AWS SDK for JavaScript, with credentials from an AWS Identity and Access Management (IAM) role that you manage.

0 commit comments

Comments
 (0)