Deploying on AWS ECS
Start course
Difficulty
Beginner
Duration
1h 18m
Students
85
Description

In this course, we will learn the concepts of microservice and spring framework with a focus on Cloud.

Learning Objectives

  • Learn about Cloud

Intended Audience

  • Beginner Java developers
  • Java developers interested in learning how to Build and Deploy RESTful Web Services
  • Java Developers who want to develop web applications using the Spring framework
  • Java Developers who want to develop web applications with microservices
  • Java Developers who wish to develop Spring Boot Microservices with Spring Cloud

Prerequisites

  • Basic Java knowledge
Transcript

Deploying on AWS ECS. Hello dear friends, in this lesson we will talk about deployment methods for AWS ECS. First, I want to give a brief introduction about ECS. An Amazon ECS cluster is a regional grouping of one or more container instances on which you can run task requests. Each account receives a default cluster the first time you use the Amazon ECS service. Clusters may contain more than one Amazon EC2 instance type. Deployment methods for ECS. There are some methodologies to deploy containers on ECS. I want to mention one of them. We can list the installation steps in the following items. Create the Docker image. Create an ECR registry. Tag the image. Give the Docker CLI permission to access your Amazon account. Upload the Docker image to ECR. Create a Fargate Cluster for ECS to use for the deployment of your container. Create an ECS task. Run the ECS task. You know we've already created the Docker image. To create an ECR registry on the Amazon management console, search for elastic container registry and select it. Append a name for repository.

The name must be your Docker image's name and then create it. Don't forget to copy the link. Tag the image. In order for ECR to know which repository we are pushing our image to, we must tag the image with that URI. The command that we use for tagging is like this. Give the Docker CLI permission to access your Amazon account. We need to log in to AWS to get a key that we passed to Docker so we can upload our image to ECR. First, we'll log into our AWS account. To log in, we use the AWS configure command. Next, we need to generate an ECR login token for Docker. We can pipe that token straight into Docker like this. Login succeeded. Upload your Docker image to ECR. We use Docker to push the image to the ECR repository. Create a Fargate cluster. To accomplish the step, we need to go back to the AWS management console. Here, search for and select Elastic Container Service.

On the Open page, select clusters from the left menu and press 'Create cluster.' Under Select cluster template, we are going to select Networking only. We don't need EC2 instances in our cluster because Fargate will take care of spinning up compute resources when we start our task and spinning them down when we stop our task. I will give the cluster a name. Leave the rest as they are and select create. Create an ECS task. An ECS task will take and deploy our image to a container. To create an ECS task, return to the ECS page, select task definitions from the left menu, then select create new task definition, select Fargate, and select 'Next'. Enter a name for the task. Leave the task role and network model as default. Leave the task execution role as default. Select minimum values for task memory and task CPU. Under Container definition, select 'Add container', enter a container name. In the image box, enter the ARN of our image. You can copy and paste this from the ECR dashboard.

We can keep the memory limit at 128 MB or a similar small size. Import mappings. You will notice that we can't actually map anything. We can change the port value to correspond to our application. Let the other definitions stay default. Click the 'Add' button. Leave everything else on the configure task and container definitions page as is and select 'Create' in the lower left corner of the page. Go back to the ECS page, select task definitions, and we should see our new task. Now we can run the ECS's task. Select the task in the task definition list. Click 'Actions' and select 'Run task' Select Fargate as launch type. Cluster should be Fargate cluster. Cluster VPC, select a VPC from the list, and finally, run the task by clicking 'Run task' in the lower left corner of the page. After you run the task, you will be forwarded to the Fargate cluster page. When the last status for your cluster changes to running, your app is up and running. All right, dear friends we learned how to upload an image to ECS. So, I'll see you in the following lesson.

 

About the Author
Students
1922
Courses
64
Learning Paths
4

OAK Academy is made up of tech experts who have been in the sector for years and years and are deeply rooted in the tech world. They specialize in critical areas like cybersecurity, coding, IT, game development, app monetization, and mobile development.