This project is a basic sample of API gateway integration with a SQS queue and a lambda consumer.
Below is an architectural drawing with resource communications.
- Terraform v0.13.5
- Your aws credentials configured
- A s3 bucket for your tf.state file
First, make sure you have your credentials file configured with your AWS account in your local machine.
[default]
aws_access_key_id = YOUR-ACCESS-KEY-ID
aws_secret_access_key = YOU-SECRET-ACCESS-KEY
Create a bucket in s3 and change your main.tf with your bucket name.
terraform {
backend "s3" {
bucket = "my-bucket-name"
key = "tf-state/terraform.tfstate"
region = "us-east-1"
}
}
Initialize Terraform.
$ terraform init
Make a plan in the project root directory. (optional)
$ terraform plan
Run apply to create all the resources.
$ terraform apply
After applying, the output shows the API gateway endpoints resources.
Outputs:
apigateway_resource_one = https://id.execute-api.us-east-1.amazonaws.com/dev/one
apigateway_resource_two = https://id.execute-api.us-east-1.amazonaws.com/dev/two
To invoke your api gateway and test your infrastructure, import the collection and environment from the docs folder and set your api gateway id generated from apply.
To destroy all your infrastructure, just run terraform destroy.
$ terraform destroy
- https://registry.terraform.io/providers/hashicorp/aws/latest/docs
- https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html
- https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-method-request-validation.html
- https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-integration-settings.html
Thanks goes to these wonderful people (emoji key):
Leonardo Menezes 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!