<?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 shubham machal on Medium]]></title>
        <description><![CDATA[Stories by shubham machal on Medium]]></description>
        <link>https://medium.com/@machal_shubham?source=rss-68895def1057------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*khdQ1HzPEeQ6xTkIx_iFtQ.jpeg</url>
            <title>Stories by shubham machal on Medium</title>
            <link>https://medium.com/@machal_shubham?source=rss-68895def1057------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 05:43:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@machal_shubham/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[How I Passed the Terraform Associate Exam (with Just a Few Resources)]]></title>
            <link>https://medium.com/@machal_shubham/how-i-passed-the-terraform-associate-exam-with-just-a-few-resources-568fe4231931?source=rss-68895def1057------2</link>
            <guid isPermaLink="false">https://medium.com/p/568fe4231931</guid>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[terraform-associate-exam]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[certification]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[shubham machal]]></dc:creator>
            <pubDate>Sun, 04 May 2025 04:11:02 GMT</pubDate>
            <atom:updated>2025-05-04T04:11:02.355Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*n0zTO2haB-0-TiN1aq8-Xg.png" /></figure><p>I recently passed the Terraform Associate certification exam, and to be honest, it wasn’t as intimidating as it first seemed — <strong>as long as you stick to the right resources</strong>. In this article, I’ll walk you through exactly what I used to prepare and why I believe <em>you don’t need a dozen courses</em> or expensive bootcamps to pass this certification exam.</p><h3>Must-Have: The Official Terraform Study Guide</h3><p>Before diving into any video tutorials or books, I began my preparation by thoroughly reading the <strong>official Terraform study guide</strong> provided by HashiCorp. This guide is <strong>the single most reliable source</strong> because it comes directly from the people who create Terraform.</p><p>It clearly outlines the exam domains and objectives — such as understanding Terraform’s workflow, managing state, configuring providers, and using modules. It also specifies which topics you need to <em>understand conceptually</em> versus those where <em>hands-on experience</em> is essential. This clarity helped me structure my study plan and prioritize topics based on weight and complexity.</p><p>Think of this guide as your <strong>syllabus or blueprint</strong> for the exam. It gives you a high-level map of what’s ahead, so you’re never caught off-guard by unfamiliar content. Every other resource you use — whether it’s a video course or a book — should be aligned with what’s listed here. In my case, I constantly referred back to the guide to make sure I wasn’t missing any topic or objective.</p><p>So, if you’re just getting started, I strongly recommend reading through the official guide first. It sets the foundation and ensures that the rest of your preparation is focused and efficient.</p><h3>Terraform Zero to Hero by Abhishek Veeramalla — A Game-Changer</h3><p>One of the best resources I came across during my preparation was the free YouTube series by Abhishek Veeramalla, titled <a href="https://www.youtube.com/watch?v=fgp-t5SqQmM&amp;list=PLdpzxOOAlwvI0O4PeKVV1-yJoX2AqIWuf"><strong><em>Terraform Zero to Hero</em></strong></a>. Honestly, this series is a complete package and, in my opinion, one of the most beginner-friendly and comprehensive resources out there.</p><p>The playlist includes 11 in-depth videos, totaling around 13 hours of content. Each video is thoughtfully structured, starting from the very basics and gradually progressing to more advanced concepts — all mapped closely to the official exam objectives.</p><p>What sets this series apart is its <strong>perfect balance of theory and hands-on practice</strong>. Abhishek doesn’t just explain concepts — he demonstrates them live using real Terraform configurations, so you’re actively learning how to use the tool, not just memorizing definitions. Whether it’s working with providers, creating resources, or managing state, he shows how everything works in practice.</p><p>And the best part? <strong>You don’t just watch — you learn by doing.</strong> If you follow along with his examples and try things out on your own, you’ll build the hands-on experience that’s essential for the exam.</p><p>I can confidently say that <strong>if you only follow this series thoroughly</strong>, you’ll be well-prepared for the exam. It’s that good.</p><h3>Concise Revision Guide from Leanpub</h3><p>In the final stretch of my preparation, I decided to purchase the <a href="https://leanpub.com/c/terraform-associate"><strong>Terraform Associate Guide on Leanpub</strong></a> — and honestly, it turned out to be one of the <strong>best $10 investments</strong> I’ve made for this certification.</p><p>This guide is designed specifically for quick, effective revision. It summarizes all the key topics from the official study guide in a way that’s clear, concise, and easy to digest. There’s no fluff — just straight-to-the-point explanations that reinforce your understanding of the core concepts.</p><p>One of the standout features of this guide is the inclusion of <strong>mini quizzes</strong> at the end of each topic. Each quiz has about <strong>7–8 carefully crafted questions</strong> that challenge your grasp of the material and help identify weak spots immediately. This active recall technique made my revision more engaging and helped solidify what I had learned.</p><p>Even more valuable were the <strong>three full-length practice quizzes</strong>, each with around <strong>50 questions</strong>. These simulate the format and difficulty level of the actual exam quite well. In fact, during the exam, I encountered at least <strong>4–5 questions that were strikingly similar</strong> to the ones I practiced from these quizzes.</p><p>This was really helpful in my final prep. It allowed me to <strong>quickly revise</strong>, <strong>reinforce tricky topics</strong>, and <strong>build confidence</strong> before exam day. Whether you’re using it as a primary study guide or a revision tool after completing a video series, it’s an excellent addition to your prep journey.</p><h3>Final Thoughts</h3><p>The exam isn’t overly difficult, but it’s definitely not a walk in the park either. The questions are practical and assess your true understanding of the concepts — they’re not just about memorizing definitions. If you don’t practice hands-on, it’s easy to forget the specific use cases of commands or details about certain topics. So, make sure to configure resources using Terraform, even if it’s just a basic project.</p><p>Even if you’re a beginner, if you:</p><ul><li>Follow Abhishek Veeramalla’s video series thoroughly, and</li><li>Revise using the Leanpub guide and complete the quizzes</li></ul><p>You’ll not only pass the exam but also build a strong foundation in Terraform that will be valuable for tackling real-world projects.</p><p><em>Thank you for reading! If you have any doubts or questions, feel free to reach out to me on </em><a href="https://www.linkedin.com/in/shubham-machal-18a51112a/"><em>LinkedIn</em></a><em>. I’d be happy to help you out!</em></p><p><em>Also, if you’re interested in learning more about </em><strong><em>Cloud</em></strong><em>, </em><strong><em>Infrastructure as Code (IaC)</em></strong><em>, and </em><strong><em>DevOps</em></strong><em>, follow my medium profile and send me a connection request on LinkedIn for more insights and resources.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=568fe4231931" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Serverless URL Shortener with AWS and Terraform]]></title>
            <link>https://towardsaws.com/building-a-serverless-url-shortener-with-aws-and-terraform-d189e448ae3f?source=rss-68895def1057------2</link>
            <guid isPermaLink="false">https://medium.com/p/d189e448ae3f</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <dc:creator><![CDATA[shubham machal]]></dc:creator>
            <pubDate>Tue, 01 Apr 2025 06:25:45 GMT</pubDate>
            <atom:updated>2025-04-01T08:27:31.943Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>While reading Alex Xu’s <em>“System Design Interview — An Insider’s Guide,”</em> I came across the classic challenge of designing a URL shortener. It struck me as an excellent opportunity to apply my cloud knowledge and sharpen my Terraform skills. Instead of limiting myself to the theoretical aspects, I decided to take a more practical approach by building my own version using AWS and Terraform.</p><p>In this article, I won’t dive too much into the system design intricacies of a URL shortener. Instead, I’ll walk you through how I built a complete full-stack website around the URL shortener, using AWS and Terraform to manage the infrastructure. If you’re interested in practical insights on deploying and managing applications in the cloud, this guide is for you. If you want to learn about the system design aspect of it, you can check out this “<a href="https://github.com/mukul96/System-Design-AlexXu/blob/master/System%20Design%20Interview%20An%20Insider%E2%80%99s%20Guide%20by%20Alex%20Xu%20(z-lib.org).pdf"><em>github repo</em></a><em>”</em></p><h3>What is a URL Shortener and Why is it Useful?</h3><p>In simpler terms, it is a service that converts long URLs into shorter, concise and manageable links. There are numerous URL shorteners available, including <em>Bitly, TinyURL, and Rebrandly</em>. These services are widely used in social media marketing and link management, helping businesses handle thousands of links while ensuring reliable access. Additionally, they often provide the option to generate QR codes from shortened URLs, which are commonly placed in print media to enhance offline-to-online engagement.</p><h3>Architecture Overview</h3><p>I developed this serverless URL shortener mainly on AWS and with the help of Terraform. Below is the system architecture of the URL shortener:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LCySEVbG31Hik-oVC378CQ.png" /><figcaption>System Architecture</figcaption></figure><h3>System Components</h3><ol><li><strong>User/Browser</strong>: The client side that interacts with your URL shortener service</li><li><strong>Domain Provider (Namecheap)</strong>: Manages the custom domain “yourtinyurl.live”</li><li><strong>AWS Cloud Services</strong>:</li></ol><ul><li><strong>ACM</strong>: Provides SSL certificate for secure HTTPS connections</li><li><strong>CloudFront</strong>: Handles content delivery and request routing</li><li><strong>S3 Bucket</strong>: Stores the static website (index.html)</li><li><strong>API Gateway</strong>: Manages API endpoints for URL creation and redirection</li><li><strong>Lambda Functions</strong>: Two serverless functions for creating and redirecting URLs</li><li><strong>DynamoDB</strong>: Database that stores URL mappings</li></ul><p>4.<strong> Terraform</strong>: Infrastructure as Code tool managing AWS resources</p><h3>Request Flow Paths</h3><h4>Path 1: Accessing the URL Shortener Interface</h4><ol><li>User navigates to “yourtinyurl.live” in their browser</li><li>Namecheap DNS resolves the domain to the CloudFront distribution</li><li>CloudFront checks the path (“/root path”)</li><li>The request matches the default behavior for root path</li><li>CloudFront retrieves index.html from the S3 bucket</li><li>The page is delivered to the user’s browser, displaying the URL shortening interface</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k2ZGhg9tcuPbIpR1EWuK8w.png" /></figure><h3>Path 2: Creating a Short URL</h3><ol><li>User enters a long URL in the interface and clicks “Shorten URL”</li><li>Browser makes a POST request to “/create” endpoint</li><li>CloudFront routes this to API Gateway based on the path</li><li>API Gateway triggers the “create_url” Lambda function</li><li>Lambda generates a short ID using Base62 encoding</li><li>Lambda stores the mapping (short_id → original URL) in DynamoDB</li><li>The response with the new short URL flows back through API Gateway and CloudFront to the user</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yp-4XbADXorBNJ6DCnBjmA.png" /></figure><p>We can see our DynamoDB table with the newly created short URL and original long URL. It contains shortID which is mapped to original long url, timestamp of the url creation and click count of a particular URL, which is useful for analysis and marketing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*anM5sIlFD54a6TS6rLTF4Q.png" /></figure><h3>Path 3: Using a Short URL</h3><ol><li>User visits “yourtinyurl.live/{short_id}” (e.g., with a 5–6 character ID)</li><li>Namecheap DNS resolves to the CloudFront distribution</li><li>CloudFront checks the path and matches it to the “/{short_id}” pattern</li><li>CloudFront routes the request to API Gateway</li><li>API Gateway triggers the “redirect_url” Lambda function</li><li>Lambda looks up the original URL in DynamoDB using the short_id</li><li>Lambda returns a 301 redirect response to the original URL</li><li>The user’s browser is automatically redirected to the original destination</li></ol><h3>Key Technical Features</h3><ul><li><strong>CloudFront Path-Based Routing</strong>: Intelligently directs traffic between S3 (static content) and API Gateway (dynamic functionality) based on URL paths</li><li><strong>Serverless Architecture</strong>: No servers to manage; all compute is handled by Lambda functions</li><li><strong>HTTPS Security</strong>: ACM certificate ensures secure connections</li><li><strong>Infrastructure as Code</strong>: Entire setup managed through Terraform for reproducibility</li><li><strong>Key-Value Storage</strong>: Simple but effective DynamoDB schema for fast lookups</li><li><strong>Efficient Encoding</strong>: Base62 encoding to generate compact, unique URLs</li></ul><h3>Technologies Used</h3><p>Here’s a detailed breakdown of the key technologies used in the URL shortener project:</p><h3>AWS Services</h3><h4><strong>AWS Lambda</strong></h4><p>AWS Lambda is a serverless compute service that runs code in response to events. In this project, I’ve used Lambda to create URLs and redirect short URLs to their original long URLs. I’ve created two Lambda functions: one for creating the URLs and another for handling the redirection. The main advantage of Lambda is its pay-per-execution pricing model, meaning you only pay for what you use.</p><h4><strong>Amazon API Gateway</strong></h4><p>API Gateway is used to handle the HTTP endpoints for creating and redirecting the URLs. I have created two endpoints for this: /create to generate short URLs and another for redirection. API Gateway seamlessly integrates with Lambda functions and routes requests based on path patterns. It also supports CORS (Cross-Origin Resource Sharing) and prevents unauthorized API access from other websites.</p><h4><strong>Amazon S3 (Simple Storage Service)</strong></h4><p>S3 is used to store the index.html file that provides the URL shortening interface. We are using cloudFront to serve the request to index.html so S3 bucket has public access blocked for security.</p><pre>resource &quot;aws_s3_bucket_public_access_block&quot; &quot;website&quot; {<br>  bucket = aws_s3_bucket.website.id<br>  block_public_acls       = true<br>  block_public_policy     = true<br>  ignore_public_acls      = true<br>  restrict_public_buckets = true<br>}</pre><h4><strong>Amazon DynamoDB</strong></h4><p>URL shortener uses DynamoDB as a simple but effective key-value store with the following structure:</p><ul><li><strong>Table Name</strong>: url_shortener</li><li><strong>Primary Key</strong>: short_id (the generated Base62 encoded short identifier)</li><li><strong>Value</strong>: The original long URL that was shortened</li><li><strong>Access Pattern</strong>: Hash key lookup enables O(1) access time for redirects</li></ul><p>When a user creates a short URL, Lambda function stores the mapping in DynamoDB, and when someone visits a short URL, another Lambda function retrieves the original URL from DynamoDB to perform the redirect.</p><h4><strong>Amazon CloudFront</strong></h4><p>I decided to use CloudFront mainly for one purpose. Since our static files are in S3 bucket and routes are configured in API gateway, I needed the root URL to route to S3 and all other routes to API Gateway.</p><ul><li><strong>Dual-Origin Configuration</strong>: CloudFront connects to both S3 (for static website content) and API Gateway (for URL redirection)</li><li><strong>Path Pattern Routing</strong>: The distribution uses ordered cache behaviors to route requests based on URL patterns:</li><li>Root path (/) → S3 Bucket (serving index.html)</li><li>Every other path except root will be redirected to API Gateway</li><li><strong>SSL/TLS Support</strong>: Provides HTTPS for your custom domain (yourtinyurl.live) using an ACM certificate</li><li><strong>Global Distribution</strong>: Makes your application available worldwide with low latency through edge locations</li></ul><p>Below is the terraform code for configuring cloudFront with origins as S3 and API Gateway.</p><pre>resource &quot;aws_cloudfront_distribution&quot; &quot;url_shortener&quot; {<br>  enabled             = true<br>  is_ipv6_enabled     = true<br>  comment             = &quot;URL Shortener Distribution&quot;<br>  default_root_object = &quot;index.html&quot; <br>  # Custom domain name<br>  aliases = [&quot;yourtinyurl.live&quot;]<br>  # Origin for S3 website (for the main website content)<br>  origin {<br>    domain_name = aws_s3_bucket.website.bucket_regional_domain_name<br>    origin_id   = &quot;s3-website&quot;<br>    <br>    s3_origin_config {<br>      origin_access_identity = aws_cloudfront_origin_access_identity.oai.cloudfront_access_identity_path<br>    }<br>  }<br>  # Origin for API Gateway (for URL shortening and redirection)<br>  origin {<br>    domain_name = &quot;${aws_apigatewayv2_api.url_shortener.id}.execute-api.${var.aws_region}.amazonaws.com&quot;<br>    origin_id   = &quot;api-gateway&quot;<br>    custom_origin_config {<br>      http_port              = 80<br>      https_port             = 443<br>      origin_protocol_policy = &quot;https-only&quot;<br>      origin_ssl_protocols   = [&quot;TLSv1.2&quot;]<br>    }<br>  }<br>  </pre><p>In cloudFront, I had to define the default and ordered cache behavior. Default cache behavior is when the request doesn’t match the ordered cache behavior. In this case default behavior is to route to S3 and ordered behavior is to route everything except root API gateway.</p><ul><li><strong>Behavior Evaluation Order</strong>: CloudFront first checks all ordered cache behaviors in sequence. If no patterns match, it falls back to the default cache behavior.</li><li><strong>Ordered Cache Behaviors: </strong>Ordered cache behavior is defined to pattern matching for URLs other than the root (/*). In this project, patterns are routed to the API Gateway origin. They are configured with a Time-To-Live (TTL) of <strong>0</strong> to ensure that redirects remain fresh and up-to-date.</li></ul><pre>ordered_cache_behavior {<br>  path_pattern     = &quot;/*&quot;  # Matches all paths except the root<br>  allowed_methods  = [&quot;GET&quot;, &quot;HEAD&quot;, &quot;OPTIONS&quot;]<br>  cached_methods   = [&quot;GET&quot;, &quot;HEAD&quot;]<br>  target_origin_id = &quot;api-gateway&quot;<br>  <br>  forwarded_values {<br>    query_string = false<br>    headers      = [&quot;Origin&quot;]<br>    cookies {<br>      forward = &quot;none&quot;<br>    }<br>  }<br>  <br>  viewer_protocol_policy = &quot;redirect-to-https&quot;<br>  min_ttl                = 0<br>  default_ttl            = 0<br>  max_ttl                = 0<br>}</pre><ul><li><strong>Default Cache Behavior</strong>: The default cache behavior in CloudFront catches all requests that don’t match the ordered behaviors. I configured it to route requests to the S3 origin where the index.html is stored, ensuring the static website is served to users when no specific API route is matched.</li></ul><pre># The default cache behavior MUST target S3 and handle the root path<br>  default_cache_behavior {<br>    allowed_methods  = [&quot;GET&quot;, &quot;HEAD&quot;, &quot;OPTIONS&quot;]<br>    cached_methods   = [&quot;GET&quot;, &quot;HEAD&quot;]<br>    target_origin_id = &quot;s3-website&quot;<br>    forwarded_values {<br>      query_string = false<br>      cookies {<br>        forward = &quot;none&quot;<br>      }<br>    }<br>    <br>    viewer_protocol_policy = &quot;redirect-to-https&quot;<br>    min_ttl                = 0<br>    default_ttl            = 3600<br>    max_ttl                = 86400<br>  }</pre><h4><strong>AWS Certificate Manager (ACM)</strong></h4><p>The ACM certificate ensures that users have a secure, encrypted connection when interacting with URL shortener, creating trust and protecting data in transit. It is configured in main.tf as shown below:</p><pre>viewer_certificate {<br>  acm_certificate_arn      = &quot;arn:aws:acm:us-east-1:XXXXXXXXXXXX:certificate/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&quot;<br>  ssl_support_method       = &quot;sni-only&quot;<br>  minimum_protocol_version = &quot;TLSv1.2_2021&quot;<br>}</pre><p>An important technical detail when setting up CloudFront with a custom domain is that <strong>SSL/TLS certificates used with CloudFront distributions must be created in the US East (N. Virginia) region (us-east-1)</strong>, regardless of where your other AWS resources are located.</p><p>CloudFront is a global service with edge locations worldwide, but its control plane is centralized in the us-east-1 region. When CloudFront needs to serve content over HTTPS, it needs to access the certificate, and it can only reference certificates in its home region.</p><h3>Infrastructure as Code</h3><p><strong>Terraform</strong><br>I used Terraform as the Infrastructure as Code (IaC) tool, which has been instrumental in creating a reproducible and maintainable deployment process.</p><p>With Terraform, I’ve defined all AWS resources — from S3 buckets and Lambda functions to API Gateway and CloudFront distributions — as code in a declarative configuration language.</p><p>I’ve structured the code with variables for customization and outputs for important reference information, making it easy to deploy the entire stack with just a few commands. Perhaps most valuable has been Terraform’s ability to handle the complex CloudFront configuration with dual origins and path-based routing — a challenging setup that would be error-prone if managed manually.</p><h4><strong>Domain Management with Namecheap</strong></h4><p>I chose Namecheap as the domain registrar to secure the custom domain <a href="https://yourtinyurl.live/">“<em>yourtinyurl.live.</em></a><em>”</em> Namecheap provided an affordable and straightforward way to register this domain.</p><p>The integration with AWS services was simple yet crucial:</p><p>I configured DNS records in Namecheap’s dashboard to point the domain to my CloudFront distribution. This involved creating a CNAME record that maps my domain to the CloudFront distribution domain (something like d2n223XXXXX.cloudfront.net), allowing user requests to “yourtinyurl.live” to reach my application.</p><p>Additionally, when setting up SSL/TLS with AWS Certificate Manager, I had to verify domain ownership through DNS validation by adding specific TXT records provided by ACM to my Namecheap DNS configuration.</p><h3>Why Serverless and CloudFront</h3><p>System design involves trade-offs and design choices, with no universally right or wrong answers. In my URL shortener project, I chose a serverless architecture to achieve scalability, cost efficiency, and simplified management.</p><p>Additionally, I integrated Amazon CloudFront as a content delivery network (CDN) to enhance performance by caching responses and reducing latency for end users. I will explain my approach and the rationale behind these choices.</p><h4>Benefits of the Serverless Approach</h4><p>The serverless architecture eliminated the need to provision, manage, or scale any servers. This provided significant advantages for a URL shortener service:</p><ol><li><strong>Cost Efficiency</strong>: With a pay-per-use model, I only incur costs when someone creates or uses a shortened URL. There are no expenses for idle server time, making this extremely cost-effective for unpredictable traffic patterns.</li><li><strong>Auto-scaling</strong>: The solution automatically scales from handling just a few requests to potentially millions without any manual intervention. Lambda functions spin up as needed, and DynamoDB scales its throughput automatically.</li><li><strong>Reduced Operational Overhead</strong>: Without servers to patch, update, or monitor, the maintenance burden is drastically reduced. This allows me to focus on features rather than infrastructure management.</li><li><strong>High Availability</strong>: AWS’s global infrastructure ensures the URL shortener remains available across multiple availability zones with built-in redundancy.</li></ol><h3>Why CloudFront Was Essential</h3><p>Routing requests between the static index.html in S3 and to API Gateway when a user enters a short URL was not an easy task. Thankfully, CloudFront solved this problem for me. Using CloudFront allowed me to serve both static content and dynamic API functionality through a single domain (yourtinyurl.live).</p><ol><li><strong>Intelligent Request Routing</strong>: The path-based routing elegantly directs requests to the appropriate backend — S3 for the web interface and API Gateway for URL operations — without requiring complex application logic.</li><li><strong>Global Edge Network</strong>: CloudFront’s worldwide edge locations reduce latency for users regardless of their geographic location, making the service fast and responsive globally.</li><li><strong>Security Layer</strong>: The integration with ACM provides HTTPS encryption, and CloudFront adds an additional security layer by hiding direct access to the backend services.</li></ol><p>In summary, the combination of serverless and CloudFront’s routing capabilities created an elegant and cost-effective solution which is also a scalable solution that perfectly matches the requirements of a modern URL shortening service. This approach showed how choosing the right architecture pattern can dramatically simplify implementation while keeping the necessary functionalities.</p><h3>Future Enhancements for the URL Shortener</h3><p>This serverless URL shortener provides a strong foundation, but there are many ways to enhance it further.</p><ul><li><strong>User Authentication &amp; Authorization:</strong> Allow users to create accounts and manage their shortened URLs.</li><li><strong>Security Improvements:</strong> Implement request validation and rate limiting to prevent DDoS attacks.</li><li><strong>Advanced Features:</strong> Add real-time analytics, TTL for DynamoDB entries, WAF integration, and QR code generation.</li></ul><p>The possibilities are indeed endless. Each of these feautres would build upon the existing serverless architecture, using additional AWS services while maintaining the scalability and cost-efficiency of the current design.</p><p>You can check out the live demo of this project on <a href="https://yourtinyurl.live/"><em>yourtinyurl.live</em></a><em>.</em></p><p>Github repo for the same: <a href="https://github.com/shubhammachal/url_shortener"><em>url-shortener</em></a></p><p><em>Thanks for reading &amp; if you want to suggest improvements or have any question regarding this project or want to connect on other social media platform, you can reach out to me on</em></p><p><em>Twitter: </em><a href="https://x.com/machal_shubham"><em>twitter.com/machal_shubham</em></a><em><br>Linkedin: </em><a href="https://www.linkedin.com/in/shubham-machal-18a51112a/"><em>linkedin.com/shubham-machal</em></a><em><br>Github: </em><a href="https://github.com/shubhammachal"><em>github.com/shubhammachal</em></a></p><p><em>Thanks for reading &amp; if you have any question regarding this project or want to connect on other social media platform, you can reach out to me on</em></p><p><em>Twitter: </em><a href="https://x.com/machal_shubham"><em>twitter.com/machal_shubham</em></a><em><br>Linkedin: </em><a href="https://www.linkedin.com/in/shubham-machal-18a51112a/"><em>linkedin.com/shubham-machal</em></a><em><br>Github: </em><a href="https://github.com/shubhammachal"><em>github.com/shubhammachal</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d189e448ae3f" width="1" height="1" alt=""><hr><p><a href="https://towardsaws.com/building-a-serverless-url-shortener-with-aws-and-terraform-d189e448ae3f">Building a Serverless URL Shortener with AWS and Terraform</a> was originally published in <a href="https://towardsaws.com/">Towards AWS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[REST vs GraphQL: Choosing the right architecture]]></title>
            <link>https://medium.com/@machal_shubham/rest-vs-graphql-choosing-the-right-architecture-bd3ea7c19831?source=rss-68895def1057------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd3ea7c19831</guid>
            <category><![CDATA[rest]]></category>
            <category><![CDATA[graphql-vs-rest]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <dc:creator><![CDATA[shubham machal]]></dc:creator>
            <pubDate>Tue, 11 Mar 2025 23:09:12 GMT</pubDate>
            <atom:updated>2025-03-23T06:43:11.759Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UpoLKD2byCKtU3IlZcDxgg.jpeg" /></figure><h3>Introduction</h3><p>Let’s first understand little bit about APIs. In the simplest terms, an API is a structured way for applications to interact with each other. APIs serve as the backbone of modern software development, and allow seamless data exchange between a client and a server. In other words, if you want to interact with a computer or system to retrieve information or perform a function, an API helps you communicate your request so the system can understand and fulfill it.</p><p>The purpose of this article is to introduce readers to two widely used API architectural styles — REST and GraphQL. System design is all about trade-offs, and in this article, we will compare REST and GraphQL to help readers determine which is better suited for their needs and applications.</p><p>Traditionally, REST (Representational State Transfer) has been the standard for API design. However, GraphQL, introduced by Facebook in 2015, has emerged as a powerful alternative. This article compares REST and GraphQL, highlighting their differences, advantages, and ideal use cases.</p><h3>What is REST?</h3><p>Representational State Transfer (REST) is a software architecture that imposes certain constraints on how an API should function. It is important to note that REST is neither a protocol nor a standard; rather, it is a set of architectural principles. For an API to be considered RESTful, it must adhere to the following constraints:</p><ul><li><strong>Client-server architecture</strong>: The API should have distinct clients, servers, and resources.</li><li><strong>Standard HTTP methods</strong>: It should use HTTP methods like GET, POST, DELTE.</li><li><strong>Stateless communication</strong>: Each request is independent and does not rely on previous requests.</li></ul><p>A REST API request looks something like this</p><pre>GET /users/123<br>Response: {<br>  &quot;id&quot;: 123,<br>  &quot;name&quot;: &quot;Shubham&quot;,<br>  &quot;email&quot;: &quot;Shubham@example.com&quot;<br>  <br>}</pre><p>Here, GET is the HTTP method used to fetch data from the server, and /users/123 is the endpoint, indicating that we are requesting data for the user with ID 123. The response is a JSON object containing the user&#39;s details.</p><h3>What is GraphQL</h3><p>GraphQL is considered the successor to REST APIs. The “QL” in GraphQL stands for <strong>Query Language</strong>, meaning it is designed to allow clients to specify exactly what data they need.</p><p>Unlike REST, which relies on multiple endpoints for different resources, GraphQL operates through a <strong>single endpoint</strong>, where clients define the precise data they require. This approach eliminates over-fetching and under-fetching of data.</p><p>A GraphQL query looks like this:</p><pre>{<br>  user(id: 123) {<br>    name<br>    email<br>  }<br>}</pre><p>The response will look something like this</p><pre>{<br>  &quot;data&quot;: {<br>    &quot;user&quot;: {<br>      &quot;name&quot;: &quot;Shubham&quot;,<br>      &quot;email&quot;: &quot;Shubham@example.com&quot;<br>    }<br>  }<br>}</pre><p>Unlike REST, GraphQL allows clients to request only the needed fields, reducing unnecessary data transfer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h61WSOVLIR12F_kPl8PnUg.jpeg" /><figcaption>Image from bytebytego showing the request and response of REST and GraphQL</figcaption></figure><h3>Key Differences Between REST and GraphQL</h3><p>Now that we have covered REST and GraphQL, let’s explore some key differences between the two:</p><ol><li><strong>Data Fetching</strong>: REST uses fixed endpoints that return predefined responses, whereas GraphQL allows flexible queries where clients specify the exact fields they need.</li><li><strong>Over-fetching and Under-fetching</strong>: REST may return more or less data than required, whereas GraphQL eliminates these issues by returning only what is requested.</li><li><strong>Batch Calls</strong>: REST requires multiple requests to fetch related data, while GraphQL allows nested queries, reducing network calls.</li><li><strong>Caching</strong>: REST benefits from HTTP caching mechanisms, making caching straightforward. In contrast, caching in GraphQL is more complex due to its flexible query structure.</li></ol><h3>When to use REST vs GraphQL</h3><p>The big question is: When should you choose REST, and when should you opt for GraphQL? The answer depends on the specific requirements of the application and development team.</p><p>Still there are few scenarios where we can decide to proceed with REST or GraphQL which we will discuss in the following section</p><h4>Use REST when</h4><p>REST is preferred for applications that require simple and consistent API contracts, where basic CRUD operations are sufficient, and when HTTP caching or microservices following standard RESTful principles are needed.Use GraphQL when</p><p>GraphQL is suitable for applications where clients need highly customizable data fetching. Since it eliminates multiple API calls, it is a good choice for applications that require efficient data retrieval.</p><h3>Conclusion</h3><p>Neither REST nor GraphQL is a perfect solution. Evaluating project requirements and trade-offs is crucial when selecting an API architecture. Both REST and GraphQL are valid options for exposing data and powering modern applications.</p><p>REST remains a good choice for <strong>simple and traditional APIs</strong>, while GraphQL excels in scenarios where <strong>efficiency and flexibility</strong> are important. In some cases, a <strong>hybrid approach</strong> combining both technologies can provide the best of both worlds. The key is to assess project needs and choose the API architecture that aligns best with them.</p><p><em>Thanks for reading &amp; if you have any question or want to connect on other social media platform, you can reach out to me on</em></p><p><em>Twitter: </em><a href="https://x.com/machal_shubham"><em>twitter.com/machal_shubham</em></a><em><br>Linkedin: </em><a href="https://www.linkedin.com/in/shubham-machal-18a51112a/"><em>linkedin.com/shubham-machal</em></a><em><br>Github: </em><a href="https://github.com/shubhammachal"><em>github.com/shubhammachal</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd3ea7c19831" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Built My Cloud Resume | Cloud Resume Challenge | AWS]]></title>
            <link>https://towardsaws.com/how-i-built-my-cloud-resume-cloud-resume-challenge-aws-c3e00bc50bd7?source=rss-68895def1057------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3e00bc50bd7</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cloud-resume-challenge]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[shubham machal]]></dc:creator>
            <pubDate>Thu, 21 Nov 2024 08:36:05 GMT</pubDate>
            <atom:updated>2025-03-24T06:18:16.329Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>The Cloud Resume Challenge is a hands-on project aimed at bridging the gap between cloud concepts and practical implementation. Created by Forrest Brazeal, a renowned figure in the cloud community and an AWS Serverless Hero, the challenge is perfect for aspiring cloud professionals or anyone eager to learn cloud technologies through hands-on experience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uMJWMSBcqEyp4lFMJWpHLg.png" /></figure><p>When I first discovered it on Reddit, I was immediately drawn to the idea of learning AWS by building something entirely on my own. What makes this challenge truly unique is the lack of step-by-step resources available online. It pushes you to take the initiative — researching cloud technologies, understanding their applications, and implementing solutions independently with minimal guidance.</p><h3>Main Idea behind the challenge</h3><p>The main idea behind this challenge is to create a static website — your resume in this case — hosted in the cloud and enhanced with a serverless API that tracks the number of visitors. To achieve this, you use cloud services like <strong>AWS S3</strong> for static website hosting, <strong>DynamoDB</strong> for storing visitor data, and <strong>API Gateway</strong> with <strong>Lambda</strong> to handle the API logic. Additionally, the challenge involves configuring AWS resources using the AWS Serverless Application Model (SAM) template and deploying them with the AWS SAM CLI, rather than configuring them manually. You can find detailed instructions for the challenge <a href="https://forrestbrazeal.com/2020/04/23/the-cloud-resume-challenge/"><em>cloud resume challenge</em></a><em>.</em></p><h3>Frontend</h3><p>I had some prior experience with HTML, CSS, and JavaScript for building simple websites. To get started, I refreshed my skills by following a few online tutorials and began working on my website. Whenever I faced challenges, Google and ChatGPT were helping me troubleshoot and implement features. For this challenge, a basic understanding of HTML is sufficient to set up the website, while CSS and JavaScript are helpful for enhancing its design and functionality.</p><h3>Infrastructure as a Code (IaC)</h3><p>The cloud journey began once I completed building my website. The first step was setting up an S3 bucket to deploy it. One of the most exciting things I learned during this challenge was <strong>AWS SAM</strong>. Instead of deploying AWS resources manually through the console, the challenge emphasized defining them in an AWS Serverless Application Model (SAM) template and deploying them using the AWS SAM CLI. This approach, known as Infrastructure as Code (IaC), not only made my task a bit easier but also more engaging and enjoyable.</p><h3>Setting up AWS resources using SAM</h3><p>Using SAM to deploy my cloud resources was a crucial part of the Cloud Resume Challenge. With the SAM template, I defined and set up essential AWS resources like the S3 bucket for hosting the website, the CloudFront distribution for content delivery, DynamoDB for visitor counter storage, and Lambda functions to handle the API logic. I also configured bucket policies and manage permissions efficiently through SAM template. Here’s how my SAM template looks like to deploy a S3 bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qf-a-ktYE2iDIHd6l8rL-g.png" /></figure><p>Using Infrastructure as Code (IaC) offered several advantages, including automated resource management, consistent and repeatable deployments, and a reduced risk of manual errors. It enabled me to define all AWS resources in a single template, streamlining updates and debugging. If I made a mistake, I could simply make minor adjustments to the template to quickly rectify it. It was mentioned in the challenge instructions that using IaC will save us the time in the long run which it surely did for me.</p><h3>Setting up a custom domain</h3><p>After deploying the site on S3, I needed a domain name to make my website accessible on the internet. To achieve this, I registered an affordable domain, <a href="https://www.shubham-machal.info/"><strong><em>shubham-machal.info</em></strong></a>, through <a href="https://www.namecheap.com/"><strong><em>Namecheap</em></strong></a>. I then configured all the necessary DNS records in <strong>Route 53</strong> — AWS’s DNS service, to connect the domain to my website.</p><p>I used <strong>CloudFront</strong> as a Content Delivery Network (CDN) to improve the website performance and set up AWS Certificate Manager (ACM) to provision the SSL/TLS certificate required for serving traffic securely over HTTPS. All of this was integrated with my custom domain name, which was managed through Route 53.</p><h3>Backend</h3><p>As part of the challenge, I needed to set up a backend to track the number of visitors by storing the visit count in a DynamoDB table each time the webpage is visited or refreshed. One key instruction was to avoid direct communication between the JavaScript code and DynamoDB. Instead, I was required to create an API that would accept requests from the web app and handle the interaction with the database. For this purpose I implemented a simple Python Lambda function that interacts with the DynamoDB table to increment and return the current visit count. I used Amazon API Gateway to expose the Lambda function as an API, which served as the backend for the website.</p><h3>CI/CD Integration</h3><p>To ensure continuous updates and deployments for both the backend and frontend, I implemented CI/CD using <strong>GitHub Actions</strong> and set up two workflows:</p><p>1. <strong>Deploying the site:</strong> Every time I push updates to the frontend code, the workflow automatically updates the website in the S3 bucket. It eliminated the need for manually uploading the updated website files to S3.<br> <br>2. <strong>Build and Deploy SAM:</strong> This workflow handles infrastructure updates. Whenever I make changes to the Python code or the SAM template, pushing those changes to the GitHub repository runs the workflow, which then builds and deploys the SAM application to AWS.</p><p>Setting up these workflows was a straightforward process, but it helped me learn a lot about CI/CD and how to run tests using GitHub Actions.</p><p>This is the typical flow of the whole process</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v9XpkOMvlGfCfgG-KVdrZg.png" /><figcaption>Cloud Resume Challenge Workflow</figcaption></figure><h3>Conclusion</h3><p>This challenge has been an incredible learning journey for me that bridged the gap between theoretical knowledge and hands-on implementation of AWS services. It allowed me to explore the power of AWS services, Infrastructure as Code, serverless architectures, and CI/CD pipelines. This project was more than just building a website — it was about solving real-world challenges, troubleshooting errors, and gaining confidence in working independently with minimal guidance.</p><p>Completing the Cloud Resume Challenge has given me the confidence to tackle more ambitious cloud projects, and I look forward to applying these skills in future projects. If you’re curious about the project or want to connect and discuss cloud technologies, feel free to reach out — I’d love to share insights and learn from others in the community!</p><p>Here are my website link and the link to my github repo</p><p>Resume Link: <a href="https://www.shubham-machal.info/"><em>shubham-machal.info</em></a></p><p>Github Repo: <a href="https://github.com/shubhammachal/cloud-resume-challenge"><em>github</em></a></p><p><em>Thanks for reading &amp; if you have any question regarding this project or want to connect on other social media platform, you can reach out to me on</em></p><p><em>Twitter: </em><a href="https://x.com/machal_shubham"><em>twitter.com/machal_shubham</em></a><em><br>Linkedin: </em><a href="https://www.linkedin.com/in/shubham-machal-18a51112a/"><em>linkedin.com/shubham-machal</em></a><em><br>Github: </em><a href="https://github.com/shubhammachal"><em>github.com/shubhammachal</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3e00bc50bd7" width="1" height="1" alt=""><hr><p><a href="https://towardsaws.com/how-i-built-my-cloud-resume-cloud-resume-challenge-aws-c3e00bc50bd7">How I Built My Cloud Resume | Cloud Resume Challenge | AWS</a> was originally published in <a href="https://towardsaws.com/">Towards AWS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simplifying CloudFront Deployment with AWS SAM]]></title>
            <link>https://towardsaws.com/how-to-deploy-amazon-cloudfront-using-aws-sam-serverless-application-model-8e7d167e8c0e?source=rss-68895def1057------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e7d167e8c0e</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws-cloudfront]]></category>
            <category><![CDATA[cloudformation]]></category>
            <category><![CDATA[cloud-resume-challenge]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[shubham machal]]></dc:creator>
            <pubDate>Sat, 26 Oct 2024 03:25:26 GMT</pubDate>
            <atom:updated>2025-03-24T06:16:53.314Z</atom:updated>
            <content:encoded><![CDATA[<h3>Content Delivery Network (CDN)</h3><p>A <strong>Content Delivery Network (CDN)</strong> is a network of proxy servers and data centers distributed globally to deliver online content faster and more efficiently. The main purpose of a CDN is to <strong>reduce latency</strong> — the delay before data transfers between a user and a website. To achieve this, CDNs use <strong>Edge Servers</strong>, which are caching servers located at strategic points worldwide. These servers store copies of frequently accessed content (e.g., HTML pages, images, videos), so users can access them from a nearby location rather than a distant server, reducing load times and improving user experience.</p><h3>AWS CloudFront</h3><p><strong>AWS CloudFront</strong> is Amazon’s CDN service. It speeds up content delivery by distributing copies of your website’s static and dynamic content to <strong>edge locations</strong> across the globe. When a user requests content, CloudFront delivers it from the edge location closest to them, ensuring fast and efficient access. This reduces the distance data needs to travel, cutting down on latency and improving site performance.</p><p>So in simpler terms, AWS CloudFront is a type of CDN that uses Amazon’s global infrastructure to help websites load faster by caching and delivering content from nearby edge servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FPGACrCfslTsiBwPxrHLWA.png" /><figcaption>Image from simplilearn</figcaption></figure><p>The working of CloudFormation is as follows:</p><ol><li>User access a website and request an object such as a file to download</li><li>The DNS routes the request to AWS CloudFront.</li><li>CloudFront connects to the nearest edge location and looks for the requested files to serve to the user.</li><li>If the file is found in the edge location, CloudFront sends the file to the user.</li><li>If the file is not presented in the edge location, CloudFront retrieves the files from the origin that you have defined. Origin can be a HTTP web server then send the requested file to the edge location.</li><li>CloudFront serve the user request with the file and also caches the file in the edge location. This caching of files in the edge locations reduces latency.</li></ol><h4>Configure CloudFront to deliver your content</h4><p>CloudFront can be set up using either the AWS Console or a CloudFormation template. Personally, I prefer using a CloudFormation template and deploying it through SAM. While the AWS Console is useful for quick, one-time setups or learning, the SAM CLI offers greater control and efficiency, especially as project complexity increases. Whether you are configuring it through console or via cloudformation template, you have to specify few things such as</p><ol><li>Specify origin server. Origin server can be a S3 bucket or HTTP web server. CloudFront gets your files from this origin server.</li><li>Upload your files to origin server. Since I am using S3 as my origin server, so I will upload my files to s3 bucket.</li><li>If you’re using an Amazon S3 bucket as an origin server, you can make the objects in your bucket publicly readable, so that anyone who knows the CloudFront URLs for your objects can access them.</li><li>Create a CloudFront distribution, which tells CloudFront which origin servers to get your files from. Again you can do this through console or CloudFormation template.</li><li>CloudFront assigns a domain name to your new distribution that you can see in the CloudFront console. You can access your files or website using this domain name.</li></ol><p>To deploy CloudFront using CloudFormation template, we will run <strong><em>sam init </em></strong>to get our template file. The directory structure will look something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1UciH1jNLyCLMqLB.png" /></figure><p>We will specify our CloudFront distribution and configuration settings in this template.yaml file. Since I have previously created my S3 bucket and assigned policies to the bucket using the same template file so it will have the following content before configuring CloudFront.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hA7wlyRDzi03n1fDylZhmw.png" /><figcaption>template.yaml for S3 Bucket</figcaption></figure><p>I have created a S3 bucket under resources with the name of shubham-cool-website which I will use later to upload my website content. Under BucketPolicy, I have assigned policies to my bucket to access it’s content.</p><p>Now I will add code in the same template.yaml for my CloudFront distribution under resources section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0J1wnFZAfmfiAlmdlCP_mA.png" /><figcaption>template.yaml for cloudfront</figcaption></figure><p>Let’s go through each part of this <strong>CloudFront Distribution configuration</strong> for MyDistribution to understand what it does:</p><h4>1. Type: AWS::CloudFront::Distribution</h4><p>It specifies that this resource is a CloudFront distribution, allowing you to define settings for delivering content to end users with low latency through AWS edge locations worldwide.</p><h4>2. Properties</h4><ul><li><strong>DistributionConfig</strong>: It contains the configuration details for how the CloudFront distribution will operate, including caching behavior, origin settings, and security settings.</li><li><strong>Default cache behavior: </strong>Here we define the default caching behavior and rules for requests to the CloudFront distribution.</li><li><strong>ViewerProtocolPolicy: </strong>It handles incoming requests with respect to HTTP or HTTPS. Allow all allows viewers to access the content using either HTTP or HTTPS. CloudFront will serve the content over whichever protocol the viewer originally used for their request. <strong><em>redirect-to-https</em></strong> is generally recommended for the security.</li><li><strong>TargetOriginId: </strong>It uniquely identifies which origin (e.g., an S3 bucket, HTTP server, or other source) CloudFront should route requests to for the specified cache behavior. In our case the origin is an S3 bucket configured in <strong><em>us-east-2</em></strong> region</li><li><strong>DefaultTTL: 0</strong> — Sets the default caching duration for objects in seconds. A value of 0 means CloudFront will not cache content by default and will re-fetch it from the origin on each request.</li><li><strong>MinTTL: 0</strong> — Sets the minimum caching duration to 0 seconds, allowing for the most up-to-date content.</li><li><strong>MaxTTL: 0</strong> — Limits the maximum cache duration to 0 seconds as well.</li><li>Setting these values to 0 disables caching for the distribution and forces the CloudFront to fetch content directly from the origin on each request. This will ensure that users get the most up to date version of the content.</li><li>Disabling caching is generally useful in scenarios where content needs to be dynamically updated on each request.</li><li><strong>Origins: </strong>It lists the origin servers (the sources of content) that CloudFront fetches content from. S3 in our case</li><li><strong>DomainName: </strong>Specifies the domain name of the origin. This setup is for an S3 bucket configured to serve static website content.</li><li><strong>Id: </strong>Provides a unique identifier for this origin, matching the TargetOriginId specified in DefaultCacheBehavior.</li><li><strong>CustomOriginConfig:</strong></li><li><strong>OriginProtocolPolicy: </strong><em>match-viewer</em>,<strong> </strong>CloudFront will connect to the origin using the same protocol as the viewer request. If the viewer uses HTTPS, CloudFront will use HTTPS; if HTTP, CloudFront will use HTTP. Generally, it is recommended to use <strong><em>https-only</em></strong> or <strong><em>redirect-to-https. </em></strong>It ensures all traffic between CloudFront and S3 is encrypted, which is ideal for securing data in transit.</li><li><strong>Enabled: </strong><em>true, </em>it activates the CloudFront distribution, making it live and capable of serving requests as soon as it is deployed.</li></ul><p>In summary, our CloudFront distribution configuration will deliver content from an S3 bucket website origin. It allows both HTTP and HTTPS viewer requests, forwards no query strings, and doesn’t cache content (fetches directly from the origin on each request.). This is useful when you need to serve up-to-date content immediately, but it will result in higher latency and cost because the caching is not enabled.</p><p>After making changes to the <strong><em>template.yaml</em></strong> file, save the file and follow these steps to build and deploy the CloudFront distribution using AWS SAM:</p><ol><li><strong>Build the SAM Application</strong>: Run the following command to build your application:</li></ol><pre>sam build</pre><p>2. <strong>Deploy the application: </strong>Deploy the application with</p><pre>sam deploy</pre><p>3. <strong>Confirm the deployment: </strong>After the deployment completes, go to the AWS Management Console and navigate to CloudFront in the AWS Console. Click on your CloudFront distribution, you’ll see the distribution’s domain name (something like d1234example.cloudfront.net).</p><p>4. <strong>Access content: </strong>Open this URL in your browser to verify that CloudFront is serving your content. If your origin is set up correctly, you should see the content from your origin (e.g., an S3 bucket) being served via CloudFront.</p><h3>Conclusion</h3><p>In this article, we’ve covered how to set up and deploy Amazon CloudFront with AWS SAM (Serverless Application Model). It is the part of <a href="https://cloudresumechallenge.dev/docs/the-challenge/aws/"><em>Cloud resume challenge</em></a>. We used SAM to deploy and configure our services. SAM simplifies and automates the deployment process, and saves time and effort in managing the infrastructure.</p><p>With SAM, one can quickly build and deploy CloudFront distributions to serve content globally. CloudFront improves loading speeds and reduces latency by caching content close to users.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e7d167e8c0e" width="1" height="1" alt=""><hr><p><a href="https://towardsaws.com/how-to-deploy-amazon-cloudfront-using-aws-sam-serverless-application-model-8e7d167e8c0e">Simplifying CloudFront Deployment with AWS SAM</a> was originally published in <a href="https://towardsaws.com/">Towards AWS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simplify S3 Deployment with AWS SAM(Serverless Application Model) and AWS Vault]]></title>
            <link>https://towardsaws.com/simplify-s3-deployment-with-aws-sam-serverless-application-model-and-aws-vault-6ab67d1dcba7?source=rss-68895def1057------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ab67d1dcba7</guid>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[aws-vault]]></category>
            <category><![CDATA[cloud-resume-challenge]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[shubham machal]]></dc:creator>
            <pubDate>Sun, 20 Oct 2024 05:25:22 GMT</pubDate>
            <atom:updated>2025-03-24T16:56:40.151Z</atom:updated>
            <content:encoded><![CDATA[<p>As a cloud developer, I’m constantly seeking better ways to enhance the security and efficiency of infrastructure deployments. Recently, I needed to set up an Amazon S3 bucket. While I could have simply done this through the AWS console, I chose to use AWS SAM instead. This approach, known as Infrastructure as Code (IaC), not only streamlines the process but also saves time in the long run.</p><h3>AWS Vault</h3><p>With multiple AWS accounts and credentials, we need a secure and scalable way to authenticate and deploy the resources. That’s when I discovered the perfect combination — AWS SAM to automate infrastructure as code (IaC) and AWS Vault to handle credentials securely.<br>AWS Vault is a third-party CLI tool(Open Source) and not an AWS service. It stores AWS credentials in your local system’s secure keystore.</p><h4>Setting up AWS Vault</h4><p>To set up AWS Vault on the MAC, run the following command if you have homebrew installed</p><pre>brew install aws-vault</pre><p>After installing AWS vault, we need to add the credentials securely</p><pre>aws-vault add my-user</pre><p>It will ask for Access key and secret key which you can see in AWS IAM console. It creates a new user as my-user and that’s just a profile on your machine and linked to those IAM credentials.</p><p>Run below command to see the S3 buckets associated with that user, if any</p><pre>aws-vault exec my-user -- aws s3 ls</pre><p>Now the credentials are stored securely, we can now start deploying S3 using AWS SAM.</p><h4>AWS SAM(Serverless Application Model)</h4><p>AWS Serverless Application Model (AWS SAM) is an open-source framework for building serverless applications using infrastructure as code (IaC). With AWS SAM’s shorthand syntax, developers declare AWS Cloudformation resources and specialized serverless resources that are transformed to infrastructure during deployment. This framework includes two main components: the AWS SAM CLI and the AWS SAM project. The AWS SAM project is the application project directory that is created when you run <strong>sam init</strong>. The AWS SAM project includes files like the AWS SAM template, which includes the template specification.</p><p>Install SAM using below command</p><pre>brew install aws-sam-cli</pre><p>After installing sam-cli, we can run <strong><em>sam init</em></strong> command. The <strong><em>sam init</em></strong> command is used to initialize a new AWS Serverless Application Model (SAM) project. It creates a directory structure for your AWS Lambda functions, event sources, and AWS SAM template. This command provides a starting point for building a serverless application and includes everything you need to get started. you need to select a template source as shown in the below figure.</p><p>You can also initialize a new SAM project using a custom template from a Git repository or from a local path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2WXrGBSpCGlpIIsqkmr0PQ.png" /></figure><p>After sam init, you can navigate to the project folder and check the files and folders there. The file structure will look like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TluHTl_uZOWXIpTVf-61fQ.png" /></figure><h4>Template File</h4><p>In AWS SAM, the template.yaml is a file that defines the infrastructure and resources for a serverless application. It is present in the root project folder and is an extension of AWS CloudFormation templates, but with a more concise syntax. It looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N8nmaRq7oHPjEExfmQa6EA.png" /></figure><h4>Configuration File</h4><p>The samconfig.toml file is a configuration file used by the AWS Serverless Application Model (SAM) CLI. It allows you to specify default values for various SAM CLI commands, such as deployment, building, and packaging. This file is optional, but it’s recommended to use it to manage your SAM applications’ configurations. Here’s an example of samconfig.toml file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_IBjmFLvu_k1fPvlsw1hqA.png" /></figure><p>Then we will run <strong><em>sam build </em></strong>command. This prepares an application for subsequent steps in the developer workflow. And finally we will deploy using the following command</p><pre>aws-vault exec my-user --no-session -- sam deploy --guided</pre><p>This will deploy a serverless application to AWS using AWS CloudFormation. When you run this command, the AWS SAM CLI will guide you through an interactive flow to configure your application’s deployment settings. After deployment, it will give an output like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bsLp-koyvS3d1cBnHH05dQ.png" /></figure><p>You can check the S3 bucket by using the following command</p><pre>aws-vault exec my-user -- aws s3 ls</pre><p>You can edit template.yaml file to deploy a custom S3 Bucket and adding below changes</p><pre>Resources:<br>  Mywebsite:<br>    Type: AWS::S3::Bucket<br>    Properties:<br>      BucketName: your-unique-bucket-name</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wf8KQXfbi6_oIhC8TjKzEw.png" /></figure><p>After updating the `<strong>template.yaml</strong>` file, execute <strong><em>sam build</em></strong> followed by <strong><em>sam deploy</em></strong> to deploy the S3 bucket. You can verify the changes by running the <strong><em>aws s3 ls</em></strong> command or by checking in the AWS console.</p><h4>Final Conslusion</h4><p>With this approach, your S3 bucket will be deployed automatically, without concerns about credential security. AWS SAM handles all the infrastructure setup, while AWS Vault ensures that access is both secure and temporary.</p><p>What I loved most about this process was how clean and secure everything felt. With AWS Vault, you can seamlessly switch between AWS environments, and SAM makes Infrastructure as Code truly effortless.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ab67d1dcba7" width="1" height="1" alt=""><hr><p><a href="https://towardsaws.com/simplify-s3-deployment-with-aws-sam-serverless-application-model-and-aws-vault-6ab67d1dcba7">Simplify S3 Deployment with AWS SAM(Serverless Application Model) and AWS Vault</a> was originally published in <a href="https://towardsaws.com/">Towards AWS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Scalable Applications with a Microservices Architecture: The E-Mart App Example]]></title>
            <link>https://medium.com/@machal_shubham/building-scalable-applications-with-a-microservices-architecture-the-e-mart-app-example-247eca174b21?source=rss-68895def1057------2</link>
            <guid isPermaLink="false">https://medium.com/p/247eca174b21</guid>
            <category><![CDATA[containerization]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[shubham machal]]></dc:creator>
            <pubDate>Fri, 11 Oct 2024 02:50:15 GMT</pubDate>
            <atom:updated>2024-10-11T02:50:15.868Z</atom:updated>
            <content:encoded><![CDATA[<h3>Microservices</h3><p>Microservices architecture is an approach to designing software systems where the application is broken down into smaller, independently deployable services. Each service communicates with other services through APIs or messaging queues.</p><p>Let’s use a ticketing system as an example to explain microservices:</p><p><strong>Traditional Monolithic Approach (Before Microservices):</strong> In a traditional monolithic architecture, a ticketing system would be built as a single, large application that handles all the processes — ticket creation, user authentication, payment processing, ticket inventory, and notifications — within one codebase. Any change or scaling to one part of the system, like the payment module, would require redeploying the entire application, making it less agile and harder to maintain.</p><p><strong>Microservices Approach: </strong>In a microservices architecture, each major function of the ticketing system is broken down into a separate service. e.g. user service, ticket service, payment service, notification service and many other services. Each service operates independently and interacts with others through APIs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*kAs0M76LQGWwRjTfBRlCuw.png" /><figcaption>Monolithic vs Microservices architecture</figcaption></figure><p><strong>Benefits of using microservices:</strong></p><p>Microservices offer several advantages, one of which is <strong>scalability</strong>. In the event of a high demand for tickets, such as during a Coldplay concert , you can scale individual services like the Ticket Service or Payment Service independently, rather than scaling the entire system. This contrasts with the monolithic approach, where the entire application must be scaled, even if only certain components are experiencing high demand.</p><p>Another major advantage is <strong>Independent Deployment</strong>: Teams can work on improving or updating services independently. If a new payment gateway is added, only the Payment Service is redeployed, not the entire application.</p><h3>App Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VarqLXCsaJF7C9whs9NqLQ.png" /></figure><p>In the frontend, we have an API gateway created with Nginx and has three endpoint <strong>Root(/), /API, and /WebAPI.</strong></p><p>When a user access the website URL, it will be redirected to the <strong>root</strong> which is a client app written in Angular. This in turn connect to <strong>/API</strong> which will be served via EMart Api written in node JS and connected to MongoDB. <strong>/webAPI</strong> connects which connects to book api written in Java and connected to MySQL database.</p><p>The app will be initially like this and then we can later add new features like another URL for videos or payment gateway and many more.</p><p>We need to clone the git repository for all the application files.</p><pre><em>git clone </em><a href="https://github.com/devopshydclub/emartapp.git"><em>https://github.com/devopshydclub/emartapp.git</em></a></pre><p>Navigate to the emartapp folder. It comtains all the files needed to run the application. you can check the files by running <strong><em>ls -la </em></strong>command. We can see there is one file <strong><em>docker-compose.yml </em></strong>which is a configuration file used to define and run multi-container Docker applications. It provides a simple and efficient way to manage complex Docker setups by specifying services, networks, and volumes. Docker Compose configuration defines a multi-service application with various components as seen below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fFHMObisyjOpSpC5JCdrMQ.png" /></figure><p>The Docker Compose file sets up a multi-service application with a client frontend, two APIs (Node.js and Java), a MongoDB and MySQL database, and Nginx for routing traffic. Each service runs in a separate container, with dependencies managed between them for seamless integration.</p><p>Next we can check the IP address by running <strong><em>ip addr show. </em></strong>We will copy paste this ip in browser and can see that the app is deployed successfully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5OtWsT1aM3NOfNN9V7ST1g.png" /></figure><p>This sample project showcased a microservices application running on a Docker platform. I hope it helps improve your understanding of microservices.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=247eca174b21" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>