Skip to main content
Launch this lab in the IP Lab Portal, then follow the steps below in the AWS console. Open IP Lab Portal

Overview

Lab details

  1. This lab walks you through the steps to create an Amazon ECS Sample App.
  2. You will practice using Fargate to create and configure Task Definition, Service, and Cluster.
  3. Duration: 45 minutes
  4. AWS Region: US East (N. Virginia) us-east-1.

Introduction

What is a Docker?

  1. Docker is a tool designed to make it easier to create, deploy, and run applications by using containers.
  2. Containers allow a developer to package up an application with all the parts it needs, such as libraries and other dependencies, and deploy it as one package.
  3. By doing so, the application will run on any other Linux machine, regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code.

What is Amazon ECS?

  1. Amazon ECS manages containers and allows developers to run applications in the cloud without having to configure an environment for the code to run in.
  2. It enables developers with AWS accounts to deploy and manage scalable applications that run on groups of servers called clusters through application program interface (API) calls and task definitions.
  3. Amazon ECS enables developers to easily use Docker containers for a range of activities; from hosting a simple website to running complex, distributed microservices that require thousands of containers.

Architecture diagram

Task details

  1. Sign into AWS Management Console.
  2. Getting started with Amazon ECS using Fargate.
  3. Creating Container and Task Definition.
  4. Defining the service.
  5. Viewing the service.
  6. Validation of the lab

Launching the lab environment

  1. To launch the lab environment, Click on the Launch lab button.
  2. Please wait until the cloud environment is provisioned. It will take less than a minute to provision.
  3. Once the Lab is started, you will be provided with IAM username, Password, Access Key, and Secret Access Key.
Note : You can only start one lab at any given time

Lab guide

Lab steps

Task 1: Sign in to AWS Management Console

  1. Click on the Open console button, and you will get redirected to AWS Console in a new browser tab.
  2. On the AWS sign-in page,
    • Leave the Account ID as default. Never edit/remove the 12-digit Account ID present in the AWS Console. Otherwise, you cannot proceed with the lab.
    • Now copy your Username and Password in the Lab Console to the IAM Username and Password in AWS Console and click on the Sign-in button.
  3. Once Signed In to the AWS Management Console, make the default AWS Region as US East (N. Virginia) us-east-1.
If you face any issues, please go through FAQs and Troubleshooting.

Task 2: Getting started with Amazon ECS using Fargate

  1. AWS Fargate is a serverless infrastructure for containers that allows you to run your containers without the need to manage the underlying infrastructure.
  2. To get started with Amazon ECS on AWS Fargate, you can use the Fargate launch type for your tasks. When you create a task definition, you can specify the Fargate launch type in the task definition.
  3. When you launch a task using this task definition, Fargate will automatically provision the required compute resources to run the task, based on the specifications in the task definition.

Task 3: Creating Container and Task Definition

  1. A task definition is a blueprint or configuration file that defines how a container-based application should run in a container cluster.
  2. In Amazon ECS (Elastic Container Service), a task definition is required each time you want to launch a task, which is a running instance of a task definition.
  3. The task definition specifies details such as the Docker image to use, the CPU and memory requirements for each container, any data volumes to mount, and any environment variables to set.
  4. Make sure you are in US East (N. Virginia) us-east-1.
  5. Select the Services button in the top and select Elastic Container Service under the Containers section.
  6. Click on Cluster from the left panel.
  7. Click on the Create Cluster button.
  8. Keep the Cluster name field as it is (default value).
  9. Keep the rest of the things as default and click on the create button.
  10. The cluster will be created successfully.
  11. Navigate to Task Definitions in the left navigation panel.
  12. Click on Create new task definition and click on Create new task definition.
  13. Step 1: Configure task definitions and containers
    • Task Definition family : Enter whizdefinition
    • Launch type: Select AWS Fargate
      • CPU: Select .25 vCPU and Memory: Select 1 GB
    • Task Role and Task Execution Role: Select None
      Note : Make sure to change task execution role to select none. by default it is Create new role.
    • Container -1
      • Name : Enter sample-app
      • Image URL: Enter httpd:2.4
      • Uncheck Use log collection
  14. Leave everything as default and click on Create button.
  15. The task definition will be created successfully.

Task 4: Defining the service

  1. In this section, we have to select how to configure the Amazon ECS service that is created from our task definition.
  2. A service allows us to run and maintain a specified number (the “desired count”) of simultaneous instances of a task definition in an ECS cluster.
  3. The Amazon ECS sample application is a web-based Hello World–style application that is meant to run indefinitely.
  4. Click on Deploy button and then on Create Service.
  5. You will be redirected to the service page.
    • Service Name: enter whizservice
    • Existing Cluster: Choose the previously created cluster. In our case, the cluster name is whizcluster
    • Compute options: Select Launch Type
    • Launch type: select Fargate
    • Schedling strategy: select Replica (default)
      • Desired Tasks : Enter 2
    • Scroll down and expand Networking section
    • Under Security group, Select Create a new security group
      • Security group name: Enter whizecssg
      • Security group description: Enter Security group for ECS cluster
      • Type : Select HTTP
      • Source: Select Anywhere
  • Click on Create button.

Task 6: Viewing the service

  1. Wait till the service gets deployed and You will see the service created successfully.
  2. If your service is a web-based application, such as the Amazon ECS sample application, you can view its containers with a web browser.
  3. Navigate to the Tasks tab.
  4. Click on a task from the list of tasks in your service.
  5. Switch to the Networking tab. Copy the Public IPv4 IP address.
  6. Enter http:// before your IP address and enter it in your web browser, and you should see a webpage that displays ”It works”.
Do you know?ECS allows developers to easily scale their containerized applications up or down based on demand. It can automatically manage the provisioning and distribution of containers across clusters, allowing for efficient resource utilization. This scalability enables businesses to handle varying workloads and adapt to changing traffic patterns without manual intervention.

Task 7: Validation Test

  1. Once the lab steps are completed, please click on the Check my work button on the right side panel.
  2. This will validate the resources in the AWS account and displays whether you have completed this lab successfully or not.
  3. Sample output :

Completion and conclusion

  1. You have successfully created a Task definition, Service and Cluster using Fargate.
  2. You have tested the Amazon ECS sample app.

End lab

  1. Sign out of AWS Account.
  2. You have successfully completed the lab.
  3. Once you have completed the steps, click on End lab in the IP Lab Portal.

What gets checked

When you press Check my work, the platform verifies each of these:
  • Check ECS Cluster Exists — Check ECS cluster is created or not
  • Create ECS Task Definition — Check whether ECS task definition created or not
  • Create ECS Service — Check whether ECS service created or not