<?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[AWS Serverless Microservices with Patterns &amp; Best Practices - Medium]]></title>
        <description><![CDATA[AWS Event-driven Serverless Microservices using AWS Lambda, API Gateway, EventBridge, SQS, DynamoDB and CDK for IaC - Medium]]></description>
        <link>https://medium.com/aws-serverless-microservices-with-patterns-best?source=rss----829476b5632d---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>AWS Serverless Microservices with Patterns &amp;amp; Best Practices - Medium</title>
            <link>https://medium.com/aws-serverless-microservices-with-patterns-best?source=rss----829476b5632d---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 12:53:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/aws-serverless-microservices-with-patterns-best" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Decompose Lambda Functions — Monolithic, Microservices vs Single-Purposed Functions]]></title>
            <link>https://medium.com/aws-serverless-microservices-with-patterns-best/decompose-lambda-functions-monolithic-microservices-vs-single-purposed-functions-f4b87465cb36?source=rss----829476b5632d---4</link>
            <guid isPermaLink="false">https://medium.com/p/f4b87465cb36</guid>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[event-driven-architecture]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Mehmet Ozkaya]]></dc:creator>
            <pubDate>Thu, 28 Apr 2022 14:27:00 GMT</pubDate>
            <atom:updated>2023-04-09T12:29:50.626Z</atom:updated>
            <content:encoded><![CDATA[<h3>Decompose Lambda Functions — Monolithic, Microservices vs Single-Purposed Functions</h3><p>When you are developing Serverless applications, How you <strong>decide to create Lambda Functions </strong>? What is the <strong>best way to design Lambda microservices</strong> ? How to <strong>organize Lambda functions</strong> into separate services ? <strong>Monolithic</strong>, <strong>Microservices </strong>vs<strong> Single-Purposed</strong> Functions ?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9OtGkRTujviRTJxO.png" /><figcaption>Serverless Event-driven E-commerce Microservices Architecture</figcaption></figure><p>When you are developing your Serverless application, it is easy to develop a few simple Lambda functions. But things changes very fast and you keep creating and developing functions and boom ! Congratulations you have <strong>hundreds of lambda functions</strong> so now what’s next ?</p><h3>Step by Step Design AWS Architectures w/ Course</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/0*WxtuiiVOgO6PcU10.png" /></figure><p><a href="https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=APRI23"><strong>I have just published a new course — AWS Serverless Microservices with Patterns &amp; Best Practices.</strong></a></p><p>In this course, we’re going to learn <strong>how to Design and Develop AWS Serverless Event-driven Microservices</strong> with using <strong>AWS Lambda</strong>, <strong>AWS DynamoDB</strong>, <strong>AWS API Gateway</strong>, <strong>AWS EventBridge</strong>,<strong> AWS SQS</strong>, <strong>AWS CDK</strong> for <strong>IaC</strong> — <strong>Infrastructure as Code</strong> tool and <strong>AWS CloudWatch</strong> for <strong>monitoring</strong>.</p><h3>Source Code</h3><p><a href="https://github.com/awsrun/aws-microservices"><strong>Get the Source Code from Serverless Microservices GitHub</strong></a> — Clone or fork this repository, if you like don’t forget the star. If you find or ask anything you can directly open issue on repository.</p><h3>Function Hell</h3><p>If you don’t follow your lambda functions, most probably you will end up with <strong>function hell </strong>case. When your Serverless application is growing, it can be really nightmare to manage your functions.</p><p>So What is the best way to design Lambda microservices ? How to organize Lambda functions into separate services ? or Should we ok with hundreds of lambda functions ?</p><p>Since there is no clear solution of this problem, AWS has offers some approaches that following the best practices when designing larger number of lambda function applications. There is no one-size-fits-all approach, and each alternative has pros and cons that we need to consider.</p><p>Before that let’s remember the Lambda function and the purpose and usage of Serverless functions.</p><h3>What is AWS Lambda ?</h3><p><strong>AWS Lambda </strong>is an <strong>event-driven, serverless computing platform </strong>that runs code in response to events and automatically manages the computing resources required by that code. You can run code without thinking any servers or underlying services.</p><p><strong>AWS Lambda </strong>is a <strong>compute service </strong>that runs custom function code and return response to events. Most AWS services generate events for communicating each other, and most of AWS Services are event sources for Lambda. So AWS Lambda is very <strong>good fit</strong> with <strong>event-driven architectures</strong>, because the nature of lambda executions trigger from events. Events can come lots of resources and able to trigger lambda functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y1wd0YgITpcwIDsb.png" /><figcaption><a href="https://docs.aws.amazon.com/lambda/latest/dg/lambda-services.html#eventsources-sqs">https://docs.aws.amazon.com/lambda/latest/dg/lambda-services.html#eventsources-sqs</a></figcaption></figure><p>When a function is <strong>triggered </strong>by an <strong>event</strong>, this is called an <strong>invocation</strong>.<br>Lambda functions are limited to <strong>15 minutes</strong> in duration, but on average, most calls take less than a second across all AWS customers.</p><p>So even the simplest <strong>Lambda-based application</strong> uses at least one <strong>event</strong>. So that’s why we said, AWS Lambda is <strong>very good fit </strong>for the <strong>Event-Driven Architectures</strong>. Because the <strong>fuel </strong>of <strong>AWS Lambda </strong>is <strong>events</strong>.</p><h3>How does AWS Lambda work?</h3><p>We said that AWS Lambda fits into the event-driven architectures. So, as you can see the image AWS Lambda triggers by event and executes the function code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/0*iPQYIw3hM3ObvCy2.png" /></figure><p>Each Lambda function runs in its own container. You can think every lambda function as a standalone docker containers. When a function is created, Lambda packages it into a new container and then executes that container on a multi-region cloud clusters of servers managed by AWS.</p><h3>Using AWS Lambda as a Microservice</h3><p>Before this article, we have explained that;</p><ul><li>We can use <a href="https://medium.com/aws-serverless-microservices-with-patterns-best/using-aws-as-an-application-development-framework-3060571c4526"><strong>AWS as an Application Development Framework</strong></a>,</li><li>also we can use <a href="https://medium.com/aws-serverless-microservices-with-patterns-best/using-aws-lambda-as-a-microservice-dd7d7296c74a"><strong>AWS Lambda as a Microservice</strong></a>,</li></ul><p>So we can put <strong>AWS Lambda</strong> as a <strong>microservice </strong>in our <strong>Serverless Projects like E-Commerce</strong> application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/0*Np9_LfrBM1VdpMpI.png" /><figcaption><a href="https://docs.aws.amazon.com/whitepapers/latest/microservices-on-aws/serverless-microservices.html">https://docs.aws.amazon.com/whitepapers/latest/microservices-on-aws/serverless-microservices.html</a></figcaption></figure><p>The <strong>Serverless Microservices Pattern </strong>reduces the barrier for the creation of each subsequent microservice. <strong>API Gateway</strong> even allows for the cloning of existing APIs, and using of Lambda functions in other accounts. Amazon API Gateway provides <strong>programmatically generated </strong>client <strong>SDKs </strong>that are programmatically built in a number of popular languages in order to reduce the integration overhead.</p><p>You can see the figure above that shows the architecture of a <strong>Serverless microservice </strong>with <strong>Amazon API Gateway </strong>and <strong>AWS Lambda</strong>. So API Gateway APIs proxy to individual microservices backed by Lambda functions. You can see the microservices-1–2–3–4 that proxy by API Gateway and all of microservices handle with AWS Lambda functions.</p><h3>Starting Lambda-Based Serverless Application</h3><p>Once you have decided to use <strong>AWS Lambda</strong> as a main compute serverless service of your project, then we can start thinking to <strong>organize our functions.</strong></p><p>There are <strong>multiple approaches </strong>to develop serverless applications but before starting your project, I assume that you are using serverless deployment frameworks such as the <a href="https://aws.amazon.com/serverless/sam/"><strong>AWS Serverless Application Model</strong></a><strong> (SAM) </strong>or the <a href="https://serverless.com/"><strong>Serverless Framework</strong></a> that can make it easier to group common pieces of functionality into smaller services. So that means you have something like a <strong>template.yaml file</strong> contains all the resources and function definitions needed for an application. And of course, We will follow the<strong> </strong><a href="https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html"><strong>best practice</strong></a> and <a href="https://aws.amazon.com/blogs/compute/best-practices-for-organizing-larger-serverless-applications/"><strong>organizing larger lambda projects</strong></a> when developing our lambda functions.</p><h3>Organize Lambda Functions</h3><p>But event you follow the best practices, you will face that <strong>continuously growing number </strong>of <strong>lambda functions </strong>living independently from each other. It become extremely hard to navigate between function and determine which lambda function related to certain service.</p><p>So we should think about how we can decompose Lambda Functions as per the our business requirements on serverless project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PHtQQVBX77hjWC_0.png" /><figcaption><a href="https://aws.amazon.com/blogs/compute/best-practices-for-organizing-larger-serverless-applications/">https://aws.amazon.com/blogs/compute/best-practices-for-organizing-larger-serverless-applications/</a></figcaption></figure><p>We have<strong> 3 ways </strong>to organize our AWS Lambda Serverless functions;</p><ul><li><strong>Single-Purposed Functions</strong></li><li><strong>Microservice-Based Functions</strong></li><li><strong>Monolithic Functions</strong></li></ul><p>Now let’s elaborate these approaches according to implementation types in the serverless projects.</p><h3>Single-Purposed Serverless Functions</h3><p>As the name suggested, this approach follows to implement only <strong>specific task </strong>based development into serverless functions. A function will do just one thing and the code for it will be as simple as possible. This will becomes of many tiny individual atomic functions into serverless project.</p><p>A good example is <strong>RESTFUL API </strong>development to perform <strong>CRUD operations </strong>with multiple endpoints and HTTP methods. Let’s assume we are building a backend in Nodejs for managing <strong><em>Products</em></strong>.<br>The code for the <strong><em>getProduct, createProduct </em></strong><em>and </em><strong><em>deleteProduct </em></strong>functions are stored in different AWS Lambda functions of index.js files and exported 3 lambda functions that triggers over the API Gateway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/0*o8soBxdV9pbc-Egu.png" /></figure><p>Following this approach, your team will implement separate 5 functions to manage Order: <strong>getProduct, listProducts, createProduct, updateProduct, and deleteProduct</strong>.</p><p>So if the team will follow this approach and create functions for each single task, in many cases, resulting in hundreds of functions and you will face function hell issue.</p><h4>Benefits and Drawbacks of Single-Purposed Functions</h4><p>The benefit is that each function is completely atomic and can have tailored set of operational characteristics, such as ;</p><ul><li>Granular permissions needed for the function. E.g. getProduct will have ready-only permission to access the Product table, while createProduct will have write permission.</li><li>Tailored resource restrictions. Each function can have a separate set of restrictions around memory, CPU, etc.</li><li>Each pull request for minor changes in the individual function can be deployed separately.</li></ul><p>So that means, with single-purpose functions, you can assign more granular permissions to each of the functions. As such, if any of the functions are compromised, the attacker would not gain full access to the data. This provides much better security for your application.</p><p>Performance can be problem when you follow single-purposed approach. Because you will face the frequency of cold starts. Every time the FaaS platform scales your function to meet increased traffic, you will experience a cold start.</p><h3>Microservice-Based Serverless Functions</h3><p>As the name suggested, this approach follows to implement microservices architecture when developing serverless functions. So that means we can follow the<a href="https://medium.com/design-microservices-architecture-with-patterns/decomposition-of-microservices-architecture-c8e8cec453e"> <strong>microservices decomposition patterns</strong></a><strong> </strong>when designing serverless lambda function.</p><p>Basically <strong>microservice-based approach</strong> suggests keeping multiple individual <strong>closely related functions</strong> together. We can also say that create serverless functions as per <strong>Bounded Contexts </strong>of our projects by <strong>grouping business capabilities</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jn_cOVEjFqE0tIRC.png" /><figcaption>Serverless Event-driven E-commerce Microservices Architecture</figcaption></figure><p>If we revisit the first simple example from above, instead of creating <strong>5 separate lambda serverless functions</strong> for the management of <strong><em>Products</em></strong>, one can create a single lambda function that handle all of these cases.</p><p>Also you can see the above example of E-Commerce architecture implemented by microservice-based lambda functions with <strong>Product</strong>, <strong>Basket </strong>and <strong>Ordering </strong>microservices that communicate over serverless event buses.</p><p><strong>The microservice pattern</strong> is a concept of keeping each of your services modular and lightweight. So for example; In our e-commerce app allows users to get products, add to basket and checkout basket in order to start ordering process.</p><p>Implementation of this approach is required to look into the<strong> </strong><a href="https://docs.aws.amazon.com/lambda/latest/dg/services-apigateway.html#apigateway-example-event"><strong>event</strong></a><strong> object</strong> which comes from Amazon API Gateway, and develop switch-case statements for the operation based codes on the<strong> http-method fields.</strong></p><p>You can find example implementation of this approach;</p><pre>// index.js<br>// This is the code for management of Products. <br>//<br>// Note:<br>//   The code snippet below is just for demo.<br>//   It includes a simple happy-path without error <br>exports.handler =  async function(event, context) {<br>   <strong> switch (event.httpMethod) {</strong><br>        <strong> case &#39;GET&#39;:</strong><br>             return await getProduct(event);<br>        <strong> case &#39;POST&#39;:</strong><br>             return await createProduct(event);<br>    <strong>     case &#39;PUT&#39;:</strong><br>             return await updateProduct(event);<br>        <strong> case &#39;DELETE&#39;:</strong><br>             return await deleteProduct(event);<br>         default:<br>             return await unknownOperation(event.httpMethod)<br>     }<br>}</pre><p>Note that <strong>getProduct </strong>will have to further separate into two functions; <strong>getProductById </strong>if an id parameter was provided and <strong>getAllProducts </strong>if not. You can check<a href="https://github.com/awsrun/aws-microservices/blob/main/src/product/index.js"> <strong>example implementation in here</strong></a>.</p><p>In a typical <strong>medium size project</strong>, this approach keeps the total number of functions in the 10s, vs. 100s. And for a typical scrum dev team, that owns only a limited number of objects, this model provides a good construct to manage each object type separately.</p><h4>Benefits and Drawbacks of Microservice-Based Functions</h4><p><strong>Lambda </strong>functions are a<strong> natural fit</strong> for a <strong>microservice based architecture</strong>. This is due to a few of reasons. Firstly, the performance of Lambda functions is related to the size of the function. Secondly, debugging a Lambda function that deals with a specific event is much easier. Finally, it is just easier to conceptually relate a Lambda function with a single event.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/0*lgv5vRWv8OQX1eDI.png" /></figure><p>The easiest way to <strong>share code</strong> between services is by having them all together in a <strong>single repository</strong>. Even though your services end up dealing with separate portions of your app, they still might need to share some code between them.</p><p>But also there are <strong>some drawbacks </strong>about this approaches;</p><ul><li>Microservices can grow out of control and each added service increases the complexity of your application.</li><li>This also means that you can end up with hundreds of Lambda functions.</li><li>Managing deployments for all these services and functions can get complicated.</li></ul><h3>Monolithic Serverless Functions</h3><p>Many serverless applications begin as <strong>monolithic applications</strong>. This can occur either because a simple application has grown more complex over time, or because developers are following existing development practices. A monolithic application is represented by a<strong> single </strong><a href="https://aws.amazon.com/lambda/"><strong>AWS Lambda</strong></a><strong> function</strong> performing multiple tasks, and a<strong> mono-repo</strong> is a single repository containing the entire application logic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/0*ZoYWz4gyY2g0vZuX.png" /><figcaption><a href="https://aws.amazon.com/blogs/compute/best-practices-for-organizing-larger-serverless-applications/">https://aws.amazon.com/blogs/compute/best-practices-for-organizing-larger-serverless-applications/</a></figcaption></figure><p>Monoliths work well for the simplest serverless applications that perform single-purpose functions. These are <strong>small applications </strong>such as<strong> cron jobs,</strong> <strong>data processing tasks,</strong> and some <strong>asynchronous processes</strong>. As those applications evolve into workflows or develop new features, it becomes important to refactor the code into smaller services.</p><h4>Comparison of Monolithic and Single-Purposed Functions</h4><p>Here you can find the table that comparison of Monolithic and Single-Purposed functions. With single-purpose functions, you can assign more <strong>granular permissions </strong>to each of the functions. This provides much better security for your application. But it can negative affect to <strong>performance </strong>due to face <strong>cold start issues</strong> more frequently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*ZGGZvlU62jbGYQpSw0S_bw.png" /></figure><h3>AWS Serverless Microservices for Ecommerce Application Architecture</h3><p>Here you can find the main overall <strong>Serverless Architecture</strong> for our application. This is the <strong>big picture </strong>of what we are going to develop together for <strong>AWS Serverless Event-driven E-commerce Microservices </strong>application that is Step by Step Implementation together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jn_cOVEjFqE0tIRC.png" /><figcaption>Serverless Event-driven E-commerce Microservices Architecture</figcaption></figure><p>We will be following the<strong> reference architecture</strong> above which is a <strong>real-world</strong> <strong>Serverless E-commerce application</strong> and it includes;</p><ul><li><strong>REST API</strong> and <strong>CRUD </strong>endpoints with using <strong>AWS Lambda, API Gateway</strong></li><li><strong>Data persistence</strong> with using <strong>AWS DynamoDB</strong></li><li><strong>Decouple microservices </strong>with <strong>events </strong>using <strong>AWS EventBridge</strong></li><li><strong>Message Queues</strong> for cross-service communication using<strong> AWS SQS</strong></li><li><strong>Cloud stack development</strong> with <strong>IaC </strong>using <strong>AWS CloudFormation CDK</strong></li></ul><h3>Step by Step Design AWS Architectures w/ Course</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/0*Tw9hPRSnheieuuHZ.png" /></figure><p><a href="https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=APRI23"><strong>I have just published a new course — AWS Serverless Microservices with Patterns &amp; Best Practices.</strong></a></p><p>In this course, we’re going to learn <strong>how to Design and Develop AWS Serverless Event-driven Microservices</strong> with using <strong>AWS Lambda</strong>, <strong>AWS DynamoDB</strong>, <strong>AWS API Gateway</strong>, <strong>AWS EventBridge</strong>,<strong> AWS SQS</strong>, <strong>AWS CDK</strong> for <strong>IaC</strong> — <strong>Infrastructure as Code</strong> tool and <strong>AWS CloudWatch</strong> for <strong>monitoring</strong>.</p><h3>Source Code</h3><p><a href="https://github.com/awsrun/aws-microservices"><strong>Get the Source Code from Serverless Microservices GitHub</strong></a> — Clone or fork this repository, if you like don’t forget the star. If you find or ask anything you can directly open issue on repository.</p><h3>References</h3><ul><li><a href="https://awstip.com/the-art-of-real-aws-lambda-apps-1f213d22e351">The Art of Building Lambda Apps</a></li><li><a href="https://medium.com/@serkhazov/organize-your-lambda-functions-into-separate-services-1b725a186604">Organize your Lambda functions into separate services</a></li><li><a href="https://serverless-stack.com/chapters/organizing-serverless-projects.html">Organizing Serverless Projects</a></li><li><a href="https://epsagon.com/development/how-should-you-organize-your-functions-in-roduction/">How To Organize Monolithic vs Single-Purposed Functions</a></li><li><a href="https://aws.amazon.com/blogs/compute/best-practices-for-organizing-larger-serverless-applications/">Best practices for organizing larger serverless applications | Amazon Web Services</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4b87465cb36" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aws-serverless-microservices-with-patterns-best/decompose-lambda-functions-monolithic-microservices-vs-single-purposed-functions-f4b87465cb36">Decompose Lambda Functions — Monolithic, Microservices vs Single-Purposed Functions</a> was originally published in <a href="https://medium.com/aws-serverless-microservices-with-patterns-best">AWS Serverless Microservices with Patterns &amp; Best Practices</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Udemy Course Published ! AWS Serverless Microservices with Patterns & Best Practices]]></title>
            <link>https://medium.com/aws-serverless-microservices-with-patterns-best/udemy-course-published-aws-serverless-microservices-with-patterns-best-practices-639a5cd13482?source=rss----829476b5632d---4</link>
            <guid isPermaLink="false">https://medium.com/p/639a5cd13482</guid>
            <category><![CDATA[event-driven-architecture]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[api-gateway]]></category>
            <dc:creator><![CDATA[Mehmet Ozkaya]]></dc:creator>
            <pubDate>Mon, 04 Apr 2022 08:32:59 GMT</pubDate>
            <atom:updated>2022-07-06T15:57:30.683Z</atom:updated>
            <content:encoded><![CDATA[<h3>Udemy Course Published ! AWS Serverless Microservices with Patterns &amp; Best Practices</h3><p><a href="https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=JULY22"><strong>Hi everyone, finally I can managed the publish one more flagship course — AWS Serverless Microservices with Patterns &amp; Best Practices.</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*yKWGxvkxseYQ8Oa3.png" /></figure><h3><strong>Yet another certificate AWS course ? NO !</strong></h3><p>Why do you want to get a <strong>certificate </strong>? To get a <strong>real AWS Job !</strong></p><p>So this course <strong>directly prepares </strong>for<strong> real-world jobs</strong>, that is<strong> fully practical</strong> and <strong>100% hands-on </strong>development of <strong>aws-microservices</strong> <strong>github repository </strong>that is <strong>verified</strong> from the <strong>community</strong>.</p><p>When <strong>learning AWS</strong>, <strong>don’t memorize</strong> all topics, <strong>feel </strong>and <strong>develop </strong>by<strong> hands-on</strong>, <strong>dirty your hands </strong>by this way you can achieve to onboard your target AWS jobs.</p><p>Through <strong>250 lectures</strong> and <strong>30+ hours, </strong>You will be <strong>step by step developing a real-world application</strong> for both<strong> infrastructure (IaC)</strong> and<strong> lambda microservices code development.</strong></p><p>Available at<strong> special discount to the first 1,000 students </strong>that sign up with coupon code: <strong>AWSROCKS </strong>(discount applied by clicking the link below):<strong><br></strong><a href="https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=AWSROCKS"><strong>https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=AWSROCKS</strong></a></p><p>You can find detail explanation of course in the below:</p><h3>Serverless Event-driven E-commerce Microservices Architecture</h3><p>This is the <strong>big picture </strong>of what we are going to develop together for <strong>AWS Serverless Event-driven E-commerce Microservices </strong>application that is Step by Step Implementation together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*dGbN-pZbYsu1_ZQJ.png" /></figure><p>In this course, we will learn <strong>AWS Event-driven Serverless Microservices</strong> with using</p><ul><li>AWS <strong>Lambda</strong>,</li><li>AWS <strong>DynamoDB</strong>,</li><li>AWS <strong>API Gateway</strong>,</li><li>AWS <strong>EventBridge</strong>,</li><li>AWS <strong>SQS </strong>which stands for Simple Queue Service,</li><li>AWS <strong>CDK </strong>stands for Cloud Development Kit for IaC — Infrastructure as Code tool and</li><li>AWS <strong>CloudWatch </strong>for monitoring.</li></ul><p>This course will be <strong>100% hands-on</strong>, and you will be <strong>developing a real-world application </strong>which includes;</p><ul><li><strong>REST API</strong> and <strong>CRUD endpoints </strong>with using (<strong>AWS Lambda, API Gateway</strong>)</li><li><strong>Data persistence</strong> with using (AWS <strong>DynamoDB</strong>)</li><li><strong>Decouple microservices </strong>with events using (<strong>AWS EventBridge</strong>)</li><li>Message <strong>Queues </strong>for cross-service communication using (<strong>AWS SQS</strong>)</li><li>Cloud <strong>stack development</strong> with <strong>IaC </strong>using (<strong>AWS CloudFormation CDK</strong>)</li></ul><p>By the end of the course, you will learn how to develop reliable and scalable Serverless applications, following the <strong>microservices architecture</strong>. We will develop <strong>event-driven microservices</strong> with <strong>AWS Serverless services</strong> which comes with power of cloud high availability and high scalability by nature. Of course we will follow the <strong>Serverless Design Patterns</strong> and <strong>Best Practices</strong> when developing our <strong>e-commerce event-driven microservices</strong> application.</p><p>There is a couple of microservices which implemented e-commerce modules over <strong>Product</strong>, <strong>Basket </strong>and <strong>Ordering microservices</strong>. We will use <strong>AWS Lambda </strong>service as a <strong>microservices </strong>and use power of lambda functions. And this microservices databases will store <strong>NoSQL AWS DynamoDB</strong> databases.</p><p>And also we have followed <strong>communication patterns </strong>and <strong>best practices </strong>when designing <strong>Serverless microservice communications</strong> for <strong>synchronous </strong>and <strong>asynchronous </strong>communications with using <strong>AWS API Gateway, AWS EventBridge</strong> as a <strong>Eventbus </strong>and <strong>AWS SQS</strong> as a <strong>queue </strong>service. That means we design our architecture rely on <strong>asynchronous </strong>connections that gives us much more flexible and resilient application.</p><h4>We will use</h4><ul><li><strong>AWS API Gateway</strong> -for- <strong>Restful API</strong>-<strong>Driven Development </strong>and Synchronous Event Sources</li><li><strong>AWS EventBridge</strong> -for- <strong>Event</strong>-<strong>Driven asynchronous Communication </strong>between Microservices</li><li><strong>AWS SQS </strong>-for- <strong>Decouple Microservices </strong>and processing events asynchronously using queues</li></ul><p>The course proposes a <strong>microservice oriented architecture </strong>implementation with <strong>AWS Serverless </strong>world using <strong>event-driven patterns </strong>and best practices. So the project will be the<strong> e-commerce application</strong> that will be totally Serverless components.</p><p>Let me try to introduce Serverless components one by one;</p><h3><strong>Api Gateway</strong></h3><ul><li>This is entry point of our microservices.</li><li>API Gateway provides <strong>Restful API-Driven Development</strong> and Synchronous Event Sources.</li><li>Synchronous commands are request/response.</li><li>API Gateway is a <strong>synchronous </strong>event source and provides a Serverless API proxy to Lambda.</li><li>API Gateway Redirects to CRUD request to internal microservices.</li></ul><h3><strong>Product Lambda microservices </strong>which performs;</h3><ul><li>CRUD operations using <strong>DynamoDB table </strong>over the <strong>AWS API Gateway</strong></li><li>This will cover product table operations fully Serverless in microservices architecture.</li><li><strong>Synchronous </strong>requests will manage by <strong>AWS API Gateway</strong> and routing requests to <strong>Product </strong>Lambda <strong>Microservices </strong>that perform CRUD operations.</li><li>We will write Lambda functions with using <strong>AWS SDK</strong> for <strong>interacting </strong>other <strong>AWS resources</strong> for example in Product case we will interact with AWS Serverless DynamoDB to perform all crud operations.</li></ul><h3><strong>Basket Lambda microservices </strong>which performs;</h3><ul><li>Add-Remove synchronous basket operations with using <strong>AWS API Gateway</strong> and <strong>DynamoDB</strong></li><li>Again synchronous requests will manage by<strong> AWS API Gateway </strong>and routing requests to Basket Lambda Microservices that perform CRUD operations.</li><li>We will write Lambda functions with using<strong> AWS SDK</strong> for interacting other AWS resources. For example in Basket case we interact with AWS Serverless DynamoDB to perform all crud operations.</li></ul><h4>But also,</h4><ul><li>Basket microservice <strong>triggers </strong>to <strong>Event-driven</strong> use case which is the <strong>Checkout Basket</strong>.</li><li>When <strong>checkout basket</strong>, this will <strong>publish </strong>and create <strong>event </strong>to <strong>Serverless Eventbus</strong> which is <strong>AWS EventBridge.</strong></li><li>So this <strong>asynchronous </strong>communication will held by Basket Lambda Microservice and <strong>AWS EventBridge </strong>and consumed by Ordering microservices over the <strong>AWS SQS.</strong></li></ul><h3><strong>AWS Event Bridge</strong></h3><p>So <strong>asynchronous </strong>communication held by<strong> AWS Serverless Eventbus </strong>service which is <strong>AWS EventBridge.</strong></p><p>We will create <strong>Rules </strong>and <strong>Target </strong>definitions for <strong>AWS EventBridge</strong> from Basket Lambda microservices.</p><p>That means we will develop Basket Lambda Microservices when <strong>publishing checkout message </strong>to AWS <strong>EventBridge </strong>with using AWS <strong>SDK </strong>for development purpose.</p><h3><strong>AWS SQS and Ordering Lambda microservices</strong></h3><p>So after <strong>publishing checkout event </strong>to the <strong>EventBridge</strong>, this event will <strong>consume </strong>by Ordering part.</p><p><strong>EventBridge </strong>send to event to <strong>AWS SQS </strong>in order to gain power of AWS <strong>queue</strong>. After that Ordering lambda microservice will <strong>consume </strong>this event with <strong>polling</strong>.</p><p>That means we will use <strong>event source mapping communication</strong> type here when <strong>consuming events</strong>, ordering lambda microservices send <strong>polling request </strong>and get event from the <strong>AWS queue</strong>.</p><p>After consuming the event from the <strong>AWS</strong> <strong>queue</strong>, Ordering lambda microservices <strong>process </strong>the event with <strong>creating order </strong>record into its <strong>DynamoDB </strong>table.</p><p>Ordering lambda microservices perform all these operations with developing lambda functions with using AWS SDK.</p><h3><strong>We have 3 communication types;</strong></h3><ol><li><strong>Synchronous </strong>communication with <strong>AWS API Gateway</strong> for routing request from client applications to downstream microservices</li><li><strong>Asynchronous </strong>communication with AWS <strong>Serverless Eventbus </strong>which is <strong>EventBridge </strong>for applying <strong>Event Driven</strong> asynchronous Communication patterns.</li><li>And lastly we have <strong>Event Source mapping </strong>communication when <strong>polling queue </strong>records from lambda services to <strong>AWS SQS</strong>-Simple Queue Service for <strong>Decouple Microservice </strong>and processing events asynchronously.</li></ol><p>During the course we will follow these Microservice communication types with Lambda invocations, and develop our sections following these arrows.</p><h3><strong>IaC Serverless Stacks with AWS CDK — Cloud Development Kit</strong></h3><ul><li>Will follow <strong>Devops </strong>best practices when <strong>coding infrastructure</strong>. The whole project, we will develop <strong>infrastructure as code Serverless Stacks</strong> with using <strong>AWS CDK — Cloud Development Kit.</strong></li><li>We will use <strong>AWS CDK</strong> for <strong>IaC Serverless Stacks </strong>developments that we will develop and provision all services step by step with together.</li></ul><h3><strong>AWS Developer and AWS Solution Architecture Jobs</strong></h3><p>This course <strong>prepares </strong>to you real <strong>AWS Developer </strong>and <strong>AWS Solution Architecture jobs</strong>, which’s offers to you 3 figure salaries.</p><p>Because we are going to develop a <strong>real-world Serverless application</strong> which is already used and developed by lots of companies in the world.</p><h3><strong>Prepare your AWS Certification with Practical Way</strong></h3><ul><li>AWS Certified Developer Associate</li><li>AWS Certified Solutions Architect Associate</li></ul><p>Don’t memorize all topics, feel and develop by<strong> hands-on</strong>, dirty your hands by this way you can achieve to onboard your target AWS jobs. This course will help you to prepare <strong>AWS Developer</strong> and <strong>Solutions Architect Associate certifications</strong> both theoretical and mostly practical way with developing Serverless e-commerce applications.</p><h3><strong>AWS Serverless + CDK Automation + Integration Patterns = AWSome!</strong></h3><p>This will be the <strong>manifesto </strong>of our course. We will follow these manifesto every place of our course and the Serverless e-commerce application.</p><p><strong>Integration Patterns </strong>that we will follow <strong>Queue-Chaning, Publish-Subscribe</strong> and <strong>Fan-out design patterns </strong>during the course when developing our serverless e-commerce application.</p><p>By the end of this course, you’ll learn how to design and developing <strong>AWS Event-driven microservices </strong>with using<strong> Serverless patterns </strong>and <strong>best practices.</strong></p><p>This course will be <strong>100% hands-on,</strong> and we will be develop all infrastructure and microservice codes with together and step by step.</p><p>I hope you’ll join me on this journey and develop this project with me.</p><h3>Step by Step Design AWS Architectures w/ Course</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*HyPm2pShqAlRPyMY.png" /></figure><p>Available at<strong> special discount to the first 1,000 students </strong>that sign up with coupon code: <strong>AWSROCKS </strong>(discount applied by clicking the link below):<strong><br></strong><a href="https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=AWSROCKS"><strong>https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=AWSROCKS</strong></a></p><p>In this course, we’re going to learn <strong>how to Design and Develop AWS Serverless Event-driven Microservices</strong> with using <strong>AWS Lambda</strong>, <strong>AWS DynamoDB</strong>, <strong>AWS API Gateway</strong>, <strong>AWS EventBridge</strong>,<strong> AWS SQS</strong>, <strong>AWS CDK</strong> for <strong>IaC</strong> — <strong>Infrastructure as Code</strong> tool and <strong>AWS CloudWatch</strong> for <strong>monitoring</strong>.</p><h3>Source Code</h3><p><a href="https://github.com/awsrun/aws-microservices"><strong>Get the Source Code from Serverless Microservices GitHub</strong></a> — Clone or fork this repository, if you like don’t forget the star. If you find or ask anything you can directly open issue on repository.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=639a5cd13482" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aws-serverless-microservices-with-patterns-best/udemy-course-published-aws-serverless-microservices-with-patterns-best-practices-639a5cd13482">Udemy Course Published ! AWS Serverless Microservices with Patterns &amp; Best Practices</a> was originally published in <a href="https://medium.com/aws-serverless-microservices-with-patterns-best">AWS Serverless Microservices with Patterns &amp; Best Practices</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Story and Articles List of AWS Serverless Medium Publication]]></title>
            <link>https://medium.com/aws-serverless-microservices-with-patterns-best/the-story-and-articles-list-of-aws-serverless-medium-publication-9d8b090f9c4b?source=rss----829476b5632d---4</link>
            <guid isPermaLink="false">https://medium.com/p/9d8b090f9c4b</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Mehmet Ozkaya]]></dc:creator>
            <pubDate>Tue, 22 Mar 2022 14:22:08 GMT</pubDate>
            <atom:updated>2023-01-06T08:44:15.929Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi all, as you see that I have created a <a href="https://medium.com/aws-serverless-microservices-with-patterns-best"><strong>medium publication</strong></a> and <a href="https://github.com/awsrun/aws-microservices"><strong>GitHub repository</strong></a> about <a href="https://medium.com/aws-serverless-microservices-with-patterns-best/aws-event-driven-serverless-microservices-using-aws-lambda-api-gateway-eventbridge-sqs-dynamodb-a7f46220b738"><strong>AWS Serverless Event-driven Microservices with using AWS Lambda, AWS DynamoDB, AWS API Gateway, AWS EventBridge, AWS SQS and AWS CDK for IaC.</strong></a></p><blockquote>But what is the story behind this articles series and which order you can follow this series ?</blockquote><p>I have set of arguments that encourage me the following this architecture design and I would like to order these arguments with article links below;</p><ul><li>First of all, I think <a href="https://medium.com/aws-serverless-microservices-with-patterns-best/cloud-native-microservices-evolves-to-aws-serverless-event-driven-architectures-9a38c473f4f8"><strong>Cloud-Native Microservices Evolves to AWS Serverless Event-driven Architectures</strong></a>,</li><li>and we can use <a href="https://medium.com/aws-serverless-microservices-with-patterns-best/aws-serverless-services-for-microservices-architectures-2b3551d884e4"><strong>AWS Serverless Services for Microservices Architectures</strong></a>,</li><li>and we can use <a href="https://medium.com/aws-serverless-microservices-with-patterns-best/using-aws-as-an-application-development-framework-3060571c4526"><strong>AWS as an Application Development Framework</strong></a>,</li><li>also we can use <a href="https://medium.com/aws-serverless-microservices-with-patterns-best/using-aws-lambda-as-a-microservice-dd7d7296c74a"><strong>AWS Lambda as a Microservice</strong></a>,</li><li>and we can use <a href="https://medium.com/aws-serverless-microservices-with-patterns-best/aws-lambda-invocation-types-e279ef136347"><strong>AWS Lambda Invocation Types</strong></a><strong> for </strong><a href="https://medium.com/aws-serverless-microservices-with-patterns-best/microservices-communications-with-aws-lambda-invocation-types-aee2d6326866"><strong>Microservices Communications</strong></a><strong>,</strong></li><li>and we can decompose <a href="https://medium.com/aws-serverless-microservices-with-patterns-best/decompose-lambda-functions-monolithic-microservices-vs-single-purposed-functions-f4b87465cb36"><strong>AWS Lambda functions as per Microservice-Based Functions</strong></a>,</li><li>and we can design microservices with <a href="https://medium.com/aws-serverless-microservices-with-patterns-best/event-driven-serverless-microservices-design-with-aws-lambda-bfc6ab2881eb"><strong>Event-driven Architecture</strong></a><strong> using </strong><a href="https://medium.com/aws-serverless-microservices-with-patterns-best/aws-lambda-best-practices-and-event-driven-architecture-d6b897d9c96e"><strong>AWS Lambda Best Practices</strong></a><strong>,</strong></li><li>and of course we can follow <a href="https://medium.com/aws-serverless-microservices-with-patterns-best/aws-serverless-architectural-patterns-and-best-practices-d2d446375924"><strong>AWS Serverless Architectural Patterns and Best Practices</strong></a></li></ul><p>You can follow the series with these order and continue to check other articles. These are my arguments that push me to creates the articles and the GitHub repository at below;</p><p>Here you can find <a href="https://medium.com/aws-serverless-microservices-with-patterns-best"><strong>all articles under medium publication</strong></a><strong>.</strong></p><p>Here you can find <a href="https://github.com/awsrun/aws-microservices"><strong>GitHub repository</strong></a><strong>.</strong></p><h3>Step by Step Design AWS Architectures w/ Course</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/0*xX7JnOOwKac_CQxv.png" /></figure><p><a href="https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=JANU23"><strong>I have just published a new course — AWS Serverless Microservices with Patterns &amp; Best Practices.</strong></a></p><p>In this course, we’re going to learn <strong>how to Design and Develop AWS Serverless Event-driven Microservices</strong> with using <strong>AWS Lambda</strong>, <strong>AWS DynamoDB</strong>, <strong>AWS API Gateway</strong>, <strong>AWS EventBridge</strong>,<strong> AWS SQS</strong>, <strong>AWS CDK</strong> for <strong>IaC</strong> — <strong>Infrastructure as Code</strong> tool and <strong>AWS CloudWatch</strong> for <strong>monitoring</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d8b090f9c4b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aws-serverless-microservices-with-patterns-best/the-story-and-articles-list-of-aws-serverless-medium-publication-9d8b090f9c4b">The Story and Articles List of AWS Serverless Medium Publication</a> was originally published in <a href="https://medium.com/aws-serverless-microservices-with-patterns-best">AWS Serverless Microservices with Patterns &amp; Best Practices</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serverless Project Code Structure for AWS Serverless E-Commerce Architecture]]></title>
            <link>https://medium.com/aws-serverless-microservices-with-patterns-best/serverless-project-code-structure-for-aws-serverless-e-commerce-architecture-e5015a0d6778?source=rss----829476b5632d---4</link>
            <guid isPermaLink="false">https://medium.com/p/e5015a0d6778</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[api-gateway]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Mehmet Ozkaya]]></dc:creator>
            <pubDate>Sat, 12 Mar 2022 14:21:55 GMT</pubDate>
            <atom:updated>2023-04-09T12:29:32.562Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we are going to see <strong>Project Code Structure </strong>for AWS <strong>Serverless E-Commerce Microservices</strong> Architecture. I will give introduction and an overview information about code structure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WK_-gPDoCp29u8_MfStF7g.png" /></figure><p>We will be following the<strong> Reference Architecture</strong> above which is a <strong>Real-world</strong> <strong>serverless e-commerce application</strong> and it includes;</p><ul><li><strong>REST API</strong> and <strong>CRUD </strong>endpoints with using <strong>AWS Lambda, API Gateway</strong></li><li><strong>Data persistence</strong> with using <strong>AWS DynamoDB</strong></li><li><strong>Decouple microservices </strong>with <strong>events </strong>using <strong>AWS EventBridge</strong></li><li><strong>Message Queues</strong> for cross-service communication using<strong> AWS SQS</strong></li><li><strong>Cloud stack development</strong> with <strong>IaC </strong>using <strong>AWS CloudFormation CDK.</strong></li></ul><p>Before we start to see our Project Code Structure, I would like to explain <strong>Monorepo </strong>that we follow <strong>Monorepo </strong>approaches in our project.</p><h3>Step by Step Design AWS Architectures w/ Course</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/0*0kKIzzJfY5E9eQOE.png" /></figure><p><a href="https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=APRI23"><strong>I have just published a new course — AWS Serverless Microservices with Patterns &amp; Best Practices.</strong></a></p><p>In this course, we’re going to learn <strong>how to Design and Develop AWS Serverless Event-driven Microservices</strong> with using <strong>AWS Lambda</strong>, <strong>AWS DynamoDB</strong>, <strong>AWS API Gateway</strong>, <strong>AWS EventBridge</strong>,<strong> AWS SQS</strong>, <strong>AWS CDK</strong> for <strong>IaC</strong> — <strong>Infrastructure as Code</strong> tool and <strong>AWS CloudWatch</strong> for <strong>monitoring</strong>.</p><h3>Source Code</h3><p><a href="https://github.com/awsrun/aws-microservices"><strong>Get the Source Code from Serverless Microservices GitHub</strong></a> — Clone or fork this repository, if you like don’t forget the star. If you find or ask anything you can directly open issue on repository.</p><h3>What is Monorepo?</h3><p><strong>Monorepo </strong>is a software development strategy where many project codes are <strong>stored </strong>in the <strong>same repository.</strong> <strong>Single repository </strong>that stores all of your <strong>code</strong> and <strong>assets </strong>for every project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*L5UcH8ObqxyLLojMTGQ-rg.png" /><figcaption><a href="https://medium.com/@jvr572/how-deploy-from-a-git-monorepo-1a9a55b23d44">https://medium.com/@jvr572/how-deploy-from-a-git-monorepo-1a9a55b23d44</a></figcaption></figure><p>This <strong>software engineering practice </strong>has been in use for over a decade, but as of 2017, it has become widespread by large companies such as Google, Facebook, Microsoft, Uber, Airbnb, and Twitter use <strong>Monorepo</strong>, one of their various strategies to scale their build systems and version control software in their daily code changes.</p><p>Using a <strong>Monorepo </strong>is important for many reasons.</p><ul><li>It creates a <strong>single source of truth.</strong></li><li>It makes it easier to <strong>share code</strong>.</li><li>It even makes it easier to <strong>refactor code</strong>.</li></ul><h4>Why we are using Monorepo ?</h4><p>We said that Monorepo is a single repository that stores all of our code and assets for every project.</p><p>So in our Serverless E-commerce application,<br>We have 2 main parts</p><ul><li>Microservices Part</li><li>Infrastructure Part</li></ul><p>So our main motivation to use Monorepo is storing <strong>Microservices Code</strong> and <strong>Infrastructure Code </strong>at the <strong>same repository</strong>.</p><h4>Project Folder Structure</h4><p>So we have 1 repository that exists all components of our Serverless e-commerce application. So we have 2 main parts into our Monorepo:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*IMO3QGwKMJpNdtl5d0cldQ.png" /></figure><ul><li><strong>Serverless Infrastructure Development</strong> — [<strong>AWS CDK</strong> Typescript IaC]</li><li><strong>Microservices Lambda Function Development </strong>— [Nodejs Lambda Functions using <strong>AWS SDK for JavaScript v3</strong>]</li></ul><p>First of all, we are going to develop <strong>Serverless Infrastructure </strong>with <strong>AWS CDK </strong>project which written <strong>typescript </strong>code. After that we will develop our microservices with Nodejs Lambda Functions using<strong> AWS SDK for JavaScript v3.</strong></p><p>I will explain every step of developments of our serverless e-commerce application. I just want to give high level of introduction about our serverless application.</p><h4>Serverless Project Folder Structure</h4><p>For that purpose we have 3 main folders about our Project Folder Structure;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*NMDZnDkVsNrV2fMEjTONNQ.png" /></figure><p><strong>bin — lib — src</strong></p><p><strong>bin/lib</strong> folders generate by AWS CDK project template. So <strong>bin/lib </strong>folder comes from AWS CDK initial project template and we follow the template for our project.</p><p><strong>bin folder</strong> — includes starting point of our application.<br><strong>lib folder</strong> — includes infrastructure codes. IaC Serverless Stacks with CDK.<br><strong>src folder </strong>— includes microservices development codes with nodejs.</p><h3>Review Project Folder Structure into Visual Studio Code</h3><p>In this part we will see real codes from our Project Folder Structure into Visual Studio Code.</p><p><strong>bin folder</strong> — includes starting point of our application.</p><pre>#!/usr/bin/env node</pre><pre>import ‘source-map-support/register’;<br>import * as cdk from ‘aws-cdk-lib’;<br>import { AwsMicroservicesStack } from ‘../lib/aws-microservices-stack’;</pre><pre>const app = new cdk.App();<br>new AwsMicroservicesStack(app, ‘AwsMicroservicesStack’, {</pre><pre>/* If you don’t specify ‘env’, this stack will be environment-agnostic.<br>* Account/Region-dependent features and context lookups will not work,<br>* but a single synthesized template can be deployed anywhere. */<br>/* Uncomment the next line to specialize this stack for the AWS Account<br>* and Region that are implied by the current CLI configuration. */<br>// env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION },<br>/* Uncomment the next line if you know exactly what Account and Region you<br>* want to deploy the stack to. */<br>// env: { account: ‘123456789012’, region: ‘us-east-1’ },<br>/* For more information, see <a href="https://docs.aws.amazon.com/cdk/latest/guide/environments.html">https://docs.aws.amazon.com/cdk/latest/guide/environments.html</a> */<br>});</pre><p><strong>lib folder</strong> — includes infrastructure codes. IaC Serverless Stacks with CDK.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*D4W1p9imXwV8WJYHfYYM7g.png" /></figure><p>Find typescript classes below that are divided as per infrastructure type;</p><ul><li>SwnDatabase</li><li>SwnMicroservices</li><li>SwnApiGateway</li><li>SwnQueue</li><li>SwnEventBus</li></ul><p>These are custom Constructs that we can develop using AWS CDK with typescript language.</p><pre>import { Stack, StackProps } from ‘aws-cdk-lib’;<br>import { Construct } from ‘constructs’;<br>import { SwnApiGateway } from ‘./apigateway’;<br>import { SwnDatabase } from ‘./database’;<br>import { SwnEventBus } from ‘./eventbus’;<br>import { SwnMicroservices } from ‘./microservice’;<br>import { SwnQueue } from ‘./queue’;</pre><pre>export class AwsMicroservicesStack extends Stack {<br>constructor(scope: Construct, id: string, props?: StackProps) {<br>super(scope, id, props);</pre><pre>const database = new SwnDatabase(this, ‘Database’);</pre><pre>const microservices = new SwnMicroservices(this, ‘Microservices’, {<br>productTable: database.productTable,<br>basketTable: database.basketTable,<br>orderTable: database.orderTable<br>});</pre><pre>const apigateway = new SwnApiGateway(this, ‘ApiGateway’, {<br>productMicroservice: microservices.productMicroservice,<br>basketMicroservice: microservices.basketMicroservice,<br>orderingMicroservices: microservices.orderingMicroservice<br>});</pre><pre>const queue = new SwnQueue(this, ‘Queue’, {<br>consumer: microservices.orderingMicroservice<br>});</pre><pre>const eventbus = new SwnEventBus(this, ‘EventBus’, {<br>publisherFuntion: microservices.basketMicroservice,<br>targetQueue: queue.orderQueue<br>});</pre><pre>}<br>}</pre><p><strong>src folder </strong>— includes microservices development codes using aws sdk with nodejs lambda functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*SikpTFx0d66p_zU--mtwXA.png" /></figure><ul><li>product</li><li>basket</li><li>ordering has index.js lambda function codes.</li></ul><p>These are typical NodeJS applications that we developed with JS ECMA scripts 6+ version.<br>And use AWS SDK libraries in order to interact with existing infrastructure, for example basket microservice get and post basket to DynamoDB and publish event to EventBridge.<br>We basically use these AWS SDK libraries. You can find example product index.js file as below;</p><pre>import { DeleteItemCommand, GetItemCommand, PutItemCommand, QueryCommand, ScanCommand, UpdateItemCommand } from &quot;@aws-sdk/client-dynamodb&quot;;<br>import { marshall, unmarshall } from &quot;@aws-sdk/util-dynamodb&quot;;<br>import { ddbClient } from &quot;./ddbClient&quot;;<br>import { v4 as uuidv4 } from &#39;uuid&#39;;</pre><pre>exports.handler = async function(event) {<br>console.log(&quot;request:&quot;, JSON.stringify(event, undefined, 2));<br>let body;<br>try {<br>switch (event.httpMethod) {<br>case &quot;GET&quot;:<br>if (event.queryStringParameters != null) {<br>body = await getProductsByCategory(event);<br>}<br>else if (event.pathParameters != null) {<br>body = await getProduct(event.pathParameters.id);<br>}<br>else {<br>body = await getAllProducts();<br>}<br>break;<br>case &quot;POST&quot;:<br>body = await createProduct(event);<br>break;<br>case &quot;DELETE&quot;:<br>body = await deleteProduct(event.pathParameters.id);<br>break;<br>case &quot;PUT&quot;:<br>body = await updateProduct(event);<br>break;<br>default:<br>throw new Error(`Unsupported route: &quot;${event.httpMethod}&quot;`);<br>}<br>console.log(body);</pre><pre>return {<br>statusCode: 200,<br>body: JSON.stringify({<br>message: `Successfully finished operation: &quot;${event.httpMethod}&quot;`,<br>body: body<br>})<br>};<br>} catch (e) {<br>console.error(e);<br>return {<br>statusCode: 500,<br>body: JSON.stringify({<br>message: &quot;Failed to perform operation.&quot;,<br>errorMsg: e.message,<br>errorStack: e.stack,<br>})<br>};<br>}<br>};</pre><pre>const getProduct = async (productId) =&gt; {<br>console.log(&quot;getProduct&quot;);<br>try {<br>const params = {<br>TableName: process.env.DYNAMODB_TABLE_NAME,<br>Key: marshall({ id: productId })<br>};</pre><pre>const { Item } = await ddbClient.send(new GetItemCommand(params));<br>console.log(Item);<br>return (Item) ? unmarshall(Item) : {};<br>} catch(e) {<br>console.error(e);<br>throw e;<br>}<br>}</pre><p>As you can see that we have overview the code structure of final application. You can find the final application in GitHub at the repository below.</p><h3>Step by Step Design AWS Architectures w/ Course</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/0*p6GXWlVjtYUMLMNx.png" /></figure><p><a href="https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=APRI23"><strong>I have just published a new course — AWS Serverless Microservices with Patterns &amp; Best Practices.</strong></a></p><p>In this course, we’re going to learn <strong>how to Design and Develop AWS Serverless Event-driven Microservices</strong> with using <strong>AWS Lambda</strong>, <strong>AWS DynamoDB</strong>, <strong>AWS API Gateway</strong>, <strong>AWS EventBridge</strong>,<strong> AWS SQS</strong>, <strong>AWS CDK</strong> for <strong>IaC</strong> — <strong>Infrastructure as Code</strong> tool and <strong>AWS CloudWatch</strong> for <strong>monitoring</strong>.</p><h3>Source Code</h3><p><a href="https://github.com/awsrun/aws-microservices"><strong>Get the Source Code from Serverless Microservices GitHub</strong></a> — Clone or fork this repository, if you like don’t forget the star. If you find or ask anything you can directly open issue on repository.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5015a0d6778" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aws-serverless-microservices-with-patterns-best/serverless-project-code-structure-for-aws-serverless-e-commerce-architecture-e5015a0d6778">Serverless Project Code Structure for AWS Serverless E-Commerce Architecture</a> was originally published in <a href="https://medium.com/aws-serverless-microservices-with-patterns-best">AWS Serverless Microservices with Patterns &amp; Best Practices</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Cost Management with AWS Free Tier]]></title>
            <link>https://medium.com/aws-serverless-microservices-with-patterns-best/aws-cost-management-with-aws-free-tier-ec104d533245?source=rss----829476b5632d---4</link>
            <guid isPermaLink="false">https://medium.com/p/ec104d533245</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[cost-management]]></category>
            <dc:creator><![CDATA[Mehmet Ozkaya]]></dc:creator>
            <pubDate>Sat, 12 Mar 2022 14:20:06 GMT</pubDate>
            <atom:updated>2023-01-06T08:46:09.455Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we are going to talk about <strong>AWS Cost Management</strong> with AWS <strong>Free Tier </strong>Account when developing <strong>Serverless E-Commerce</strong> application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kJecJA9TuvDHMbKQGoawmA.png" /><figcaption>AWS Cost Management with AWS Free Tier</figcaption></figure><p>If you followed the other articles, you can see that, we deployed full <strong>Serverless E-commerce </strong>application services on AWS Serverless cloud environment. <br>And these services are mostly <strong>free services </strong>with the <strong>Free Tier </strong>account, but it needs to <strong>manage to stay </strong>in <strong>Free Tier </strong>account limits.</p><blockquote>So <strong>How can we stay </strong>in Free Tier Account limits when you are developing a Serverless E-Commerce project ?</blockquote><p>Let me start with remembering our <strong>Serverless E-Commerce </strong>application.</p><h3>Step by Step Design AWS Architectures w/ Course</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*T29ZCKk9JazTQOnKwheJbA.png" /></figure><p><a href="https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=JANU23"><strong>I have just published a new course — AWS Serverless Microservices with Patterns &amp; Best Practices.</strong></a></p><p>In this course, we’re going to learn <strong>how to Design and Develop AWS Serverless Event-driven Microservices</strong> with using <strong>AWS Lambda</strong>, <strong>AWS DynamoDB</strong>, <strong>AWS API Gateway</strong>, <strong>AWS EventBridge</strong>,<strong> AWS SQS</strong>, <strong>AWS CDK</strong> for <strong>IaC</strong> — <strong>Infrastructure as Code</strong> tool and <strong>AWS CloudWatch</strong> for <strong>monitoring</strong>.</p><h3>Source Code</h3><p><a href="https://github.com/awsrun/aws-microservices"><strong>Get the Source Code from Serverless Microservices GitHub</strong></a> — Clone or fork this repository, if you like don’t forget the star. If you find or ask anything you can directly open issue on repository.</p><h3>AWS Serverless Microservices for Ecommerce Application Architecture</h3><p>Here, you can find the main overall <strong>Serverless Architecture</strong> for our application. This is the <strong>big picture </strong>of what we are going to develop together for <strong>AWS Serverless Event-driven E-commerce Microservices </strong>application that is Step by Step Implementation together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_kdcw6XYskm6nUIydqn1Hw.png" /><figcaption>Serverless E-commerce application</figcaption></figure><p>We have followed the<strong> reference architecture</strong> above which is a <strong>real-world</strong> <strong>serverless e-commerce application</strong> and it includes;</p><ul><li><strong>REST API</strong> and <strong>CRUD </strong>endpoints with using <strong>AWS Lambda, API Gateway</strong></li><li><strong>Data persistence</strong> with using <strong>AWS DynamoDB</strong></li><li><strong>Decouple microservices </strong>with <strong>events </strong>using <strong>AWS EventBridge</strong></li><li><strong>Message Queues</strong> for cross-service communication using<strong> AWS SQS</strong></li><li><strong>Cloud stack development</strong> with <strong>IaC </strong>using <strong>AWS CloudFormation CDK</strong></li></ul><h3>How can we stay in Free Tier Account ?</h3><p>When I developed this project, AWS didn’t charge me any amount of money from <strong>AWS </strong>with <strong>Free Tier</strong> <strong>account</strong>. So if we follow the <strong>Free tier</strong>, you don’t get charged. But you should consider and careful that these are paid services that can comes with cost.</p><p>Let me show my <strong>billing results</strong>. Here is my <strong>Cost and Usage</strong> for our <strong>Serverless E-commerce application</strong>, as you can see that I didn’t changed any amount of cost for my usages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kJecJA9TuvDHMbKQGoawmA.png" /><figcaption>AWS Cost Management with AWS Free Tier</figcaption></figure><h3>Free Tier Usage of Serverless E-Commerce Application</h3><p>And here is my <strong>free tier </strong>usage of AWS Services. As you can see that I have send lots of request to the AWS services when preparing this project and all these services has <strong>zero cost </strong>of me with the <strong>AWS Free Tier.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gw7LJDXmN_5VufJBOxM3JQ.png" /><figcaption>AWS Usage During the Project Development</figcaption></figure><p>See that I have almost <strong>300 request usage</strong> for <strong>AWS Lambda</strong>, <strong>200 request</strong> for <strong>AWS SQS</strong>. And these are spending very low amount of limits. You can also see here <strong>AWS Free Tier</strong> usage limits under the second column.</p><p>You can also see this detail into “<strong>AWS Cost Management</strong>” module, you can access from your dashboard page. But you should login with root user. Only root user can see these details.</p><h3>AWS Free Tier Account Limits</h3><p>You can see AWS Free Account Limits from the official website.</p><p><a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc&amp;awsf.Free%20Tier%20Types=*all&amp;awsf.Free%20Tier%20Categories=*all"><strong>See AWS Free Tier Account Limits</strong></a></p><p>As you can see that we opened <strong>AWS Free Tier</strong> page.</p><p>With these Free Tier Account, we can use more than <strong>100 products</strong> for building applications. And most of the services allowed <strong>good amount of usage</strong> depending on the product. But I can say that this free tier account is <strong>really really sufficient</strong> to develop something like average applications on AWS.</p><h4>Free Tier details</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ugAvo1ILtvluxLKobMvlfA.png" /></figure><p>We can see details of free services on the above picture.<br>For example filter to “<strong>Always Free</strong>”</p><p>See that;</p><ul><li><strong>25 GB </strong>DynamoDb</li><li><strong>1 million</strong> Lambda request</li><li><strong>1 TB</strong> Amazon CloudFront <br> and so on</li></ul><p>So these are <strong>good amount of numbers </strong>that you can create your own <strong>startup</strong> applications with this free tier and AWS power of high scalability and high availability.</p><h3>Turn off the lights before leaving the room</h3><p>Now we come to the part where we have to be careful. Now we can talk about to be careful when developing our<strong> Serverless E-commerce </strong>project.</p><p>I always clear resources after finish the section or leave from computer.</p><p>At this stage, I would like to emphasizes the quote from <strong>AWS CTO Werner Vogels </strong>about cloud usages and global warming;</p><blockquote>Turn off the lights before leaving the room</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VUuc9ZFwnN9xY2bZfQFWtw.png" /><figcaption><a href="https://www.youtube.com/watch?v=8_Xs8Ik0h1w">https://www.youtube.com/watch?v=8_Xs8Ik0h1w</a></figcaption></figure><p>So you can think that if you leave from computer and shut the light off, that means you also shut down the <strong>AWS resource</strong>.</p><p>He is saying this for the <strong>un-used resources </strong>on the cloud, but from our course perspective, we can also follow this quote.</p><p>Because we don’t need to stay live on production. You can think that we are going to prepare <strong>demo session</strong> with your <strong>customer </strong>and you should show the <strong>Serverless </strong>application during the customer presentation. <br>After that we <strong>shut-down resources </strong>since new customer session arranged. Please consider this, clear all resources after you finished the work at that day.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WK_-gPDoCp29u8_MfStF7g.png" /><figcaption>Serverless E-commerce application provisioned by AWS CDK</figcaption></figure><p>Don’t worry, when you come back tomorrow, we can instantly come the same situation with the power of <strong>AWS CDK.</strong><br>When you run <br><strong> cdk deploy</strong><br>command, this will immediately provision all resources where you left.</p><p>As the same way you can clear all resources with running</p><p><strong>cdk destroy</strong></p><p>command, this will immediately clear all resources.</p><p>Within our application architecture, you’ll learn how to design and developing <strong>AWS Event-driven microservices </strong>with using<strong> Serverless patterns </strong>and <strong>best practices. </strong>You can find the final application in GitHub at the repository below.</p><h3>Step by Step Design AWS Architectures w/ Course</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*T29ZCKk9JazTQOnKwheJbA.png" /></figure><p><a href="https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=JANU23"><strong>I have just published a new course — AWS Serverless Microservices with Patterns &amp; Best Practices.</strong></a></p><p>In this course, we’re going to learn <strong>how to Design and Develop AWS Serverless Event-driven Microservices</strong> with using <strong>AWS Lambda</strong>, <strong>AWS DynamoDB</strong>, <strong>AWS API Gateway</strong>, <strong>AWS EventBridge</strong>,<strong> AWS SQS</strong>, <strong>AWS CDK</strong> for <strong>IaC</strong> — <strong>Infrastructure as Code</strong> tool and <strong>AWS CloudWatch</strong> for <strong>monitoring</strong>.</p><h3>Source Code</h3><p><a href="https://github.com/awsrun/aws-microservices"><strong>Get the Source Code from Serverless Microservices GitHub</strong></a> — Clone or fork this repository, if you like don’t forget the star. If you find or ask anything you can directly open issue on repository.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec104d533245" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aws-serverless-microservices-with-patterns-best/aws-cost-management-with-aws-free-tier-ec104d533245">AWS Cost Management with AWS Free Tier</a> was originally published in <a href="https://medium.com/aws-serverless-microservices-with-patterns-best">AWS Serverless Microservices with Patterns &amp; Best Practices</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Lambda Invocation Types]]></title>
            <link>https://medium.com/aws-serverless-microservices-with-patterns-best/aws-lambda-invocation-types-e279ef136347?source=rss----829476b5632d---4</link>
            <guid isPermaLink="false">https://medium.com/p/e279ef136347</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[invocation]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Mehmet Ozkaya]]></dc:creator>
            <pubDate>Sat, 12 Mar 2022 14:18:22 GMT</pubDate>
            <atom:updated>2022-11-01T17:15:20.975Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we are going to see how <strong>triggered </strong>our <strong>Lambda functions</strong>, that means we will see <strong>AWS Lambda Invocation Types</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lyt3v8G6aSzXQmMl_izcBw.png" /></figure><p>After that we will <strong>map </strong>these <strong>Lambda Invocation Types</strong> with our course when developing <strong>Serverless E-commerce </strong>application. So AWS Lambda Invocation Types will be our <strong>Serverless Journey</strong> when developing our <strong>Serverless E-commerce</strong> application.</p><h3>Step by Step Design AWS Architectures w/ Course</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/0*069kBO4-LNaYoHye.png" /></figure><p><a href="https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=NOVE22"><strong>I have just published a new course — AWS Serverless Microservices with Patterns &amp; Best Practices.</strong></a></p><p>In this course, we’re going to learn <strong>how to Design and Develop AWS Serverless Event-driven Microservices</strong> with using <strong>AWS Lambda</strong>, <strong>AWS DynamoDB</strong>, <strong>AWS API Gateway</strong>, <strong>AWS EventBridge</strong>,<strong> AWS SQS</strong>, <strong>AWS CDK</strong> for <strong>IaC</strong> — <strong>Infrastructure as Code</strong> tool and <strong>AWS CloudWatch</strong> for <strong>monitoring</strong>.</p><h3>Source Code</h3><p><a href="https://github.com/awsrun/aws-microservices"><strong>Get the Source Code from Serverless Microservices GitHub</strong></a> — Clone or fork this repository, if you like don’t forget the star. If you find or ask anything you can directly open issue on repository.</p><h3>AWS Lambda Invocation Types</h3><p><strong>AWS Lambda</strong> functions is using everywhere for various use cases. Sometimes we want to <strong>invoke Lambda functions </strong>over <strong>HTTP </strong>and other times <strong>trigger </strong>a <strong>function</strong> based on different <strong>events</strong>. It is extremely useful to understand the different ways that we can<strong> invoke Lambda functions. </strong><br>Here are <strong>3 different ways</strong> we can invoke AWS Lambda function:</p><p>AWS Lambda has <strong>3 Invocation Types;</strong></p><ul><li>Lambda <strong>Synchronous </strong>Invocation</li><li>Lambda <strong>Asynchronous </strong>Invocation</li><li>Lambda <strong>Event Source Mapping</strong> with <strong>Polling </strong>Invocation</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nf8j_-RuIMy6F0w0mnbrlA.png" /><figcaption><a href="https://aws.amazon.com/blogs/architecture/understanding-the-different-ways-to-invoke-lambda-functions/">https://aws.amazon.com/blogs/architecture/understanding-the-different-ways-to-invoke-lambda-functions/</a></figcaption></figure><p>You can all invocation types in one image.<br><strong>Synchronous invocation</strong> is trigger by push model and execute immediately and wait response. we can say RequestResponse model.<br><strong>Asynchronous invocation</strong> is trigger by event model and executes asynchronous don’t wait immediate response.<br><strong>Event Source Mapping invocation</strong> is triggered by poll-based. That means lambda function receives multiple items.</p><p>Lets see one by one and explain these invocation types.</p><h3>Lambda Synchronous Invocation</h3><p>This is one of the<strong> simple lambda invocation </strong>model. In this communication type, lambda functions <strong>execute immediately </strong>when you perform the Lambda <strong>Invoke </strong>by <strong>API call</strong>. <br>So when we perform a Lambda <strong>invoke an API call</strong>, we <strong>wait </strong>for the function to <strong>process</strong> the function and <strong>return back </strong>to <strong>response</strong>. The response data includes the <strong>function response </strong>and additional data which can be retrieved from DynamoDB or some other resources.</p><p>A common scenario for synchronous invocation is the <strong>API Gateway + Lambda integration:</strong><br>You can see in the image of <strong>API Gateway — Lambda — DynamoDB</strong> that we can perform <strong>CRUD </strong>operations for a particular DynamoDB table with exposing APIs from API Gateway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*DWtDS5rCGITauepvuckC1w.png" /></figure><p>The important thing; The <strong>Invocation-type flag</strong> should be “<strong>RequestResponse</strong>”. This instructs AWS to execute our Lambda function and wait for the response of function to complete. <br>When we perform a <strong>synchronous invocation</strong>, we are responsible for <strong>inspecting </strong>the response and <strong>determining </strong>if there was an error like time out exceptions and decide to retry the invocation.</p><p>We can perform <strong>Synchronous RequestResponse invocation </strong>using the AWS CLI, SDKs and many other options.</p><p>Example of synchronous invocation using the AWS CLI:</p><pre>aws lambda invoke — function-name MyLambdaFunction — invocation-type RequestResponse — payload ‘{ “key”: “value” }’</pre><p>As you can see that when we specify the <strong>Invocation-type flag</strong> is <strong>RequestResponse</strong>. That means AWS execute our function and wait for the function to complete. The important part is we are responsible for <strong>checking </strong>the <strong>response </strong>and determining whether it is an error and we should retry the invoke.</p><p>There are many AWS services that can trigger lambda function <strong>synchronously</strong>. <br>Here are some of them:</p><ul><li>ELB (Application Load Balancer)</li><li>Amazon Cognito</li><li>Amazon Lex</li><li>Amazon Alexa</li><li>Amazon API Gateway</li><li>Amazon CloudFront (Lambda@Edge)</li><li>Amazon Kinesis Data Firehose</li></ul><h3>Lambda Asynchronous Invocation</h3><p>In this communication type, Lambda functions works with <strong>events </strong>and <strong>invoke </strong>by <strong>events </strong>and <strong>not respond immediately</strong>.</p><p>Basically we can <strong>invoke </strong>a lambda function <strong>asynchronously</strong>, after that Lambda sends the event to a <strong>internal queue </strong>and returns a success response without any additional information. After that a separate process reads events from the queue and runs our lambda function.</p><h4>S3 + Lambda + DynamoDB</h4><p>A common scenario for Asynchronous invocation is the<strong> S3 / SNS + Lambda + DynamoDB.</strong> You can see in the image of <strong>S3 / SNS + Lambda + DynamoDB.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*MJE1ZmlN8vfvCdTluiWCLQ.png" /></figure><p>In the diagram, Amazon S3 will <strong>call </strong>the <strong>lambda asynchronous </strong>when a new object is written into the <strong>bucket</strong>. In order to invoke a function <strong>asynchronously</strong>, we should set the invocation type parameter to <strong>Event</strong>.</p><p>Example of an asynchronous invokes using the CLI:</p><pre>aws lambda invoke — function-name MyLambdaFunction — invocation-type Event — payload ‘{ “key”: “value” }’</pre><p>When we specify the<strong> Invocation-type</strong> parameter value as <strong>Event </strong>if the function failed AWS will automatically <strong>retry </strong>the <strong>invoke twice.</strong></p><p>By default <strong>AWS Lambda </strong>sets a <strong>retry policy</strong> for <strong>asynchronous invocation</strong>, your function will be invoked twice if there is an error.</p><p>In order to avoid <strong>event losses </strong>when using <strong>asynchronous </strong>lambda, always attach a <strong>dead-letter queue</strong> on the function in order to save events that weren’t successfully processed.</p><p>Here is a list of services that invoke <strong>Lambda </strong>functions <strong>asynchronously</strong>:</p><ul><li>S3</li><li>EventBridge</li><li>SNS</li><li>SES</li><li>CloudFormation</li><li>CloudWatch Logs</li><li>CloudWatch Events</li><li>CodeCommit</li><li>Pool Based Invokes</li></ul><h3>Lambda Event Source Mapping with Polling Invocation</h3><p><strong>Pool-Based invocation</strong> model allows us to integrate with<strong> AWS Stream</strong> and <strong>Queue </strong>based services. These services don’t invoke Lambda function directly. Lambda will poll from the <strong>AWS SQS</strong> or Kinesis streams, retrieve records, and invoke functions.<br>AWS Lambda <strong>Event Source Mapping </strong>manages the poller and performs Synchronous invokes of our function.</p><p>Data stream or queue are read in <strong>batches</strong>, the function receives multiple items when execute function. <strong>Batch sizes </strong>can configure according to service types and after that the <strong>event source mapping </strong>will send data according to batch size. If the batch size is too large to send in one event, it has to be split up, resulting in events with smaller numbers of items than the batch size.</p><h4>SQS + Lambda</h4><p>A common scenario for <strong>Event Source Mapping </strong>with <strong>Polling Invocation </strong>is the<strong> SQS + Lambda</strong>. You can see in the image of <strong>SQS + Lambda</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*NFvUkDdpqTnVQ9qXpDz0Vw.png" /></figure><p>In the diagram, <strong>Amazon SQS</strong> has some queue records, this queue record can be added from other AWS Services like <strong>EventBridge</strong>, <strong>SNS </strong>and so on.<br>After that a lambda function <strong>poll events </strong>from <strong>AWS SQS </strong>and <strong>receive queue </strong>records with<strong> Event Source Mapping invocations</strong>. Lambda function retrieve queue records according to <strong>Batch Size </strong>property of polling configurations.</p><p>Another common scenario for <strong>Event Source Mapping </strong>with <strong>Polling Invocation</strong> is <strong>stream </strong>based processing. These are <strong>Kinesis </strong>and <strong>DynamoDB Streams </strong>that Lambda can poll stream records with Event Source Mapping invocations.</p><p>Here is a list of services that invoke Lambda functions as event source mapping:</p><ul><li>Amazon Kinesis</li><li>Amazon DynamoDB</li><li>Amazon Simple Queue Service</li></ul><p>As you can see we have we have seen AWS Lambda Invocation Types.</p><h3>Serverless E-Commerce Microservices with Lambda Invocation Types</h3><p>If we map these Lambda Invocation Types with our microservices architecture when developing <strong>serverless e-commerce application</strong>, you can see the diagram below;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*228B5l9xcNsBEL0dbTgMUQ.png" /><figcaption>Serverless Event-driven E-commerce Microservices Architecture</figcaption></figure><p>So AWS <strong>Lambda Invocation Types </strong>will be our <strong>Serverless Journey </strong>when developing our serverless e-commerce application.</p><p>See details in the below captions.</p><h3>AWS Serverless Microservices for Ecommerce Application Architecture</h3><p>Here, you can find the main overall <strong>Serverless Architecture</strong> for our application that we will follow these steps and build tihs Serverless E-Commerce Microservices Architecture.</p><p>This is the <strong>big picture </strong>of what we are going to develop together for <strong>AWS Serverless Event-driven E-commerce Microservices </strong>application that is Step by Step Implementation together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_kdcw6XYskm6nUIydqn1Hw.png" /><figcaption>Serverless Event-driven E-commerce Microservices Architecture</figcaption></figure><p>We have followed the<strong> reference architecture</strong> above which is a <strong>real-world</strong> <strong>serverless e-commerce application</strong> and it includes;</p><ul><li><strong>REST API</strong> and <strong>CRUD </strong>endpoints with using <strong>AWS Lambda, API Gateway</strong></li><li><strong>Data persistence</strong> with using <strong>AWS DynamoDB</strong></li><li><strong>Decouple microservices </strong>with <strong>events </strong>using <strong>AWS EventBridge</strong></li><li><strong>Message Queues</strong> for cross-service communication using<strong> AWS SQS</strong></li><li><strong>Cloud stack development</strong> with <strong>IaC </strong>using <strong>AWS CloudFormation CDK</strong></li><li><strong>Decouple microservices </strong>with <strong>events </strong>using <strong>AWS EventBridge</strong></li><li><strong>Message Queues</strong> for cross-service communication using<strong> AWS SQS</strong></li><li><strong>Cloud stack development</strong> with <strong>IaC </strong>using <strong>AWS CloudFormation CDK</strong></li></ul><h3>Step by Step Design AWS Architectures w/ Course</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/0*GFzU1MITdsid5hxr.png" /></figure><p><a href="https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=NOVE22"><strong>I have just published a new course — AWS Serverless Microservices with Patterns &amp; Best Practices.</strong></a></p><p>In this course, we’re going to learn <strong>how to Design and Develop AWS Serverless Event-driven Microservices</strong> with using <strong>AWS Lambda</strong>, <strong>AWS DynamoDB</strong>, <strong>AWS API Gateway</strong>, <strong>AWS EventBridge</strong>,<strong> AWS SQS</strong>, <strong>AWS CDK</strong> for <strong>IaC</strong> — <strong>Infrastructure as Code</strong> tool and <strong>AWS CloudWatch</strong> for <strong>monitoring</strong>.</p><h3>Source Code</h3><p><a href="https://github.com/awsrun/aws-microservices"><strong>Get the Source Code from Serverless Microservices GitHub</strong></a> — Clone or fork this repository, if you like don’t forget the star. If you find or ask anything you can directly open issue on repository.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e279ef136347" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aws-serverless-microservices-with-patterns-best/aws-lambda-invocation-types-e279ef136347">AWS Lambda Invocation Types</a> was originally published in <a href="https://medium.com/aws-serverless-microservices-with-patterns-best">AWS Serverless Microservices with Patterns &amp; Best Practices</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Serverless Services for Microservices Architectures]]></title>
            <link>https://medium.com/aws-serverless-microservices-with-patterns-best/aws-serverless-services-for-microservices-architectures-2b3551d884e4?source=rss----829476b5632d---4</link>
            <guid isPermaLink="false">https://medium.com/p/2b3551d884e4</guid>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[api-gateway]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Mehmet Ozkaya]]></dc:creator>
            <pubDate>Sat, 12 Mar 2022 14:15:46 GMT</pubDate>
            <atom:updated>2023-03-09T10:24:40.773Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we are going to learn how <strong>AWS Serverless Services </strong>can be use in <strong>Microservices Architectures</strong> with designing <strong>Serverless Event-driven E-Commerce</strong> Application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WK_-gPDoCp29u8_MfStF7g.png" /><figcaption>Serverless Event-driven E-commerce Microservices Architecture</figcaption></figure><p>We will start with looking for <strong>AWS Serverless Services</strong> and after that we will continue to understand how we can use these AWS Serverless services into an example <strong>microservices architecture</strong>.</p><h3>Step by Step Design AWS Architectures w/ Course</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/0*MzS6C5Wp6PCEQBC0.png" /></figure><p><a href="https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=MARC23"><strong>I have just published a new course — AWS Serverless Microservices with Patterns &amp; Best Practices.</strong></a></p><p>In this course, we’re going to learn <strong>how to Design and Develop AWS Serverless Event-driven Microservices</strong> with using <strong>AWS Lambda</strong>, <strong>AWS DynamoDB</strong>, <strong>AWS API Gateway</strong>, <strong>AWS EventBridge</strong>,<strong> AWS SQS</strong>, <strong>AWS CDK</strong> for <strong>IaC</strong> — <strong>Infrastructure as Code</strong> tool and <strong>AWS CloudWatch</strong> for <strong>monitoring</strong>.</p><h3>Source Code</h3><p><a href="https://github.com/awsrun/aws-microservices"><strong>Get the Source Code from Serverless Microservices GitHub</strong></a> — Clone or fork this repository, if you like don’t forget the star. If you find or ask anything you can directly open issue on repository.</p><h3>AWS Operational Responsibility Model</h3><p>When we talk about <strong>Serverless</strong>, the best way to explain what <strong>Serverless </strong>is looking to <strong>AWS Operational Responsibility Models</strong>. You can think this is a spectrum about responsibility level of services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tErs3QZ0_6f7ItiEYy-pLA.png" /><figcaption><a href="https://d1.awsstatic.com/events/reinvent/2019/REPEAT_3_Serverless_architectural_patterns_and_best_practices_ARC307-R3.pdf">https://d1.awsstatic.com/events/reinvent/2019/REPEAT_3_Serverless_architectural_patterns_and_best_practices_ARC307-R3.pdf</a></figcaption></figure><p>If we look at the image, and if we look at the <strong>horizontal way</strong>, we can see the traditional <strong>on-premises machines</strong> , <strong>virtual machines</strong>, bare metal hardware devices at the beginning of the image.</p><p>And if we go to right hand side, you can see the<strong> cloud infrastructure</strong>, which includes managed services that managed application services on the cloud.</p><p>And if we go the last of the right hand side, you can reach the <strong>fully Serverless</strong> services that we <strong>don’t any responsibility </strong>about <strong>servers</strong>, <strong>patches</strong>, <strong>updates </strong>and also not consider about scaling, reliability and availability so on.</p><p>And if we look the <strong>vertical way</strong>, you can see the separation of services</p><ul><li><strong>Compute</strong></li><li><strong>Databases</strong></li><li><strong>Storage</strong></li><li><strong>Messaging / Application Integrations</strong></li><li><strong>Analytics</strong></li><li>and we can put here<strong> API Management</strong> for AWS API Gateway</li></ul><p>So these are the services by grouping for AWS Services that we mostly use when developing enterprise level applications.</p><p>You can also see this kind of grouping in Products of Amazon website;<br> <a href="https://aws.amazon.com/">https://aws.amazon.com/</a><br> Products</p><p>You can see that;</p><ul><li><strong>Application Integrations</strong> — SNS, Event Bridge, Step Functions</li><li><strong>Compute </strong>— Lambda, EC2</li><li><strong>Database </strong>— DynamoDB, Auora Serverless</li><li><strong>Frontend Web </strong>— API Gateway</li><li><strong>Serverless</strong></li><li><strong>Storage </strong>and so on.</li></ul><p>So according to these grouping, AWS services <strong>evolve by time </strong>and now in Serverless part they have very great service which you don’t consider any server management and scalability issues.</p><p>Lets see which services available for <strong>AWS Serverless </strong>by grouping;</p><ul><li><strong>Compute </strong>— AWS Lambda</li><li><strong>Databases </strong>— DynamoDB, Auora Serverless Database</li><li><strong>Storage </strong>— S3</li><li><strong>Messaging/Application Integrations</strong> — SNS,SQS, EventBridge</li><li><strong>Analytics </strong>— Athena</li><li><strong>API Management</strong> for AWS API Gateway</li></ul><p>We will use lots of these services when designing our <strong>Serverless E-commerce</strong> application.</p><h3>AWS Serverless Services for Microservices Architectures</h3><p>We will use a set of AWS Serverless Services for our <strong>Serverless E-Commerce</strong> Microservices application. Lets see what exactly <strong>AWS Serverless services</strong> used by grouping in our application;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dmVkt7J1_kdXzzOmYphcmQ.png" /><figcaption>AWS Serverless Services for Microservices Architectures</figcaption></figure><h4>Compute — AWS Lambda</h4><p><strong>AWS Lambda</strong> is Serverless service that you don’t worry about servers and machines, you only worry about uploading code. AWS responsible for scaling your application, provision machine on behalf of our cloud environment and deploying code when traffic comes our application. All server related tasks are hidden from us when using AWS Lambda.</p><h4>Databases — DynamoDB</h4><p><strong>NoSQL key-value database</strong> that scales horizontally and most popular database in AWS Serverless resources.</p><h4>Messaging/Application Integrations — SQS, EventBridge</h4><p>Building <strong>event-driven architecture </strong>with these integration services, we will implement fanout integration pattern with using these services.</p><h4>API Management — AWS API Gateway</h4><p>Provide to expose <strong>rest apis </strong>without thinking servers and scaling your api methods.</p><h4>IaC — AWS CloudFormation and AWS CDK Stacks</h4><p>We will develop our <strong>infrastructure </strong>with using <strong>AWS CDK </strong>and AWS CDK using <strong>AWS CloudFormation </strong>on behalf of our typescript codes.</p><h4>Monitoring — Amazon CloudWatch</h4><p>We will examine microservice <strong>lambda logs </strong>with <strong>CloudWatch</strong>. Very important to follow lambda invocation types from Amazon CloudWatch.</p><p>We will use lots of these services when <strong>designing </strong>our <strong>Serverless E-Commerce</strong> application. And we can also extend these services with adding new use cases into our Serverless microservices architecture.</p><h3>AWS Serverless Microservices for Ecommerce Application</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*228B5l9xcNsBEL0dbTgMUQ.png" /><figcaption>Serverless Event-driven E-commerce Microservices Architecture</figcaption></figure><p>If we look at the <strong>AWS Serverless Microservices</strong> for Ecommerce Application you can see how we can use these AWS services into our application architecture.</p><h3>Synchronous Communication for RESTful Microservices</h3><p>Synchronous commands are request/response. In a synchronous model, the client makes a request and waits for a response. We will developed <strong>RESTful Microservices </strong>with <strong>API Gateway, Lambda Functions </strong>and <strong>DynamoDB</strong>.</p><p>We called this = <strong>RESTful Microservices</strong></p><ul><li><strong>REST API</strong> and <strong>CRUD </strong>endpoints (AWS Lambda, API Gateway)</li><li><strong>Data </strong>persistence (AWS DynamoDB)</li></ul><p>AWS API Gateway -for- Restful API-Driven Development for performing CRUD operations amongst lambda and DynamoDB.</p><h3>Asynchronous Communication</h3><p>In an <strong>asynchronous design</strong>, the client sends a request and may get an <strong>acknowledgement </strong>that the event was received, but it doesn’t get a response that includes the results of the request.</p><p>We will use</p><ul><li><strong>Amazon EventBridge </strong>-for- Event-Driven <strong>asynchronous communication </strong>between Microservices</li></ul><p>We will develop<strong> Amazon EventBridge </strong>with Lambda <strong>Basket microservices </strong>which publish the event in <strong>asynchronous </strong>way and this will consume by Ordering queue.</p><h3>Event Source Mapping for Polling Event Messages</h3><p>In a polling event, consumers poll the producer for messages in <strong>batches </strong>and then <strong>process </strong>the batch before returning for a new batch of records.</p><p>We will use</p><ul><li><strong>AWS SQS</strong> -for- <strong>Decouple Microservices </strong>and processing events asynchronously using queues</li></ul><p>We will develop <strong>AWS SQS</strong> with Lambda <strong>Ordering microservices </strong>which consumes by polling the event from the Ordering queue.</p><p>As you can see that we follow <strong>Serverless Microservices </strong>with AWS Lambda Invocation Types; Following Microservices Communication Types for Serverless;</p><ul><li><strong>Synchronous </strong>Communication</li><li><strong>Asynchronous </strong>Communication</li><li><strong>Event Source Mapping</strong> for Poling events</li></ul><h3>AWS Serverless Microservices for Ecommerce Application Architecture</h3><p>This is the <strong>big picture </strong>of what we are going to develop together for <strong>AWS Serverless Event-driven E-commerce Microservices </strong>application that is Step by Step Implementation together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_kdcw6XYskm6nUIydqn1Hw.png" /><figcaption>Serverless Event-driven E-commerce Microservices Architecture</figcaption></figure><p>We have followed the<strong> reference architecture</strong> above which is a <strong>real-world</strong> <strong>serverless e-commerce application</strong> and it includes;</p><ul><li><strong>REST API</strong> and <strong>CRUD </strong>endpoints with using <strong>AWS Lambda, API Gateway</strong></li><li><strong>Data persistence</strong> with using <strong>AWS DynamoDB</strong></li><li><strong>Decouple microservices </strong>with <strong>events </strong>using <strong>AWS EventBridge</strong></li><li><strong>Message Queues</strong> for cross-service communication using<strong> AWS SQS</strong></li><li><strong>Cloud stack development</strong> with <strong>IaC </strong>using <strong>AWS CloudFormation CDK</strong></li></ul><h3>Step by Step Design AWS Architectures w/ Course</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/0*qxWl-GHpttQAzyqm.png" /></figure><p><a href="https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=MARC23"><strong>I have just published a new course — AWS Serverless Microservices with Patterns &amp; Best Practices.</strong></a></p><p>In this course, we’re going to learn <strong>how to Design and Develop AWS Serverless Event-driven Microservices</strong> with using <strong>AWS Lambda</strong>, <strong>AWS DynamoDB</strong>, <strong>AWS API Gateway</strong>, <strong>AWS EventBridge</strong>,<strong> AWS SQS</strong>, <strong>AWS CDK</strong> for <strong>IaC</strong> — <strong>Infrastructure as Code</strong> tool and <strong>AWS CloudWatch</strong> for <strong>monitoring</strong>.</p><h3>Source Code</h3><p><a href="https://github.com/awsrun/aws-microservices"><strong>Get the Source Code from Serverless Microservices GitHub</strong></a> — Clone or fork this repository, if you like don’t forget the star. If you find or ask anything you can directly open issue on repository.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b3551d884e4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aws-serverless-microservices-with-patterns-best/aws-serverless-services-for-microservices-architectures-2b3551d884e4">AWS Serverless Services for Microservices Architectures</a> was originally published in <a href="https://medium.com/aws-serverless-microservices-with-patterns-best">AWS Serverless Microservices with Patterns &amp; Best Practices</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microservices Communications with AWS Lambda Invocation Types]]></title>
            <link>https://medium.com/aws-serverless-microservices-with-patterns-best/microservices-communications-with-aws-lambda-invocation-types-aee2d6326866?source=rss----829476b5632d---4</link>
            <guid isPermaLink="false">https://medium.com/p/aee2d6326866</guid>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[communication]]></category>
            <category><![CDATA[microservice-architecture]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <dc:creator><![CDATA[Mehmet Ozkaya]]></dc:creator>
            <pubDate>Sat, 12 Mar 2022 14:14:17 GMT</pubDate>
            <atom:updated>2022-12-05T14:44:41.309Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we are going to see how <strong>Microservices Communications</strong> handle in Serverless world with using <strong>AWS Lambda Invocation Types</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*228B5l9xcNsBEL0dbTgMUQ.png" /><figcaption>Serverless Event-driven E-commerce Microservices Architecture</figcaption></figure><p>We will map these <strong>Lambda Invocation Types</strong> with our architecture when designing <strong>Serverless E-commerce</strong> application. So <strong>AWS Lambda Invocation Types</strong> will be our <strong>Microservices communication</strong> styles when developing our <strong>Serverless Event-driven E-commerce Microservices Architecture</strong> application.</p><p>Let’s start with remembering AWS Lambda Invocation Types.</p><h3>Step by Step Design AWS Architectures w/ Course</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/0*OGXGNyTzi1ysc1A3.png" /></figure><p><a href="https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=DECE22"><strong>I have just published a new course — AWS Serverless Microservices with Patterns &amp; Best Practices.</strong></a></p><p>In this course, we’re going to learn <strong>how to Design and Develop AWS Serverless Event-driven Microservices</strong> with using <strong>AWS Lambda</strong>, <strong>AWS DynamoDB</strong>, <strong>AWS API Gateway</strong>, <strong>AWS EventBridge</strong>,<strong> AWS SQS</strong>, <strong>AWS CDK</strong> for <strong>IaC</strong> — <strong>Infrastructure as Code</strong> tool and <strong>AWS CloudWatch</strong> for <strong>monitoring</strong>.</p><h3>Source Code</h3><p><a href="https://github.com/awsrun/aws-microservices"><strong>Get the Source Code from Serverless Microservices GitHub</strong></a> — Clone or fork this repository, if you like don’t forget the star. If you find or ask anything you can directly open issue on repository.</p><h3>AWS Lambda Invocation Types</h3><p><strong>AWS Lambda</strong> functions is using everywhere for various use cases. Sometimes we want to <strong>invoke Lambda functions </strong>over <strong>HTTP </strong>and other times <strong>trigger </strong>a <strong>function</strong> based on different <strong>events</strong>. It is extremely useful to understand the different ways that we can<strong> invoke Lambda functions. </strong><br>Here are <strong>3 different ways</strong> we can invoke AWS Lambda function:</p><p>AWS Lambda has <strong>3 Invocation Types;</strong></p><ul><li>Lambda <strong>Synchronous </strong>Invocation</li><li>Lambda <strong>Asynchronous </strong>Invocation</li><li>Lambda <strong>Event Source Mapping</strong> with <strong>Polling </strong>Invocation</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nf8j_-RuIMy6F0w0mnbrlA.png" /><figcaption><a href="https://aws.amazon.com/blogs/architecture/understanding-the-different-ways-to-invoke-lambda-functions/">https://aws.amazon.com/blogs/architecture/understanding-the-different-ways-to-invoke-lambda-functions/</a></figcaption></figure><p>You can all invocation types in one image.<br><strong>Synchronous invocation</strong> is trigger by push model and execute immediately and wait response. we can say RequestResponse model.<br><strong>Asynchronous invocation</strong> is trigger by event model and executes asynchronous don’t wait immediate response.<br><strong>Event Source Mapping invocation</strong> is triggered by poll-based. That means lambda function receives multiple items.</p><p>Lets see one by one and explain these invocation types.</p><h3>Lambda Synchronous Invocation</h3><p>This is one of the<strong> simple lambda invocation </strong>model. In this communication type, lambda functions <strong>execute immediately </strong>when you perform the Lambda <strong>Invoke </strong>by <strong>API call</strong>. <br>So when we perform a Lambda <strong>invoke an API call</strong>, we <strong>wait </strong>for the function to <strong>process</strong> the function and <strong>return back </strong>to <strong>response</strong>. The response data includes the <strong>function response </strong>and additional data which can be retrieved from DynamoDB or some other resources.</p><p>A common scenario for synchronous invocation is the <strong>API Gateway + Lambda integration:</strong><br>You can see in the image of <strong>API Gateway — Lambda — DynamoDB</strong> that we can perform <strong>CRUD </strong>operations for a particular DynamoDB table with exposing APIs from API Gateway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*DWtDS5rCGITauepvuckC1w.png" /></figure><p>The important thing; The <strong>Invocation-type flag</strong> should be “<strong>RequestResponse</strong>”. This instructs AWS to execute our Lambda function and wait for the response of function to complete. <br>When we perform a <strong>synchronous invocation</strong>, we are responsible for <strong>inspecting </strong>the response and <strong>determining </strong>if there was an error like time out exceptions and decide to retry the invocation.</p><p>We can perform <strong>Synchronous RequestResponse invocation </strong>using the AWS CLI, SDKs and many other options.</p><p>Example of synchronous invocation using the AWS CLI:</p><pre>aws lambda invoke — function-name MyLambdaFunction — invocation-type RequestResponse — payload ‘{ “key”: “value” }’</pre><p>As you can see that when we specify the <strong>Invocation-type flag</strong> is <strong>RequestResponse</strong>. That means AWS execute our function and wait for the function to complete. The important part is we are responsible for <strong>checking </strong>the <strong>response </strong>and determining whether it is an error and we should retry the invoke.</p><p>There are many AWS services that can trigger lambda function <strong>synchronously</strong>. <br>Here are some of them:</p><ul><li>ELB (Application Load Balancer)</li><li>Amazon Cognito</li><li>Amazon Lex</li><li>Amazon Alexa</li><li>Amazon API Gateway</li><li>Amazon CloudFront (Lambda@Edge)</li><li>Amazon Kinesis Data Firehose</li></ul><h3>Lambda Asynchronous Invocation</h3><p>In this communication type, Lambda functions works with <strong>events </strong>and <strong>invoke </strong>by <strong>events </strong>and <strong>not respond immediately</strong>.</p><p>Basically we can <strong>invoke </strong>a lambda function <strong>asynchronously</strong>, after that Lambda sends the event to a <strong>internal queue </strong>and returns a success response without any additional information. After that a separate process reads events from the queue and runs our lambda function.</p><h4>S3 + Lambda + DynamoDB</h4><p>A common scenario for Asynchronous invocation is the<strong> S3 / SNS + Lambda + DynamoDB.</strong> You can see in the image of <strong>S3 / SNS + Lambda + DynamoDB.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*MJE1ZmlN8vfvCdTluiWCLQ.png" /></figure><p>In the diagram, Amazon S3 will <strong>call </strong>the <strong>lambda asynchronous </strong>when a new object is written into the <strong>bucket</strong>. In order to invoke a function <strong>asynchronously</strong>, we should set the invocation type parameter to <strong>Event</strong>.</p><p>Example of an asynchronous invokes using the CLI:</p><pre>aws lambda invoke — function-name MyLambdaFunction — invocation-type Event — payload ‘{ “key”: “value” }’</pre><p>When we specify the<strong> Invocation-type</strong> parameter value as <strong>Event </strong>if the function failed AWS will automatically <strong>retry </strong>the <strong>invoke twice.</strong></p><p>By default <strong>AWS Lambda </strong>sets a <strong>retry policy</strong> for <strong>asynchronous invocation</strong>, your function will be invoked twice if there is an error.</p><p>In order to avoid <strong>event losses </strong>when using <strong>asynchronous </strong>lambda, always attach a <strong>dead-letter queue</strong> on the function in order to save events that weren’t successfully processed.</p><p>Here is a list of services that invoke <strong>Lambda </strong>functions <strong>asynchronously</strong>:</p><ul><li>S3</li><li>EventBridge</li><li>SNS</li><li>SES</li><li>CloudFormation</li><li>CloudWatch Logs</li><li>CloudWatch Events</li><li>CodeCommit</li><li>Pool Based Invokes</li></ul><h3>Lambda Event Source Mapping with Polling Invocation</h3><p><strong>Pool-Based invocation</strong> model allows us to integrate with<strong> AWS Stream</strong> and <strong>Queue </strong>based services. These services don’t invoke Lambda function directly. Lambda will poll from the <strong>AWS SQS</strong> or Kinesis streams, retrieve records, and invoke functions.<br>AWS Lambda <strong>Event Source Mapping </strong>manages the poller and performs Synchronous invokes of our function.</p><p>Data stream or queue are read in <strong>batches</strong>, the function receives multiple items when execute function. <strong>Batch sizes </strong>can configure according to service types and after that the <strong>event source mapping </strong>will send data according to batch size. If the batch size is too large to send in one event, it has to be split up, resulting in events with smaller numbers of items than the batch size.</p><h4>SQS + Lambda</h4><p>A common scenario for <strong>Event Source Mapping </strong>with <strong>Polling Invocation </strong>is the<strong> SQS + Lambda</strong>. You can see in the image of <strong>SQS + Lambda</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*NFvUkDdpqTnVQ9qXpDz0Vw.png" /></figure><p>In the diagram, <strong>Amazon SQS</strong> has some queue records, this queue record can be added from other AWS Services like <strong>EventBridge</strong>, <strong>SNS </strong>and so on.<br>After that a lambda function <strong>poll events </strong>from <strong>AWS SQS </strong>and <strong>receive queue </strong>records with<strong> Event Source Mapping invocations</strong>. Lambda function retrieve queue records according to <strong>Batch Size </strong>property of polling configurations.</p><p>Another common scenario for <strong>Event Source Mapping </strong>with <strong>Polling Invocation</strong> is <strong>stream </strong>based processing. These are <strong>Kinesis </strong>and <strong>DynamoDB Streams </strong>that Lambda can poll stream records with Event Source Mapping invocations.</p><p>Here is a list of services that <strong>invoke Lambda functions </strong>as <strong>event source mapping</strong>:</p><ul><li>Amazon Kinesis</li><li>Amazon DynamoDB</li><li>Amazon Simple Queue Service</li></ul><p>As you can see we have we have seen <strong>AWS Lambda Invocation Types.</strong></p><p>Now let’s remember the <strong>microservices communication</strong> types, after that we will map these two concepts when designing our Serverless E-Commerce architecture.</p><h3>Microservices Communication Types — Sync or Async Communication</h3><p>We are going to learn Microservices Communication types — <strong>Synchronous </strong>— <strong>Asynchronous Communication</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dZKUyOZbuFaYS4oJ.png" /></figure><p>Client and services communicate with each other with many different types of communication. Mainly, those types of communications can be classified in two axes.</p><p><strong>Synchronous </strong>and <strong>Asynchronous</strong></p><p>Lets start to talk about Synchronous communication.</p><h3>What is Synchronous communication ?</h3><p>Basically, we can say that Synchronous communication is using <strong>HTTP </strong>or <strong>gRPC protocol </strong>for returning sync response. The client sends a request and waits for a response from the service. So that means client code block their thread, until the response reach from the server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/923/0*TvtoTNQOQ55sfxfR.png" /></figure><p>The synchronous communication protocols can be <strong>HTTP </strong>or <strong>HTTPS</strong>.<br>In <strong>synchronous communication</strong>, the client sends a request with using http protocols and waits for a response from the service.</p><p>So that means the client call the server and<strong> block client </strong>their operations.<br>The client code will continue its task when it receives the HTTP server response. So this operation called <strong>Synchronous communication</strong>. It has pros and cons that we should consider when we pick this way.</p><p>Another communication type is <strong>Asynchronous communication</strong>.</p><h3>What is Asynchronous communication ?</h3><p>Basically, In Asynchronous communication, the client sends a request but it doesn’t wait for a response from the service. So the key point here is that, the client should not have <strong>blocked </strong>a <strong>thread </strong>while waiting for a response.</p><p>The most popular protocol for this Asynchronous communications is <strong>AMQP (Advanced Message Queuing Protocol)</strong>. So with using <strong>AMQP protocols</strong>, the client sends the message with using message broker systems like <strong>Kafka </strong>and <strong>RabbitMQ queue</strong>. The message producer usually does not wait for a response. This message consume from the subscriber systems in <strong>async </strong>way, and no one waiting for response suddenly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/0*HhbI9bcaS0KZtY62.png" /></figure><p>An <strong>asynchronous communication </strong>also divided by 2 according to implementation. An asynchronous systems can be implemented in a <strong>one-to-one(queue) mode</strong> or <strong>one-to-many (topic) mode.</strong></p><p>In a <strong>one-to-one(queue)</strong> implementation there is a single producer and single receiver. But in <strong>one-to-many (topic)</strong> implementation has Multiple receivers. Each request can be processed by zero to multiple receivers. <strong>one-to-many (topic) </strong>communications must be asynchronous.</p><p>So we will see this communication with the <strong>publish/subscribe </strong>mechanism used in patterns like <strong>Event-driven microservices </strong>architecture in the upcoming articles. Basically an<strong> event-bus </strong>or <strong>message broker</strong> system is publishing events between multiple microservices, and communication provide with subscribing these events in an <strong>async way</strong>.</p><p><strong>Kafka </strong>and <strong>RabbitMQ </strong>is the best tools for this operations.</p><p>As you can see that we have understand both<strong> Microservices Communication</strong> types and <strong>AWS Lambda Invocation Types</strong>. It’s time to <strong>map </strong>these two concepts when designing our<strong> Serverless E-Commerce </strong>architecture.</p><h3>Serverless E-Commerce Microservices with Lambda Invocation Types</h3><p>If we map these Lambda Invocation Types with our microservices architecture when developing <strong>serverless e-commerce application</strong>, you can see the diagram below;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*228B5l9xcNsBEL0dbTgMUQ.png" /><figcaption>Serverless Event-driven E-commerce Microservices Architecture</figcaption></figure><p>So AWS <strong>Lambda Invocation Types </strong>will be our <strong>Microservices Communications </strong>when developing our <strong>Serverless Event-driven E-commerce</strong> Microservices application.</p><p>So during the article, we will follow these<strong> Lambda Invocation types</strong> as a M<strong>icroservices Communication</strong> <strong>types </strong>of our serverless e-commerce microservices project.</p><p><strong>Lambda Invocation Types</strong> = Sync -&gt; Async -&gt; Event Mapping</p><p>Following Microservices Communication Types for Serverless</p><ul><li><strong>Synchronous </strong>Communication</li><li><strong>Asynchronous </strong>Communication</li><li><strong>Event Source Mapping </strong>for Poling queue events</li></ul><blockquote>So how we can follow these invocation types into our application ?</blockquote><h3>Synchronous Communication for RESTful Microservices</h3><p>Synchronous commands are request/response. In a synchronous model, the client makes a request and waits for a response. We will developed <strong>RESTful Microservices </strong>with <strong>API Gateway, Lambda Functions </strong>and <strong>DynamoDB</strong>.</p><p>We called this = <strong>RESTful Microservices</strong></p><ul><li><strong>REST API</strong> and <strong>CRUD </strong>endpoints (AWS Lambda, API Gateway)</li><li><strong>Data </strong>persistence (AWS DynamoDB)</li></ul><p><strong>AWS API Gateway</strong> -for- <strong>Restful API-Driven Development </strong>for performing CRUD operations amongst lambda and DynamoDB.</p><h3>Asynchronous Communication</h3><p>In an <strong>asynchronous design</strong>, the client sends a request and may get an <strong>acknowledgement </strong>that the event was received, but it doesn’t get a response that includes the results of the request.</p><p>We will use</p><ul><li><strong>Amazon EventBridge </strong>-for- Event-Driven <strong>asynchronous communication </strong>between Microservices</li></ul><p>We will develop<strong> Amazon EventBridge </strong>with Lambda <strong>Basket microservices </strong>which publish the event in <strong>asynchronous </strong>way and this will consume by Ordering queue.</p><h3>Event Source Mapping for Polling Event Messages</h3><p>In a polling event, consumers poll the producer for messages in <strong>batches </strong>and then <strong>process </strong>the batch before returning for a new batch of records.</p><p>We will use</p><ul><li><strong>AWS SQS</strong> -for- <strong>Decouple Microservices </strong>and processing events asynchronously using queues</li></ul><p>We will develop <strong>AWS SQS</strong> with Lambda <strong>Ordering microservices </strong>which consumes by polling the event from the Ordering queue.</p><p>As you can see that we follow <strong>Serverless Microservices </strong>with AWS Lambda Invocation Types; Following Microservices Communication Types for Serverless;</p><ul><li><strong>Synchronous </strong>Communication</li><li><strong>Asynchronous </strong>Communication</li><li><strong>Event Source Mapping</strong> for Poling events</li></ul><h3>AWS Serverless Microservices for Ecommerce Application Architecture</h3><p>This is the <strong>big picture </strong>of what we are going to develop together for <strong>AWS Serverless Event-driven E-commerce Microservices </strong>application that is Step by Step Implementation together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_kdcw6XYskm6nUIydqn1Hw.png" /><figcaption>Serverless Event-driven E-commerce Microservices Architecture</figcaption></figure><p>We have followed the<strong> reference architecture</strong> above which is a <strong>real-world</strong> <strong>serverless e-commerce application</strong> and it includes;</p><ul><li><strong>REST API</strong> and <strong>CRUD </strong>endpoints with using <strong>AWS Lambda, API Gateway</strong></li><li><strong>Data persistence</strong> with using <strong>AWS DynamoDB</strong></li><li><strong>Decouple microservices </strong>with <strong>events </strong>using <strong>AWS EventBridge</strong></li><li><strong>Message Queues</strong> for cross-service communication using<strong> AWS SQS</strong></li><li><strong>Cloud stack development</strong> with <strong>IaC </strong>using <strong>AWS CloudFormation CDK</strong></li></ul><h3>Step by Step Design AWS Architectures w/ Course</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/0*XxucN1jZlJCtQCx6.png" /></figure><p><a href="https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=DECE22"><strong>I have just published a new course — AWS Serverless Microservices with Patterns &amp; Best Practices.</strong></a></p><p>In this course, we’re going to learn <strong>how to Design and Develop AWS Serverless Event-driven Microservices</strong> with using <strong>AWS Lambda</strong>, <strong>AWS DynamoDB</strong>, <strong>AWS API Gateway</strong>, <strong>AWS EventBridge</strong>,<strong> AWS SQS</strong>, <strong>AWS CDK</strong> for <strong>IaC</strong> — <strong>Infrastructure as Code</strong> tool and <strong>AWS CloudWatch</strong> for <strong>monitoring</strong>.</p><h3>Source Code</h3><p><a href="https://github.com/awsrun/aws-microservices"><strong>Get the Source Code from Serverless Microservices GitHub</strong></a> — Clone or fork this repository, if you like don’t forget the star. If you find or ask anything you can directly open issue on repository.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aee2d6326866" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aws-serverless-microservices-with-patterns-best/microservices-communications-with-aws-lambda-invocation-types-aee2d6326866">Microservices Communications with AWS Lambda Invocation Types</a> was originally published in <a href="https://medium.com/aws-serverless-microservices-with-patterns-best">AWS Serverless Microservices with Patterns &amp; Best Practices</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Security Best Practices of AWS Accounts]]></title>
            <link>https://medium.com/aws-serverless-microservices-with-patterns-best/security-best-practices-of-aws-accounts-e71321478614?source=rss----829476b5632d---4</link>
            <guid isPermaLink="false">https://medium.com/p/e71321478614</guid>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Mehmet Ozkaya]]></dc:creator>
            <pubDate>Sat, 12 Mar 2022 14:11:48 GMT</pubDate>
            <atom:updated>2022-06-04T07:32:30.707Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we are going to talk about<strong> Security Best Practices of AWS Accounts</strong> when developing <strong>Serverless E-Commerce</strong> application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*FUF48HA-fSoBHK8tuPC1Eg.png" /><figcaption><a href="https://trailhead.salesforce.com/en/content/learn/modules/aws-identity-and-access-management/set-iam-policies">https://trailhead.salesforce.com/en/content/learn/modules/aws-identity-and-access-management/set-iam-policies</a></figcaption></figure><p>We will see the way of Improving the security of your AWS account.</p><h3>Step by Step Design AWS Architectures w/ Course</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/0*n1tF3pPUdv_ZayVB.png" /></figure><p><a href="https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=JUNE22"><strong>I have just published a new course — AWS Serverless Microservices with Patterns &amp; Best Practices.</strong></a></p><p>In this course, we’re going to learn <strong>how to Design and Develop AWS Serverless Event-driven Microservices</strong> with using <strong>AWS Lambda</strong>, <strong>AWS DynamoDB</strong>, <strong>AWS API Gateway</strong>, <strong>AWS EventBridge</strong>,<strong> AWS SQS</strong>, <strong>AWS CDK</strong> for <strong>IaC</strong> — <strong>Infrastructure as Code</strong> tool and <strong>AWS CloudWatch</strong> for <strong>monitoring</strong>.</p><h3>Source Code</h3><p><a href="https://github.com/awsrun/aws-microservices"><strong>Get the Source Code from Serverless Microservices GitHub</strong></a> — Clone or fork this repository, if you like don’t forget the star. If you find or ask anything you can directly open issue on repository.</p><h3>AWS IAM Users</h3><p>When we have activated your <strong>AWS account</strong> and login the<strong> AWS console</strong>, we have login with <strong>Root user </strong>account.<br><br>But AWS has 2 main user type when login the AWS Management Console</p><ul><li><strong>AWS Root User Account</strong></li><li><strong>AWS IAM User Account</strong></li></ul><h4>AWS Root User Account</h4><p>As you guest that AWS root user account is the only one user that has <strong>full power </strong>of your AWS account and it has <strong>un-restricted access </strong>over to your AWS cloud account.<br>That means its <strong>really dangerous </strong>to use this root account for<strong> daily usage</strong> of your AWS cloud infrastructure.</p><h4>AWS IAM User Account</h4><p>Another type of user account is “<strong>AWS IAM User Account</strong>”. You can think this is <strong>sub-users</strong> under the <strong>root user account</strong> and you can define <strong>policies </strong>over this account and able to restrict over to your AWS cloud account.<br>That means “AWS IAM User Account” can create and <strong>restrict </strong>by your <strong>root account</strong>.</p><h3>Create IAM User Account and Configure for Programmatic and Console Access</h3><p>And Creating IAM User Account is the<strong> best practice</strong> to follow when you first active your AWS account. <br>After active our account, We have got only a <strong>AWS root user,</strong> and the first thing We should do<strong> create “IAM User” </strong>under <strong>root account </strong>and use this “IAM User” for our <strong>daily usage </strong>of AWS console.<br>Even you have the only <strong>one user </strong>to use AWS account creating a <strong>dedicating </strong>user <strong>account </strong>is one of the first thing the we should do after active our <strong>AWS account</strong>. This is the <strong>security best practices</strong> that we should follow.</p><p>So we should <strong>create user-specific IAM User accounts</strong> under root user that they have own login and passwords.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*FUF48HA-fSoBHK8tuPC1Eg.png" /><figcaption><a href="https://trailhead.salesforce.com/en/content/learn/modules/aws-identity-and-access-management/set-iam-policies">https://trailhead.salesforce.com/en/content/learn/modules/aws-identity-and-access-management/set-iam-policies</a></figcaption></figure><p>Because <strong>root account</strong> has <strong>power </strong>of <strong>full access</strong> that can change your payment information changing your password removing users and lots of dangerous things.</p><h3>AWS Console Sign-in Page</h3><p>If you open to sign-in console page, You will see the option of</p><ul><li>Root User</li><li>IAM User</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*_K3NvxpYocjAA687DB_qWQ.png" /></figure><p><strong>IAM stands for Identity and Access Management (IAM)</strong> and as the name suggest its managing identity and access of AWS resources. We are going to <strong>create our IAM User</strong>, give required permissions and login with IAM User.</p><p>But before that I would like to share you other <strong>security best practices</strong> that you should consider about AWS accounts.</p><p>As you know that we have followed this steps<br><a href="https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/">https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/</a></p><p>At the end of the page, you can see the part of ;</p><p><strong>Improving </strong>the <strong>security </strong>of your <strong>AWS account</strong><br>To help secure your AWS resources, see Security best practices in <strong>AWS Identity and Access Management (IAM).</strong></p><p>If you go to this link :<br><a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#delegate-using-roles">https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#delegate-using-roles</a></p><h4>Security best practices in IAM</h4><p>In this page you can see lots of <strong>security best practices </strong>that&#39;s very important to follow for the AWS accounts.</p><p>For example;</p><ul><li><strong>Lock </strong>away your AWS account root user access keys</li><li>Grant<strong> least privilege</strong></li><li>Get started <strong>using permissions </strong>with AWS managed policies</li><li>Use <strong>access levels </strong>to review IAM permissions</li><li>Remove <strong>unnecessary credentials</strong><br>and so on..</li></ul><p>But For our application, its enough to create “IAM User” under the root user.<br>We will create “IAM User” and follow the course with “IAM User”.</p><h3>Programmatic and Console Access</h3><p>When creating user-specific AWS account We should Define Programmatic and Console Access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-qjMeQFhDeENdjMQslVyCA.png" /></figure><p>Also Programmatic access is required for our <strong>Serverless E-commerce</strong> application, because we will use all interactions with AWS resources like AWS Console, AWS CLI, AWS CDK and AWS SDK.</p><h3>AWS Serverless Microservices for Ecommerce Application Architecture</h3><p>Here, you can find the main overall <strong>Serverless Architecture</strong> for our application that we will follow these steps and build tihs Serverless E-Commerce Microservices Architecture.</p><p>This is the <strong>big picture </strong>of what we are going to develop together for <strong>AWS Serverless Event-driven E-commerce Microservices </strong>application that is Step by Step Implementation together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_kdcw6XYskm6nUIydqn1Hw.png" /><figcaption>Serverless Event-driven E-commerce Microservices Architecture</figcaption></figure><p>We have followed the<strong> reference architecture</strong> above which is a <strong>real-world</strong> <strong>serverless e-commerce application</strong> and it includes;</p><ul><li><strong>REST API</strong> and <strong>CRUD </strong>endpoints with using <strong>AWS Lambda, API Gateway</strong></li><li><strong>Data persistence</strong> with using <strong>AWS DynamoDB</strong></li><li><strong>Decouple microservices </strong>with <strong>events </strong>using <strong>AWS EventBridge</strong></li><li><strong>Message Queues</strong> for cross-service communication using<strong> AWS SQS</strong></li><li><strong>Cloud stack development</strong> with <strong>IaC </strong>using <strong>AWS CloudFormation CDK</strong></li></ul><h3>Step by Step Design AWS Architectures w/ Course</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/0*yq8HSOMHdPKFZdTO.png" /></figure><p><a href="https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=JUNE22"><strong>I have just published a new course — AWS Serverless Microservices with Patterns &amp; Best Practices.</strong></a></p><p>In this course, we’re going to learn <strong>how to Design and Develop AWS Serverless Event-driven Microservices</strong> with using <strong>AWS Lambda</strong>, <strong>AWS DynamoDB</strong>, <strong>AWS API Gateway</strong>, <strong>AWS EventBridge</strong>,<strong> AWS SQS</strong>, <strong>AWS CDK</strong> for <strong>IaC</strong> — <strong>Infrastructure as Code</strong> tool and <strong>AWS CloudWatch</strong> for <strong>monitoring</strong>.</p><h3>Source Code</h3><p><a href="https://github.com/awsrun/aws-microservices"><strong>Get the Source Code from Serverless Microservices GitHub</strong></a> — Clone or fork this repository, if you like don’t forget the star. If you find or ask anything you can directly open issue on repository.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e71321478614" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aws-serverless-microservices-with-patterns-best/security-best-practices-of-aws-accounts-e71321478614">Security Best Practices of AWS Accounts</a> was originally published in <a href="https://medium.com/aws-serverless-microservices-with-patterns-best">AWS Serverless Microservices with Patterns &amp; Best Practices</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Access Types — Programmatic and Management Console Access]]></title>
            <link>https://medium.com/aws-serverless-microservices-with-patterns-best/aws-access-types-programmatic-and-management-console-access-134cb4ea2d2a?source=rss----829476b5632d---4</link>
            <guid isPermaLink="false">https://medium.com/p/134cb4ea2d2a</guid>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[api-gateway]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Mehmet Ozkaya]]></dc:creator>
            <pubDate>Sat, 12 Mar 2022 14:10:28 GMT</pubDate>
            <atom:updated>2023-01-06T08:45:00.216Z</atom:updated>
            <content:encoded><![CDATA[<h3>AWS Access Types — Programmatic and Management Console Access</h3><p>In this article, we are going to learn<strong> AWS Access Types — Programmatic and Management Console Access</strong> when developing <strong>Serverless E-Commerce</strong> application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1zsFKvNZRgXBdNv0ekr7jQ.png" /><figcaption>AWS Access Types — Programmatic and Management Console Access</figcaption></figure><p>As you know that, in the previous article, when we create a user, we have an option about AWS access types and we have select both</p><ul><li><strong>Programmatic Access </strong>and</li><li><strong>AWS Management Console Access</strong></li></ul><h3>Step by Step Design AWS Architectures w/ Course</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/0*CAH8DU9fCegGNqtC.png" /></figure><p><a href="https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=JANU23"><strong>I have just published a new course — AWS Serverless Microservices with Patterns &amp; Best Practices.</strong></a></p><p>In this course, we’re going to learn <strong>how to Design and Develop AWS Serverless Event-driven Microservices</strong> with using <strong>AWS Lambda</strong>, <strong>AWS DynamoDB</strong>, <strong>AWS API Gateway</strong>, <strong>AWS EventBridge</strong>,<strong> AWS SQS</strong>, <strong>AWS CDK</strong> for <strong>IaC</strong> — <strong>Infrastructure as Code</strong> tool and <strong>AWS CloudWatch</strong> for <strong>monitoring</strong>.</p><h3>Source Code</h3><p><a href="https://github.com/awsrun/aws-microservices"><strong>Get the Source Code from Serverless Microservices GitHub</strong></a> — Clone or fork this repository, if you like don’t forget the star. If you find or ask anything you can directly open issue on repository.</p><h3>Select AWS Account Type</h3><p>You can also see the option when creating user. There is a “<strong>Select AWS Account Type</strong>” section, and in this section we can select access types.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-qjMeQFhDeENdjMQslVyCA.png" /></figure><p>If you read detail of “<strong>Programmatic access</strong>” you can see that</p><ul><li>Enables <strong>access key ID</strong> and <strong>secret access key</strong> for the <strong>AWS API, CLI, SDK,</strong> and other development tools.</li></ul><p>So you can see these important keywords; <strong>AWS API, CLI, SDK </strong>and other development tools.</p><p>So let me deep dive what is this access types and when we use this access types. Also when developing our <strong>Serverless E-commerce application</strong>, we will almost use all of these programmatic access types and of course use AWS Management Console every time.</p><h3>Access AWS Resources with APIs</h3><p>Lets think about <strong>AWS </strong>core services into the one <strong>box</strong>. This <strong>box </strong>will represent whole <strong>AWS cloud services </strong>implementation from AWS. You can see in the below image, There are lots of services into AWS but I put some of them in here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JHXHsHgiHhUeiA4G5Unxpg.png" /></figure><p>And AWS give us some <strong>APIs </strong>to create and <strong>manage </strong>some <strong>resources </strong>on AWS Cloud. So that means <strong>AWS exposes APIs </strong>in order to give ability to manage resources.<br>You can see the image above,</p><ul><li><strong>AWS expose APIs</strong> that we can invoke <strong>create </strong>and <strong>manage AWS services,</strong><br> for example <strong>create S3 bucket</strong>, <strong>invoke lambda</strong> function asynchronously,<br> <strong>publish event </strong>to event bridge and so on.</li></ul><blockquote>So how we can invoke this AWS APIs for interacting actual AWS resources ?</blockquote><h3>Invoke AWS APIs with Different Ways</h3><p>Aws gives us <strong>2 main way</strong> to call their APIs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*mzo8YLDLq8NpIr1qlhx95Q.png" /></figure><p><strong>1- AWS Management Console Access</strong>; which we have already see that you can think as a web application allows us to manage AWS resources for particular AWS accounts.<br><strong>2- Programmatic Access;</strong> which gives us to manage AWS resources from our development environments and manage by writing codes.</p><p>So these 2 access is the only way to interact AWS resources.</p><h3><strong>AWS Management Console Access</strong></h3><p>First one is very common and everyone reach the <strong>AWS management console</strong>, right after the account creation. So I am not going to give deep explanation for it, you can think this is an <strong>AWS web application</strong> that consumes <strong>AWS cloud backend services</strong> in order to manage actual infrastructure cloud resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gYJ6vTZMOFckhGID-RzHwQ.png" /></figure><h3><strong>Programmatic Access</strong></h3><p>Second one is <strong>Programmatic access </strong>and it is also very important when it comes to develop enterprise level applications on AWS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BdwsGf7W5UjWGQDZfpYlrQ.png" /></figure><p><strong>Programmatic access;</strong> which gives us to <strong>manage AWS resources</strong> from our <strong>development </strong>environments and manage by<strong> writing codes.</strong></p><p>This part is really helpful when you manage large scale of resources on AWS.</p><p>I would like to show breakdowns of Programmatic accesses;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*XwqLmOZoawCGLbl6D1IggQ.png" /><figcaption>Programmatic access of AWS</figcaption></figure><h4>AWS CLI</h4><p><strong>The AWS Command Line Interface (CLI)</strong> is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.</p><p>First you should download <strong>AWS CLI</strong> and you can use commands very easily;<br>$ aws ec2 describe-instances<br>$ aws ec2 start-instances — instance-ids i-1348636c</p><h4>AWS SDK</h4><p><strong>AWS SDK — software development kit</strong> simpliﬁes use of AWS Services by providing a set of libraries that are consistent and familiar for developers. <br>It provides <strong>support </strong>for <strong>APIs </strong>of AWS.<br>And there are several programming languages <strong>AWS SDK packages</strong> that you can use, like Java, NodeJS, JavaScript, .NET, go and so on..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*5HZ2VUURJHdMC5r3bp9_Dg.png" /><figcaption><a href="https://aws.amazon.com/blogs/developer/modular-aws-sdk-for-javascript-release-candidate/">https://aws.amazon.com/blogs/developer/modular-aws-sdk-for-javascript-release-candidate/</a></figcaption></figure><p>Also you can see <strong>Tools </strong>to <strong>Build </strong>on <strong>AWS</strong>. Tools for developing and managing applications on AWS. Let open website and see all tools for managing resources on AWS;<br> <a href="https://aws.amazon.com/tools/">https://aws.amazon.com/tools/</a></p><p>We can browse with <strong>2 types</strong>;</p><ul><li>Browse by <strong>Programming Language</strong></li><li>Browse by <strong>Tool Type</strong></li></ul><p>Most common use case of <strong>AWS SDKs</strong>, when you have infrastructure exist on AWS, you can access these infrastructure resource from your development repositories.<br>For example, if you have <strong>DynamoDB </strong>database under your AWS account,<br> you can <strong>perform crud operations </strong>in your application code with using <strong>AWS SDK libraries</strong>. We will also use AWS SDK in our microservices codes when interacting with AWS DynamoDB, EventBridge and SQS.</p><h4>AWS CloudFormation — IaC</h4><p><strong>AWS CloudFormation</strong> is an infrastructure as code (<strong>IaC</strong>) service that allows you to easily model, provision, and manage AWS resources. AWS <strong>CloudFormation </strong>provides easy way to <strong>create </strong>a <strong>collection </strong>of related AWS resources, and provision and manage them. This is a <strong>devops tool </strong>that provide to create<strong> infrastructure as code.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*gihWzV0vFU71GDy8V-hgNQ.png" /><figcaption><a href="https://aws.amazon.com/cloudformation/">https://aws.amazon.com/cloudformation/</a></figcaption></figure><p>Under “<strong>AWS CloudFormation</strong>” we have 2 breakdowns;</p><ul><li><strong>AWS SAM</strong></li><li><strong>AWS CDK</strong></li></ul><p>These are the tools that use AWS CloudFormation behind the scenes. <br>But also provide great benefits to developers when creating collection of resources.</p><p>When developing our <strong>Serverless E-Commerce </strong>application, I am not going to use “AWS SAM”. Instead, we will focus on “<strong>AWS CDK</strong>”.</p><h4>AWS CDK</h4><p><strong>The AWS Cloud Development Kit (AWS CDK)</strong> is an open-source software development framework to define your cloud application resources using familiar programming languages.</p><figure><img alt="Use AWS CDK to Write Amazon API Gateway service for Uploading Objects to AWS  S3 | by Utkarsha Bakshi | Geek Culture | Medium" src="https://cdn-images-1.medium.com/proxy/1*e5YMnDmcJHAtj1Zqh1plkQ.png" /></figure><p>We can Provisioning cloud infrastructure with using Java, Typescript, JavaScript, .NET, go and so on.</p><p>When developing our <strong>Serverless E-commerce</strong> application, we will install and use all of these access types and interact with AWS resources.</p><p>Let me recap all these information for our project development in the course.</p><p>First of all we will use “<strong>AWS Management Console</strong>” when exploring AWS services, like when we learning <strong>AWS EventBridge</strong>, we will define rules and targets via “<strong>AWS Management Console</strong>”.<br> But this is only exploration.</p><p>So when it comes to developing Serverless projects,</p><p>we will follow 2 best practices,<br><strong> 1- Infrastructure as code (IaC) with using AWS CDK</strong> — of course AWS CDK uses CloudFormation behind the scene. Basically we developed whole picture with typescript coding using AWS CDK.</p><p><strong>2- Developing Microservices Interact AWS resources with AWS SDK</strong> (Software Development Kit). So that means after infrastructure ready and its up and running, we will connect and perform our use cases.<br>For example we have use case about e-commerce basket which&#39;s is add basket / remove basket and checkout basket. So when we adding item into basket, we will interact with basket table in DynamoDB from our basket microservices lambda functions.</p><h3>AWS Serverless Microservices for Ecommerce Application Architecture</h3><p>Here, you can find the main overall <strong>Serverless Architecture</strong> for our application that we will follow these steps and build tihs Serverless E-Commerce Microservices Architecture.</p><p>This is the <strong>big picture </strong>of what we are going to develop together for <strong>AWS Serverless Event-driven E-commerce Microservices </strong>application that is Step by Step Implementation together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_kdcw6XYskm6nUIydqn1Hw.png" /><figcaption>Serverless Event-driven E-commerce Microservices Architecture</figcaption></figure><p>We have followed the<strong> reference architecture</strong> above which is a <strong>real-world</strong> <strong>serverless e-commerce application</strong> and it includes;</p><ul><li><strong>REST API</strong> and <strong>CRUD </strong>endpoints with using <strong>AWS Lambda, API Gateway</strong></li><li><strong>Data persistence</strong> with using <strong>AWS DynamoDB</strong></li><li><strong>Decouple microservices </strong>with <strong>events </strong>using <strong>AWS EventBridge</strong></li><li><strong>Message Queues</strong> for cross-service communication using<strong> AWS SQS</strong></li><li><strong>Cloud stack development</strong> with <strong>IaC </strong>using <strong>AWS CloudFormation CDK</strong></li></ul><h3>Step by Step Design AWS Architectures w/ Course</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/0*uG1GEDnxquafxQbt.png" /></figure><p><a href="https://www.udemy.com/course/aws-serverless-microservices-lambda-eventbridge-sqs-apigateway/?couponCode=JANU23"><strong>I have just published a new course — AWS Serverless Microservices with Patterns &amp; Best Practices.</strong></a></p><p>In this course, we’re going to learn <strong>how to Design and Develop AWS Serverless Event-driven Microservices</strong> with using <strong>AWS Lambda</strong>, <strong>AWS DynamoDB</strong>, <strong>AWS API Gateway</strong>, <strong>AWS EventBridge</strong>,<strong> AWS SQS</strong>, <strong>AWS CDK</strong> for <strong>IaC</strong> — <strong>Infrastructure as Code</strong> tool and <strong>AWS CloudWatch</strong> for <strong>monitoring</strong>.</p><h3>Source Code</h3><p><a href="https://github.com/awsrun/aws-microservices"><strong>Get the Source Code from Serverless Microservices GitHub</strong></a> — Clone or fork this repository, if you like don’t forget the star. If you find or ask anything you can directly open issue on repository.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=134cb4ea2d2a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aws-serverless-microservices-with-patterns-best/aws-access-types-programmatic-and-management-console-access-134cb4ea2d2a">AWS Access Types — Programmatic and Management Console Access</a> was originally published in <a href="https://medium.com/aws-serverless-microservices-with-patterns-best">AWS Serverless Microservices with Patterns &amp; Best Practices</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>