To run the example first setup your AWS credentials. You also need to install apex and Terraform cli.
$ git clone https://github.com./stanislaw-glogowski/apex-typescript-example.git && cd ./apex-typescript-example
$ npm install
$ apex infra apply # creating lambda role
$ apex deploy
$ apex infra apply # creating api gateway
You can test your lambda function using apex cli
$ apex invoke lambda_with_api_gateway_event < ./events/api-gateway.json
output:
{
"statusCode": 200,
"headers": {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": true,
"Content-Type": "application/json"
},
"body": "{\"method\":\"GET\"}"
}
In addition, lambda_with_api_gateway_event
is integrated with API Gateway in infrastructure configuration.
After successful installation there should be apex-typescript-example_api_gateway
api, available from AWS console.
$ apex infra destroy # destroying infrastructure
$ apex infra apply # creating lambda role (needed for deleting lambdas)
$ apex delete # deleting lambdas
$ apex infra destroy # final infrastructure destroying
The MIT License