Create infrastructure on AWS to handle webhooks with reliability
create AWS IAM User on AWS IAM and set:
- access type: Programmatic access
- policies: AdministratorAccess
save access_key
and secret_key
run the commands below replacing values for your access and secret keys:
$ export AWS_ACCESS_KEY_ID="anaccesskey"
$ export AWS_SECRET_ACCESS_KEY="asecretkey"
run the commands below:
$ cd terraform/
$ terraform init # to download all dependencies
$ terraform plan # to plan a modification
$ terraform apply # to apply this change
After the terraform apply
you can see the API Gateway endpoint in terminal.
Use this url to make a HTTP POST
run terraform destroy
to clean up.
The architecture created is:
- API Gateway receive HTTP request (Webhook endpoint) and send to Lambda Callback
- Lambda Callback write request's body in SQS Queue
- A new event in SQS Queue start the Lambda Worker
- Lambda Worker process the message
This architecture works, but we can simplify to:
- API Gateway receive HTTP request (Webhook endpoint) and write it in SQS Queue
- A new event in SQS Queue start the Lambda Worker
- Lambda Worker process the message