generated from agendrix/terraform-aws-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 68407bd
Showing
25 changed files
with
1,990 additions
and
0 deletions.
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,67 @@ | ||
name: Release | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
env: | ||
UPLOAD_LAMBDA: false | ||
|
||
jobs: | ||
test: | ||
name: Test lambda function | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Test | ||
run: yarn test | ||
|
||
build-and-upload: | ||
name: Build GitHub action and AWS lambda function | ||
needs: test | ||
if: "false" # To be removed | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Build lambda distribution | ||
run: yarn dist | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
|
||
- name: Upload new build to AWS lambda | ||
run: | | ||
aws lambda update-function-code --function-name "$FUNCTION_ARN" --zip-file "fileb://$(pwd)/out/lambda.zip" | ||
env: | ||
FUNCTION_ARN: ${{ secrets.LAMBDA_FUNCTION_ARN }} | ||
|
||
test-new-version: | ||
name: Test uploaded lambda | ||
needs: build-and-upload | ||
if: "false" # To be removed | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Integration tests | ||
run: yarn test | ||
env: | ||
LAMBDA_URL: ${{ secrets.LAMBDA_URL }} |
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,61 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
terraform: | ||
name: Validate Terraform code | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
TERRAFORM_VERSION: 0.13.5 | ||
TERRAFORM_WORK_DIR: ./terraform | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Terraform | ||
uses: hashicorp/setup-terraform@v1 | ||
with: | ||
terraform_version: ${{ env.TERRAFORM_VERSION }} | ||
|
||
- name: Terraform Init | ||
working-directory: ${{ env.TERRAFORM_WORK_DIR }} | ||
run: terraform init | ||
|
||
- name: Terraform Validate | ||
working-directory: ${{ env.TERRAFORM_WORK_DIR }} | ||
run: terraform validate | ||
env: | ||
AWS_DEFAULT_REGION: ca-central-1 # https://github.com/hashicorp/terraform/issues/21408#issuecomment-495746582 | ||
|
||
test: | ||
name: Test lambda function | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Test | ||
run: yarn test | ||
|
||
build: | ||
name: Build lambda function | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Build lambda distribution | ||
run: yarn dist |
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,5 @@ | ||
node_modules | ||
/dist | ||
/out | ||
.terraform | ||
yarn-error.log |
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,6 @@ | ||
{ | ||
"arrowParens": "avoid", | ||
"printWidth": 120, | ||
"singleQuote": false, | ||
"quoteProps": "consistent" | ||
} |
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,3 @@ | ||
{ | ||
"recommendations": ["esbenp.prettier-vscode", "hashicorp.terraform", "annsk.alignment"] | ||
} |
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 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Mocha Current File", | ||
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha", | ||
"args": ["--no-timeouts", "--colors", "${file}", "--require", "ts-node/register"], | ||
"console": "integratedTerminal", | ||
"sourceMaps": true, | ||
"internalConsoleOptions": "neverOpen" | ||
}, | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Debug File", | ||
"program": "${workspaceFolder}/node_modules/.bin/ts-node", | ||
"args": ["${file}"] | ||
} | ||
] | ||
} |
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,5 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"editor.tabSize": 2, | ||
"editor.trimAutoWhitespace": 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Contributing | ||
|
||
## Testing | ||
|
||
```bash | ||
yarn install | ||
yarn test | ||
``` | ||
|
||
## Publish a new release | ||
|
||
- Bump [`package.json`](./package.json) version (ie.: 1.0.0) | ||
- Create a new release (ie.: v1.0.0) | ||
- A GitHub workflow will automatically run, build and upload the new code to AWS Lambda. | ||
|
||
## Note about `aws-sdk` | ||
|
||
`aws-sdk` is placed as a devDependency in the projet in order to build smaller zip file for the distribution. | ||
|
||
From the [Building Lambda functions with Node.js](https://docs.aws.amazon.com/lambda/latest/dg/lambda-nodejs.html) documentation: | ||
|
||
> 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. |
Oops, something went wrong.