This project deploys AWS infrastructure using Terraform. The main purpose of this infrastructure is to retrieve the price of a cryptocurrency token using the Coingecko API. The infrastructure includes an API Gateway (HTTP API) and a Lambda function.
⋅ Terraform installed in your environment.
⋅ AWS account with sufficient permissions to create and manage AWS resources.
- Clone the repository to your local machine.
- Navigate to the root of the project in the terminal.
- Set up your own AWS credentials in the
main.tf
file. - Initialize Terraform by running
terraform init
. - Create an execution plan by running
terraform plan
. - Apply the plan by running
terraform apply
. - You'll see an output in the terminal when the "apply" finishes, showing the API Endpoint URL
This file contains the basic Terraform code containing the credentials and output parameters. that deploys the AWS infrastructure. It creates an API Gateway (REST API) and a Lambda function. This includes deploying the API gateway, linking it to the Lambda function so it triggers it when it's invoked, and uploads all the necessary files to the Lambda function.
This Terraform config file deploys the API GW in AWS and performs the needed configurations on this service.
This Terraform config file deploys the Lambda function in AWS and performs the needed configurations on this service.
This Terraform config file defines the needed IAM roles and policies to be attached to the services, so the Lambda function can be invoked through the API GW.
This file contains the Python code for the Lambda function that retrieves the price of a cryptocurrency token.
This file contains all the necessary files for the Lambda function to work (source code, and needed libraries)
The Terraform code creates the following AWS resources:
⋅ API Gateway (REST API)
⋅ Lambda function
The API Gateway is connected to the Lambda function. When a GET request is made to the API with a "symbol"
querystring parameter, the Lambda function retrieves the price of the corresponding cryptocurrency token.
https://{base-url}/price?symbol=btc
Don't forget to destroy the infrastructure when you are done using it, by running terraform destroy
.