<?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: Aleksandar Polic</title>
    <description>The latest articles on Forem by Aleksandar Polic (@exambitional).</description>
    <link>https://forem.com/exambitional</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%2F351434%2F1f547a3b-d92e-4dbc-9537-e612ee9b169b.jpg</url>
      <title>Forem: Aleksandar Polic</title>
      <link>https://forem.com/exambitional</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/exambitional"/>
    <language>en</language>
    <item>
      <title>AWS ECS: Terms and Concepts</title>
      <dc:creator>Aleksandar Polic</dc:creator>
      <pubDate>Thu, 15 Dec 2022 21:59:21 +0000</pubDate>
      <link>https://forem.com/exambitional/aws-ecs-terms-and-concepts-26gc</link>
      <guid>https://forem.com/exambitional/aws-ecs-terms-and-concepts-26gc</guid>
      <description>&lt;p&gt;AWS ECS can be really daunting to grasp at first, mostly because it introduces a lot of new concepts. Without clear analogies, it is hard to understand tutorials explaining all the processes in ECS.&lt;/p&gt;

&lt;p&gt;This blog post should serve you as entry point to ECS terms. It should help you understand them and give you examples so you can start learning one of the most valuable AWS services with ease.&lt;/p&gt;

&lt;h2&gt;
  
  
  Task Definition
&lt;/h2&gt;

&lt;p&gt;To prepare your application to run on Amazon ECS, you create a task definition. The task definition is a text file, in JSON format, that describes one or more containers, up to a maximum of ten, that form your application.&lt;/p&gt;

&lt;p&gt;It can be thought of as a blueprint for your application. Task definitions specify various parameters for your application. Examples of task definition parameters are which containers to use, which launch type to use, which ports should be opened for your application, and what data volumes should be used with the containers in the task. The specific parameters available for your task definition depend on the needs of your specific application.&lt;/p&gt;

&lt;p&gt;Your entire application stack doesn't need to be on a single task definition. You can do this by combining related containers into their own task definitions, each representing a single component.&lt;/p&gt;

&lt;p&gt;The following is an example of a task definition containing a single container that runs an NGINX web server using the Fargate launch type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"family"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"webserver"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"containerDefinitions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"web"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"image"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"nginx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"memory"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"100"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"cpu"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"99"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"requiresCompatibilities"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"FARGATE"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"networkMode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"awsvpc"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"memory"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"512"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"cpu"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"256"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Task
&lt;/h2&gt;

&lt;p&gt;Task is the instantiation of a task definition. After you create a task definition for your application within Amazon ECS, you can specify the number of tasks to run on your cluster. You can run a standalone task, or you can run a task as part of a service within a cluster. Task can be seen as running container instances.&lt;/p&gt;

&lt;p&gt;Cluster and service are ECS terms used to name concepts used for logical grouping of tasks.&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%2F07vjzne68nmujuomlzjb.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%2F07vjzne68nmujuomlzjb.png" alt="From Task definition to Task" width="800" height="345"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Service
&lt;/h2&gt;

&lt;p&gt;You can use an Amazon ECS &lt;em&gt;service&lt;/em&gt; to run and maintain your desired number of tasks simultaneously in an Amazon ECS cluster. In case a task fails or stops, service will replace the broken one with the new instance of the same.&lt;/p&gt;

&lt;p&gt;Services can be really useful when your apps need maintained availability.&lt;/p&gt;

&lt;h2&gt;
  
  
  Containers, Images and AWS ECR
&lt;/h2&gt;

&lt;p&gt;To deploy applications on Amazon ECS, your application components must be configured to run in &lt;em&gt;containers.&lt;/em&gt; Containers are created from a read-only template that's called an &lt;em&gt;image.&lt;/em&gt; ECS calls running containers tasks.&lt;/p&gt;

&lt;p&gt;Images are typically built from a &lt;strong&gt;Dockerfile&lt;/strong&gt;. A Dockerfile is a plaintext file that specifies all of the components that are included in the container. &lt;/p&gt;

&lt;p&gt;After they're built, these images are stored in a &lt;em&gt;registry&lt;/em&gt; where they can be downloaded from. Most popular one is Dockerhub, but AWS provides such a registry with AWS ECR (Elastic Container Registry). You can upload your images to ECR, then use them to create Task Definitions.&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%2Fdvszzq5iriwawp9km1jf.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%2Fdvszzq5iriwawp9km1jf.png" alt="Image lifecycle" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cluster
&lt;/h2&gt;

&lt;p&gt;An Amazon ECS &lt;em&gt;cluster&lt;/em&gt; is a logical grouping of both tasks or services. You can use clusters to isolate your applications. &lt;/p&gt;

&lt;p&gt;In environments using EC2, clusters are valuable to separate underlying infrastructures, so your apps don’t share them.&lt;/p&gt;

&lt;p&gt;On the other hand, if you are using Fargate, your cluster resources are also managed by Fargate.&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%2Feof09w5ulvfyqtio45yp.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%2Feof09w5ulvfyqtio45yp.png" alt="Cluster example" width="800" height="487"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vue</category>
      <category>react</category>
      <category>frontend</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Elastic Beanstalk: Developer's AWS paradise</title>
      <dc:creator>Aleksandar Polic</dc:creator>
      <pubDate>Sun, 20 Nov 2022 09:42:11 +0000</pubDate>
      <link>https://forem.com/exambitional/elastic-beanstalk-developers-aws-paradise-3d72</link>
      <guid>https://forem.com/exambitional/elastic-beanstalk-developers-aws-paradise-3d72</guid>
      <description>&lt;h2&gt;
  
  
  Beanstalk in a nutshell
&lt;/h2&gt;

&lt;p&gt;Starting with the cloud, it can be pretty intimidating because of all the fancy words you hear while learning. Auto-scaling and resource provisioning are just a couple of phrases that may be confusing for new developers. Besides that, most developers just want their code to run, without digging deep into hosting technology. Especially when deadlines are approaching.&lt;/p&gt;

&lt;p&gt;Enters the room, Elastic Beanstalk. It is a managed service that helps developers run their web applications fast and without worrying about best practices in the AWS environment. It is used by both new and more experienced developers since it is easy to set up but also rich with features so you can tailor your system to your custom needs.&lt;/p&gt;

&lt;p&gt;But first, what does managed service even means? It means AWS itself is managing everything. You don't need to worry about updates, security patches, and every other detail that is essential for running the application securely and consistently.&lt;/p&gt;

&lt;p&gt;What is your job then? Just provide an overview of what your system needs and upload a code. It is that simple. You simply upload your code and Elastic Beanstalk automatically handles the deployment, from capacity provisioning, load balancing, and automatic scaling to web application health monitoring.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;p&gt;Beanstalk works with the application/environment model. You create your application, and then you can have multiple environments for it. This basically means you can have completely different system architectures for different environments. For example, your server could run in only one instance for the development environment but have scaling functionalities implemented for production. And what do you need to do there? Just pick the options for scaling. Pick how many instances should be running minimally and maximally. Pick the thresholds for spinning new instances and terminating unused instances. Everything else is managed by Beanstalk itself.&lt;/p&gt;

&lt;p&gt;You have the freedom to choose the deployment options for your applications. Some of them are All at once, Rolling, Blue/Green... This will not be covered in this blog post but it is mentioned to point out the vast range of features Beanstalk has.&lt;/p&gt;

&lt;h2&gt;
  
  
  Supported Platforms
&lt;/h2&gt;

&lt;p&gt;Beanstalk supports a wide variety of platforms. The list is as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GO&lt;/li&gt;
&lt;li&gt;JAVA SE&lt;/li&gt;
&lt;li&gt;JAVA Tomcat&lt;/li&gt;
&lt;li&gt;.NET with IIS&lt;/li&gt;
&lt;li&gt;NodeJS&lt;/li&gt;
&lt;li&gt;PHP&lt;/li&gt;
&lt;li&gt;Python&lt;/li&gt;
&lt;li&gt;Ruby&lt;/li&gt;
&lt;li&gt;Packer builder&lt;/li&gt;
&lt;li&gt;Single Container Docker&lt;/li&gt;
&lt;li&gt;Multi Container Docker&lt;/li&gt;
&lt;li&gt;Preconfigured Docker&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;New platforms are added constantly. There is also one nice feature that makes Elastic Beanstalk perfectly capable of every need you can think of. It is called Custom platform. You can completely configure the platform you need for your applications. This is very important for companies that have a lot of custom system configurations. Custom platform has a major drawback though. It is seen as a very advanced feature which means that it is not easy at all to create your personalized platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  Beanstalk CLI
&lt;/h2&gt;

&lt;p&gt;We can install an additional CLI called the EB CLI which makes working with Beanstalk from the CLI easier. It’s helpful for your automated deployment pipelines!&lt;/p&gt;

&lt;p&gt;After configuration of the environment, you can basically set up one command that will deploy your whole application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating your first Beanstalk web app
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Starting point
&lt;/h3&gt;

&lt;p&gt;First login to your AWS account, and search for Elastic Beanstalk. &lt;br&gt;
When you land on EB service home page, click on create a new application.&lt;/p&gt;

&lt;p&gt;You will then be redirected to page shown below:&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%2Fsfbr89jm63zv2irmuyxx.jpg" 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%2Fsfbr89jm63zv2irmuyxx.jpg" alt="Create application form" width="800" height="744"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the place where you give your application the name, pick a platform and upload your code. This is basically all you need to do for your application to be deployed. Of course, you can manually configure in more detail by clicking Configure more options button. This is what we will do to check more in depth configurations.&lt;/p&gt;

&lt;p&gt;As you can see, you can use Sample application code. AWS has sample source codes for every platform, so you can get a hang of most common Beanstalk features without the need for any code from your side.&lt;/p&gt;

&lt;h3&gt;
  
  
  Overview of most common environment configurations
&lt;/h3&gt;

&lt;p&gt;After clicking on Configure more options button, you will land on Configure environment page:&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%2Fsrl3a0djsw8pr0nw95i2.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%2Fsrl3a0djsw8pr0nw95i2.png" alt="Application environment" width="800" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is where the magic happens. As you can see, configurations are categorized so it is easier to configure individual resources for your application.&lt;/p&gt;

&lt;p&gt;We will go through the most important ones, but feel free to experiment with all. Just be aware that, even though Beanstalk is free, resources provisioned by it, that are out of free tier will be charged, so don't forget to check the pricing pages or erase all of the resources if you are just researching Beanstalk capabilities. &lt;/p&gt;

&lt;p&gt;Presets:&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%2F541s4ca2l70gdwb89r4u.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%2F541s4ca2l70gdwb89r4u.png" alt="Presets" width="800" height="249"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Presets, also called deployment modes, tell Beanstalk the overall architecture you want for your environment. Single instance presets are great for development and testing. As the name suggests they use one instance (server) for running your web app. &lt;/p&gt;

&lt;p&gt;High availability presets are most commonly used in production. They are leveraging the load balancer features and they use auto-scaling.&lt;/p&gt;

&lt;p&gt;Platform:&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%2Fvw2np0is5y20muoomy6x.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%2Fvw2np0is5y20muoomy6x.png" alt="Platform" width="800" height="135"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the place where you can pick your platform and its version.&lt;/p&gt;

&lt;p&gt;Software:&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%2Fh82ozdp3zidzgi38xrgz.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%2Fh82ozdp3zidzgi38xrgz.png" alt="Software" width="500" height="266"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Software category is used for your software-related configs. You can set your environment variables (called environment properties here) in software configuration. Bye, bye env files.&lt;/p&gt;

&lt;p&gt;Instances:&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%2Fh5r3308mqoiigpqwh6oe.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%2Fh5r3308mqoiigpqwh6oe.png" alt="Instances" width="491" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here you can configure your instances memory resources and public availability. In high availability applications, it is best practice to keep your instances private while the load balancer should be public, which will route all the traffic to your application.&lt;/p&gt;

&lt;p&gt;Load balancer:&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%2Fncu0jd42q28pczwqy2ro.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%2Fncu0jd42q28pczwqy2ro.png" alt="Load Balancer" width="491" height="221"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Load balancer type, as well as listeners, protocols and ports, are configured here&lt;/p&gt;

&lt;p&gt;Capacity:&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%2Fabocfo2a0z5m9m4t6u9f.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%2Fabocfo2a0z5m9m4t6u9f.png" alt="Capacity" width="487" height="249"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In capacity section, you choose your EC2 instance type and system image. Basically, this is the same old school EC2 configuration&lt;/p&gt;

&lt;p&gt;Security:&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%2Fw3tmkfykeu0ad837l1ec.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%2Fw3tmkfykeu0ad837l1ec.png" alt="Security" width="487" height="218"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And last but not least, security. This is where the role is created that performs all the deployment actions on your behalf. It is also the place where you will need to create and assign private keys for SSH access to your instance(s).&lt;/p&gt;

&lt;p&gt;After you are ready click on create an app and let Beanstalk create every resource for your application. After a few minutes, you should land on the page below, and if everything is OK, your application should be fully deployed. &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%2Fop3iufz4dz7w3ho59uwg.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%2Fop3iufz4dz7w3ho59uwg.png" alt="Environment health page" width="800" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use link below environment name to visit your Beanstalk application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Outro
&lt;/h2&gt;

&lt;p&gt;This is just scratching the surface of one of the most powerful tools AWS is providing to developers. I hope I could show you how EB can save developers time every day while also being a platform where developers can learn about cloud best practices. Elastic Beanstalk is the service you should definitely have in your cloud tools arsenal.&lt;/p&gt;

</description>
      <category>cleancoding</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Deployment of .NET 6 apps on ECS with Fargate</title>
      <dc:creator>Aleksandar Polic</dc:creator>
      <pubDate>Mon, 14 Nov 2022 20:04:57 +0000</pubDate>
      <link>https://forem.com/exambitional/deployment-of-net-6-apps-on-ecs-with-fargate-2n37</link>
      <guid>https://forem.com/exambitional/deployment-of-net-6-apps-on-ecs-with-fargate-2n37</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;AWS offers great support for running apps inside docker containers. The whole management cycle is made easy and the real difference is that it offers running containers in serverless environment. Using Fargate, we can spin up and down number of containers without having a host infrastructure. &lt;/p&gt;

&lt;p&gt;ECS with Fargate will give you all the tools you need to build, deploy and maintain docker containers using serverless technology.&lt;/p&gt;

&lt;p&gt;This article will guide you through all the steps you need to take to run fully functional ASP.NET 6 application in ECS environment. I know that running the app is not good enough for modern needs, so at the end of the article, there are also explanations of how to set up HTTPS with SSL certificate on load balancer and CI/CD pipeline. With that, you will have full development cycle covered in ECS. The only thing you will then need is to write code!&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a Dockerfile
&lt;/h2&gt;

&lt;p&gt;Dockerfile example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;mcr.microsoft.com/dotnet/sdk:6.0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;build-env&lt;/span&gt;
&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /app&lt;/span&gt;

&lt;span class="c"&gt;# Copy everything&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; . ./&lt;/span&gt;
&lt;span class="c"&gt;# Restore as distinct layers&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;dotnet restore
&lt;span class="c"&gt;# Build and publish a release&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;dotnet publish &lt;span class="nt"&gt;-c&lt;/span&gt; Release &lt;span class="nt"&gt;-o&lt;/span&gt; out

&lt;span class="c"&gt;# Build runtime image&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; mcr.microsoft.com/dotnet/aspnet:6.0&lt;/span&gt;
&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /app&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; --from=build-env /app/out .&lt;/span&gt;
&lt;span class="k"&gt;ENTRYPOINT&lt;/span&gt;&lt;span class="s"&gt; ["dotnet", "SampleProject.Presentation.dll"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example is valid if Dockerfile is added to the same directory where the solution file resides.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build an image using Dockerfile*
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;This step can be skipped if you are directly building an image for ECR&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To build a docker image is a necessary step, since we will be using docker image to start a container in any environment. The command that we want to use is &lt;code&gt;docker build&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;Example for building the image would be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt; docker build -f SampleProject/Dockerfile -t sample-project-image ./SampleProject
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-f flag stands for path to Dockerfile&lt;/p&gt;

&lt;p&gt;-t will tell the Docker how we want to name our image&lt;/p&gt;

&lt;p&gt;The only parameter in &lt;code&gt;docker build&lt;/code&gt; command is &lt;code&gt;PATH&lt;/code&gt; or &lt;code&gt;URL&lt;/code&gt;. It gives the context about image, or to be precise, set of files necessary to build an image. For more information check out &lt;code&gt;docker build&lt;/code&gt; docs page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.docker.com/engine/reference/commandline/build/" rel="noopener noreferrer"&gt;docker build&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Push the image to Repository (ECR)
&lt;/h2&gt;

&lt;p&gt;Docker images must be stored in repository from which we can access it to run a container. In our case, we will use AWS ECR (Elastic Container Registry).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To start, create a repository.&lt;/li&gt;
&lt;li&gt;Go to AWS Console and search for Elastic Container Registry service.&lt;/li&gt;
&lt;li&gt;Locate Create a repository button and click on it.&lt;/li&gt;
&lt;li&gt;Choose if you want it to be Public facing or Private, give it a name, leave all other settings as they are and click Create repository button&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now go to Repositories tab on the left and select your new repository via radio button on the left side&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fb9ppoh4qx2xmc3d00erb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fb9ppoh4qx2xmc3d00erb.png" alt="Repository example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, above the list of repos, there should be a button called View push commands. It will give you the instructions for pushing the Docker image to ECR based on OS you are using&lt;/p&gt;

&lt;p&gt;After all steps are completed successfully, you should be able to see your image in the ECR repository you created earlier.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fdwhjtp37za0t1v7tkfx2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fdwhjtp37za0t1v7tkfx2.png" alt="Pushing steps"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Create Task definition
&lt;/h2&gt;

&lt;p&gt;Task definition defines containers and their settings as well as it specifies which containers are included in your task and how they interact with each other. You can also specify data volumes for your containers to use.&lt;/p&gt;

&lt;p&gt;To start go to AWS Console and search for ECS:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On the left side, choose Task definitions&lt;/li&gt;
&lt;li&gt;Click on Create new Task definiton&lt;/li&gt;
&lt;li&gt;For launch type compatibility choose Fargate and click Next step button&lt;/li&gt;
&lt;li&gt;Give your task a name&lt;/li&gt;
&lt;li&gt;Task should have Task role

&lt;ul&gt;
&lt;li&gt;This is just IAM role, which can be created directly from this page by clicking on the link below the input field&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fpxixihsndkeaedheecq9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fpxixihsndkeaedheecq9.png" alt="Task role"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This role will be created with AmazonECSTaskExecutionRolePolicy policy.&lt;/li&gt;
&lt;li&gt;This is fine for the most part, but we want to have Logging to CloudWatch from our CI/CD pipeline later on. To be able to log to a different AWS service, we will need to add access policy for that particular service.&lt;/li&gt;
&lt;li&gt;Add CloudWatchLogsFullAccess policy to newly created IAM Role&lt;/li&gt;
&lt;li&gt;You are all set now!&lt;/li&gt;
&lt;li&gt;Operating system family should be Linux&lt;/li&gt;
&lt;li&gt;For &lt;strong&gt;Task execution IAM role&lt;/strong&gt; choose the same Role you created in a step above&lt;/li&gt;
&lt;li&gt;For &lt;strong&gt;Task size&lt;/strong&gt; you can pick a value that is best for you, but for now, let’s choose 0.5GB for memory and 0.5 vCPU for Task CPU&lt;/li&gt;
&lt;li&gt;Now it is time to add &lt;strong&gt;Container definitions&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Click on Add container button. This will toggle a new modal&lt;/li&gt;
&lt;li&gt;Give your container a name&lt;/li&gt;
&lt;li&gt;For Image, copy the value of your image link from ECR repository&lt;/li&gt;
&lt;li&gt;Add soft limit to be the same as Task memory (500mb)&lt;/li&gt;
&lt;li&gt;For port mappings, you can add HTTP and HTTPS ports for example (80 and 443)&lt;/li&gt;
&lt;li&gt;In advanced container configuration section you can fine tune your container. Add environment files and variables, open volumes if necessary etc.&lt;/li&gt;
&lt;li&gt;Regarding our app, this is not necessary, so we will go straight to creation, so click Add button&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;You can leave other settings after container definitions unchanged. Of course, for other cases, these other settings can be tuned.&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Create Service based on Task
&lt;/h2&gt;

&lt;p&gt;Service represents the place for long running tasks to live. It is part of the Cluster in ECS.&lt;/p&gt;

&lt;p&gt;First create a cluster in ECS.&lt;/p&gt;

&lt;p&gt;For cluster template use Networking only, since we want out cluster to be using Fargate.&lt;/p&gt;

&lt;p&gt;Give cluster a name on the next screen, leave everything else as default and click Create.&lt;/p&gt;

&lt;p&gt;Go into your new cluster if you are not redirected automatically.&lt;br&gt;
Locate Services tab.&lt;br&gt;
On Services tab, click on Create button.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For &lt;strong&gt;launch type&lt;/strong&gt;, choose Fargate&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Operating system family&lt;/strong&gt; should be Linux&lt;/li&gt;
&lt;li&gt;For &lt;strong&gt;Task definition&lt;/strong&gt;, use the definition we created earlier&lt;/li&gt;
&lt;li&gt;Give your service a meaningful &lt;strong&gt;name&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Service type&lt;/strong&gt; should be REPLICA&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add number of tasks you want to run by default&lt;/strong&gt; (number of containers to be running all the time). For testing purposes, leave insert 1&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Minimum health capacity&lt;/strong&gt; should be 0. This means we are OK to have 0 tasks running while doing a deployment&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Minimum health capacity&lt;/strong&gt; should be 100. This means we are OK to have 1 task running max when we are deploying new version&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;default&lt;/strong&gt; settings for rest and click Next step&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the &lt;strong&gt;next step&lt;/strong&gt;, we are setting up &lt;strong&gt;VPC&lt;/strong&gt; (virtual private cloud) settings and &lt;strong&gt;Load Balancer&lt;/strong&gt;. You will need to create a Load balancer first (explained below). After you create the load balancer, do the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now select VPC and for subnets, include all 3&lt;/li&gt;
&lt;li&gt;Next we should setup is load balancing&lt;/li&gt;
&lt;li&gt;For Load balancer type choose Application Load Balancer&lt;/li&gt;
&lt;li&gt;In Load balancer name dropdown, choose the balancer we created earlier&lt;/li&gt;
&lt;li&gt;You should now see the container from task definition in &lt;strong&gt;Container to load balance&lt;/strong&gt; section&lt;/li&gt;
&lt;li&gt;Click on Add to load balancer button to set up the container&lt;/li&gt;
&lt;li&gt;For production listener port use 80:HTTP from dropdown (we created this port listener when we created load balancer)&lt;/li&gt;
&lt;li&gt;For target group name choose the group we created when creating load balancer&lt;/li&gt;
&lt;li&gt;Now, click on Next step&lt;/li&gt;
&lt;li&gt;On Set Auto Scaling page, just click Next step&lt;/li&gt;
&lt;li&gt;Now you can rewiew your service, once you are happy with everyhing, click Create service&lt;/li&gt;
&lt;li&gt;If the service is created successfully, click on View service button, and check out how the service is booted up and how tasks are starting to run.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Congratulations, you should now have the running service in place!&lt;/p&gt;
&lt;h2&gt;
  
  
  Create Load balancer
&lt;/h2&gt;

&lt;p&gt;Load balancer will be used as an entry point to our application. It is also responsible to send the request to one of the ECS service tasks.&lt;/p&gt;

&lt;p&gt;To create a load balancer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to EC2 instance&lt;/li&gt;
&lt;li&gt;Locate &lt;strong&gt;Load Balancers&lt;/strong&gt; section on the left and enter it&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Create Load Balancer&lt;/strong&gt; button&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;Application Load Balancer&lt;/strong&gt; as a type&lt;/li&gt;
&lt;li&gt;Give your ALB a &lt;strong&gt;name&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;Network mappings&lt;/strong&gt; section check all 3 mappings&lt;/li&gt;
&lt;li&gt;Create new &lt;strong&gt;Secutity group&lt;/strong&gt; for ALB and open &lt;strong&gt;ports 80 and 443&lt;/strong&gt;, then choose it from the dropdown&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;Listeners and Routing&lt;/strong&gt; section Add HTTP listener for port 80&lt;/li&gt;
&lt;li&gt;You will need to create a &lt;strong&gt;target group&lt;/strong&gt; to forward to

&lt;ul&gt;
&lt;li&gt;Use &lt;strong&gt;Create target group&lt;/strong&gt; link below the dropdown field. It will redirect you to page to create a new target group&lt;/li&gt;
&lt;li&gt;Choose IP addresses for target type&lt;/li&gt;
&lt;li&gt;Give group a name and leave everything else as default&lt;/li&gt;
&lt;li&gt;Click on Next button&lt;/li&gt;
&lt;li&gt;On the next page leave everything as it is and click Create target group&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Now the target group can be selected from the dropdown&lt;/li&gt;
&lt;li&gt;After that, click Create load balancer button and that is it!&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  HTTPS Specifics
&lt;/h2&gt;

&lt;p&gt;To be able to use HTTPS with our new load balancer, we will need to have SSL certificate present in ACM (Amazon certificate manager).&lt;br&gt;
You can either get the certificate from Amazon (free), or import your own certificate. &lt;br&gt;
More info here: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/acm/latest/userguide/import-certificate-api-cli.html" rel="noopener noreferrer"&gt;Importing a certificate&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-request-public.html" rel="noopener noreferrer"&gt;Requesting a public certificate&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you have your verified certificate in ACM, go to load balancers in EC2 service:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select your load balancer&lt;/li&gt;
&lt;li&gt;Locate and go to Listeners tab&lt;/li&gt;
&lt;li&gt;Click on Add Listener button&lt;/li&gt;
&lt;li&gt;For protocol, choose HTTPS&lt;/li&gt;
&lt;li&gt;For action choose Forward and find your target group in dropdown&lt;/li&gt;
&lt;li&gt;In secure listener settings for Default SSL/TLS certificate choose your certificate from a dropdown&lt;/li&gt;
&lt;li&gt;Now click Add&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, you have to add CNAME DNS record in your DNS settings. Use domain you used for setting up ACM certificate and  value of the record should be DNS address of your load balancer.&lt;/p&gt;

&lt;p&gt;Evrything is set up now, but HTTP to HTTPS redirection is not yet in place.&lt;/p&gt;

&lt;p&gt;To do this, again, go to load balancers, select your load balancer and go to Listeners tab.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the Listeners table locate Rules column&lt;/li&gt;
&lt;li&gt;For HTTP:80 listener click on View/Edit rules in Rules column&lt;/li&gt;
&lt;li&gt;Click on Edit rules tab on the next page&lt;/li&gt;
&lt;li&gt;Click on Edit rule (pencil icon) button next to Listener name&lt;/li&gt;
&lt;li&gt;In Then section, edit the rule from Forward to Redirect to&lt;/li&gt;
&lt;li&gt;Select HTTPS and 443 for redirect values&lt;/li&gt;
&lt;li&gt;Click on circled checkmark icon to save the changes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, all the HTTP requests will be automatically redirected to our secure listener&lt;/p&gt;


&lt;h2&gt;
  
  
  CI/CD pipeline
&lt;/h2&gt;

&lt;p&gt;We will be using Gitlab CI to set up the pipeline. The process will automate everything we did above. &lt;br&gt;
For pipeline to be successful, there should be initial setup. This means, there must be cluster, service and task definition created beforehand.&lt;/p&gt;

&lt;p&gt;CI/CD pipeline for this particular case is very easy to set up since we are only going to use 2 template files.&lt;/p&gt;

&lt;p&gt;Variable fields will be presented in  format, and for each variable there will be example at the end.&lt;/p&gt;

&lt;p&gt;First template file is &lt;strong&gt;aws-ecs.json&lt;/strong&gt;, which is used to configure AWS ECS service from code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"executionRoleArn"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;execution-role-arn&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"containerDefinitions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="w"&gt;

        &lt;/span&gt;&lt;span class="nl"&gt;"memoryReservation"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1024&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"environment"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ASPNETCORE_ENVIRONMENT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Test"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}],&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;cluster-&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"mountPoints"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[],&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"image"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;image-link&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"essential"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"logConfiguration"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="nl"&gt;"logDriver"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"awslogs"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="nl"&gt;"options"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"awslogs-create-group"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"true"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"awslogs-region"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;region&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"awslogs-stream-prefix"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ecs"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"awslogs-group"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;log-group&amp;gt;"&lt;/span&gt;&lt;span class="w"&gt;
             &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"portMappings"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"hostPort"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"protocol"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tcp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"containerPort"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"requiresCompatibilities"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"FARGATE"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"networkMode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"awsvpc"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"cpu"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"512"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"taskRoleArn"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;execution-role-arn&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"memory"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1024"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"family"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"aws-ecs"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Variables, examples and definitions:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt; - unique identifier for Task execution role (found in IAM role)&lt;/p&gt;

&lt;p&gt;arn:aws:iam::123482667567:role/ecsTaskExecutionRole&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt; - name of the cluster you created for this pipeline&lt;/p&gt;

&lt;p&gt;sample-project-image&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt; - unique image link found in ECR repository&lt;/p&gt;

&lt;p&gt;123482667567.dkr.ecr.eu-west-2.amazonaws.com/sample-project-image&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt; - region where you want your logs to reside&lt;/p&gt;

&lt;p&gt;eu-west-2&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt; - name of the log group in CloudWatch where the logs about this cluster will reside&lt;/p&gt;

&lt;p&gt;/ecs/sample-project-logs&lt;/p&gt;

&lt;p&gt;Settings like portMappings, cpu, memory and family can be changed based on your applications needs, but I won’t be putting those as variables.&lt;/p&gt;

&lt;p&gt;Second template file is &lt;strong&gt;.gitbal-ci.yml&lt;/strong&gt;. It is the file that tells the Gitlab CI how to run the pipeline.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;stages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;publish&lt;/span&gt;

&lt;span class="na"&gt;variables&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;EXAMPLE_REPOSITORY_URL&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;repo-url&amp;gt;&lt;/span&gt;
  &lt;span class="na"&gt;REGION&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;region&amp;gt;&lt;/span&gt;
  &lt;span class="na"&gt;EXAMPLE_TASK_DEFINTION_NAME&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;task-definition-name&amp;gt;&lt;/span&gt;
  &lt;span class="na"&gt;EXAMPLE_CLUSTER_NAME&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;cluster-name&amp;gt;&lt;/span&gt;
  &lt;span class="na"&gt;EXAMPLE_SERVICE_NAME&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;service-name&amp;gt;&lt;/span&gt;
  &lt;span class="na"&gt;EXAMPLE_DESIRED_COUNT&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;task-count&amp;gt;&lt;/span&gt;

&lt;span class="na"&gt;publish&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;publish&lt;/span&gt;
  &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;docker:latest&lt;/span&gt;
  &lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;docker:18-dind&lt;/span&gt;
  &lt;span class="na"&gt;before_script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;apk add --no-cache curl jq python3 py3-pip&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;pip install awscli&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;date&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;docker version&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;$(aws ecr get-login --no-include-email --region "${REGION}")&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "Building image"&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;docker build -f &amp;lt;path-to-Dockerfile&amp;gt; -t &amp;lt;image-name&amp;gt; &amp;lt;path-to-root-of-project&amp;gt;&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "Tagging image"&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;docker tag &amp;lt;image-name&amp;gt;:latest "${EXAMPLE_REPOSITORY_URL}"&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "Pushing image to ECR"&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "${EXAMPLE_REPOSITORY_URL}"&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;docker push "${EXAMPLE_REPOSITORY_URL}"&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;aws ecs register-task-definition --region "${REGION}" --family "${EXAMPLE_TASK_DEFINTION_NAME}" --cli-input-json file://aws-ecs.json&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;aws ecs update-service --region "${REGION}" --cluster "${EXAMPLE_CLUSTER_NAME}" --service "${EXAMPLE_SERVICE_NAME}" --task-definition "${EXAMPLE_TASK_DEFINTION_NAME}" --desired-count "${EXAMPLE_DESIRED_COUNT}"&lt;/span&gt;
  &lt;span class="na"&gt;only&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;release/testing&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Variables, examples and definitions:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt; -  url to the image found in ECR repository&lt;/p&gt;

&lt;p&gt;123482667567.dkr.ecr.eu-west-2.amazonaws.com/sample-project-image:latest&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt; - Region where ECS should be set up&lt;/p&gt;

&lt;p&gt;eu-west-2&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt; - Name of the Task Definition you created earlier&lt;/p&gt;

&lt;p&gt;sample-task-definition&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt; - Name of the Cluster you created earlier&lt;/p&gt;

&lt;p&gt;sample-project-cluster&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt; - Name of the Service in Cluster you created earlier&lt;/p&gt;

&lt;p&gt;sample-project-cluster&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt; - Number of Tasks you want to run after deployment&lt;/p&gt;

&lt;p&gt;1&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt; - Number of Tasks you want to run after deployment&lt;/p&gt;

&lt;p&gt;SampleProject/Dockerfile&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt; - Number of Tasks you want to run after deployment&lt;/p&gt;

&lt;p&gt;sample-project-image&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt; - Number of Tasks you want to run after deployment&lt;/p&gt;

&lt;p&gt;./SampleProject&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>aws</category>
      <category>ecs</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
