<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rosina Garagorry on Medium]]></title>
        <description><![CDATA[Stories by Rosina Garagorry on Medium]]></description>
        <link>https://medium.com/@rosina.garagorry?source=rss-a59f7a93fbc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Tplvjg-R3p6VnUjq</url>
            <title>Stories by Rosina Garagorry on Medium</title>
            <link>https://medium.com/@rosina.garagorry?source=rss-a59f7a93fbc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 03:12:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rosina.garagorry/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Active-active API Gateway: a step-by-step guide with terraform code]]></title>
            <link>https://medium.com/globant/active-active-api-gateway-a-step-by-step-guide-with-terraform-code-9882d6c2609a?source=rss-a59f7a93fbc------2</link>
            <guid isPermaLink="false">https://medium.com/p/9882d6c2609a</guid>
            <category><![CDATA[cloudops]]></category>
            <category><![CDATA[globant]]></category>
            <category><![CDATA[high-availability]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Rosina Garagorry]]></dc:creator>
            <pubDate>Thu, 15 Sep 2022 21:53:28 GMT</pubDate>
            <atom:updated>2022-09-15T21:53:28.723Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d2VZFb-qLkQ-gjPb" /></figure><p>Application infrastructure and disaster recovery strategies vary, depending on the needs of each company. What’s the point of having rugged code when you don’t have a rugged infrastructure? Adopting an active-active strategy, though more expensive than other strategies such as pilot light or warm stand by; ensures that our customers are not affected by failures in our primary site, and they are always served by the region with the least latency. Here we will explain the step-by-step of deploying an active-active API gateway and share some useful code.</p><p>The following sections will be reviewed in this article:</p><ul><li>Architecture</li><li>Deployment of needed resources</li><li>Conclusions</li></ul><h3>Architecture</h3><p>The infrastructure we will deploy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cFsWS7FI8m2SWb6d" /></figure><p>The flow would be as follows:</p><ul><li>The users go to our-site</li><li>Route53 redirects to the region with the least latency or if one of the regions is down, toe the one that’s working</li><li>HTTP API authenticates the user against a third-party OAuth</li><li>If the user is correctly authenticated, it will redirect to the load balancer</li><li>The load balancer will check against the WAF rules if it is allowed to proceed</li><li>If allowed to proceed, the user will be directed to the corresponding application</li></ul><p>Since Amazon Cognito doesn’t support active-active API Gateway configuration, we are using a custom solution that provides a JSON Web Token (JWT) for authentication. This custom solution pushed us towards deciding to implement an HTTP API instead of a Rest Api. We could have used the JWT authorizer with a Lambda, but we preferred this approach that’s more straightforward. Besides, HTTP apis are cheaper than their Rest counterparts (for an AWS comparison between APIs, you can refer to the official documentation <a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html">here</a>).</p><h3>Deploying resources</h3><ol><li>Create a hosted zone</li></ol><p>Unless you already have your hosted zone where you want to create your records, you should create one. To do so, go to your AWS console, Route53 and click on create hosted zone:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q3kAhOmHS2SsiiyU" /></figure><p>In your domain name, you’ll need to indicate the domain name for your hosted zone. A domain name is the suffix that all your subdomains will have. Example, if your domain name is my-domain.com, then you will be able to create subdomains such as cool.my-domain.com and supercool.my-domain.com. Also, you need to mark your hosted zone as Public, since we want the zone to be publicly accessible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RHgh_xZ2pgQMlgSh" /></figure><p>When creating a hosted zone, AWS automatically creates two records: one of type NS and another one of type SOA. NS stands for nameserver, and refers to the servers that contain your DNS. SOA stands for Start of Authority and has all the administrative information associated with the domain name, such as your name and contact information (this is related to RFC 1035 rules, you can read more <a href="https://www.rfc-editor.org/rfc/rfc1035">here</a>).</p><p>2. Create API and API records</p><p>Once you have created your hosted zone, first you need to create your custom domain name and the API you’d like to expose. Therefore, you should go to API gateway console.</p><p>3. Create a domain name, that matches the suffix of your hosted zone</p><p>When creating your domain name, you will have to indicate: its name, the minimum TLS version, the endpoint configuration and if it has an ACM certificate, you will have to select it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WDAfKyPbr6-keIww" /></figure><p>4. Create HTTP API</p><p>When creating an HTTP API, you will be required to:</p><ul><li>Add an integration</li><li>Indicate the HTTP API name</li><li>Configure routes</li><li>Add a VPC link</li></ul><p>In a few words, how does this work? The user will make a request to your {yourcustomdomainname}/{api}. In this example, it could be: devops.cool.my-domain.com/learn-api . Note that your custom domain name ends with the domain name of the hosted zone we created in the first instance.</p><p>When you create the integration, you are indicating where the api should redirect the request. In our case, we redirect traffic to an already existing application load balancer. If using a ACM certificate, it’s important in the integration to make sure that the HTTPS hostname and in the parameter mapping the hostname match those of the certificate. Otherwise, it will throw an unauthorized error.</p><p>The routes of an api specify the path. Following our example, maybe y I would like my api to expose different paths such as “aws-courses” and “gcp-courses”, In that case, my api would have two routes, one for each path; being available at:</p><ul><li>devops.cool.my-domain.com/learn-api/aws-courses</li><li>devops.cool.my-domain.com/learn-api/gcp-courses</li></ul><p>Each route also has a method. Possible methods are POST, PUT, PATCH, GET, DELETE. If you would like the user to be able to use any of these methods, you can indicate ANY as a method for that specific route.</p><p>The VPC link is vital, since without it the api won’t be able to access the resources to which it should be redirecting.</p><p>If you would like to know more about how api works, you can find more information on <a href="https://www.alexdebrie.com/posts/api-gateway-elements/">this article</a>.</p><p>IMPORTANT: Since we are deploying an active-active configuration, make sure that the custom domain name and your routes are deployed in different regions but named the same. In our example, both custom domain names should be “devops.cool.my-domain.com” and both api routes should be the same.</p><p>In our case, we needed to implement a custom authorizer. Adding an authorizer to an api can be done from the AWS Api Gateway console, as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s9xfyoFQQ_MiQX5l" /></figure><p>Where it says name, you should put the name you want for your authorizer. In case, you leave $request.header.Authorization it means that the authorization token should be included in the request. The issuer URL is the authorization server endpoint, and the audience is the client IDs registered. If, when executing the request with a token, the token doesn’t match any of the audiences listed, the api will return an authorization error.</p><p>5. Create route53 CNAME records</p><p>Once you have set up your api gateway, set up your DNS record for your api gateway. Here is the confusing part.</p><p>Step one: create a latency record for your custom domain names</p><p>Step two: create a CNAME record for your application load balancer.</p><p>Let’s go in depth into each of these steps.</p><p>Step one is setting up the latency records, one for each of the regions you want to work on. Each latency record should have the same exactly name; however, they will be pointing to their corresponding api gateway. Therefore, when a user makes a request to your custom domain name, route53 will redirect the user to the region with the least latency.</p><p>Once having done this, you need to proceed into step two. For each of your services behind your application load balancer, make sure you have a DNS record of type CNAME. In this way, the application load balancer will be able to redirect traffic to it.</p><h3>Optional: configure WAF</h3><p>Configuring a WAF ALC is optional, but is always recommended. Configuring this has two important aspects. The first is setting the rules, these could match by IP, location, etc. And the second one is associating the WAF ACL with the resources, it should apply its rules. If you want to save WAF logs into Kinesis Data Firehose , please bear in mind that its name should begin with aws-waf-logs (see official documentation <a href="https://docs.aws.amazon.com/waf/latest/developerguide/logging-kinesis.html">here</a>).</p><h3>Conclusions</h3><p>Configuring an active-active api might be useful as both, a disaster recovery strategy and so ensure users get redirected to the region with the least latency. The configuration of this kind of api requires setting the identical api configuration in two different regions, and then creating the route53 resources to redirect traffic to them. Adding an authorizer to the api and WAF ACL to the application load balancer is not compulsory, but is definitely a good practice doing so.</p><h3>Bonus</h3><p>Instead of doing this from the console, you can also do it using Terraform. We have uploaded the modules we have used to create all these resources (except the hosted zone that was created manually from the console) in<a href="https://registry.terraform.io/modules/rgg1993/api-gateway/aws/1.0.0"> this terraform repository</a>.</p><h3>Acknowledgements</h3><p>This solution was designed by <a href="https://www.linkedin.com/in/ivanferb?miniProfileUrn=urn%3Ali%3Afs_miniProfile%3AACoAAA9buSIBllgcvnAXktSbJJ96--ECOmykhd8&amp;lipi=urn%3Ali%3Apage%3Ad_flagship3_search_srp_all%3BzrVmI26AT0mqMrcC0CYwVw%3D%3D">Ivan Fernandez </a>, so all credits should go to him. I merely wrote the modules to implement the solution under his guidance and decided to write this article to make sure I understood the process.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9882d6c2609a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/globant/active-active-api-gateway-a-step-by-step-guide-with-terraform-code-9882d6c2609a">Active-active API Gateway: a step-by-step guide with terraform code</a> was originally published in <a href="https://medium.com/globant">Globant</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A walkthrough to Lambda layers]]></title>
            <link>https://medium.com/globant/a-walkthrough-to-lambda-layers-69c0f0c2392a?source=rss-a59f7a93fbc------2</link>
            <guid isPermaLink="false">https://medium.com/p/69c0f0c2392a</guid>
            <category><![CDATA[cloudops]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[lambda-function]]></category>
            <category><![CDATA[globant]]></category>
            <dc:creator><![CDATA[Rosina Garagorry]]></dc:creator>
            <pubDate>Mon, 27 Sep 2021 18:04:28 GMT</pubDate>
            <atom:updated>2021-09-27T18:04:28.670Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Ever since I learned about AWS Lambda functions, I have implemented them as much as possible. Among AWS services, AWS Lambda functions stand out because of their adaptability and ease of use. However, I recently had to implement a Lambda function to update a Confluence wiki and use the Atlassian-python-API library. And guess what? AWS Lambda did not have the library included; hence the code broke.</p><figure><img alt="Image showing error module not found" src="https://cdn-images-1.medium.com/max/1024/0*34ePXGPaohah5sw0" /></figure><p>I had already encountered the same issue before, but since we could use alternative methods, we just adapted the code. This time was different since the workaround would have been so error-prone that we’d instead sort this issue out. Here’s how we solved it.</p><h3>The problem</h3><p>Need to run AWS Lambda function written in python, which uses python libraries that are not available by default on AWS Lambda. The function uses Terraform for deployment.</p><h3>The solution</h3><p>After doing some research, AWS Lambda layers appeared as the solution to our worries. As per the AWS documentation, a layer “<em>is a .zip file archive that can contain additional code or data”.</em> In other words, you can zip anything you know beforehand your function will need to run correctly, or other functions will use that. Then, by zipping it and keeping it as a layer, you can reuse whatever you have zipped without having to recreate it over again.</p><h3>The implementation</h3><ol><li><em>Create the zip file</em></li></ol><p>To create the zip file, you must know that the folder must have the following structure: python/your library. For instance, we wanted to install the libraries of atlassian-python-api and requests, and after having installed them, the folder looked like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ebc0f38fe407a3cab52e30e10c82d8fd/href">https://medium.com/media/ebc0f38fe407a3cab52e30e10c82d8fd/href</a></iframe><p>Keep this in mind; otherwise, your Lambda function won’t recognize the libraries installed, and it will keep throwing errors.</p><p>Having generated the folder named python with all the needed libraries, you zip it</p><pre>zip -r9 ../lambda_layer.zip .</pre><p>Important notes:</p><p>a) The -r tag zips recursively into all folders inside the directory, and the 9 tag indicates the highest compression.</p><p>b) Execute this command in the directory where the python folder is located. If your python folder is in $HOME/python_layer, you do it inside that directory. To avoid a point of failure, it’s recommended you check inside that folder there’s only the python folder with the libraries that you want to add to the layer. Just in case, you can check this with the ls command:</p><pre>$HOME/python_layer ls<br>python</pre><p>There is no need for your function code to be in this directory.</p><p><em>2. Create your layer and attach it to a function</em></p><p>Either you’re managing your infrastructure as code or in the traditional way, both ways are possible. Bear in mind that each lambda function can have up to 5 different layers attached.</p><ul><li>IaC with Terraform</li></ul><p>Luckily enough for us, Terraform does have a resource for lambda layers, so we just configured it as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/280db9b230129cf8fc00b2a628053b2a/href">https://medium.com/media/280db9b230129cf8fc00b2a628053b2a/href</a></iframe><p>As you can see, the first resource is the lambda function to which we needed to attach the layer. This step may be overlooked if you want to create the layer without attaching it to any function. When configuring a lambda with a layer, the main difference is that you add the attribute “layers” in the resource.</p><p>The second resource is the one that creates the layer, called “lambda_utils_layer.” Two key aspects to watch out for:</p><p>a) Make sure the path you use on the filename is exactly where your zipped folder is.</p><p>b) Double check that the lambda function runtime is among the compatible runtimes listed for your layer.</p><p>When executing terraform apply, if the lambda function already exists, it will be updated in place as shown below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0462164c5b62696d91fa81aa1d30c698/href">https://medium.com/media/0462164c5b62696d91fa81aa1d30c698/href</a></iframe><p>On the contrary, if the lambda function doesn’t exist, both resources are created. You can check on the AWS Console that everything went ok by going to your Lambda function and seeing that it has a layer attached.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*V69BCY-8Z2fz_udC" /></figure><ul><li>From AWS Management Console:</li></ul><p>Adding a layer to a Lambda from the Management Console is pretty straightforward:</p><p>On the left-hand side menu, choose Layers option,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/0*zTe9W1yWi2GEB-C7" /></figure><p>Select the Create Layer on the right hand,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pOjxExeUM2SVkOe5" /></figure><p>And upload the zip file you have created on the previous steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gQ7aDsVP7NTQUkTg" /></figure><p>Then go to your function, and click on layers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3M6j6WjLjj5hTrH6" /></figure><p>And choose Add a layer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WlBJEnphxAG-RWAq" /></figure><p>Note that if your function runtime is not among the compatible runtimes of your layer, the layer you’ve created just won’t appear.</p><h3>Summarizing</h3><p>AWS Lambda functions are a powerful tool, and their possibilities of use are extended when adding layers to them. Adding layers simplifies the process of customizing your functions, as well as ensures the function will be able to access the libraries needed to run correctly. Therefore, learning how to use them is definitely a required skill to boost your Lambda functions.</p><h3>Bonus track</h3><p>To create the zip file, my colleague <a href="https://co.linkedin.com/in/felipe-mej%C3%ADa-alvarez-54754899">Felipe Mejia</a> shared with me this script he had written in bash to create the zip file and publish the layer to AWS. He definitely saved my week, and with his approval, we share it with you in the hope it saves yours as well:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/980d19fd26ab466ad94e03524a36e09f/href">https://medium.com/media/980d19fd26ab466ad94e03524a36e09f/href</a></iframe><h3>References</h3><ul><li><a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html">https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html</a></li><li><a href="https://medium.com/globant/connecting-to-sql-server-from-aws-lambda-docker-container-b474727522eb">https://medium.com/globant/connecting-to-sql-server-from-aws-lambda-docker-container-b474727522eb</a></li><li><a href="https://towardsdatascience.com/introduction-to-amazon-lambda-layers-and-boto3-using-python3-39bd390add17">https://towardsdatascience.com/introduction-to-amazon-lambda-layers-and-boto3-using-python3-39bd390add17</a></li><li><a href="https://www.globant.com/stay-relevant/partnerships/aws">Globant AWS</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69c0f0c2392a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/globant/a-walkthrough-to-lambda-layers-69c0f0c2392a">A walkthrough to Lambda layers</a> was originally published in <a href="https://medium.com/globant">Globant</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>