Git Product home page Git Product logo

aws_ecs_python_project's Introduction

Terraform_ECS_Python

How we can create a Python Hello World project deploy the docker image, how we can push the Amazon ECR and deploy the Amazon ECS.

Dockerize the Project

How we can create a Dockerfile and run the same application in Docker.

// change directory
cd hello-world-python
// build the image
docker build -t terraform-ecs-project .
// list the image
docker images

If you check docker container, run and connect

// run the container
docker run -d -p 80:80 --name terraform-ecs-project terraform-ecs-project
// list the container
docker ps
// logs
docker logs terraform-ecs-project
// exec into running container
docker exec -it terraform-ecs-project /bin/sh

Pushing Docker Image to ECR AWScli

Firstly authenticate to your default registry.

aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin <aws-account-id>.dkr.ecr.us-east-2.amazonaws.com

Create a repository with the following command

aws ecr create-repository --repository-name rest-api --image-scanning-configuration scanOnPush=true --image-tag-mutability IMMUTABLE --region us-east-2

Tagging local Docker image

Local docker image tagging

docker tag TerraformEcsProject:version1 <aws_account>.dkr.ecr.us-east-2.amazonaws.com/TerraformEcsProject:version1

Check and Push

// list the images
docker images
// push the image
docker push <aws_account>.dkr.ecr.us-east-2.amazonaws.com/TerraformEcsProject:version1

Deploy On AWS ECS

Set some enviroment variables

cd terraform
export AWS_ACCESS_KEY_ID="YOUR_AWS_ACCESS_KEY_ID"
export AWS_SECRET_ACCESS_KEY="YOUR_AWS_SECRET_ACCESS_KEY"

terraform init
terraform apply

Note: If you limit site access to your own IP Adress Edit securitygroups.tf

aws_ecs_python_project's People

Watchers

 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.