0% found this document useful (0 votes)
13 views

Deploy Containerized Apache Application On ECS Using ECR

Deploy containerized ECS

Uploaded by

mmurugayen
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Deploy Containerized Apache Application On ECS Using ECR

Deploy containerized ECS

Uploaded by

mmurugayen
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Deploy Containerized Apache

Application on ECS Using ECR

By
Mahendran Selvakumar
https://devopstronaut.com/

https://www.linkedin.com/in/mahendran-selvakumar-36444a77/
1.Create ECR Repository for ECS Container

Go to Amazon Elastic Container Registry and click "Create repository"

Select "Private" and provide the repository name

https://www.linkedin.com/in/mahendran-selvakumar-36444a77/
Click "Create repository"

2. Create an IAM user with ECR permissions

Go to IAM and click "Create user"

Provide a username

https://www.linkedin.com/in/mahendran-selvakumar-36444a77/
Add the user to the admin group. Here, you can also restrict access with a custom
policy

https://www.linkedin.com/in/mahendran-selvakumar-36444a77/
Click "Create user"

Go to the new user and create an Access key for AWS CLI

https://www.linkedin.com/in/mahendran-selvakumar-36444a77/
Select "Command line interface (CLI)"

Enter a description for the access key and click “create access key”

Copy the access key and secret key, as the secret key value will not be visible again

https://www.linkedin.com/in/mahendran-selvakumar-36444a77/
To verify if AWS CLI is installed and available on your system, you can run the following
command in your terminal or command prompt. If AWS CLI is installed, this command
will display the version information. If it is not installed, you'll receive an error message
indicating that the command is not recognized

To configure AWS CLI with your access credentials

You'll be prompted to enter the following details:

• AWS Access Key ID: Enter your access key.


• AWS Secret Access Key: Enter your secret key.
• Default region name: Enter your preferred AWS region (e.g., us-west-2).

https://www.linkedin.com/in/mahendran-selvakumar-36444a77/
• Default output format: Enter your preferred output format (e.g., Json, text, or
yaml).

Verify the configuration

3. Build the Docker image and push it to ECR

Create a Dockerfile to build a Docker image

Build docker image using this command (docker build -t devopstronaut .)

https://www.linkedin.com/in/mahendran-selvakumar-36444a77/
Retrieve an authentication token and authenticate your Docker client to your registry. Use the
AWS CLI

aws ecr get-login-password --region eu-north-1 | docker login --username AWS --


password-stdin 851725583489.dkr.ecr.eu-north-1.amazonaws.com

Tag your image so you can push the image to this repository

docker tag devopstronaut:latest 851725583489.dkr.ecr.eu-north-


1.amazonaws.com/devopstronaut:latest

Run the following command to push this image to your newly created AWS repository

docker push 851725583489.dkr.ecr.eu-north-1.amazonaws.com/devopstronaut:latest

Verify that the docker image has been pushed

https://www.linkedin.com/in/mahendran-selvakumar-36444a77/
4.Create ECS Cluster

Go to AWS ECS and click “Create Cluster”

Enter a cluster name and choose "AWS Fargate" so that the cluster is automatically
configured for AWS Fargate

https://www.linkedin.com/in/mahendran-selvakumar-36444a77/
The Cluster has been created successfully

https://www.linkedin.com/in/mahendran-selvakumar-36444a77/
Create Task definition

Specify the task definition family and set the launch type to "AWS Fargate"

Enter the container name, provide the ECR image URI, and specify the port name

https://www.linkedin.com/in/mahendran-selvakumar-36444a77/
You can verify the created task by checking the container name

https://www.linkedin.com/in/mahendran-selvakumar-36444a77/
Create ECS Service

Go back to the "Deploy" section and select "Create service"

Choose the existing cluster and select compute option as “capacity provider”

https://www.linkedin.com/in/mahendran-selvakumar-36444a77/
Provide the Service name and specify the desired tasks to “1”

https://www.linkedin.com/in/mahendran-selvakumar-36444a77/
In the Networking section, choose the VPC, subnet, and security group

https://www.linkedin.com/in/mahendran-selvakumar-36444a77/
It will take more time to create the service

Verify the task status after the service has been created

https://www.linkedin.com/in/mahendran-selvakumar-36444a77/
Go to Tasks configuration and Copy the Public IP Address from Task

Paste the IP address to the browser and now you should be able to access the Apache
website from AWS ECS.

https://www.linkedin.com/in/mahendran-selvakumar-36444a77/
Keep Learning, Keep Automating!!!

Feel free to reach out to me, if you have any other queries or suggestions

Stay connected on Linkedin https://www.linkedin.com/in/mahendran-selvakumar-


36444a77/

https://www.linkedin.com/in/mahendran-selvakumar-36444a77/

You might also like