<?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>DEV Community: Luis Nuñez</title>
    <description>The latest articles on DEV Community by Luis Nuñez (@luisyonaldo).</description>
    <link>https://dev.to/luisyonaldo</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%2F427090%2Fe9adf089-1444-4ceb-8c4e-fb0c91be34bd.jpeg</url>
      <title>DEV Community: Luis Nuñez</title>
      <link>https://dev.to/luisyonaldo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/luisyonaldo"/>
    <language>en</language>
    <item>
      <title>My journey into The Cloud Resume Challenge</title>
      <dc:creator>Luis Nuñez</dc:creator>
      <pubDate>Sun, 02 Aug 2020 10:44:44 +0000</pubDate>
      <link>https://dev.to/luisyonaldo/my-journey-into-the-cloud-resume-challenge-2d7g</link>
      <guid>https://dev.to/luisyonaldo/my-journey-into-the-cloud-resume-challenge-2d7g</guid>
      <description>&lt;p&gt;I was on my normal daily Twitter scrolling when I saw this:&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--6KKGBBk8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/1259236310990061575/8poErtri_normal.jpg" alt="Forrest Brazeal profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Forrest Brazeal
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        &lt;a class="comment-mentioned-user" href="https://dev.to/forrestbrazeal"&gt;@forrestbrazeal&lt;/a&gt;

      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P4t6ys1m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      Introducing the &lt;a href="https://twitter.com/hashtag/CloudResumeChallenge"&gt;#CloudResumeChallenge&lt;/a&gt;. I'm volunteering my network to help you get your first job in the cloud. But I can only share a certain kind of resume. Thread -&amp;gt; &lt;a href="https://t.co/FRUuzBupXr"&gt;forrestbrazeal.com/2020/04/23/the…&lt;/a&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      17:19 PM - 27 Apr 2020
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1254822417203113986" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-reply-action.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1254822417203113986" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-retweet-action.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      75
      &lt;a href="https://twitter.com/intent/like?tweet_id=1254822417203113986" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-like-action.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
      142
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


&lt;p&gt;I love the idea of motivating people into going to the Cloud and after reading the &lt;a href="https://cloudresumechallenge.dev"&gt;challenge&lt;/a&gt;, I got immediately hooked (you know, WCGW with another side project?).&lt;/p&gt;

&lt;p&gt;I’ve been working in software development for the last 5 years and have previous experience with the Cloud. I’m currently working as a Site Reliability Engineer and the company I work for recently decided to go “all-in” into the Cloud. The challenge would help me to refresh my memory and learn new things (~1 year apart from the Cloud and everything seemed new).&lt;/p&gt;

&lt;p&gt;The idea is to have a static website (your resume) deployed online using a serverless API to count the number of visitors. You can read the full &lt;a href="https://cloudresumechallenge.dev/instructions/"&gt;instructions&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Enough talk, let’s dive into my journey of doing the challenge.&lt;/p&gt;

&lt;p&gt;&lt;a href="//i.imgflip.com/wa1a0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="//i.imgflip.com/wa1a0.jpg" alt="So it begins"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Frontend
&lt;/h1&gt;

&lt;p&gt;So far, almost all my programming experience has been on the backend side. I always wanted to have my own blog/website (you know, like a &lt;strong&gt;cool&lt;/strong&gt; kid). Hopefully, this will be the kick-start I need.&lt;/p&gt;

&lt;p&gt;I have been following &lt;a class="comment-mentioned-user" href="https://dev.to/kentcdodds"&gt;@kentcdodds&lt;/a&gt;
 &lt;a href="https://kentcdodds.com"&gt;blog&lt;/a&gt; and getting more hooked into &lt;a href="https://reactjs.org/"&gt;React&lt;/a&gt;. I try to follow all the examples but never got to do a full project (tried multiple times with side projects and failed constantly). Maybe this time's a charm.&lt;/p&gt;

&lt;p&gt;Therefore, I decided to build the website with &lt;a href="https://reactjs.org"&gt;React&lt;/a&gt; using &lt;a href="https://nextjs.org"&gt;Next.js&lt;/a&gt; so I can forget about things like bundling modules and Javascript compiling for the time being (yes, I’m looking at you &lt;a href="https://webpack.js.org"&gt;Webpack&lt;/a&gt; and &lt;a href="https://babeljs.io"&gt;Babel&lt;/a&gt;). I also avoided using components libraries and things like &lt;a href="https://getbootstrap.com"&gt;Bootstrap&lt;/a&gt; or &lt;a href="https://tailwindcss.com"&gt;tailwindcss&lt;/a&gt; so I can learn the basics of React and CSS (hence why my resume looks so ugly 😄).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;: if you want to increase the chances for your resume to grab recruiters' and Companies' attention, I recommend you to buy &lt;em&gt;&lt;a href="https://blog.pragmaticengineer.com/the-tech-interview-inside-out"&gt;The Tech Interview Inside-Out&lt;/a&gt;&lt;/em&gt; book by &lt;a class="comment-mentioned-user" href="https://dev.to/gergelyorosz"&gt;@gergelyorosz&lt;/a&gt;
. I've already applied some suggestions for my resume.&lt;/p&gt;

&lt;p&gt;Once I got the static site done, all left was to deploy online all HTML and Javascript files. Here is where the Cloud part starts. First, I used S3 to serve the files online. Later on, added a &lt;a href="https://aws.amazon.com/cloudfront/"&gt;CloudFront&lt;/a&gt; web distribution as a Content delivery network (CDN) in front, together with &lt;a href="https://dev.toCertificate%20Manager"&gt;Certificate Manager&lt;/a&gt; to handle the SSL/TLS certificate needed to serve traffic through HTTPS. All under a custom domain name managed by &lt;a href="https://aws.amazon.com/route53/"&gt;Route 53&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here is a brief overview of the architecture:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZsIQIjXg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ucrnp89eajqmp2kgfce4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZsIQIjXg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ucrnp89eajqmp2kgfce4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Backend
&lt;/h1&gt;

&lt;p&gt;Recently a friend of mine asked for some help to debug some issues with his company website, which was under a serverless architecture. So I already had my fair share of reading documentation and understanding concepts behind &lt;a href="https://aws.amazon.com/api-gateway/"&gt;API Gateway&lt;/a&gt;, &lt;a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html"&gt;Lambda  Proxy integration&lt;/a&gt;, &lt;a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html"&gt;SAM&lt;/a&gt;. Now that I know more about what a serverless architecture entails, things should not be that hard right?&lt;/p&gt;

&lt;p&gt;The main logic is inside a simple python lambda function that talks to &lt;a href="https://aws.amazon.com/dynamodb/"&gt;DynamoDB&lt;/a&gt; table and increases and returns the current visits counter of the domain. I used Amazon API Gateway to expose my lambda function and used it as a backend for the static site. By default, the API Gateway uses an &lt;a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-basic-concept.html#apigateway-definition-edge-optimized-api-endpoint"&gt;Edge-optimized API endpoint&lt;/a&gt;, which has an AWS managed CloudFront web distribution in front of it to help improve the client connection time. Since we already have a CloudFront distribution, we can choose a &lt;a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-basic-concept.html#apigateway-definition-regional-api-endpoint"&gt;Regional API endpoint&lt;/a&gt; instead and use the same distribution used for the static site. Here you can read a detailed &lt;a href="https://aws.amazon.com/premiumsupport/knowledge-center/api-gateway-cloudfront-distribution/."&gt;explanation&lt;/a&gt; of how to do this.&lt;/p&gt;

&lt;p&gt;Here is a brief overview of the architecture:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--O3-a8TXB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pnsxkt0e23grgygjt7qo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--O3-a8TXB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pnsxkt0e23grgygjt7qo.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Infrastructure as Code (IaC)
&lt;/h1&gt;

&lt;p&gt;I'm used to working with &lt;a href="https://www.terraform.io"&gt;Terraform&lt;/a&gt; (and a bit of &lt;a href="https://aws.amazon.com/cloudformation"&gt;CloudFormation&lt;/a&gt;) to deploy and maintain the infrastructure in the Cloud. But recently a new &lt;em&gt;cool&lt;/em&gt; kid came to play, &lt;a href="https://aws.amazon.com/cdk/"&gt;CDK&lt;/a&gt;, and of course, now I want it to give it a try.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CDK&lt;/strong&gt; is a developer-friendly abstraction to manage cloud infrastructure as a code. It is a higher abstraction compared to things like &lt;strong&gt;Terraform&lt;/strong&gt; and &lt;strong&gt;CloudFormation&lt;/strong&gt;, that lets you use a language you are already comfortable with (yes even Terraform has its &lt;strong&gt;DSL&lt;/strong&gt; that you need to learn) and apply some higher logic that might not be possible or nice to do with lower-level tools. I will not state which approach is better since I don’t want to start a &lt;strong&gt;declarative&lt;/strong&gt; vs &lt;strong&gt;imperative&lt;/strong&gt; discussion. On the positive side, there are both low-level and high-level abstractions so you can choose how to deploy things. Also, Terraform recently released a &lt;a href="https://www.hashicorp.com/blog/cdk-for-terraform-enabling-python-and-typescript-support"&gt;CDK&lt;/a&gt; so you can now also leverage the same principles for &lt;strong&gt;IaC&lt;/strong&gt; for different Cloud vendors.&lt;/p&gt;

&lt;p&gt;I recommend having a look at &lt;a href="https://github.com/aws-samples/aws-cdk-examples"&gt;aws-cdk-examples&lt;/a&gt; which contains some good examples with best practices. As an example, I started my project by using two examples, &lt;a href="https://github.com/aws-samples/aws-cdk-examples/tree/master/typescript/static-site"&gt;static-site&lt;/a&gt; and &lt;a href="https://github.com/aws-samples/aws-cdk-examples/tree/master/typescript/api-cors-lambda-crud-dynamodb"&gt;api-cors-lambda-crud-dynamodb&lt;/a&gt;, which later I modified and tuned according to my needs.&lt;/p&gt;

&lt;p&gt;The outcome:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;MyAPIStack&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Stack&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;StackProps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Api&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;API&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;siteDomain&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tryGetContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;domain&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;MyStaticSiteStack&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Stack&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;StackProps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;StaticSite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;StaticSite&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;siteDomain&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tryGetContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;domain&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="na"&gt;api&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Fn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;importValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ApiId&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="na"&gt;originPath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Fn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;importValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ApiOriginPath&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;account&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;CDK_DEFAULT_ACCOUNT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;region&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;CDK_DEFAULT_REGION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;MyAPIStack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;MyApi&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;MyStaticSiteStack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;MyStaticSite&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;synth&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Two CDK &lt;strong&gt;stacks&lt;/strong&gt;, &lt;a href="https://github.com/luisyonaldo/cloudresumechallenge/blob/master/.github/workflows/site.yaml"&gt;Static Site&lt;/a&gt; and &lt;a href="https://github.com/luisyonaldo/cloudresumechallenge/blob/master/.github/workflows/api.yaml"&gt;Api&lt;/a&gt; (architecture was explained above) which can be deployed separately while considering dependencies: &lt;code&gt;Api&lt;/code&gt; stack exports the URL endpoint and origin path needed by the &lt;code&gt;StaticSite&lt;/code&gt; stack so CloudFront can redirect the traffic intended for API to the API Gateway and later on to the lambda function (or CORS settings).&lt;/p&gt;

&lt;h1&gt;
  
  
  CI/CD
&lt;/h1&gt;

&lt;p&gt;Well here you should already know what’s going to happen, we are going to use the newest cool kid, Github &lt;a href="https://github.com/features/actions"&gt;Actions&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;My experience with Github Actions has been a bit of a roller coaster. I was expecting more features implemented out of the box: share artifacts and dependencies between workflows and better/easier container integrations, e.g. services in Jobs, etc. On the other hand, I like the &lt;a href="https://github.com/marketplace?type=actions"&gt;Marketplace&lt;/a&gt; and how easy it's to use or share Actions within the community.&lt;/p&gt;

&lt;p&gt;Again things are simple here, two workflows, one for the &lt;a href="https://github.com/luisyonaldo/cloudresumechallenge/blob/master/.github/workflows/site.yaml"&gt;Static Site&lt;/a&gt; and one for the &lt;a href="https://github.com/luisyonaldo/cloudresumechallenge/blob/master/.github/workflows/api.yaml"&gt;API&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Static Side:

&lt;ul&gt;
&lt;li&gt;Build the website (&lt;a href="https://nextjs.org/docs/advanced-features/static-html-export"&gt;Next.js export&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;Deploy resources using CDK (&lt;code&gt;distributionPaths&lt;/code&gt; option invalidates the cache in CloudFront distribution).&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;API

&lt;ul&gt;
&lt;li&gt;Test python code&lt;/li&gt;
&lt;li&gt;Build assets code: install dependencies and &lt;code&gt;zip&lt;/code&gt; all files.&lt;/li&gt;
&lt;li&gt;Deploy resources using CDK.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Code Review
&lt;/h1&gt;

&lt;p&gt;After finishing the challenge I added &lt;a class="comment-mentioned-user" href="https://dev.to/forrestbrazeal"&gt;@forrestbrazeal&lt;/a&gt;
 (the &lt;strong&gt;real&lt;/strong&gt; cool kid) as a collaborator, who gave me a personalized &lt;a href="https://github.com/luisyonaldo/cloudresumechallenge/issues/3"&gt;code review&lt;/a&gt;. There was a bug with DynamoDB increasing the visits counter with initial zero values and suggestions to use &lt;strong&gt;on-demand&lt;/strong&gt; billing for DynamoDB and structured logging for the lambda function.&lt;/p&gt;

&lt;p&gt;The bug was an easy fix and I added some tests to cover the interactions with DynamoDB. For this, I used the &lt;a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html"&gt;dynamo-local&lt;/a&gt; container and &lt;strong&gt;AWS CLI&lt;/strong&gt; to initialize the table. Turning on &lt;strong&gt;on-demand&lt;/strong&gt; billing was just setting some config on the AWS DynamoDB construct. And finally, adding structured logging was also an easy thing thanks to &lt;a href="https://github.com/awslabs/aws-lambda-powertools-python"&gt;aws-lambda-powertools-python&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now the fun part begins.&lt;/p&gt;

&lt;p&gt;When I added structured logging, I added an external dependency into the lambda code (&lt;a href="https://aws.amazon.com/sdk-for-python/"&gt;boto3&lt;/a&gt; is also an external dependency but it is included by default on the AWS python lambda runtime). Now just having the lambda python file was not enough, now you need to bundle dependencies: &lt;code&gt;pip install -r requirements.txt --target=&amp;lt;output_dir&amp;gt;&lt;/code&gt; and a &lt;code&gt;zip&lt;/code&gt; all files.&lt;/p&gt;

&lt;p&gt;This is when &lt;a href="https://aws.amazon.com/serverless/sam/"&gt;SAM&lt;/a&gt; comes to play. It helps you to build serverless applications and abstract things like bundling asset code for you. Here is an easy to follow &lt;a href="https://blog.heyitschris.com/posts/get-your-foot-in-the-door-with-sam/"&gt;blog&lt;/a&gt; about how to start working with SAM (done by a person also doing this challenge). You can use SAM together with CDK to test, build, and deploy serverless resources. Here is another &lt;a href="https://sanderknape.com/2019/05/building-serverless-applications-aws-cdk/"&gt;blog&lt;/a&gt; with a detailed explanation.&lt;/p&gt;

&lt;p&gt;TL;DR:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cdk synth --no-staging &amp;gt; template.yaml
sam local invoke &amp;lt;function&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;First, I was bundling assets manually inside Github pipeline, then I was using SAM and later I learn CDK lambda construct also has built-in &lt;a href="https://docs.aws.amazon.com/cdk/api/latest/docs/aws-lambda-readme.html#bundling-asset-code"&gt;support&lt;/a&gt; already. To keep things in sync, I decided to use CDK for both bundling and deploying then lambda function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Code&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fromAsset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../api/app&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;bundling&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Runtime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PYTHON_3_8&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bundlingDockerImage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bash&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;-c&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cp -R /asset-input/* /asset-output &amp;amp;&amp;amp; pip install -r requirements.txt -t /asset-output&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;}),&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h1&gt;
  
  
  Downfall
&lt;/h1&gt;

&lt;p&gt;After finishing fixing bugs and suggestions in the code review, I informed &lt;a class="comment-mentioned-user" href="https://dev.to/forrestbrazeal"&gt;@forrestbrazeal&lt;/a&gt;
 that it was done. Now I’m happy, I have finished the challenge (only blog post is left), it’s almost midnight and it’s time to go to bed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--areCSY1B--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/s33h19bft8r1s180jgoz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--areCSY1B--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/s33h19bft8r1s180jgoz.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qT8NpxDq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ibqm8t6136dgqc5k05th.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qT8NpxDq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ibqm8t6136dgqc5k05th.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Wait, what? I've tested it before, I have been playing with it for so long already (my counter was at 150 already and I was the only one that knew the domain by that time).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YhVo32G6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://memegenerator.net/img/instances/25328811.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YhVo32G6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://memegenerator.net/img/instances/25328811.jpg" alt="It was working a second ago"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I try to see what differences are between deploy code and latest committed changes with &lt;code&gt;cdk diff&lt;/code&gt; and nothing comes up. I even locally reverted the latest commit and tried again, and the same happens.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zCjW5zwU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sayingimages.com/wp-content/uploads/black-man-wait-what-meme.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zCjW5zwU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sayingimages.com/wp-content/uploads/black-man-wait-what-meme.jpg" alt="Wait what?"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Deploying things with multiple tools at the same time is not a good thing to do. I was doing manual deployments of the lambda function on AWS console and with SAM to test things before committing changes. Which caused a CloudFormation (CDK leverage deployment of resources to CloudFormation) &lt;strong&gt;drift&lt;/strong&gt;. CloudFormation's state of managed resources diverged from what was currently deployed, due to manual actions on the lambda function (this reminds me of old times working with Terraform without storing the state on S3 with versioning enabled). Fortunately, now there is a new &lt;a href="https://aws.amazon.com/blogs/aws/new-cloudformation-drift-detection/"&gt;drift detection&lt;/a&gt; which tells what things diverged and on which resources.&lt;/p&gt;

&lt;p&gt;It's past midnight, you are tired, and there is no urgency in fixing this right away. What do you do?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bXSGZEtj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://media.makeameme.org/created/well-duh-hkhlch.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bXSGZEtj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://media.makeameme.org/created/well-duh-hkhlch.jpg" alt="Duh!"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Obviously, you try to fix it now so you can sleep in peace. Here is where I tried to be &lt;em&gt;clever&lt;/em&gt; and decided to manually delete the lambda function so it can be re-deployed again by CDK.&lt;/p&gt;

&lt;p&gt;Remember that I said there was a drift in my CloudFormation stack, so How manually deleting the lambda function is going to help? Now the state has diverged even more. To fix this you need to bring the state back in sync, which means manually editing resources until they match CF state or editing CF stack to match the current state.&lt;/p&gt;

&lt;p&gt;As said before, it is late, and I want to go to bed. I don’t want to manually keep trying to edit things until the drift is gone. Luckily we have used &lt;strong&gt;IaC&lt;/strong&gt; so it should be simple to delete everything and bring it back by just doing &lt;code&gt;cdk destroy &amp;amp;&amp;amp; cdk deploy&lt;/code&gt; again right? &lt;strong&gt;YOLO&lt;/strong&gt; (please don’t do this with a production application).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s1oV8oIK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.memesmonkey.com/images/memesmonkey/4d/4dc1994d6fe6e901e025b18f7c462170.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s1oV8oIK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.memesmonkey.com/images/memesmonkey/4d/4dc1994d6fe6e901e025b18f7c462170.jpeg" alt="Fingers cross"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This went surprisingly well and after a few minutes, all resources were destroyed and re-deployed again. Now everything is working, I tried multiple times refreshing the page to make sure the counter is working, so now I can inform that it is ready and go quickly to sleep before I break something else 😄.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;It was a fun journey, I learned and struggle more than I thought. If you are new to the Cloud or even to IT, don't worry if you are struggling too much. Being honest, this “simple” challenge covers most of the best practices in software deployment that a production application &lt;strong&gt;should&lt;/strong&gt; have.&lt;/p&gt;

&lt;p&gt;Kudos again to &lt;a class="comment-mentioned-user" href="https://dev.to/forrestbrazeal"&gt;@forrestbrazeal&lt;/a&gt;
 for this great initiative, I hope more people can enjoy this challenge. I’m open to suggestions or questions about how I did things. Also, feel free to reach if you need help. Hopefully, in the following days, I’ll add better explanations into the GitHub &lt;a href="https://github.com/luisyonaldo/cloudresumechallenge"&gt;repo&lt;/a&gt; and I can write a follow-up post with a deeper focus on the technical side.&lt;/p&gt;

&lt;p&gt;Almost forget, this is the final outcome: &lt;a href="https://luisyonaldo.com"&gt;https://luisyonaldo.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>serverless</category>
      <category>challenge</category>
      <category>career</category>
    </item>
  </channel>
</rss>
