Coder Social home page Coder Social logo

yourtechmafia / terra-tier Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kelvinskell/terra-tier

0.0 0.0 0.0 130 KB

This is project demonstartes the use of terraform to provision and deploy a three-tier application architecture to AWS

License: MIT License

Shell 7.68% Python 25.34% HTML 28.31% HCL 36.72% Procfile 0.04% Dockerfile 1.91%

terra-tier's Introduction

Terra-tier

Terra-tier is a Python Flask application that is deployed on AWS using a three-tier architecture. This project includes terraform scripts that automate the deployment of this application on AWS.

Running the App Locally with Docker Compose

In addition to deploying the terra-tier application on AWS using Terraform, you can run the application locally using Docker Compose. This approach is ideal for development, testing, or trying out the application without deploying it to the cloud.

Prerequisites

Before you begin, ensure you have the following installed on your local machine or virtual instance:

These tools are required to create containerized instances of the application and its required services (e.g., MySQL database).

Steps to Run Locally

  1. Navigate to the Project Directory: After cloning the repository, navigate to the root directory of the project where the docker-compose.yml file is located.

    cd path/to/terra-tier
  2. Environment Configuration: The project includes a .env file located in the root directory, which contains the necessary environment variables required by the application and Docker Compose. Before running the application, you may want to modify the .env file with your preferred parameters.

    Default .env content:

    SECRET_KEY=08dae760c2488d8a0dca1bfb
    API_KEY=f39307bb61fb31ea2c458479762b9acc
    MYSQL_DB=yourdbname
    MYSQL_USER=yourusername
    DATABASE_PASSWORD=Yourpassword@123
    MYSQL_HOST=db
    MYSQL_ROOT_PASSWORD=yourrootpassword

    You can replace these values in the .env file with your preferred values.

  3. Build and Start the Application: Use a single Docker Compose command to build and start the application along with its dependencies (e.g., MySQL). This command also starts the services defined in the docker-compose.yml file.

    docker-compose up --build

    The --build flag ensures that Docker images are built using the latest version of the application. Omit this flag if you have not made any changes to the Dockerfile or application code and wish to start the containers faster.

  4. Accessing the Application: Once the containers are up and running, the Flask application will be accessible via your web browser at http://localhost:5000.

  5. Shutting Down: To stop and remove the containers, networks, and volumes created by Docker Compose, run the following command in the same directory as your docker-compose.yml file:

    docker-compose down

Additional Information

  • Database Initialization: On the first run, the application will automatically create the necessary database tables.
  • Logs and Troubleshooting: You can view logs for each service using docker-compose logs [service_name] to troubleshoot any issues that arise during startup or runtime.

How To Use With Terraform

  • Fork this repository.
  • Clone your forked repository
  • Navigate to the terraform directory
  • Edit the backend.tf file. Add your own remote backend or use a local backend.
  • Execute terraform plan
  • If you are satisfied with the output of the plan, run terraform apply
  • Navigate to the your AWS EC2 Console, go to the provisioned load balancer, copy your DNS name.
  • The DNS name is also printed as output to your screen after you finish running terraform apply.
  • Paste this DNS name into a web browser to access your appplication.

Here is a guide for you if you wish to manually deploy this application.

You can also choose to deploy this application using a CI/CD pipeline, specifically AWS CodePipeline. Here is an amazing resource I put up to guide on to deploy this application in a CI/CD pipeline using the blue/green deployment.

Happy Clouding!!!

terra-tier's People

Contributors

kelvinskell avatar yourtechmafia avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.