<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Zineb El Bachiri</title>
    <description>The latest articles on Forem by Zineb El Bachiri (@gozineb).</description>
    <link>https://forem.com/gozineb</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F865340%2F45f2caff-90b2-4150-8678-79f7061c72e3.jpeg</url>
      <title>Forem: Zineb El Bachiri</title>
      <link>https://forem.com/gozineb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/gozineb"/>
    <language>en</language>
    <item>
      <title>Level Up Your AWS CDK Development: Demystifying integ-runner and integ-test</title>
      <dc:creator>Zineb El Bachiri</dc:creator>
      <pubDate>Fri, 21 Jul 2023 10:53:33 +0000</pubDate>
      <link>https://forem.com/slsbytheodo/level-up-your-aws-cdk-development-demystifying-integ-runner-and-integ-test-542j</link>
      <guid>https://forem.com/slsbytheodo/level-up-your-aws-cdk-development-demystifying-integ-runner-and-integ-test-542j</guid>
      <description>&lt;p&gt;Do you ever get frustrated testing your infrastructure and resources' behavior, only to discover errors after deployment? 😫 As a developer, I feel your pain. Testing is an essential aspect of software development that can be complex and time-consuming. But fear not! AWS CDK offers two powerful testing tools - integ-runner and aws-cdk integ-test library - to streamline the testing process. 🧪🚀&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fgozineb%2Farticles%2Fmaster%2Fblog-posts%2Finteg-test%2FintroArticle%2Fassets%2Fdev-working-with-aws-cdk.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fgozineb%2Farticles%2Fmaster%2Fblog-posts%2Finteg-test%2FintroArticle%2Fassets%2Fdev-working-with-aws-cdk.jpg" alt="Meme: Don't be confused while working with AWS CDK - use integ test"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This article kicks off a series dedicated to integ-test. Here, we'll unravel the underlying principles of integ-test and delve into the theory surrounding tests. In the next article, I'll walk you through a CDK App example repository that illustrates how to implement and use these tools. By the conclusion of this series, you'll have a clear understanding of how AWS CDK integration tests can help you build better infrastructure with less stress! 🎉&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Access the &lt;a href="https://github.com/gozineb/aws-cdk-app-integration-tests" rel="noopener noreferrer"&gt;Github repository&lt;/a&gt; used in this series.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the Value of Integration Tests
&lt;/h2&gt;

&lt;p&gt;You can use unit tests to check that your DynamoDB table or Lambda function is correctly set, but you can't use unit tests to check if they interact correctly with each other. That's where integration tests come in. And as nothing is more self-explanatory than a meme:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fgozineb%2Farticles%2Fmaster%2Fblog-posts%2Finteg-test%2FintroArticle%2Fassets%2F2-unit-tests-0-integration-test.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fgozineb%2Farticles%2Fmaster%2Fblog-posts%2Finteg-test%2FintroArticle%2Fassets%2F2-unit-tests-0-integration-test.gif" alt="Please, don't forget integration tests."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Harness the Latest Tools to Test Your AWS CDK Constructs
&lt;/h2&gt;

&lt;p&gt;AWS Cloud Development Kit (CDK) enables developers to define cloud infrastructure as code using familiar programming languages like TypeScript. 👩‍💻🚀&lt;/p&gt;

&lt;p&gt;As we develop a CDK app or library, two critical questions often arise at each phase:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Have I inadvertently introduced flaws in my infrastructure? 🤔&lt;/li&gt;
&lt;li&gt;While my infrastructure seems fine, does everything that functioned earlier still operate as expected? 🧐&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In the context of AWS CDK integration tests, there are two types of tests that can help answer these questions and that will bring you answer: snapshot tests and assertion tests. ✅🔍&lt;/p&gt;

&lt;p&gt;Snapshot tests are useful for checking your CloudFormation templates, while assertion tests are designed to test the behavior of your deployed resources. Combined, they provide a comprehensive testing approach:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fgozineb%2Farticles%2Fmaster%2Fblog-posts%2Finteg-test%2FintroArticle%2Fassets%2Fintegrations-tests-overview.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fgozineb%2Farticles%2Fmaster%2Fblog-posts%2Finteg-test%2FintroArticle%2Fassets%2Fintegrations-tests-overview.png" alt="Schema: snapshot and assertion testing tools"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To write integration tests, we'll be utilizing the IntegTest library. Subsequently, we'll leverage integ-runner for running and managing these tests.&lt;/p&gt;

&lt;h2&gt;
  
  
  Unpacking Our Testing Tools
&lt;/h2&gt;

&lt;p&gt;Let's go on a Github repository adventure! Take a look at this &lt;a href="https://github.com/gozineb/aws-cdk-app-integration-tests" rel="noopener noreferrer"&gt;repo&lt;/a&gt;. Inside the 'tests' folder, you'll find our various integration tests:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fgozineb%2Farticles%2Fmaster%2Fblog-posts%2Finteg-test%2FintroArticle%2Fassets%2Fgithub_repo_files.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fgozineb%2Farticles%2Fmaster%2Fblog-posts%2Finteg-test%2FintroArticle%2Fassets%2Fgithub_repo_files.png" alt="Structure of the Github repository"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is an example of a typical test file, it includes the declaration of a new App, a new stack to feed to integ-test and as many assertion tests as required.&lt;/p&gt;

&lt;p&gt;Once we declare our test file with integ-tests, we use &lt;code&gt;aws-cdk-lib/assertions&lt;/code&gt; to add assertions, and then we run it with integ-runner! 🏃‍♀️🏃‍♂️&lt;/p&gt;

&lt;h3&gt;
  
  
  Snapshot Testing
&lt;/h3&gt;

&lt;p&gt;Snapshots allow you to avoid re-running all your tests every time. Here's how it works:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fgozineb%2Farticles%2Fmaster%2Fblog-posts%2Finteg-test%2FintroArticle%2Fassets%2Fsnapshot_testing.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fgozineb%2Farticles%2Fmaster%2Fblog-posts%2Finteg-test%2FintroArticle%2Fassets%2Fsnapshot_testing.png" alt="Schema: snapshot testing"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To re-run integration tests for failed tests, run:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;integ-runner --update-on-failed&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will run the snapshot tests and collect all the failed tests. It will then re-execute the integration test for the failed tests. If successful, the new snapshot will be saved.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Snapshot testing is quite common (e.g., &lt;a href="https://jestjs.io/docs/snapshot-testing" rel="noopener noreferrer"&gt;with react components using jest&lt;/a&gt;). It is often overlooked by developers when they automatically use the &lt;code&gt;--update-on-failed&lt;/code&gt; option.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Assertion Testing
&lt;/h3&gt;

&lt;p&gt;In AWS CDK, assertion testing is used to test the behavior of deployed resources. Developers define an integration test using the &lt;code&gt;IntegTest&lt;/code&gt; construct. Then, using the different integ-test tools, API calls are made, and once the request has timed out, we can check that the actions resulted in the expected events.&lt;/p&gt;

&lt;p&gt;By using &lt;code&gt;aws-cdk-lib/assertions&lt;/code&gt;, we can add fine-grained assertions to test specific aspects of the generated CloudFormation template, such as "this resource has this property with this value." These assertions validate the infrastructure before the deployment is considered successful.&lt;/p&gt;

&lt;p&gt;Here's an overview of integ-test and its assertion tools:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fgozineb%2Farticles%2Fmaster%2Fblog-posts%2Finteg-test%2FintroArticle%2Fassets%2Fassertion_tools.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fgozineb%2Farticles%2Fmaster%2Fblog-posts%2Finteg-test%2FintroArticle%2Fassets%2Fassertion_tools.png" alt="Schema: Assertion testing tools"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Congratulations! 🎉 You now have a good understanding of the importance of integration testing in AWS CDK development and the available tools to harness the power of testing.&lt;/p&gt;

&lt;p&gt;Stay tuned for the upcoming article, where you'll be guided through the process of becoming a proficient integration tester in the world of AWS CDK! ✨&lt;/p&gt;

</description>
      <category>serverless</category>
      <category>cdk</category>
      <category>aws</category>
      <category>javascript</category>
    </item>
    <item>
      <title>That one AWS Lambda hidden configuration that will make you a Hero - Guardian is watching over you</title>
      <dc:creator>Zineb El Bachiri</dc:creator>
      <pubDate>Fri, 05 Aug 2022 16:19:22 +0000</pubDate>
      <link>https://forem.com/slsbytheodo/that-one-aws-lambda-hidden-configuration-that-will-make-you-a-hero-guardian-is-watching-over-you-5gi7</link>
      <guid>https://forem.com/slsbytheodo/that-one-aws-lambda-hidden-configuration-that-will-make-you-a-hero-guardian-is-watching-over-you-5gi7</guid>
      <description>&lt;p&gt;&lt;em&gt;This article is part of a series on &lt;a href="https://www.npmjs.com/package/@kumo-by-theodo/guardian" rel="noopener noreferrer"&gt;Guardian&lt;/a&gt;, an open-source, highly configurable, automated best-practice audit tool for AWS serverless architectures.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When I first started working on Guardian, I realized that AWS was releasing super cool features at an incredible speed but that an important number of them would go unnoticed by developers. This is especially the case for new options that can not be set by default to avoid breaking changes on AWS APIs. One of them is the introduction in 2021 of the new Graviton2 processor architecture in the AWS ephemeral compute service: Lambda. If you don't want to miss out on the performance, sustainability and cost saving, keep on reading!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fgozineb%2Farticles%2Fmaster%2Fblog-posts%2Fguardian%2FuseArm%2Fassets%2Fimage.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fgozineb%2Farticles%2Fmaster%2Fblog-posts%2Fguardian%2FuseArm%2Fassets%2Fimage.png" alt="Meme: Lambda running on Graviton (dog on steroids)  vs Plain old Lambda (sad little doggo with tear)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Use the latest infrastructures for your Lambdas: Graviton processors
&lt;/h2&gt;

&lt;p&gt;The X86 architecture is widely adopted in the computer science field and is the go-to choice when it comes to computers and servers hardware. Yet, in the last couple of years, ARM have seduced more than one. AWS is one of the early adopters of ARM architecture in their on-demand cloud computing offer. In 2018, they unveiled their Graviton processors using 64-bit ARM chips for their compute offering stream (AWS EC2). In 2021, AWS Lambda followed up and now AWS Lambda followed up and functions could also be powered by AWS Graviton2 processor. Now, AWS Graviton3 processors are the latest in the AWS Graviton family and is ready to use on EC2.&lt;/p&gt;

&lt;h2&gt;
  
  
  Improve your performance with ARM based technology
&lt;/h2&gt;

&lt;p&gt;The family of processors has brought revolution by hardware as it offers reduced costs and latency while increasing performance and scalability.&lt;/p&gt;

&lt;h3&gt;
  
  
  Think performance
&lt;/h3&gt;

&lt;p&gt;Graviton2 has shown impressive performance improvements in comparison to the X86 processor family, this is especially the case with higher loads and concurrencies. Though it is difficult to assign an overall improvement percentage, it is undeniable that using ARM processors will definitely boost your app's performance. Graviton3 is previewed to give 25% performance improvement to the previous graviton2 according to AWS. ARM also provides more predictable performance with less latency and disruptions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Think sustainability
&lt;/h3&gt;

&lt;p&gt;Your software projects —serverless or not— ultimately run on hardware and as your projects continue to grow, so does the reliance on and the use of the hardware. A 64-bit ARM core undertakes operations faster than x86_64: the task gets done quicker, and then the chip shuts down. Using an ARM architecture, you are guaranteed to reduce your carbon footprint.&lt;/p&gt;

&lt;h3&gt;
  
  
  Think costs
&lt;/h3&gt;

&lt;p&gt;A quicker run time rhymes with saving costs. &lt;a href="https://redpanda.com/blog/aws-graviton-2-arm-vs-x86-comparison" rel="noopener noreferrer"&gt;RedPanda&lt;/a&gt;, a streaming platform for mission-critical workloads, measured key performance metrics using the storage intensive workload platform as a target application. The results show a 20% price to performance advantage with Graviton2 compared to x86.&lt;/p&gt;

&lt;h2&gt;
  
  
  Specify your Architecture
&lt;/h2&gt;

&lt;p&gt;The AWS Lambda service offers the possibility to use the AWS Graviton2 processor. By default, architecture is set to x86_64 to avoid breaking changes as it was the only available option up to a year ago. That is why you should specify the architecture in your lambda.&lt;/p&gt;

&lt;p&gt;Switching all functions to AWS Graviton2 processor is easily done by specifying the architecture at the provider level whether you're using serverless-framework, cdk, san, sst or any other. With serverless-framework for example, you'll have to modify your serverless.yml as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;// serverless.yml&lt;/span&gt;

&lt;span class="na"&gt;provider&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="s"&gt;...&lt;/span&gt;
  &lt;span class="s"&gt;architecture&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt; &lt;span class="s"&gt;arm64&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Only one line of code to add and huge benefits.&lt;/p&gt;

&lt;p&gt;You can (almost) always migrate your project from previous x86_64 to ARM64. Here is a &lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/foundation-arch.html#foundation-arch-adv" rel="noopener noreferrer"&gt;link&lt;/a&gt; to the AWS documentation with migration instructions for Lambda Functions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Easily monitor Lambda Functions Architecture with Guardian 🛡️
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/@kumo-by-theodo/guardian" rel="noopener noreferrer"&gt;Guardian&lt;/a&gt; now offers a &lt;strong&gt;new rule&lt;/strong&gt; guiding you to specify the architecture of your lambda functions.&lt;/p&gt;

&lt;p&gt;Guardian also comes with &lt;strong&gt;many other rules&lt;/strong&gt; to help you make the best decisions for your Serverless project. It will help you identify where your deployed resources can be optimized to achieve better performance at a lower cost.&lt;/p&gt;

&lt;h3&gt;
  
  
  Guardian how-to
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @kumo-by-theodo/guardian
npx guardian -p &amp;lt;your_aws_profile&amp;gt; -c &amp;lt;your_stack_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Guardian is available on &lt;a href="https://www.npmjs.com/package/@kumo-by-theodo/guardian" rel="noopener noreferrer"&gt;NPM&lt;/a&gt;. You will find instructions to use Guardian in your CI.&lt;/p&gt;

&lt;h2&gt;
  
  
  See also
&lt;/h2&gt;

&lt;p&gt;Switching your apps architecture to ARM64 is a great step into making serverless sustainable. You can find more actions to take to make your apps even greener in this &lt;a href="https://dev.to/kumo/you-thought-serverless-was-green-here-is-how-to-really-make-it-sustainable-1m0p"&gt;article&lt;/a&gt; by Charles for &lt;a href="https://dev.to/kumo"&gt;Kumo&lt;/a&gt;. Of course, guardian is watching over you, so &lt;a href="https://github.com/Kumo-by-Theodo/guardian" rel="noopener noreferrer"&gt;open an issue&lt;/a&gt; or leave a comment below if you think of any new rule to keep track of!&lt;/p&gt;

</description>
      <category>serverless</category>
      <category>lambda</category>
      <category>sustainability</category>
      <category>aws</category>
    </item>
  </channel>
</rss>
