<?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 Mykola Shorobura on Medium]]></title>
        <description><![CDATA[Stories by Mykola Shorobura on Medium]]></description>
        <link>https://medium.com/@shorobura.mykola?source=rss-28268982308e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*aQ4iMDDHwrqJXXsQtD18GQ.jpeg</url>
            <title>Stories by Mykola Shorobura on Medium</title>
            <link>https://medium.com/@shorobura.mykola?source=rss-28268982308e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 19:44:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shorobura.mykola/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[Сonfigure a continuous deployment pipeline for a simple project in GCP and AWS?]]></title>
            <link>https://medium.com/@shorobura.mykola/%D1%81onfigure-a-continuous-deployment-pipeline-for-a-simple-project-in-gcp-and-aws-c452976444be?source=rss-28268982308e------2</link>
            <guid isPermaLink="false">https://medium.com/p/c452976444be</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[continuous-deployment]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <dc:creator><![CDATA[Mykola Shorobura]]></dc:creator>
            <pubDate>Fri, 09 Sep 2022 06:22:06 GMT</pubDate>
            <atom:updated>2022-09-09T06:52:21.182Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*Kno_oKf4jmRvtC5xTCbd9Q.jpeg" /></figure><p>Based on my previous <a href="https://medium.com/@shorobura.mykola/the-multi-environment-continuous-deployment-strategy-for-aws-lambda-in-a-single-aws-account-d793f6237208">article about a continuous deployment pipeline for a specific case in AWS</a> I have decided to write an article in which I want to compare a continuous deployment configuration for simple projects in GCP and AWS. Also, want to measure how much time and effort it takes to configure the CD pipeline in these cloud providers.</p><p>For testing purposes, I have created two projects which will be deployed to GCP and AWS.</p><ul><li>For the first one, I have created a simple dashboard that represents how many russian invaders were deactivated by the Armed Forces of Ukraine.</li><li>The second one is as simple as possible Lambda function written on Python which will be deployed to AWS using CodeBuild.</li></ul><p><strong>Technologies</strong>: Python, GitHub, GCP CloudBuild, GCP CloudRun, AWS CodeBuild, AWS Lambda.</p><h3>GCP</h3><p><strong>Prerequisites</strong>:</p><ul><li><strong>Very important to have the name of the GitHub repository in lowercase. Google Cloud Run seems not to like camel case names, and it causes a very vague error message.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qaz6bmgWe-4qOFGav4w7vw.png" /><figcaption>It was very easy to build this nice dashboard using the <a href="https://dash.plotly.com/">Plotly</a> framework. Link to dashboard <a href="https://armed-forces-of-ukraine-chart-elyjij3ara-ew.a.run.app/">https://armed-forces-of-ukraine-chart-elyjij3ara-ew.a.run.app/</a></figcaption></figure><p>Inside a GCP project, we must go to CloudRun and create a new service. If you are doing it for the first time, you will need to enable CloudRun API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QzWOX9W1waN3dj-YESLRew.png" /></figure><p>On the CloudRun config page choose <strong>continuously deploy new revisions from a source repository</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q0ULbL8TY15-3ODTUkKFRg.png" /></figure><p>After you press the <strong>set up with CloudBuild</strong> button side window will pop up. There you need to enable CloudBuild and Container Analysis APIs if you didn’t do it yet. If so, then just enable it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nKl4HrXZUorgP2eof04w3g.png" /></figure><p>After we enabled all necessary APIs, we needed to authenticate in GitHub. Let’s do it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*djxJUwWIVrda06DJPUh8XA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FEpn5GEOE5Wfa2g6hlY8Ew.png" /></figure><p>After authentication, we will need to install the Google CloudBuild app on our GitHub.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WCpYkXdyPfjX04G0sd_HHQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ik1gILCrceJbtTZcp9gDkw.png" /></figure><p>We can install the CloudBuild app for one or all GitHub repositories. If we do it only for one repo, we will need to do it whenever we create a CloudRun service to be able to use the new repository.</p><p>Now, in the CloudBuild sidebar, you can find your project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BL6Ii-P0ccCyphZC7iajuA.png" /></figure><p>After that, we must choose a branch in the project for which we want to continuously deploy new revisions and build type. So, I choose the <strong>master </strong>branch and <strong>Dockerfile</strong> and press the save button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Ol3YUMstTQPvM_BXIoTDg.png" /></figure><p>The last things we need to choose are:</p><ul><li>Service name.</li><li>Region. Not for all of them it is impossible to add subdomain mapping. Here is the <a href="https://cloud.google.com/run/docs/mapping-custom-domains#limitations">list of regions where domain mappings are available</a>.</li><li>A minimum number of instances. <strong>Has to be greater than 0.</strong></li><li>Ingress. <strong>We need to allow all traffic.</strong></li><li>Authentication. <strong>Allow unauthenticated invocations.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nhVSGfMQBqe4LBmkp5X95w.png" /></figure><p>Press create button, and a new revision build will be automatically triggered. After the build is finished, you will see the link you can click on to open your deployed app in a browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y6HMKVJPEKfx3vj9nXilow.png" /></figure><p>In the CloudBuild service, you can see the build history with all build details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pRHJfa9nrivqeSGWZ7ZzPQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fCAQkG-6PZ4xOz2ftfavVw.png" /></figure><ul><li>This is what it looks like in the end. Nice.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qaz6bmgWe-4qOFGav4w7vw.png" /></figure><p>Small notes:</p><ul><li><a href="https://en.wikipedia.org/wiki/2S22_Bohdana">2S22 Bohdana</a>, <a href="https://en.wikipedia.org/w/index.php?title=Burevyi_MLRS&amp;action=edit&amp;redlink=1">Burevyi MLRS</a>, <a href="https://en.wikipedia.org/wiki/M142_HIMARS">M142 HIMARS</a>, <a href="https://en.wikipedia.org/wiki/M142_HIMARS">M142 HIMARS</a>, <a href="https://en.wikipedia.org/wiki/Vilkha_(missile_complex)">Vilkha</a>, <a href="https://en.wikipedia.org/wiki/R-360_Neptune">Neptune</a>, and many others are machines that were used by the Armed Forces of Ukraine to accomplish such nice stats.</li></ul><h3>AWS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*APfO1h-OZbREjBi8XjRRgg.jpeg" /></figure><p><strong>Prerequisites</strong>:</p><ul><li>Existed Lambda function. Our pipeline will only update the Lambda function. Look like CodeBuild can not create Lambda by itself from initial changes saved on GitHub.</li><li>Lambda project on GitHub with <strong>particular buildspec.yml</strong>. You can check it in my GitHub repo <a href="https://github.com/shorobura-mykola/GloryToUkraineLambdaFunction/blob/master/buildspec.yml">here</a>.</li></ul><pre>version: 0.2<br>phases:<br>  install:<br>    runtime-versions:<br>      python: 3.9<br>    commands:<br>      - echo &quot;Installing dependencies...&quot;<br>      - pip install -r requirements.txt -t lib<br>  build:<br>    commands:<br>      - echo &quot;Zipping deployment package...&quot;<br>      - cd lib<br>      - zip -r9 ../deployment_package.zip .<br>      - cd ..<br>      - zip -g deployment_package.zip lambda_function.py<br>  post_build:<br>    commands:<br>      - echo &quot;Updating lambda Function...&quot;<br>      - aws lambda update-function-code --function-name GloryToUkraineLambdaFunction --zip-file fileb://deployment_package.zip<br>      - echo &quot;DONE!!&quot;</pre><p>So, to configure a continuous deployment pipeline in AWS, you need to go to the CodeBuild service and create a new project. Then give a name for the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4XTf-goLzbV2Z10pfp5Atw.png" /></figure><p>In the <strong>Source </strong>section, we will need to connect to our GitHub account. For it, we can use OAuth or personal access token. I have chosen <strong>Connect using OAuth.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HfZ5ABWVArcWdvMh2QSZEw.png" /></figure><p>We will be redirected to a middle page where we can authorize AWS CodeBuild.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oasDbckYaDQ1eZw2utB-Dg.jpeg" /></figure><p>Then we need to confirm a request to connect CodeBuild to our GitHub account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jexlVdC6Yo2pU1wZXYj0DQ.png" /></figure><p>After authorization, find a GitHub project for which you want to build a continuous deployment pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XQgjLwv9AELIBPxZrwvRLQ.png" /></figure><p>Now we need to configure the primary source webhook event. I am configuring a webhook for a <strong>PUSH </strong>event into the master branch. We could not simply define the master branch. The branch name should match the regular expression pattern (for example, refs/heads/branch-name and refs/tags/tag-name)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rnHNkIrHgVbciJfVomcXBA.png" /></figure><p>For the <strong>Environment</strong> section in CodeBuild, we can choose one of the operating systems: Amazon Linux 2 or Ubuntu. And for the service role parameter, we can create a new role or use an existing one. I go with the latest versions of Amazon Linux 2 and the new service role.</p><p>Everything else I left as a default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XMHB9e4wYA-PysQiFohdUw.png" /></figure><p>The last thing we need is to set up policies for the CodeBuild to allow it to update the Lambda function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Srs0eFSp5FlXXxQ7VVucAQ.png" /></figure><p>UpdateLambdaFunctionPolicy</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Id&quot;: &quot;default&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Sid&quot;: &quot;AllowUpdateFunction&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: &quot;lambda:UpdateFunctionCode&quot;,<br>            &quot;Resource&quot;: &quot;*&quot;<br>        }<br>    ]<br>}</pre><p>Now we can test our continuous deployment pipeline. Let’s push some changes to the master branch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sbOfrYpz-z1ug9W3ctRuGQ.png" /></figure><p>The build finished successfully.</p><p>Below is the response from the default implementation of the Lambda function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WGtPmmfBQ1hi2H9wmW755g.png" /></figure><p>And this is the new response after pushing changes to the master branch. Much Better!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SyCRTq6U3-TeWwGchvAOWQ.png" /></figure><h3>Summary</h3><p><strong>AWS</strong>:</p><ul><li>You have to have buildspec.yml. You should keep it inside your project or declare buildspec script inside the AWS CodeBuild project.</li><li>You need to create the Lambda function first and then update it using CodeBuild.</li><li>While configuring the CodeBuild project you need to specify a branch pattern manually, like ^refs/heads/master$ .</li><li>You will need to configure policies to allow the CodeBuild project to update the Lambda function.</li></ul><p><strong>GCP</strong>:</p><ul><li>You can configure everything without adding some additional configuration for continuous deployment.</li><li>You do not need to have some CloudRun project to update it after creating a continuous deployment pipeline. You can simply create everything from scratch at any moment.</li><li>After authenticating in GitHub, CloudBuild will load all existing branches, and you can simply choose the wished branch from the dropdown list.</li><li>While creating a new service in CloudRun, you can authenticate in GitHub, set up CloudBuild trigger, and configure environment variables.</li></ul><p><strong>Both</strong>:</p><ul><li>We can easily authenticate to GitHub from each cloud provider.</li><li>For both GCP and AWS, you can use the free tier.</li><li>In GitHub you will see an identifier about success/fail build for a particular commit</li></ul><p><strong>Resources:</strong></p><ul><li>The dashboard repo link <a href="https://github.com/shorobura-mykola/armed_forces_of_ukraine_chart">https://github.com/shorobura-mykola/armed_forces_of_ukraine_chart</a></li><li>The simple Lambda function repo link <a href="https://github.com/shorobura-mykola/GloryToUkraineLambdaFunction">https://github.com/shorobura-mykola/GloryToUkraineLambdaFunction</a></li></ul><p><strong>P.S. </strong>In the beginning, I wanted to write an article with a title like, “Is it possible to configure a continuous deployment pipeline for a simple project in 5 minutes in GCP or AWS?”. But configuring a continuous deployment pipeline in AWS took me more than 30 mins, and I did it previously some time ago. So in my humble opinion, you can configure continuous deployment in GCP in ~5 mins but not in AWS.</p><p><strong>P.S.S. </strong>Do not forget that right now at this very moment Ukraine is fighting for its freedom and the freedom of all democratic world. If you have a will to help Ukraine, please donate to ComeBackAlive fund <a href="https://savelife.in.ua/en/donate-en/#donate-army-card-monthly">https://savelife.in.ua/en/donate-en/#donate-army-card-monthly</a>.</p><h3><strong>Glory to Ukraine! Glory to heroes.</strong></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c452976444be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The multi-environment continuous deployment strategy for AWS Lambda in a single AWS account]]></title>
            <link>https://medium.com/@shorobura.mykola/the-multi-environment-continuous-deployment-strategy-for-aws-lambda-in-a-single-aws-account-d793f6237208?source=rss-28268982308e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d793f6237208</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[continuous-deployment]]></category>
            <category><![CDATA[aws-codebuild]]></category>
            <dc:creator><![CDATA[Mykola Shorobura]]></dc:creator>
            <pubDate>Mon, 15 Aug 2022 07:12:24 GMT</pubDate>
            <atom:updated>2022-08-15T07:12:24.096Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KveBmARIO5URFpSXQUaa6Q.png" /></figure><p>Some time ago, I saw a post from one of my previous coworkers <a href="https://medium.com/u/fa9034c873a8">Anton Bakalets</a> regarding the <a href="https://medium.com/nerd-for-tech/continuous-deployment-of-aws-lambda-with-java-runtime-7b6d6188607">continuous deployment project in AWS</a>. And in regard to previously passed <a href="https://www.credly.com/badges/79caf860-3380-494e-aeb5-fb93e14debfd/public_url">AWS Certified Solutions Architect — Associate</a>, I want to use my knowledge in a practical approach. I want to expand the continuous deployment topic by solving one particular problem for small companies, mostly startups. Please enjoy reading the topic below regarding the continuous deployment strategy<strong>.</strong></p><p>If you are a small startup company and you want to build a continuous<strong> </strong>deployment<strong> </strong>multi-environments pipeline you basically do not want to spend one month or more building a complex, robust, and super powerful solution without suffering while configuring multi-account access. You want to have the most simple, cheap, and easily configured in one place solution and it would be great to have it for yesterday or even for a week before.</p><p>The use case for this article sounds like this: <em>how to build a small, not complex, multi-environments continuous</em><strong><em> </em></strong><em>deployment solution for hundreds of lambda stored in GitHub repos that are easy to manage in one place</em>?</p><p>So, in this article, I want to use <strong>multiple AWS regions as separate environments</strong>. Thanks to this approach, we can save time on configuring AWS multi-account access and use it for development work. And since time equals money, we’ll use our resources more efficiently.</p><p><strong>Use case prerequisites:</strong></p><ul><li>A bunch of projects is stored on GitHub. Let it be 100 lambda projects</li><li>A single place/tool to manage continuous<strong> </strong>deployment for all of these projects</li><li>Changes for any repo should be deployed for a maximum of 15 minutes with the ability to deploy changes manually anytime</li></ul><h4>TechStack: GitHub, Python, AWS S3, AWS CodeBuild, AWS Lambda.</h4><p><strong>What we will use:</strong></p><ul><li>GitHub token to have access to each GitHub project</li><li>AWS CodeBuild as a building tool</li><li>AWS S3 to store custom build script</li><li>AWS Dynamo DB to keep the latest commit hashes for each tag/branch in each repository</li><li>AWS Lambda for running our services</li><li>AWS IAM for configuring service role policies</li></ul><h4>AWS CodeBuild</h4><ul><li>Create a new CodeBuild project</li><li>Choose <strong>No Source</strong> for the <strong>Source provider </strong>as we will load changes programmatically. Also, CodeBuild has other options for the source providers. It may be AWS Code Commit, AWS S3, BitBucket, GitHub, and GitHub Enterprise.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OjsM9rRyJ-TLBKTdYzd9sQ.png" /></figure><ul><li>For the <strong>Environment</strong> section in CodeBuild, we can choose one of the operating systems: Amazon Linux 2 or Ubuntu. For the service role parameter, we can create a new role or use an existing one.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q3RcHHoxbL7KaZWCCpJtxQ.png" /></figure><ul><li>I created a CodeBuild project with a new service role which I will configure later with all necessary permissions. But you can go with preconfigured service role too.</li><li>We are able to configure a timeout, certificate, VPC, compute type, environment variables, and file systems parameters inside of the <strong>Additional configuration</strong> subsection of the <strong>Environment</strong> section. So, do not forget to add all necessary environment variables.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mBcJlucBYic0rq490kHg6A.png" /></figure><ul><li>As previously I chose <strong>No Source</strong> for the <strong>Source provider </strong>section I need to insert a build script directly to the <strong>Buildspec </strong>section</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sXq9A0hP9_xCbYwSs3t_Yg.png" /></figure><ul><li>Rest of the parameters I left with default values</li><li>Press create a CodeBuild project button</li><li>After the CodeBuild project have been created, I created the trigger for the build using a cron expression. I have a trigger and scheduled it for every 10 minutes between working hours cron(0/10 9-18 ? * MON-FRI *) . Let’s imagine that we are living in a universe where we are working during working hours. Hope such one exists.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VsPiKLci0rnD_qFc7rNzYA.png" /></figure><h3>AWS S3</h3><ul><li>I uploaded the custom deployment script in the proper S3 bucket declared in <a href="https://github.com/shorobura-mykola/codebuild-deploy-lambda/blob/main/buildspec.yml">buildspec.yaml</a></li><li>Better to put the deployment script file into some folder within a bucket</li></ul><h3>AWS Dynamo DB</h3><ul><li>I used a DynamoDB table to keep meta information regarding the last hashes for each GitHub repos.</li><li>Bellow is one particular item from the DynamoDB table</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GIrmMp9HQnY6oEcBahX3-A.png" /></figure><h3>AWS Lambda</h3><ul><li>It will be easier to manage lambdas across regions/environments if you use different prefixes for lambda names. For instance, dev-YOUR_LAMBDA_NAME, beta-YOUR_LAMBDA_NAME, prod-YOUR_LAMBDA_NAME</li></ul><h3>AWS IAM Policies</h3><ul><li>Always go with the least permission principle</li><li>Go to AWS IAM service and find the service role attached to your CodeBuild project and add the policies described below</li><li>If previously you choose to create a new service role for a code build project, the first policy is generated automatically</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ryQaVa6bOglhGiRT-cTXfg.png" /></figure><ul><li><strong>S3 bucket policy</strong></li></ul><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;s3:GetObject&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;arn:aws:s3:::codebuild-metadata/deploy-lambda.py&quot;<br>        }<br>    ]<br>}</pre><ul><li><strong>DynamoDB table policy</strong></li></ul><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Sid&quot;: &quot;VisualEditor0&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;dynamodb:PutItem&quot;,<br>                &quot;dynamodb:GetItem&quot;,<br>                &quot;dynamodb:Scan&quot;,<br>                &quot;dynamodb:Query&quot;,<br>                &quot;dynamodb:UpdateItem&quot;,<br>                &quot;dynamodb:UpdateTable&quot;,<br>                &quot;dynamodb:GetRecords&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;arn:aws:dynamodb:eu-north-1:452602032075:table/codebuild-metadata-table&quot;<br>        }<br>    ]<br>}</pre><ul><li><strong>Update Lambda policy</strong></li></ul><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Id&quot;: &quot;default&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Sid&quot;: &quot;AllowUpdateFunction&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: &quot;lambda:UpdateFunctionCode&quot;,<br>            &quot;Resource&quot;: &quot;*&quot;<br>        }<br>    ]<br>}</pre><h3>Deployment flow steps</h3><ul><li>Read GitHub repos meta-data from the DynamoDB table</li><li>Go through each repo and check if any of the tag/branch has a new commit hash</li><li>If a new commit hash exists for any tracked tag/branch, start the deployment process which is simply archiving the new project version and deploying it to the proper region</li><li>After deployment is finished simply update the latest tag/branch hash for particular repo in the DynamoDB table</li></ul><p>All deployment steps described above take only a few seconds. But CodeBuild takes some time to start the build process. Most of the working time it takes for the provisioning phase. See screenshots below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t-BSu6Eohinf_Axdvx6oFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yesDcAkEjSbYqLVAzXCzCA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*akPNDT_FKwqf--AyX2f1Aw.png" /></figure><h3>Billing (pay attention that it may be different in your case)</h3><p>I would expect that the CodeBuild run for 100 projects will take roughly 5 minutes. So, if we want to trigger our CodeBuild every 10 minutes between 9–18 hours every working day MON-FRI the billing may look like the below.</p><ul><li>One minute of CodeBuild in our case costs 0.005$</li><li>Run CodeBuild 6 times in an hour. So, it is 54 times in one day.</li><li>54 times * 5 mins CodeBuild = 270 minutes of CodeBuild in a day</li><li>270 minutes * 21 working days in a year * 0.005 cents = <strong>~28$ in a month</strong></li><li>270 minutes * 260 working days in a year = 70 200 minutes of CodeBuild in a year</li><li>70 200 minutes * 0.005 cents = <strong>~350$ in a year</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DzQHm5PU1W4wTkX0j2ElCw.png" /></figure><p><strong>Summary</strong></p><p>I wouldn’t recommend using this kind of continuous deployment strategy before you find out what are the requirements. AWS provides a lot of services using which you can come up with different deployment strategies. The particular strategy described in this article looks useful only for a big number of repos with provided requirements. Maybe if you have a few or even one project/service in meaning of AWS Lambda function I would rather recommend building separate AWS CodeBuild projects for each project/service and for each environment/account. Anyway, before starting to implement anything you should spend some time figuring out what will better fit your needs.</p><p><strong>Pros</strong></p><ul><li>You do not need to set up or modify code build configuration for any new project</li><li>You can customize the deployment script with any conditions in the code</li><li>It is possible to use the git branch or tags</li><li>You do not have 3 code build projects for each lambda function. For instance, you will need to have 300 code build projects (100 GitHub projects * 3 envs = 300 CodeBuild projects)</li><li>For a new repo, you just need to create 3 default lambda functions in each env==region with the proper env prefix, and after CodeBuild runs you will see the updated Lambda function</li><li>Serverless &amp; pay-as-you-go</li></ul><p><strong>Cons</strong></p><ul><li>You are not able to perform an automatic invocation of CodeBuild for any new pushed commits in this scenario</li><li>You will need another GitHub project to maintain the versioning of buildspec.yaml and deployment script files</li></ul><p><strong>Resources:</strong></p><ul><li>GitHub repo <a href="https://github.com/shorobura-mykola/codebuild-deploy-lambda">https://github.com/shorobura-mykola/codebuild-deploy-lambda</a></li><li>AWS CodeBuild <a href="https://aws.amazon.com/codebuild/?nc=sn&amp;loc=0">https://aws.amazon.com/codebuild/?nc=sn&amp;loc=0</a></li><li>AWS CodeBuild Billing <a href="https://aws.amazon.com/codebuild/pricing/?nc=sn&amp;loc=3">https://aws.amazon.com/codebuild/pricing/?nc=sn&amp;loc=3</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d793f6237208" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>