> ## Documentation Index
> Fetch the complete documentation index at: https://cloud-architect.ipoint-labs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Getting Started with Amazon Elastic Container Service using Fargate

> Hands-on lab · 30m

Launch this lab in the IP Lab Portal, then follow the steps below in the AWS console.

<a className="ip-lab-portal-btn" href="https://labs.intellectualpoint.com/labs/getting-started-with-amazon-elastic-container-service-using-fargate" target="_blank" rel="noreferrer">
  Open IP Lab Portal
</a>

## 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

<img src="https://mintcdn.com/ip-cloud-architect-pathway/OagrkbHBQ8SYHp5M/images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/001.png?fit=max&auto=format&n=OagrkbHBQ8SYHp5M&q=85&s=c638e73f165283b97d715999fbb51c9d" alt="" width="1638" height="1834" data-path="images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/001.png" />

### 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.**

<Note>
  If you face any issues, please go through [**FAQs and Troubleshooting**](/aws-cp/support/faqs-and-troubleshooting).
</Note>

#### 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.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/OagrkbHBQ8SYHp5M/images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/002.png?fit=max&auto=format&n=OagrkbHBQ8SYHp5M&q=85&s=39b6e02c3e9d32ac62e3b163d20f1610" alt="" width="1222" height="257" data-path="images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/002.png" />

8. Keep the Cluster name field as it is **(default value).**

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/OagrkbHBQ8SYHp5M/images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/003.png?fit=max&auto=format&n=OagrkbHBQ8SYHp5M&q=85&s=83475e0a80d28727b699b4b594c89f98" alt="" width="1011" height="250" data-path="images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/003.png" />

9. Keep the rest of the things as default and click on the **create** button.

10. The cluster will be created successfully.

    <img src="https://mintcdn.com/ip-cloud-architect-pathway/OagrkbHBQ8SYHp5M/images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/004.png?fit=max&auto=format&n=OagrkbHBQ8SYHp5M&q=85&s=e7a0bd225d428f2cac938a2c949c2fea" alt="" width="1222" height="257" data-path="images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/004.png" />

11. Navigate to Task Definitions in the left navigation panel.

12. Click on **Create new task definition** and click on **Create new task definition**.

    <img src="https://mintcdn.com/ip-cloud-architect-pathway/OagrkbHBQ8SYHp5M/images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/005.png?fit=max&auto=format&n=OagrkbHBQ8SYHp5M&q=85&s=408ab06f2fcfa1a3de363056ab1d0929" alt="" width="1222" height="274" data-path="images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/005.png" />

13. **Step 1: Configure task definitions and containers**

    * Task Definition family : Enter **whizdefinition**

      <img src="https://mintcdn.com/ip-cloud-architect-pathway/OagrkbHBQ8SYHp5M/images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/006.png?fit=max&auto=format&n=OagrkbHBQ8SYHp5M&q=85&s=8a72b8e1d5b61053647a06cc556bb22c" alt="" width="1222" height="247" data-path="images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/006.png" />
    * 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.

      <img src="https://mintcdn.com/ip-cloud-architect-pathway/OagrkbHBQ8SYHp5M/images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/007.png?fit=max&auto=format&n=OagrkbHBQ8SYHp5M&q=85&s=7279ad870871069a775087b23821c54a" alt="" width="1222" height="765" data-path="images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/007.png" />
    * **Container -1**

      * Name : Enter **sample-app**
      * Image URL: Enter **httpd:2.4**
      * **Uncheck** Use log collection

        <img src="https://mintcdn.com/ip-cloud-architect-pathway/OagrkbHBQ8SYHp5M/images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/008.png?fit=max&auto=format&n=OagrkbHBQ8SYHp5M&q=85&s=5e3b4ffa23bf4954e4a4fba3cbc74226" alt="" width="1222" height="237" data-path="images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/008.png" />

        <img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/009.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=09921b53edc95747c2eeb7f3e57d3978" alt="" width="1222" height="127" data-path="images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/009.png" />

14. Leave everything as default and click on **Create** button.

15. The task definition will be created successfully.

    <img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/010.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=c09120382be926d23e684ec43219a694" alt="" width="1222" height="479" data-path="images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/010.png" />

#### 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.**

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/011.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=46f1a5705fc2be6505d2455303e10815" alt="" width="1222" height="481" data-path="images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/011.png" />
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**

     <img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/012.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=c846d36e53a94673757845db39f5fbac" alt="" width="1222" height="707" data-path="images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/012.png" />

   * Schedling strategy: select **Replica (default)**

     * Desired Tasks : Enter **2**

     <img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/013.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=be46a25ced76cc38bd6f1d6ef4cbd9ce" alt="" width="1222" height="358" data-path="images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/013.png" />

   * 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**

       <img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/014.jpg?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=893a837a2c9bc8ecf1907bf452fe4efd" alt="" width="2242" height="835" data-path="images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/014.jpg" />

* Click on **Create** button.

#### Task 6: Viewing the service

1. Wait till the service gets deployed and You will see the service created successfully.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/015.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=045e89ad65f3364012c626a9168416a0" alt="" width="1222" height="596" data-path="images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/015.png" />

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.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/016.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=14bce7c301891cd16ce5d6ecea5041de" alt="" width="1222" height="335" data-path="images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/016.png" />

5. Switch to the **Networking** tab. Copy the **Public IPv4 IP** address.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/017.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=5077ab2aafc41369a65fe1437ed289bf" alt="" width="1222" height="443" data-path="images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/017.png" />

6. Enter **http\://** before your IP address and enter it in your web browser, and you should see a webpage that displays ”**It works**”.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/018.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=3f9d2837462e6c4eae7142da555e0bf3" alt="" width="996" height="450" data-path="images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/018.png" />

<Tip>
  **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.
</Tip>

#### 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 :

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/019.gif?s=43224c1b500179c98c07eb3f93a713d0" alt="" width="998" height="583" data-path="images/labs/getting-started-with-amazon-elastic-container-service-using-fargate/019.gif" />

### 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

## Related help

* [FAQs and Troubleshooting](/aws-cp/support/faqs-and-troubleshooting)
