<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Elman Hasa on Medium]]></title>
        <description><![CDATA[Stories by Elman Hasa on Medium]]></description>
        <link>https://medium.com/@elmanhasa?source=rss-ca9a54f776a4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*8zftisAMqpVbzveB</url>
            <title>Stories by Elman Hasa on Medium</title>
            <link>https://medium.com/@elmanhasa?source=rss-ca9a54f776a4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 17:03:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@elmanhasa/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What I learned studying Enterprise Architecture]]></title>
            <link>https://medium.com/swlh/what-i-learned-studying-enterprise-architecture-cafbde9e6dc2?source=rss-ca9a54f776a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/cafbde9e6dc2</guid>
            <category><![CDATA[enterprise-architecture]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[togaf]]></category>
            <dc:creator><![CDATA[Elman Hasa]]></dc:creator>
            <pubDate>Fri, 20 Dec 2019 17:37:24 GMT</pubDate>
            <atom:updated>2019-12-21T09:37:33.593Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>“We think of enterprise architecture as the process for fully describing business functionality and business requirements and relate them to information systems requirements.”</blockquote><p>Advancing in my career as a developer, I became increasingly curious about the concept of architecture in software. We often develop the idea of architecture as a cohesive design of our domain of interest. The more I delved into the topic the more I connected it with software architecture patterns and the latest technology. Whenever I thought of architecture, the keywords that came to mind were service-oriented-architecture, pull vs push, AQMP vs RPC, Cloud vs On-premise, etc.</p><p>I had only heard about the term of Enterprise Architecture. At first, I assumed I was dealing with the same concept of architecture applied to an enterprise. I was expecting concerns about scalability, architecture patterns and so on. To understand more on the subject, I studied resources provided by the “The Open Group”. They provide a framework for applying an Enterprise Architecture to an organization “The Open Group Architecture Framework” (TOGAF).</p><p>To my surprise, during the study material, I rarely encountered IT guidelines or patterns. Instead, I found tools and methodologies aimed to provide a business change to an organization, including IT. I saw my vision was only one small part of a bigger picture — a picture I started to appreciate. To grasp more of the big picture, I picked the study path for TOGAF certification.</p><p>Here I will outline some of the main differences from my previous perspective as a developer.</p><h3>Description</h3><p><strong>Enterprise architecture (EA)</strong> is “a well-defined practice for conducting enterprise analysis, design, planning, and implementation, using a holistic approach at all times, for the successful development and execution of strategy. Enterprise architecture applies architecture principles and practices to guide organizations through the business, information, process, and technology changes necessary to execute their strategies.” — OpenGroup</p><p>The definition already gives a good hint — business-driven implementation and planning. The Open Group suggests a method for applying EA called Architecture Development Method (ADM).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wOMgLvFAU4q9N4SM.jpg" /><figcaption>TOGAF ADM Phases</figcaption></figure><p>This method defines the architecture development in phases, outlined in order:</p><ul><li>Architecture Vision -&gt; Focus on understanding requirements and stakeholders’ concerns. Display a draft of the final architecture and how it will impact the enterprise.</li><li>Business -&gt; Design a business architecture and approve it with the stakeholders.</li><li>Information Systems -&gt; Design Data and Application architecture with domain experts based on previous business architecture.</li><li>Technology -&gt; Design the technology platform architecture that will support the application and data.</li><li>Planning -&gt; Group all the required work analyzed in the previous phases into work packages. Integrate with portfolio management to plan the work packages into the organization roadmap.</li><li>Implementation -&gt; Follow the implementation executed by the teams.</li><li>Change Management -&gt; Continuous process to ensure the architecture keeps satisfying requirements, and keep track of new opportunities.</li></ul><p>Basically, the result of the ADM is</p><ul><li>The implementation of the systems based on designed architectures</li><li>The governance processes to keep the implementation valid in continuity.</li></ul><p>I have simplified the description and phases to give a general idea about the methodology. If you want to understand the ADM more in detail I suggest the TOGAF documentation on “The Open Group” website.</p><p>This method is abstract — thought to be tailored for a specific organization. Any phase can be changed, removed or reordered. Despite this, the ADM does apply certain concepts regardless of the enterprise.</p><h3>Business first</h3><blockquote>Recognizing the need is the primary condition for design.</blockquote><p>Architecture development starts with “Business Architecture” (Phase B), which will provide the basis for application, data, and technology architectures. This ensures a focus on business outcomes while designing the solution.</p><p>It might seem simple at first, but how many times have we been driven into technical excellence train of thought with little attention to specific requirements. Developers and IT architects are smart people. They like smart solutions and often get excited about <em>how</em> they will solve the problem. Using “the next big thing” or “finding the perfect tool” can easily become our focus. If not properly managed, this can shift our attention <em>away </em>from thoroughly understanding requirements to build a <em>specific</em> system for it.</p><p>TOGAF emphasizes focus on business outcomes first. This does not mean we disregard technological excellence, on the contrary, we focus more precisely on that topic during the respective phases and may even provide feedback on the business architecture. Which brings me to the next topic.</p><h3>Opportunities in Iterations</h3><blockquote>Good design is good business.</blockquote><p>TOGAF advises an iteration approach to architecture development. That is more impactful than it sounds. As a consequence, it allows a feedback loop through all phases.</p><p>For instance, when we are evaluating technology architecture, we can advise about new technology (or lack thereof) that impacts business action. This way, IT may give a meaningful impact on business requirements. For example, some business activity may be simplified or removed thanks to technology such as “we can share this information using the cloud, no need for manual sending” or “we could also sell this online with x cost instead of a door-to-door salesman” etc.</p><p>This understanding is realized through the use of a common language: “business architecture”. By interacting with the business architecture, solutions architects/domain experts can communicate opportunities that arise from IT/technology to the business. Business architects and stakeholders may decide to take advantage of this opportunity, changing the business architecture, starting the iteration of designing business, application, and technology. This framework allows a consistent way to provide feedback from IT to the business that allows focussing on outcomes <em>and </em>technical excellence.</p><p>Note that the business architecture should be decoupled from technological concerns, but given the rate of technological and product advancement in some fields, they may impact business activity in ways not previously expected.</p><h3>Architecture is about continuity</h3><blockquote>Change is the only constant. Hanging on is the only wrong.</blockquote><p>The architecture process is not over with the implementation. Enterprise Architecture involves “Change Management” as a continuous process. During this process, we monitor the current state of the architecture. This means we monitor whether original requirements are still satisfied in time and we track new opportunities that may have arisen (e.g new products, new technology, etc).</p><p>This approach is interesting, as it treats the architecture itself as an artifact to be maintained — an artifact that involves people, IT and business changes. As a developer, I have encountered situations where to implement new logic, I had to tread lightly and keep track of previous requirements to avoid conflict. This often happens when changing aspects of the software that manage several business processes. This had to be done during the implementation. Having a framework that specifically monitors this, allows for safer changes, better requirements management, and a healthier system.</p><h3>Architecture is about people</h3><blockquote>A design isn’t finished until someone is using it.</blockquote><p>Enterprise Architecture is about restructuring the enterprise itself around the business strategy. It is less about specific IT system design and more about people and processes. It is tailored for each enterprise to achieve change and a set of continuous activity. In most organizations, the architecture will impact people at the business, IT and portfolio management levels. In fact, one of the main points of TOGAF is the organization’s “architecture capability” — which is the ability of the enterprise to consume the desired architecture changes. In practical terms, this usually means ‘training people’, making sure the changes are well received and understood. You may have the most effectively designed architecture to date, but if people are not able to use it, you are bound to fail.</p><p>This is a powerful and down to earth concept to keep in mind. It is the job of the enterprise architect to align all actors into a cohesive process that will bring the desired change and maintain continuity.</p><h3>Conclusions</h3><p>Studying Enterprise Architecture provided an interesting point of view for me. As developers, we are problem solvers. Viewing the desired change from the perspective of the entire organization considers a new set of problems and solutions that involve business, IT, people and processes. Understanding these problems is a different type of challenge, one that may initially seem distant from us, but that affects our work and environment. This broadens our vision on how to manage a change beyond its implementation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cafbde9e6dc2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/what-i-learned-studying-enterprise-architecture-cafbde9e6dc2">What I learned studying Enterprise Architecture</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Universal CICD pipeline for K8S on AWS]]></title>
            <link>https://medium.com/swlh/universal-cicd-pipeline-on-aws-and-k8s-7b4129fac5d4?source=rss-ca9a54f776a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b4129fac5d4</guid>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Elman Hasa]]></dc:creator>
            <pubDate>Wed, 05 Jun 2019 16:36:28 GMT</pubDate>
            <atom:updated>2019-06-22T10:39:41.625Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>At an abstract level, a deployment pipeline is an automated manifestation of your process for getting software from version control into the hands of your users.</blockquote><p>The term CI/CD is becoming widely used in the industry right now. You might have heard about it as Continuous Integration, Continuous Delivery or Continuous Deployment. It’s a concept that goes by many names but covers some basic ideas. Briefly, it outlines practices to keep your code more maintainable, testable and get to your users more quickly. Ultimately, it generates value for the user and the consumer.</p><p>At first glance, it might seem best suited for enterprises or some capital venture. But by understanding its value, you will find CICD to be valuable whether you’re building scalable enterprise applications or simply getting your personal project up and running.</p><h4>Decoupling Infrastructure</h4><blockquote>Develop systems, not software</blockquote><p><em>Microservices </em>has been a widespread term in our industry for a while. It has many shapes and definitions depending on who you ask or the level of detail you want to discuss. But we all agree on one thing: smart decoupling of your applications is the way to go. Whether it is based on the bounded context or application types, you have criteria by which you decouple services in your project.</p><p>Hence, it is a good idea to consider this early on. Many developers design a certain level of decoupling from the start. This requires some forward thinking, as you need to decide the decoupling criteria and the tools you will use for this scope. These tools represent the infrastructure (AMQP, Databases, storage and so on).</p><p>I could go on for a lot more than this article about decoupling techniques and tools. But here, I will mention the tools I use for this example and get back to the CICD pipeline.</p><h4>Entering AWS and K8S</h4><p>A general (and quick way) to maintain infrastructure is through a Cloud System, because of the abstraction and sheer amount of tools they provide. I am using AWS for the variety of its tools. Specifically:</p><ul><li>CodePipeline for CICD pipeline construction</li><li>CodeBuild for running build commands during the pipeline steps</li><li>ECR (Elastic Container Registry) as a repository for build result images.</li><li>S3 for storage</li></ul><p>Kubernetes (K8S) is a Docker containers orchestrator. It applies the IaC (Infrastructure as Code) pattern to provide further abstraction. By applying YAML format files to K8S we can update its state, deploying containers or other objects.</p><p>I will use K8S hosted on AWS. This can be done using <em>kops. </em><a href="https://medium.com/containermind/how-to-create-a-kubernetes-cluster-on-aws-in-few-minutes-89dda10354f4">Here</a> is a nice article explaining how-to.</p><h4>Universal CICD</h4><p>Yes, great. But where does CICD fit in all this? Well, I started by explaining decoupling to lay down the idea of requiring <em>several </em>services divided by context. The services we develop might have different deployment requirements. Running environments may differ by endpoints, dependencies and so on.</p><p>For this reason, we normally have a CICD pipeline for each project.</p><p>The abstraction of the infrastructure (provided by K8S) is very useful here, as it allows us to set the environment requirements in a YAML file on the codebase.</p><p>Continuing this concept we can abstract the CICD pipeline itself. Making it agnostic of project type, build and deployment requirements.</p><p>By having these 3 components in our solution:</p><ul><li>Build commands file. (Buildspec.yml for AWS CodeBuild)</li><li>Dockerfile image of the running application</li><li>K8S object YAML files, for deployment requirements.</li></ul><p>We have all the information on how to build, test and deploy any of our services.</p><h4>CICD schema presentation</h4><blockquote>The most powerful tool we have as developers is automation</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v-kfm5jhb80QPxWIC1r1gA.png" /><figcaption>CICD Schema</figcaption></figure><p>The pipeline must be triggered on every commit. It should pull the source files without using specific information of any repository.</p><p>To achieve this, the pipeline will be triggered by a GitHub webhook. This allows for multiple uses by different projects.</p><p>Through API Gateway, the webhook will call an AWS Lambda function. This function will pull the git repository and zip it to an S3 bucket.</p><p>AWS CodePipeline can be triggered whenever an S3 object is updated. It “watches” for our zip file, and whenever it is updated triggers the pipeline.</p><p>CodeBuild uses the buildspec.yml file from the solution, to build and run tests.</p><p>Next, a Docker image will be built and pushed to AWS ECR.</p><p>Finally, the YML files on the solution will be applied to the existing K8S clusters on AWS. Usually, this results in pulling the Docker image from ECR and deploying it to a container in K8S.</p><p>To recap, the pipeline can build and deploy any project as long as it provides</p><ul><li>Buildspec.yml file with build environment requisites and commands</li><li>A DockerFile image in order to push it to ECR</li><li>Kubernetes deployment files under “/k8s” folder</li></ul><p>So let’s take this step by step. I use a SCALA PLAY project as an example. You can find the project with the required files <a href="https://github.com/hasael/hello-play">here</a>.</p><h4>AWS Lambda and API Gateway</h4><p>We can expose an endpoint for an AWS Lambda function using API Gateway. Set this endpoint as a webhook on our GitHub project.</p><p>The Lambda function finds the GitHub URL on the json file sent by Github, pulls the solution to a temporary directory, creates a zip and uploads it to an S3 bucket. This will be triggered on every commit.</p><p>The resulting zip will be updated to an S3 bucket, which will trigger the pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*beQ-W8zesVhV1-TlAeMlAw.png" /></figure><p>On AWS Lambda I use NodeJs version 8.10.</p><p>You can find the Lambda function <a href="https://github.com/hasael/github-webhook-deploy"><em>here</em></a><em>, </em>written in NodeJs<em>.</em></p><p>Many thanks to Enki for this <a href="https://blog.enki.com/using-git-on-aws-lambda-f365a2db706b"><em>hack </em></a>using lambda-git.</p><h4>The Pipeline</h4><p>Here is an overview of the pipeline in AWS CodePipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*DXrcvIX0P-29HLAcvbHdVA.png" /></figure><p>The first step is triggered by an upload to S3 of a specific object. This object will be updated by the previous lambda function. This step generates the “Source Artifact”, which is a .zip with the source files.</p><p>The “Source Artifact” is sent to the Build step. The solution is compiled, tested, and generates the build result files as “Build Artifact”.</p><p>This artifact is sent to the Push-ECR step. The Dockerfile is built using the “Build Artifact” files and pushed to ECR.</p><p>Finally, the Apply-KOPS step applies the YAML files found on the “Source Artifact” on K8S with kubectl. Additionally, it saves the K8S YML files to an S3 bucket. This stores information about the current infrastructure.</p><h4>Continuous Integration</h4><p>The Build Step is an AWS Code Build project outlined here. To configure a CodeBuild project, we specify a build environment and build commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2T9zuU7gjaoBcwByhg9mPw.png" /></figure><p>The build environment is the CodeBuild standard 1.0 -1.8.0.</p><p>Under the hood, AWS CodeBuld creates these Docker images as build environments. For more info, you can check these images <a href="https://github.com/aws/aws-codebuild-docker-images">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gu50ne5vYmBhuI8i9iargw.png" /></figure><p>This project will get the Buildspec.yml file from the source. The YAML file contains the build commands to execute.</p><p>Here is a buildspec file for a project in SCALA PLAY.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a0769b79ca2679cfe82ba49eac30c87/href">https://medium.com/media/3a0769b79ca2679cfe82ba49eac30c87/href</a></iframe><p>The project will start the compilation and run tests. If everything is green, a zip file will be created as a «Build Artifact». It will contain all the necessary files to run the application.</p><h4>Push Docker Image</h4><p>On this stage, a Docker image is created and pushed to ECR. This is done by a CodeBuild project as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IaebqhSKgYsBTQRrNWMQlQ.png" /></figure><p>We insert the buildspec commands directly into the project. These commands expect a Dockerfile on the source root. This requires the «Build Artifact» files to create an image with the running application. The image is built and pushed to AWS ECR.</p><p>The Dockerfile image runs the application, assuming it was built.</p><p>Here is a Dockerfile to run a project in the PLAY framework in SCALA. It unzips the build result and runs it using the provided secret key.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/260d0e1179368f21dbe45a3e10d6d750/href">https://medium.com/media/260d0e1179368f21dbe45a3e10d6d750/href</a></iframe><p>The Build environment is the same standard 1.0 -1.8.0.</p><h4>Deploy to K8S</h4><p>The assumption is that all YML files under the “k8s” folder are Kubernetes objects (generally deployments and services). These files are pulled and applied to the Kubernetes cluster. In order to do this, we need kubectl. I have used this Docker image as a custom build environment for CodeBuild.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b4ff9f5e1302487d71d5412a04c7645f/href">https://medium.com/media/b4ff9f5e1302487d71d5412a04c7645f/href</a></iframe><p>Push this image to an ECR repository, and set it as build environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*XNrjiiypYue7D0ZMyrA2LQ.png" /></figure><p>The buildspec for this project is the following</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7804592be20890065d07f84aad00791b/href">https://medium.com/media/7804592be20890065d07f84aad00791b/href</a></iframe><p>All K8S objects under folder “./k8s/” are applied and then saved to an S3 bucket, to store the current cluster state for future reference. Kubectl obtains the K8S cluster configuration using ‘export kubecfg’ command.</p><p>For example, these are the K8S objects for the project in SCALA PLAY.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8918a5842953ecc9b6e8caa8aaef11e/href">https://medium.com/media/d8918a5842953ecc9b6e8caa8aaef11e/href</a></iframe><p>Through K8S, this will result in deploying a Docker container. Also, AWS will create a Load Balancer pointing to the container.</p><h4>Conclusion</h4><p>Being able to deploy a service solely by its code is a powerful tool for a developer. Through this, you can work on several services and deploy their infrastructure in a decoupled pattern. All while maintaining CICD advantages without having to worry about its specific implementation.</p><p>The next steps towards abstraction may be using bash commands on the solution instead of Buildspec, which is specific to CodeBuild. Making it compatible also with Jenkins or other build tools out there.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b4129fac5d4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/universal-cicd-pipeline-on-aws-and-k8s-7b4129fac5d4">Universal CICD pipeline for K8S on AWS</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CI/CD in AWS — Continuous Deployment with CodeDeploy]]></title>
            <link>https://medium.com/@elmanhasa/ci-cd-in-aws-continuous-deployment-with-codedeploy-5c3d5f554d4f?source=rss-ca9a54f776a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c3d5f554d4f</guid>
            <category><![CDATA[continuous-deployment]]></category>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[codedeploy]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <dc:creator><![CDATA[Elman Hasa]]></dc:creator>
            <pubDate>Wed, 20 Feb 2019 13:20:56 GMT</pubDate>
            <atom:updated>2019-02-20T13:20:56.055Z</atom:updated>
            <content:encoded><![CDATA[<h3>CI/CD in AWS — Continuous Deployment with CodeDeploy</h3><p><em>Continuous deployment of a .net core application in AWS</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*tbmc4Zub9udxVp1twG43qQ.png" /></figure><p>On this article I describe configuration for CodeDeploy on a CI/CD pipeline for a .Net Core project. I have previously created the pipeline using CodePipeline and have configured an Auto Scaling Group as a deploy target. I have outlined these steps on the previous parts of this series. Here I will create the CodeDeploy application and configure the deployment commands on my EC2.</p><p>The example project is hosted in <a href="https://github.com/hasael/HelloWorldWebCore">GitHub</a>.</p><h3>Configure Deployment</h3><blockquote>“There should be two tasks for a human being to perform to deploy software into a development, test, or production environment: to pick the version and to press the “deploy” button.”</blockquote><p>To configure CodeDeploy , first I need to create an IAM Role that will allow the service to manage EC2 instances.</p><p>Then I have to create a new CodeDeploy application, that will be my deploy target.</p><h4>Create Deployment IAM Role</h4><p>From AWS, go to IAM section (Identity Access Management) and select “Roles” and then “Create Role”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kxni0E61VoDE7pBGQAP6uw.png" /></figure><p>On the first section , select “CodeDeploy” and as use case pick the first option “CodeDeploy”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8X_XShClfFb46_I3uC77tA.png" /></figure><p>Next on the policies select <em>“AWSCodeDeployRole”</em> .</p><p>On the review screen, I will name the new role DeployRole and confirm role creation.</p><h4>Create CodeDeploy Application</h4><p>Login to AWS Console and navigate to “CodeDeploy”. From there select “Create Application”. I will name it “HelloWorldNetCore” .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*JirUw6MbSA7axV5lCpQMbA.png" /></figure><p>After creating the application, I need to create a “Deployment Group”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*ycoKPJR7ZSXSv2tjzkksnw.png" /></figure><p>I name the deployment group AutoScaleDeploymentGroup and select as ‘Service Role” the IAM role created in the previous step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*kc_0Cf0p_x-IuCqXVr_zJA.png" /></figure><p>Select In-Place as deployment type , and my Auto Scaling group as Environment configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/923/1*yeyOjpLrmPIpI09HgjxSHA.png" /></figure><p>Finally , I leave the Deployment settings to “AllAtOnce” and disable load balancing , as I will not require it for this project. Hit Create to finish this step.</p><h3>Deploy stage on the pipeline</h3><p>Let’s go back to the CI/CD pipeline , select “Edit” and “+Add stage” , naming it “Deploy”.</p><p>Next, on the “Deploy” stage I add an “Action Group”, which will contain deploy steps. On the Action creation form, name it “Deploy” and select “AWS CodeDeploy” as provider.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*ATzG2PfBy0szkIcXxPaNoQ.png" /></figure><p>On the Edit Action form I select Region, CodeDeploy application and deployment group previously created. As Input artifacts, select “BuildArtifact” which passes the build result files to CodeDeploy as input. Hit Save to confirm this Action and then Save on the pipeline to confirm changes.</p><h4>Deployment Steps file</h4><p>The CodePipeline is complete, but as on the build stage, we still need to <em>tell</em> CodeDeploy <em>how </em>to deploy our application on the instance. CodeDeploy uses a YAML file which by default is named appspec.yml and found on source code root. File reference <a href="https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-structure-hooks.html">here</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/adfe0ec96922b98c72425e968a8b1a7e/href">https://medium.com/media/adfe0ec96922b98c72425e968a8b1a7e/href</a></iframe><p>This is my result appsepc.yml file.</p><p>On ApplicationStart step, I run “installApp.sh” script which will</p><ul><li>Kill all previous ‘dotnet’ processes</li><li>Run my current website dll with ‘dotnet’ command</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c86683455fd96f2232e15dcbe3804973/href">https://medium.com/media/c86683455fd96f2232e15dcbe3804973/href</a></iframe><p>Finally, both of these files need to be included as artifacts on the build result. So I edit the buildspec.yml to include them.</p><pre>version: 0.2</pre><pre>phases:<br>  build:<br>    commands:<br>      - dotnet test ./src/HelloTests/HelloTests.csproj<br>      - dotnet publish -c release -o ./build_output ./src/HelloWorldWebCore/HelloWorldWebCore.csproj<br>artifacts:<br>  files:<br>    - src/HelloWorldWebCore/build_output/*<br>    - appspec.yml<br>    - installApp.sh</pre><p>Commit changes and files added and let’s see the results!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_gzKVHOvCuURarJunPnYgg.png" /></figure><p>The CodePipeline is automatically started on commit push and the results are green.</p><p>Let’s access the EC2 and see the results for myself!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CKWE9-zUJwMTUopaq2DI_g.png" /></figure><p>From EC2 dashboard, copy the public DNS of the instance and paste it on the address bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CiWvo_cr69AJo4HfH_qnMA.png" /></figure><p>Success! My application is deployed on every change on the EC2 instance, scaled by an Auto Scaling group.</p><h4>Conclusion</h4><p>If you have followed previous steps outlined in this series, you have a CI/CD pipeline that will build and deploy on the Auto Scaling group on each commit. Further improvements of this process can be enabling a Load Balancer for the multiple EC2 instances, and configure a Blue/Green deploy.</p><h3>Posts in this Series:</h3><p><strong>Introduction</strong>: <a href="https://medium.com/@elmanhasa/226b70574f83?source=your_stories_page---------------------------">CI/CD in AWS — A pipeline with CodeBuild and CodeDeploy</a></p><p><strong>Part 1</strong>: <a href="https://medium.com/@elmanhasa/30c0dcefb7a3?source=your_stories_page---------------------------">CI/CD in AWS — Continuous Integration with CodeBuild</a></p><p><strong>Part 2</strong>: <a href="https://medium.com/@elmanhasa/28063b9e714?source=your_stories_page---------------------------">CI/CD in AWS — Configure Auto Scaling for CodeDeploy</a></p><p><strong>Part 3</strong>: <a href="https://medium.com/@elmanhasa/5c3d5f554d4f?source=your_stories_page---------------------------">CI/CD in AWS — Continuous Deployment with CodeDeploy</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c3d5f554d4f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CI/CD in AWS — Configure Auto Scaling for CodeDeploy]]></title>
            <link>https://medium.com/@elmanhasa/ci-cd-in-aws-configure-auto-scaling-for-codedeploy-28063b9e714?source=rss-ca9a54f776a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/28063b9e714</guid>
            <category><![CDATA[auto-scaling-groups]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[codedeploy]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Elman Hasa]]></dc:creator>
            <pubDate>Wed, 20 Feb 2019 13:20:46 GMT</pubDate>
            <atom:updated>2019-02-20T13:20:46.933Z</atom:updated>
            <content:encoded><![CDATA[<h3>CI/CD in AWS — Configure Auto Scaling for CodeDeploy</h3><p><em>Creating an Auto Scaling Group as a deploy target</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*agWCFCmyphsWAYqKvbGQYg.png" /></figure><p>In order to deploy to an EC2 using CodeDeploy, some pre-configuration is required. In this scenario, I will configure an EC2 to host an ASP .Net Core project, which will later be deployed with CodeDeploy. I will show the CodeDeploy configuration in the next article. Here I am focusing on the deploy target configuration. Going one step further, I will create an Auto Scaling group with this EC2 as launch configuration. As a result, I may use this Auto Scaling group as a deploy target for CodeDeploy.</p><p>The example project is hosted in <a href="https://github.com/hasael/HelloWorldWebCore">GitHub</a>.This article is a part of a series where I implement and improve a CI/CD pipeline in AWS using CodeBuild ,CodeDeploy and Auto Scaling.</p><h3>Preparing EC2 Instance for Deploy</h3><blockquote>“Give me six hours to chop down a tree and I will spend the first four sharpening the axe.”</blockquote><p>First, let’s define the Amazon Machine Image (<a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html">AMI</a>) I will be using for the EC2. The target instance OS will be Linux with .Net Core installed. Conveniently, Amazon provides an Image of this. The AMI currently available is “<strong>.NET Core 2.1 with Amazon Linux 2”</strong>. Of course, you may also pick any other Linux AMI and setup .Net Core installation on startup.</p><p>The minimum requirements to have an EC2 as a deploy target in CodeDeploy are</p><ul><li>Create and attach an IAM role, which allows access to specific S3 buckets.</li><li>Install CodeDeploy Agent on the EC2</li></ul><h4>Creating the new IAM Role</h4><p>From AWS, go to IAM section (Identity Access Management) and select “Roles” and then “Create Role”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d9KVnCB2s0Hyt7UH43TlqQ.png" /></figure><p>On the first section , select EC2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*932-8sK13EQ4GWDjxUqrpQ.png" /></figure><p>Next on the policies select <em>“AmazonEC2RoleForAWSCodeDeploy”</em> which will give the EC2 permission to the bucket to download and install CodeDeploy agent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V9BfoCNtM1T4BIN--iHL6Q.png" /><figcaption>Create Role</figcaption></figure><p>On the review screen, I will name the new role EC2CodeDeployRole and confirm role creation.</p><h4>Installing CodeDeploy Agent</h4><p><a href="https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent.html"><strong>CodeDeploy Agent</strong></a> allows AWS CodeDeploy to interact with our instance in order to install the components.</p><p>On Amazon Linux can be installed using the following commands</p><pre>sudo yum install -y httpd</pre><pre>sudo yum install -y git</pre><pre>sudo yum install -y ruby</pre><pre>sudo yum install -y wget</pre><pre>cd /home/ec2-user</pre><pre>wget <a href="https://bucket-name.s3.amazonaws.com/latest/install">https://</a><a href="https://bucket-name.s3.amazonaws.com/latest/install"><em>bucket-name</em>.s3.amazonaws.com/latest/install</a></pre><pre>chmod +x ./install</pre><pre>sudo ./install auto</pre><p>Where <em>bucket-name</em> is the name of the Amazon S3 bucket that contains the CodeDeploy Resource Kit files for your region. For example, for the US East (Ohio) Region, replace <em>bucket-name</em> with aws-codedeploy-us-east-2. For a list of bucket names, see <a href="https://docs.aws.amazon.com/codedeploy/latest/userguide/resource-kit.html#resource-kit-bucket-names">Resource Kit Bucket Names by Region</a>.</p><h4>Install and Configure HTTP Server</h4><p>In my case the instance will be a web-server. For this I have to <strong>install an HTTP server</strong> <em>and</em> <strong>configure its reverse proxy</strong> to point to my website. As an HTTP server I will be using Apache.</p><p>In case of .Net Core, when we open the main project component (dll), the website is run by default on port 5000. So I can forward all traffic from port 80 to port 5000 in my reverse proxy configuration.</p><p>In Apache server for Linux this can be done by adding the following string to the configuration file <em>etc/httpd/conf/httpd.conf</em></p><pre>&lt;VirtualHost *:80&gt;</pre><pre>ProxyPreserveHost On</pre><pre>ProxyPass / <a href="http://127.0.0.1:5000/">http://127.0.0.1:5000/</a></pre><pre>ProxyPassReverse / <a href="http://127.0.0.1:5000/">http://127.0.0.1:5000/</a></pre><pre>ErrorLog ${APACHE_LOG_DIR}helloapp-error.log</pre><pre>CustomLog ${APACHE_LOG_DIR}helloapp-access.log common</pre><pre>&lt;/VirtualHost&gt;</pre><p>So to recap target EC2 steps during startup:</p><ul><li>The selected AMI will be “.NET Core 2.1 with Amazon Linux 2” (so .Net Core installation not required in my case)</li><li>Install CodeDeploy Agent</li><li>Install Apache</li><li>Configure reverse proxy configuration to forward traffic to port 5000</li></ul><p>Here is the resulting script, which will be run on EC2 startup.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/790df9565bafd66a7b71ae513b2465b7/href">https://medium.com/media/790df9565bafd66a7b71ae513b2465b7/href</a></iframe><h3>Diving in Auto Scaling Group</h3><p>Now that I have an AMI and configuration ready for my EC2, I can create an Auto Scaling group on AWS, which will be my deploy target.</p><p>Login to AWS Console and navigate to EC2. From there, on the left select “Auto Scaling Groups”, and then “Create Auto Scaling Group”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O5YxTl7Z1PJwdFw8BvT5Yg.png" /></figure><p>On the first screen, select “Create a new launch configuration”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*erktOXCBmWXxlDwkI3hJCw.png" /></figure><p>On the next step, as an AMI for EC2 I select<strong> </strong>“ .NET Core 2.1 with Amazon Linux 2”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sxo_jLSetgGk08cfuCAq3Q.png" /></figure><p>For instance size I will select t2.micro in order to stay within free tier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TLa0txbZ5WdWYkgRqsYpoA.png" /></figure><p>Now on creating the new launch configuration, I will name it CodeDeployLC and attach the role EC2CodeDeployRole previously created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sopxikwrpuV1T-FR5vzg3w.png" /></figure><p>Expand “Advanced Details” and paste in the the script of the previous step in the “User Data” text box. This configures the script to be executed on instance startup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EDQOyT_3KTdCKBuSEaKoXQ.png" /></figure><p>On the “Security Group” section create a new security group and configure it to open the ports 22 (SSH) and 80 (HTTP) to public.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XMQQKjmScKukz0jQRLzGMg.png" /></figure><p>Finally, select the security key-pair and confirm the launch group configuration. This Launch group is configured to create an EC2 with the Amazon Linux OS with .Net Core pre-installed, and run our configuration script on startup of each EC2 instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R8Yjl1gKq_nYqayf5oNo_w.png" /></figure><p>Next, following the Auto Scaling group creation, I will name it DeployAutoScaleGroup , select the default VPC and start with 1 instance.</p><p>The advantage of Auto Scaling group is that this instance will be automatically re-provisioned in case of failure.</p><p>On next steps, I will just keep the default settings which are “Keep this group at its initial size” as scaling policy and no notifications or tags configured.</p><p>Ok! So now I have an Auto Scale group that will automatically provision an EC2 instance. On each startup, an instance will</p><ul><li>Download and install CodeDeploy agent</li><li>Install and run Apache server</li><li>Configure reverse proxy and restart Apache</li></ul><p>Now, what is left is to deploy my application on this instance, which will be done through CodeDeploy.</p><h3>Posts in this Series:</h3><p><strong>Introduction</strong>: <a href="https://medium.com/@elmanhasa/226b70574f83?source=your_stories_page---------------------------">CI/CD in AWS — A pipeline with CodeBuild and CodeDeploy</a></p><p><strong>Part 1</strong>: <a href="https://medium.com/@elmanhasa/30c0dcefb7a3?source=your_stories_page---------------------------">CI/CD in AWS — Continuous Integration with CodeBuild</a></p><p><strong>Part 2</strong>: <a href="https://medium.com/@elmanhasa/28063b9e714?source=your_stories_page---------------------------">CI/CD in AWS — Configure Auto Scaling for CodeDeploy</a></p><p><strong>Part 3</strong>: <a href="https://medium.com/@elmanhasa/5c3d5f554d4f?source=your_stories_page---------------------------">CI/CD in AWS — Continuous Deployment with CodeDeploy</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28063b9e714" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CI/CD in AWS — Continuous Integration with CodeBuild]]></title>
            <link>https://medium.com/@elmanhasa/ci-cd-in-aws-continuous-integration-with-codebuild-30c0dcefb7a3?source=rss-ca9a54f776a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/30c0dcefb7a3</guid>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[codepipeline]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[codebuild]]></category>
            <dc:creator><![CDATA[Elman Hasa]]></dc:creator>
            <pubDate>Wed, 20 Feb 2019 13:20:28 GMT</pubDate>
            <atom:updated>2019-02-20T13:20:28.379Z</atom:updated>
            <content:encoded><![CDATA[<h3>CI/CD in AWS — Continuous Integration with CodeBuild</h3><p><em>Creating a CI pipeline in AWS</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XS2opeHZngV13mQnHAXgmg.png" /></figure><p>Having an external build server for Continuous Integration is certainly advantageous in productivity for larger teams as well as single developers. As this concept is very clear today, there are a plethora of choices for a CI platform out there. Amazon Web Services have their own fully managed service for compiling source code named <a href="https://aws.amazon.com/codebuild/">CodeBuild</a>. Whether you are a cloud practitioner or a developer, the pay-as-you-go model coupled with the lack of maintenance of a build server makes CodeBuild a viable choice especially for smaller teams.</p><p>On the following, I will guide step by step the creation of a CI pipeline in AWS using a .Net Core project as an example. The example project is hosted in <a href="https://github.com/hasael/HelloWorldWebCore">GitHub</a>.</p><p>This article is a part of a series where I implement a CI/CD pipeline in AWS using CodeBuild ,CodeDeploy and Auto Scaling.</p><h3><strong>Creating the pipeline</strong></h3><p>Login to AWS Console and navigate to Aws Codepipeline. From there, select “Create Pipeline” and follow the creation wizard.</p><p>In the first form basic information is required. On the first screen, default settings are sufficient. Select “New Service Role” to leave it to the wizard the creation of a new IAM role for the service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*TWR_WrOM61PKrJ2R1Oumjw.png" /><figcaption>Create Pipeline</figcaption></figure><h4>Source location</h4><blockquote>“Where.is.the sauce!”</blockquote><p>Next the wizard will prompt for a source code location. Conveniently, the pipeline can be connected to a GitHub account. All of the repositories and branches will be loaded as a result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*bU1oEQw09crRulJDEZWnBg.png" /></figure><p>I am selecting GitHub web-hooks for change detection. AWS will add web-hooks configuration to the GitHub repository automatically.</p><p>Next the build stage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*SbYZqNLUx5hVCtzgIJiZSA.png" /><figcaption>Build Stage</figcaption></figure><p>This step is necessary since at least 2 stages are required for a pipeline. Select AWS CodeBuild , Region and go ahead “Create project”. This will create a new CodeBuild project, which will be used by the pipeline to build the solution.</p><p>Following the steps name the project and select the OS Environment for .Net Core.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*FLX1QrdND5fX2No4K7G_8w.png" /></figure><p>Leave the other settings to default and confirm creation.</p><p>Proceed to the next step on CodePipeline creation.</p><p>For now, skip the deploy stage as I will add it manually later, and focus on the CI part.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*UvMtUdyzB1fKQfO1xjUqNw.png" /><figcaption>Skip deploy stage</figcaption></figure><p>Confirm the review to finish pipeline creation!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*cFQIZT7RvjwGDio3gP59EQ.png" /></figure><h3><strong>Continuous Integration</strong></h3><blockquote>“ And where are the people, father, whose hands <strong>built</strong> your city — -?”</blockquote><p>It may seem the pipeline is ready to go, but one more step is required to implement build function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VcCnEHW0uRl0k2-tVsT9Qw.png" /></figure><p>The CodeBuild project is created and attached but it still doesn’t “<em>know” </em>how to build our project, but merely what OS environment it requires.</p><h4>Build specification</h4><p>CodeBuild expects a YAML file, named by default buildspec.yml to be present on the root of the project. This file contains build commands that CodeBuild will launch. File Reference and hooks <a href="https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html">here</a>.</p><p>Here is my buildspec.yml for a .Net Core project.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a5256ef373d3c50cbe7ee450d8f47a9/href">https://medium.com/media/7a5256ef373d3c50cbe7ee450d8f47a9/href</a></iframe><p>The main focus for most projects will be the “commands” and “artifacts”section.</p><p>The “commands” section specifies build commands. In this case, run the unit tests and publish the project in the folder /build_output.</p><p>The “artifacts” section specifies which files are to be copied in the release. In this cases, all files of the publish result.</p><p>Add this file on the root folder in the git repository. Pushing the commit will trigger the pipeline to start the build process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yv1863OzQ1XZWFEWd7pQEg.png" /></figure><p>That is it. Now the build process is automated on every commit of the repository. On each commit, the code is tested and compiled automatically on AWS. No need for servers or client configuration. This completes the Continuous Integration part of the pipeline.</p><h3>Posts in this Series:</h3><p><strong>Introduction</strong>: <a href="https://medium.com/@elmanhasa/226b70574f83?source=your_stories_page---------------------------">CI/CD in AWS — A pipeline with CodeBuild and CodeDeploy</a></p><p><strong>Part 1</strong>: <a href="https://medium.com/@elmanhasa/30c0dcefb7a3?source=your_stories_page---------------------------">CI/CD in AWS — Continuous Integration with CodeBuild</a></p><p><strong>Part 2</strong>: <a href="https://medium.com/@elmanhasa/28063b9e714?source=your_stories_page---------------------------">CI/CD in AWS — Configure Auto Scaling for CodeDeploy</a></p><p><strong>Part 3</strong>: <a href="https://medium.com/@elmanhasa/5c3d5f554d4f?source=your_stories_page---------------------------">CI/CD in AWS — Continuous Deployment with CodeDeploy</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30c0dcefb7a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CI/CD in AWS — A pipeline with CodeBuild and CodeDeploy]]></title>
            <link>https://medium.com/@elmanhasa/ci-cd-in-aws-a-pipeline-with-codebuild-and-codedeploy-226b70574f83?source=rss-ca9a54f776a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/226b70574f83</guid>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[codebuild]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[codedeploy]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Elman Hasa]]></dc:creator>
            <pubDate>Wed, 20 Feb 2019 13:20:14 GMT</pubDate>
            <atom:updated>2019-02-20T13:20:14.207Z</atom:updated>
            <content:encoded><![CDATA[<h3>CI/CD in AWS — Intro — A pipeline with CodeBuild and CodeDeploy</h3><p><em>Building my CI/CD platform in AWS</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*M_rUV22f110SeTDCesd0GA.png" /></figure><p>As a startup or even as a single developer the choice of a CI/CD platform is a critical factor. As a developer who tries out different projects out of work, I required a Build &amp; Deploy platform that is simple, cost-effective, and can be launched from different locations, independent whether I commit a new change from my work or home laptop. This implies the build and deployment process has to be executed on external servers, preferably with a pay-as-you-go model.</p><p>The trend of <a href="https://en.wikipedia.org/wiki/Infrastructure_as_a_service">IAAS</a> empowers developers for such needs and allows for flexibility. <a href="https://aws.amazon.com/">Amazon Web Services</a> is one of the main platforms championing this, in terms of services and cost-effectiveness.</p><p>On this article I will focus more on the theoretical approach, outlining the tools required and how they will be used. I will dive into implementation details on the next articles as a part of this series.</p><h4>Requirements</h4><p>An AWS account is required for this purpose. The account can be created for free, and a <a href="https://aws.amazon.com/free/">free tier</a> of services is available for one year.</p><h3>Tools</h3><blockquote>The best investment is in the tools of one’s own trade</blockquote><p>The main AWS services for CI/CD automation are:</p><ul><li><a href="https://docs.aws.amazon.com/codepipeline/latest/userguide/welcome.html">CodePipeline</a> allows to model an automated build and deployment pipeline. The pipeline is modelled in steps and stages. On each step, it can integrate with various services to achieve Continuous Integration and Deployment.</li><li><a href="https://aws.amazon.com/codebuild/">CodeBuild </a>is a fully managed service than can compile a solution and run unit tests. By creating a project, I can select an OS target and environment required to build my application. CodeBuild does the heavy lifting as no further maintenance is required on our side.</li><li><a href="https://aws.amazon.com/codedeploy/">CodeDeploy</a> can automate software deployments on the Cloud Platform or On-Premise. Supports continuous deployments on EC2, ECS, Auto Scaling and On-Premise servers.</li></ul><p>As a deploy target I want something similar to a virtual machine.</p><ul><li>An <a href="https://aws.amazon.com/ec2/">EC2</a> instance is the equivalent of a virtual machine instance in AWS.</li></ul><p>But as any machine, an EC2 can be prone to failure, data corruption or incidents. Cloud platforms have a great advantage on this, allowing us to provision these instances on the fly, based on durability and scaling needs.</p><ul><li><a href="https://aws.amazon.com/autoscaling/">AWS Auto Scaling</a> is a service that provisions EC2 instances automatically in case of failure or high CPU utilization</li></ul><p>An Auto Scaling group can be used as a deploy target for CodeDeploy.</p><p>AWS CodePipeline is a place to start and a good exercise to learn more about these tools in Amazon Web Services. Now we know the tools, I can define a use case.</p><h3>Defining Scenario</h3><blockquote>A creative project is a moving target. You never end up where you start.</blockquote><p>Consider an ASP. NET Core application hosted on GitHub. I want to deploy this web application automatically on every commit. The deploy target will be one or more EC2 , which will have a public DNS where I can view the hosted web application. This can be used as a test or production environment.</p><p>To obtain this result, CodePipeline can be used to create a Build and Deploy Pipeline.</p><ul><li>The pipeline can integrate with the source code from GitHub.</li><li>Build the solution using AWS CodeBuild.</li><li>The Build result can be deployed to one or more EC2 intance using AWS CodeDeploy. To improve performance and scalability, I will use <a href="https://aws.amazon.com/autoscaling/">AWS Auto Scaling</a> group as a deploy target.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*rjr6_bKHInHmU8QHk_7CLg.png" /><figcaption>CI/CD Diagram</figcaption></figure><p>To keep things simple, I am using a Hello-World style solution in .Net Core hosted <a href="https://github.com/hasael/HelloWorldWebCore">here</a>. It is basically a template of ASP.Net Core project at the time of this writing, with a Hello World title on the index page.</p><h3>Putting it all together</h3><p>So to recap, first I need to create a <strong><em>pipeline</em></strong> using CodePipeline. This pipeline will contain the source code location, build and deploy steps. CodePipeline can be connected to a GitHub account and pull a repository when required. For the build step, I will create a new CodeBuild <strong><em>project </em></strong>for a .Net Core environment. Then, I can attach the pipeline build step with this project. For the deploy purpose, I have to create a CodeDeploy <strong><em>application </em></strong>and a <strong><em>deployment group, </em></strong>which will be added to the deploy step on the pipeline.<strong><em> </em></strong>My deploy target will be an Auto scaling group, which I need to configure and setup for deploy. The result will be a CI/CD pipeline, that will compile and deploy my ASP .Net Core application on each commit.</p><h3>Posts in this Series:</h3><p><strong>Introduction</strong>: <a href="https://medium.com/@elmanhasa/226b70574f83?source=your_stories_page---------------------------">CI/CD in AWS — A pipeline with CodeBuild and CodeDeploy</a></p><p><strong>Part 1</strong>: <a href="https://medium.com/@elmanhasa/30c0dcefb7a3?source=your_stories_page---------------------------">CI/CD in AWS — Continuous Integration with CodeBuild</a></p><p><strong>Part 2</strong>: <a href="https://medium.com/@elmanhasa/28063b9e714?source=your_stories_page---------------------------">CI/CD in AWS — Configure Auto Scaling for CodeDeploy</a></p><p><strong>Part 3</strong>: <a href="https://medium.com/@elmanhasa/5c3d5f554d4f?source=your_stories_page---------------------------">CI/CD in AWS — Continuous Deployment with CodeDeploy</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=226b70574f83" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>