terraform-containerization-bookstore-api

Containerization of Python Flask Bookstore Web API with MySQL using Docker Compose and Terraform

Terraform Containerization Bookstore Api Github top language Github language count Repository size License


About   |   Case Study Details   |   Technologies   |   Requirements   |   Starting   |   License   |   Author


:dart: About

Bookstore Web API Application aims to create a bookstore web service using Docker to have the understanding to dockerization of an application. The application code is to be deployed as a RESTful web service with Flask using Dockerfile and Docker Compose on AWS Elastic Compute Cloud (EC2) Instance using Terraform.

Project Architecture

Project

:sparkles: Case Study Details

HTTP Method Action Example
GET Obtain information about a resource http://[ec2-hostname]/books (retrieves list of all books)
GET Obtain information about a resource http://[ec2-hostname]/books/123 (retrieves book with id=123)
POST Create a new resource http://[ec2-hostname]/books (creates a new book, from data provided with the request)
PUT Update a resource http://[ec2-hostname]/books/123 (updates the book with id=123, from data provided with the request)
DELETE Delete a resource http://[ec2-hostname]/books/123 (delete the book with id=123)

:rocket: Technologies

The following tools were used in this project:

:white_check_mark: Requirements

Before starting :checkered_flag:, you need to have Git, Docker and Terraform installed on your machine.

:checkered_flag: Starting

# Clone this project
git clone https://github.com/devenes/terraform-containerization-bookstore-api

# Access
cd terraform-containerization-bookstore-api

# Initialize terraform
terraform init

# Apply terraform
terraform apply -auto-approve

note

GET

curl --request GET \
--url 'http://ec2-52-91-247-19.compute-1.amazonaws.com/books' \
--header 'content-type: application/json'

POST

curl --request POST \
--url 'http://ec2-52-91-247-19.compute-1.amazonaws.com/books' \
--header 'content-type: application/json' \
--data '{"author":"Paulo Coelho", "title":"The Alchemist", "is_sold":true}'
curl --request POST \
--url 'http://ec2-52-91-247-19.compute-1.amazonaws.com/books' \
--header 'content-type: application/json' \
--data '{"author":"Gabriel Garcia Marquez", "title":"One Hundred Years of Solitude", "is_sold":true}'
curl --request POST \
--url 'http://ec2-52-91-247-19.compute-1.amazonaws.com/books' \
--header 'content-type: application/json' \
--data '{"author":"Harper Lee", "title":"To Kill a Mockingbird", "is_sold":true}'

PUT

curl --request PUT \
--url 'http://ec2-52-91-247-19.compute-1.amazonaws.com/books/3' \
--header 'content-type: application/json' \
--data '{"author":"Jose Rodrigues dos Santos", "title":"A Formula de Deus", "is_sold":true}'

DELETE

curl --request DELETE \
--url 'http://ec2-52-91-247-19.compute-1.amazonaws.com/books/2' \
--header 'content-type: application/json'

Expected Outcome

At the end of the project, following topics are to be covered;

At the end of the project, you will be able to;

Resources

:memo: License

This project is under license from MIT. For more details, see the LICENSE file.

Made with :heart: by devenes

 

Back to top