This repo contains a basic Node.JS function built in TypeScript. It includes 2 entrypoints: 1 for Docker, and 1 for AWS Lambda.
We're running this in Node LTS v18 because that's the most recent version available in AWS Lambda.
- Run
npm install
[!NOTE] Make sure you're running Node v18
-
Duplicate the
.env.example
file to.env
-
Compile the TypeScript:
npm run build
-
Run the function:
npm start
Each environment will need its own Lambda function. For this example, we have 2 environments: "dev" and "prod".
- Install the AWS CLI
- Create an IAM user and get the access key and secret key
- Set the following secrets in the GitHub:
AWS_ACCESS_KEY_ID
- IAM access keyAWS_SECRET_ACCESS_KEY
- IAM secret key- For more information on creating secrets for GitHub Actions, see "Using secrets in GitHub Actions."
- Follow the steps in "Setup for all AWS"
- Figure out which AWS Region you want to deploy to
- For this example, we're using
us-east-2
- You can change this in the Lambda Deploy Workflow file
- For this example, we're using
- Create 2 Node.JS Lambda functions named
gh-actions-lambda-dev
andgh-actions-lambda-prod
in the AWS region from the previous step.
- Make a commit
- Create a Pull Request into one of the
deploy/lambda/xxx
branches- Either
deploy/lambda/dev
ordeploy/lambda/prod
depending on which environment you want to deploy to
- Either
- Merge the PR
- The GitHub action will start running