<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: khaled Eltaweel</title>
    <description>The latest articles on Forem by khaled Eltaweel (@khaledeltaweel).</description>
    <link>https://forem.com/khaledeltaweel</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1005915%2F57dd34c3-d541-4188-a5e0-a272a72394b0.jpeg</url>
      <title>Forem: khaled Eltaweel</title>
      <link>https://forem.com/khaledeltaweel</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/khaledeltaweel"/>
    <language>en</language>
    <item>
      <title>Deploy a container web application with Amazon ECS &amp; Fargate - Hands On</title>
      <dc:creator>khaled Eltaweel</dc:creator>
      <pubDate>Fri, 20 Jan 2023 12:39:09 +0000</pubDate>
      <link>https://forem.com/khaledeltaweel/deploy-a-container-web-application-with-amazon-ecs-fargate-hands-on-46i1</link>
      <guid>https://forem.com/khaledeltaweel/deploy-a-container-web-application-with-amazon-ecs-fargate-hands-on-46i1</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is ECS in AWS?&lt;/strong&gt;&lt;br&gt;
ECS stands for (Elastic Container Service) which is a container management service on &lt;a href="https://aws.amazon.com/" rel="noopener noreferrer"&gt;AWS&lt;/a&gt; that supports Docker containers and allows you to manage your containers on clusters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Fargate?&lt;/strong&gt;&lt;br&gt;
AWS Fargate is a serverless, pay-as-you-go compute engine that lets you focus on building applications without managing servers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Steps to deploy your application on ECS:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a &lt;strong&gt;task definition&lt;/strong&gt; and add your image source.&lt;/li&gt;
&lt;li&gt;Create a security group for the &lt;strong&gt;cluster&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;create a &lt;strong&gt;cluster&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;create a &lt;strong&gt;service&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Visit your &lt;strong&gt;website&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's start our detailed steps journey to deploy our container.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Create a task definition and add your image source:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Open your AWS console and search for &lt;strong&gt;ECS&lt;/strong&gt; and click on &lt;strong&gt;task definitions&lt;/strong&gt; then click on create a new task definition&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkzstsj1hozaab2kdpzm4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkzstsj1hozaab2kdpzm4.png" alt="Image description" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the configure task definition and containers step give your task a name then add your container name and image URL.&lt;/p&gt;

&lt;p&gt;In this example we will use an image on my &lt;strong&gt;docker hub&lt;/strong&gt; from this &lt;a href="https://hub.docker.com/r/khaledeltaweel/webapp" rel="noopener noreferrer"&gt;Link&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Add your container port that you want the application to run on it, I will use &lt;strong&gt;port 80&lt;/strong&gt; then go to the bottom of the page and click next.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa6bk9uq8knnob2fsoki1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa6bk9uq8knnob2fsoki1.png" alt="Image description" width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the configure environment, storage, monitoring, and tags step we will choose &lt;a href="https://docs.aws.amazon.com/AmazonECS/latest/userguide/what-is-fargate.html" rel="noopener noreferrer"&gt;AWS Fargate&lt;/a&gt; as our app environment to run our application on it.&lt;/p&gt;

&lt;p&gt;Operating system will be linux.&lt;/p&gt;

&lt;p&gt;CPU will be 0.5 vCPU and Memory will be 1GB.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkikxcsp1q8mpp5jtw7nb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkikxcsp1q8mpp5jtw7nb.png" alt="Image description" width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click next and review your task details then click create.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Create a security group for the cluster&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the search tab, search for &lt;a href="https://aws.amazon.com/ec2/ec2-get-started/" rel="noopener noreferrer"&gt;EC2&lt;/a&gt; and choose Security Groups from the Network and Security tab and click on create security group.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbez0y20g9mf2bfc3ud17.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbez0y20g9mf2bfc3ud17.png" alt="Image description" width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Give your security group a name and a description, the security group will have two inbound rules:&lt;/p&gt;

&lt;p&gt;The first rule will have an all traffic protocol type and will be running on port 80 and the traffic source will Anywhere-ipv4.&lt;/p&gt;

&lt;p&gt;The second rule will have an all traffic protocol type and will be running on port 80 and the source will Anywhere-ipv6.&lt;/p&gt;

&lt;p&gt;Then click Create security group.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fys4eoqc6wqh0ltceezo9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fys4eoqc6wqh0ltceezo9.png" alt="Image description" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. create a cluster&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Go to clusters from the left side nav and click on create cluster.&lt;/p&gt;

&lt;p&gt;Give your cluster a name and choose a VPC, in this example I used the default VPC.&lt;/p&gt;

&lt;p&gt;Then click create.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy27aii3ktdi3hefb2fid.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy27aii3ktdi3hefb2fid.png" alt="Image description" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ohgsgek7menq2vdp6nh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ohgsgek7menq2vdp6nh.png" alt="Image description" width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One thing left to finish the mission! 🤗&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. create a service&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Go to the cluster that we have created and go to service tab and create a new service.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9q4pzfp8qt2d7oeom3y9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9q4pzfp8qt2d7oeom3y9.png" alt="Image description" width="800" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the deployment configuration tab specify the application type  to be a service, and the task definition choose our task definition that we created in the first step, then type your service name.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Froitervbg5g15isoibpt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Froitervbg5g15isoibpt.png" alt="Image description" width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the Networking tab choose a VPC and subnets.&lt;/p&gt;

&lt;p&gt;Choose an existing security group and choose our security group the we created the second step.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuvzxa3f6o7zxjfhqmc4t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuvzxa3f6o7zxjfhqmc4t.png" alt="Image description" width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then Click create. &lt;/p&gt;

&lt;p&gt;Now go to services tab in the cluster your will find the service exists with an active status.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Visit your website&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Go to tasks tab in the cluster, you will find a new task has been created click on it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6l9c2hw2z0v1ez0x2c5g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6l9c2hw2z0v1ez0x2c5g.png" alt="Image description" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The task will be running and you can access the website via public ip address copy and past it in your browser or click on open address and it will open the website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ve6q8o59a8ul5ijvrtu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ve6q8o59a8ul5ijvrtu.png" alt="Image description" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, welcome on board.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnpwlcw6wbma0btrnk66b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnpwlcw6wbma0btrnk66b.png" alt="Image description" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F274b63kx1k3u5g46zyng.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F274b63kx1k3u5g46zyng.png" alt="Image description" width="800" height="423"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>html</category>
    </item>
  </channel>
</rss>
