<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>ecs on Alperen Doc</title><link>https://blog.ulutasalperen.com/docs/aws/ecs/</link><description>Recent content in ecs on Alperen Doc</description><generator>Hugo</generator><language>en</language><atom:link href="https://blog.ulutasalperen.com/docs/aws/ecs/index.xml" rel="self" type="application/rss+xml"/><item><title>vpc-and-networking-setup-for-ecs</title><link>https://blog.ulutasalperen.com/docs/aws/ecs/vpc-and-networking-setup-for-ecs/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/aws/ecs/vpc-and-networking-setup-for-ecs/</guid><description>&lt;h1 id="vpc-and-networking-setup"&gt;VPC and Networking Setup&lt;a class="anchor" href="#vpc-and-networking-setup"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;As we dive into &lt;a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/Welcome.html"&gt;ECS&lt;/a&gt; (Elastic Container Service), I want to re-emphasize that having your networking set up correctly is critical. Luckily, we&amp;rsquo;ve already done it! Just know that it will be important that it&amp;rsquo;s all still set up.&lt;/p&gt;&#10;&lt;p&gt;For ECS to work properly, we need:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;A &lt;strong&gt;&lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html"&gt;VPC&lt;/a&gt;&lt;/strong&gt; with CIDR &lt;code&gt;10.0.0.0/22&lt;/code&gt; (our &lt;code&gt;patientping&lt;/code&gt; VPC)&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Two public &lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/configure-subnets.html"&gt;subnets&lt;/a&gt;&lt;/strong&gt; (&lt;code&gt;patientping-public-a&lt;/code&gt; and &lt;code&gt;patientping-public-b&lt;/code&gt;)&lt;/li&gt;&#10;&lt;li&gt;An &lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/working-with-igw.html#create-igw"&gt;&lt;strong&gt;Internet Gateway&lt;/strong&gt;&lt;/a&gt; attached to the VPC (&lt;code&gt;patientping-igw&lt;/code&gt;)&lt;/li&gt;&#10;&lt;li&gt;A &lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Route_Tables.html"&gt;&lt;strong&gt;route table&lt;/strong&gt;&lt;/a&gt; that sends &lt;code&gt;0.0.0.0/0&lt;/code&gt; to the Internet Gateway, associated with both public subnets (&lt;code&gt;patientping-public-rt&lt;/code&gt;)&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;We&amp;rsquo;ll run our Fargate tasks and the load balancer in these public subnets. Tasks get outbound internet access (for example, to pull images from ECR) through the Internet Gateway, so we don&amp;rsquo;t need a &lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html"&gt;NAT Gateway&lt;/a&gt; for this course. (In production, you&amp;rsquo;d often use private subnets and a NAT Gateway or &lt;a href="https://docs.aws.amazon.com/vpc/latest/privatelink/concepts.html"&gt;VPC endpoints&lt;/a&gt; for stronger isolation.)&lt;/p&gt;</description></item><item><title>why-ecs</title><link>https://blog.ulutasalperen.com/docs/aws/ecs/why-ecs/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/aws/ecs/why-ecs/</guid><description>&lt;h1 id="why-ecs"&gt;Why ECS?&lt;a class="anchor" href="#why-ecs"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;Containers are a big part of how software is typically built and deployed today.&lt;/p&gt;&#10;&lt;p&gt;If you&amp;rsquo;ve never used them before, you should take our &lt;a href="https://www.boot.dev/courses/learn-docker"&gt;course on Docker&lt;/a&gt; before proceeding! You&amp;rsquo;ll also need &lt;code&gt;docker&lt;/code&gt; installed locally to complete this chapter.&lt;/p&gt;&#10;&lt;p&gt;If you&amp;rsquo;re running just a container or two on a single machine, &lt;code&gt;docker&lt;/code&gt; is a great way to get up running, but When your needs grow beyond a single machine, &lt;a href="https://kubernetes.io/"&gt;Kubernetes&lt;/a&gt;, a powerful container orchestration platform, tends to be the go-to solution.&lt;/p&gt;</description></item><item><title>elastic-container-registry</title><link>https://blog.ulutasalperen.com/docs/aws/ecs/elastic-container-registry/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/aws/ecs/elastic-container-registry/</guid><description>&lt;h1 id="elastic-container-registry"&gt;Elastic Container Registry&lt;a class="anchor" href="#elastic-container-registry"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;Before we can deploy any containers, we need somewhere to &lt;em&gt;store their images&lt;/em&gt;. Those images need to be available all the time because containers are regularly replaced and may need to pull a fresh copy of the software.&lt;/p&gt;&#10;&lt;p&gt;AWS provides the &lt;a href="https://aws.amazon.com/ecr/"&gt;&lt;strong&gt;Elastic Container Registry&lt;/strong&gt; (ECR)&lt;/a&gt; as a managed registry service. It&amp;rsquo;s like &lt;a href="https://hub.docker.com/"&gt;Docker Hub&lt;/a&gt;, but integrated directly with AWS services.&lt;/p&gt;&#10;&lt;p&gt;ECR helps with straightforward things like storing images in the right region, and more advanced things like controlling access with &lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html"&gt;IAM&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>ecr-repo</title><link>https://blog.ulutasalperen.com/docs/aws/ecs/ecr-repo/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/aws/ecs/ecr-repo/</guid><description>&lt;h1 id="ecr-repo"&gt;ECR Repo&lt;a class="anchor" href="#ecr-repo"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;Now that we have a Docker image, let&amp;rsquo;s host it on ECR!&lt;/p&gt;&#10;&lt;h2 id="assignment"&gt;Assignment&lt;a class="anchor" href="#assignment"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;&lt;strong&gt;Create an ECR repository &lt;code&gt;patientping-ecs&lt;/code&gt;, and push the image.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Cost check:&lt;/strong&gt; ECR storage costs about $0.10 per GB per month. For a small image like ours, which we&amp;rsquo;ll keep on ECR only long enough for learning/testing, this is essentially free. Data transfer costs also apply when pulling images, but again, for learning purposes it&amp;rsquo;s minimal.&lt;/p&gt;</description></item><item><title>ecs-clusters</title><link>https://blog.ulutasalperen.com/docs/aws/ecs/ecs-clusters/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/aws/ecs/ecs-clusters/</guid><description>&lt;h1 id="ecs-clusters"&gt;ECS Clusters&lt;a class="anchor" href="#ecs-clusters"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;We&amp;rsquo;ve got our image, now it&amp;rsquo;s time to &lt;em&gt;run&lt;/em&gt; it.&lt;/p&gt;&#10;&lt;p&gt;Enter the &lt;a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/clusters.html"&gt;&lt;strong&gt;ECS Cluster&lt;/strong&gt;&lt;/a&gt;. Think of it as a logical grouping of compute resources where containers can run. It doesn&amp;rsquo;t cost anything by itself, but it provides the foundation for running ECS tasks.&lt;/p&gt;&#10;&lt;p&gt;A cluster can hold a number of &lt;a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-capacity-provider-console-v2.html"&gt;&lt;strong&gt;capacity providers&lt;/strong&gt;&lt;/a&gt;, which provide resources to our cluster on an as-needed basis. It&amp;rsquo;s like the ECS version of &lt;a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/auto-scaling-groups.html"&gt;&lt;strong&gt;EC2 Auto Scaling Groups&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>ecs-permissions</title><link>https://blog.ulutasalperen.com/docs/aws/ecs/ecs-permissions/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/aws/ecs/ecs-permissions/</guid><description>&lt;h1 id="ecs-permissions"&gt;ECS Permissions&lt;a class="anchor" href="#ecs-permissions"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;We&amp;rsquo;ve dealt with &lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html"&gt;&lt;strong&gt;IAM roles&lt;/strong&gt;&lt;/a&gt; with EC2, but they also apply to ECS. We have two problems to solve:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;We need to give ECS access to specific containers to pull them in and start them up.&lt;/li&gt;&#10;&lt;li&gt;After the container boots up, it needs to have its own set of permissions. In our case, we&amp;rsquo;ll give it permissions to read SSM parameters.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;Two different permission sets, and AWS handles them with:&lt;/p&gt;</description></item><item><title>ecs-task-definitions</title><link>https://blog.ulutasalperen.com/docs/aws/ecs/ecs-task-definitions/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/aws/ecs/ecs-task-definitions/</guid><description>&lt;h1 id="ecs-task-definitions"&gt;ECS Task Definitions&lt;a class="anchor" href="#ecs-task-definitions"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;With our &lt;strong&gt;container image&lt;/strong&gt; in &lt;strong&gt;ECR&lt;/strong&gt; and our &lt;strong&gt;Fargate&lt;/strong&gt;-ready &lt;strong&gt;ECS Cluster&lt;/strong&gt; set up, we need to tell ECS exactly how to run our container. What ports should it expose? How much memory does it need? What permissions should it have?&lt;/p&gt;&#10;&lt;p&gt;We answer all these questions with a &lt;a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definitions.html"&gt;&lt;strong&gt;Task Definition&lt;/strong&gt;&lt;/a&gt;. It&amp;rsquo;s a JSON file that describes everything ECS needs to know about running our container, for example:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-json" data-lang="json"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;family&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;patientping-ecs&amp;#34;&lt;/span&gt;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;cpu&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;256&amp;#34;&lt;/span&gt;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;memory&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;512&amp;#34;&lt;/span&gt;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;networkMode&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;awsvpc&amp;#34;&lt;/span&gt;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;executionRoleArn&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;arn:aws:iam::&amp;lt;MY_ACCOUNT_ID&amp;gt;:role/patientping-ecs-execution-role&amp;#34;&lt;/span&gt;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;taskRoleArn&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;arn:aws:iam::&amp;lt;MY_ACCOUNT_ID&amp;gt;:role/patientping-ecs-task-role&amp;#34;&lt;/span&gt;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;runtimePlatform&amp;#34;&lt;/span&gt;: { &lt;span style="color:#f92672"&gt;&amp;#34;operatingSystemFamily&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;LINUX&amp;#34;&lt;/span&gt; },&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;requiresCompatibilities&amp;#34;&lt;/span&gt;: [&lt;span style="color:#e6db74"&gt;&amp;#34;FARGATE&amp;#34;&lt;/span&gt;],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;volumes&amp;#34;&lt;/span&gt;: [],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;containerDefinitions&amp;#34;&lt;/span&gt;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;name&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;patientping-ecs&amp;#34;&lt;/span&gt;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;image&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;&amp;lt;MY_ACCOUNT_ID&amp;gt;.dkr.ecr.us-east-1.amazonaws.com/patientping-ecs&amp;#34;&lt;/span&gt;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;portMappings&amp;#34;&lt;/span&gt;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;containerPort&amp;#34;&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;8000&lt;/span&gt;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;hostPort&amp;#34;&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;8000&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;essential&amp;#34;&lt;/span&gt;: &lt;span style="color:#66d9ef"&gt;true&lt;/span&gt;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;logConfiguration&amp;#34;&lt;/span&gt;: {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;logDriver&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;awslogs&amp;#34;&lt;/span&gt;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;options&amp;#34;&lt;/span&gt;: {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;awslogs-group&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;/ecs/patientping-ecs&amp;#34;&lt;/span&gt;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;awslogs-region&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;us-east-1&amp;#34;&lt;/span&gt;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;awslogs-stream-prefix&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;ecs&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Property&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Description&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;.family&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;The name of the task definition&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;.cpu&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;The amount of CPU to allocate to the task, in units of roughly 1/1024th of a core&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;.memory&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;The amount of memory to allocate to the task, in MB&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;.networkMode&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;The network mode to use for the task; &lt;code&gt;awsvpc&lt;/code&gt; assigns an IP address directly within the VPC.&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;.executionRoleArn&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;This is an IAM role that&amp;rsquo;s used &lt;strong&gt;while the task is booting up&lt;/strong&gt;.&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;.runtimePlatform&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;The operating system family to use for the task&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;.requiresCompatibilities&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;The compute resources that the task can use&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;.volumes&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Optional volume configuration for the task.&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;containerDefinitions.name&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;The name of the container&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;containerDefinitions.image&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;The container image to run&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;containerDefinitions.portMappings&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;The ports to expose from the container&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;containerDefinitions.essential&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;If &lt;code&gt;true&lt;/code&gt;, the task will try to recover if this container exits&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;containerDefinitions.logConfiguration&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;The logging configuration for the container (more details on this later)&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;h2 id="example"&gt;Example&lt;a class="anchor" href="#example"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;The cluster is ready, but ECS doesn&amp;rsquo;t know what to run or how. The task definition is the recipe: which image, how much CPU and memory, which IAM roles, where to send logs. Our app reads &lt;code&gt;/CMO_NAME&lt;/code&gt; from SSM at runtime and returns it in the response when available.&lt;/p&gt;</description></item><item><title>ecs-security-groups</title><link>https://blog.ulutasalperen.com/docs/aws/ecs/ecs-security-groups/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/aws/ecs/ecs-security-groups/</guid><description>&lt;h1 id="ecs-security-groups"&gt;ECS Security Groups&lt;a class="anchor" href="#ecs-security-groups"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;Now we need &lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/vpc-security-groups.html"&gt;&lt;strong&gt;Security Groups&lt;/strong&gt;&lt;/a&gt; to control who can reach our ECS tasks. We&amp;rsquo;ll place our tasks in public subnets; only the load balancer should be able reach them. Security groups let us define exactly which traffic is allowed. We&amp;rsquo;ll need two of them:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;One for the &lt;strong&gt;ECS tasks&lt;/strong&gt;. This will be an &lt;strong&gt;internal security group&lt;/strong&gt; that allows traffic from an &lt;a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html"&gt;Application Load Balancer (ALB)&lt;/a&gt; to our ECS tasks. A powerful feature of security groups is that they can reference &lt;em&gt;other&lt;/em&gt; security groups instead of IP addresses, so we can allow traffic from the load balancer without hardcoding IPs.&lt;/li&gt;&#10;&lt;li&gt;One for the &lt;strong&gt;Load Balancer&lt;/strong&gt;. This will be an &lt;strong&gt;external security group&lt;/strong&gt; that allows internet traffic to the load balancer.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;Security groups referencing other security groups is one of those AWS features that seems obvious once you see it, but it&amp;rsquo;s easy to miss. It&amp;rsquo;s way better than managing IP addresses manually, especially when things change.&lt;/p&gt;</description></item><item><title>application-load-balancer</title><link>https://blog.ulutasalperen.com/docs/aws/ecs/application-load-balancer/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/aws/ecs/application-load-balancer/</guid><description>&lt;h1 id="application-load-balancer"&gt;Application Load Balancer&lt;a class="anchor" href="#application-load-balancer"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;I know that it looks like we&amp;rsquo;re working on anything &lt;em&gt;but&lt;/em&gt; &lt;code&gt;ECS&lt;/code&gt; and &lt;code&gt;containers&lt;/code&gt; at the moment, but I promise we&amp;rsquo;re getting closer. We just have to &lt;a href="https://en.wiktionary.org/wiki/yak_shaving"&gt;shave a few more yaks&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;Now it&amp;rsquo;s time to start listening for traffic. To do that, we&amp;rsquo;ll set up a &lt;strong&gt;Load Balancer&lt;/strong&gt; and a &lt;a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-listeners.html"&gt;&lt;strong&gt;Listener&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="https://storage.googleapis.com/qvault-webapp-dynamic-assets/course_assets/GQ1RvYY-638x721.png" alt="listener diagram" /&gt;&lt;/p&gt;&#10;&lt;p&gt;A &lt;a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/userguide/what-is-load-balancing.html"&gt;load balancer&lt;/a&gt; sits in front of our service and distributes incoming traffic across your task(s). It handles things like health checks, SSL termination, and routing traffic to healthy containers. We&amp;rsquo;ll place the load balancer in public subnets so it can receive traffic from the internet.&lt;/p&gt;</description></item><item><title>ecs-target-groups</title><link>https://blog.ulutasalperen.com/docs/aws/ecs/ecs-target-groups/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/aws/ecs/ecs-target-groups/</guid><description>&lt;h1 id="target-groups"&gt;Target Groups&lt;a class="anchor" href="#target-groups"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;Now it&amp;rsquo;s time to configure the load balancer to actually route traffic to our ECS tasks (instead of just returning its own fixed response). This is where &lt;a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html"&gt;&lt;strong&gt;Target Groups&lt;/strong&gt;&lt;/a&gt; come in.&lt;/p&gt;&#10;&lt;p&gt;A &lt;strong&gt;target group&lt;/strong&gt; tells the load balancer where to send traffic. It defines:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Protocol and port:&lt;/strong&gt; What protocol (HTTP/HTTPS) and which port your tasks are listening on&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Health checks:&lt;/strong&gt; How the load balancer determines if a target is healthy&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Target type:&lt;/strong&gt; Whether targets are IP addresses (for Fargate) or instance IDs (for EC2)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;For ECS with Fargate, we&amp;rsquo;ll use the &lt;code&gt;ip&lt;/code&gt; target type because each task gets its own IP address. The load balancer will route traffic directly to the task&amp;rsquo;s IP address.&lt;/p&gt;</description></item><item><title>cloudwatch-log-groups</title><link>https://blog.ulutasalperen.com/docs/aws/ecs/cloudwatch-log-groups/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/aws/ecs/cloudwatch-log-groups/</guid><description>&lt;h1 id="cloudwatch-log-groups"&gt;CloudWatch Log Groups&lt;a class="anchor" href="#cloudwatch-log-groups"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;Now, how will we know if something goes wrong with our containers at runtime? We need to set up &lt;a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html"&gt;&lt;strong&gt;CloudWatch Log Groups&lt;/strong&gt;&lt;/a&gt; so we can see what&amp;rsquo;s happening inside our containers (&lt;code&gt;stdout&lt;/code&gt;, &lt;code&gt;stderr&lt;/code&gt;, application logs, etc.).&lt;/p&gt;&#10;&lt;p&gt;Think of &lt;a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Working-with-log-groups-and-streams.html"&gt;CloudWatch log groups and log streams&lt;/a&gt; as folders for your logs. Each group can have multiple streams (one per container instance), so you can see all logs for a service in one place.&lt;/p&gt;</description></item><item><title>ecs-services</title><link>https://blog.ulutasalperen.com/docs/aws/ecs/ecs-services/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/aws/ecs/ecs-services/</guid><description>&lt;h1 id="ecs-services"&gt;ECS Services&lt;a class="anchor" href="#ecs-services"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;Finally! Time to build the &lt;a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs_services.html"&gt;&lt;strong&gt;ECS Service&lt;/strong&gt;&lt;/a&gt; that ties everything together, and answers these questions:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Where do we place our tasks?&lt;/li&gt;&#10;&lt;li&gt;How do we scale them?&lt;/li&gt;&#10;&lt;li&gt;How do we connect to the load balancer?&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Once we create an ECS service with load balancer settings, ECS automatically registers tasks with the &lt;a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html"&gt;target group&lt;/a&gt; as they start.&lt;/p&gt;&#10;&lt;h2 id="assignment"&gt;Assignment&lt;a class="anchor" href="#assignment"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;&lt;strong&gt;Create an ECS service &lt;code&gt;patientping-svc&lt;/code&gt;&lt;/strong&gt; that runs your task definition and connects it to the load balancer (cluster &lt;code&gt;patientping-ecs&lt;/code&gt;, ALB &lt;code&gt;patientping-alb&lt;/code&gt;, target group &lt;code&gt;patientping-tg&lt;/code&gt;).&lt;/p&gt;</description></item></channel></rss>