TerraTicTac: Containerized Tic-Tac-Toe Game Hosted on AWS ECS with Terraform for Iac

TerraTicTac: Containerized Tic-Tac-Toe Game Hosted on AWS ECS with Terraform for Iac
  1. Create a new repository and launch a github Code-spaces

  2. Rebuilding Codespace container with Terraform and AWS

Docker comes pre-installed, or else you can add Docker as well.

Rebuild the container:

Checking whether everything is installed properly:

  1. Code for tic tac toe game

Find code in repo: https://github.com/Rupak-Shrestha/Terraform-ECS-tictactoe/tree/main/tictactoe-app
Push code to GitHub:

Adding logo file:

Check image in codespace:

  1. Write a Docker file

    Build image with Dockerfile: docker build -t tictactoeapp:latest .

    Build a container with this image

    Open in Browser:
    App running successfully:

  2. Push image to DockerHub
    docker tag tictactoeapp:latest rupaks/tictactoe-app:latest
    docker login
    docker push rupaks/tictactoe-app:latest

  3. Terraform for ECS
    Creating the files

    Find code in repo: https://github.com/Rupak-Shrestha/Terraform-ECS-tictactoe/tree/main/tf-for-ecs

    Create access key and secret key from AWS console:

    Push code to remote repo:

    aws configure:

    Keep the key secure.

  4. Run terraform commands

  5. Check resources
    VPC, Subnet, Route table, Internet Gateway

    Security Group

    ECS cluster

    Running ECS container:

  6. Access the application:

  7. Destroy the resources:

    Never forget to destroy the resources.

    Happy Learning!