<?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 Mina Mahdi on Medium]]></title>
        <description><![CDATA[Stories by Mina Mahdi on Medium]]></description>
        <link>https://medium.com/@minayazmahdi?source=rss-44af945b0e34------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*GYMAdqHzwkQbvxCOK1B4TQ.jpeg</url>
            <title>Stories by Mina Mahdi on Medium</title>
            <link>https://medium.com/@minayazmahdi?source=rss-44af945b0e34------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 20:54:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@minayazmahdi/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[Canary Deployment of AWS Step Functions: Aliases vs Versioning for Lambda Functions]]></title>
            <link>https://medium.com/deloitte-uk-cloud-blog/canary-deployment-of-aws-step-functions-aliases-vs-versioning-for-lambda-functions-e2ff0dc56609?source=rss-44af945b0e34------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2ff0dc56609</guid>
            <category><![CDATA[cloud-and-architecture]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[step-functions]]></category>
            <category><![CDATA[canary-deployments]]></category>
            <category><![CDATA[lambda-function]]></category>
            <dc:creator><![CDATA[Mina Mahdi]]></dc:creator>
            <pubDate>Tue, 26 Nov 2024 08:02:11 GMT</pubDate>
            <atom:updated>2024-12-09T17:35:33.871Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="An image of a canary bird" src="https://cdn-images-1.medium.com/max/1024/1*ug2tCdthxPx3jZwoRMklBQ.jpeg" /><figcaption>Photo by Fernando B M on Pexels</figcaption></figure><p>In this article we’ll explore various deployment strategies, but with a focus on canary deployment for Step Functions. We’ll specifically dive into the concepts of aliases and versions in AWS Lambda and discuss why, in the context of Step Functions, it may be prudent to use versioning instead of aliases as an approach.</p><p><strong>Different types of deployment strategies</strong></p><p>A deployment strategy is the approach used to release software to end users or integrated systems, below are the 5 main deployment strategies used:</p><h4><strong>All-at-once</strong></h4><p><strong>Description:</strong> Deploys all software changes in one go. It aims for the fastest possible rollout, without a phased implementation.</p><p><strong>Benefits of usage:</strong> It is a quick, simple deployment strategy that allows for a fast rollout of a new application version or a new application.</p><figure><img alt="Diagram showing an all-at-once deployment strategy: a current version is updated and then rolled out to all users simultaneously" src="https://cdn-images-1.medium.com/max/1024/1*ZFkCSyglP-gK5hBmJtXw9Q.png" /></figure><h4>Blue/Green Deployment</h4><p><strong>Description: </strong>Blue/green deployment is a deployment strategy that uses two nearly identical environments: the blue environment (current live version) and the green environment (new version with the latest changes). These two versions run in parallel in a production environment and the blue environment continues serving live traffic. Once the green environment is validated through testing ensuring all behaviour is as expected and stable, all traffic is switched to it. The green version then becomes the live version, and the blue environment is deprecated.</p><p><strong>Benefits of usage: </strong>Blue/Green deployment aims to minimise downtime and increase service availability as well as allowing for easy reversion back to the blue environment easily. This is achieved by keeping the blue version live while the green version is tested in parallel prior to deprecating the blue environment. This ensures that the new version does not cause any disruptions to users, as it will have been thoroughly validated and tested in the green environment before routing all traffic to it.</p><figure><img alt="Diagram illustrating Blue/Green deployment. A tested version replaces the live version, minimising downtime" src="https://cdn-images-1.medium.com/max/1024/1*-DFFJX88xMTIWOFKTH6cbQ.png" /></figure><h4>Canary Deployment</h4><p><strong>Description: </strong>In a canary deployment, a new version of the software is deployed, and a small percentage of users are routed for a certain amount of time, while remaining users continue to use the old, stable version. During the deployment phase, should any monitoring alarms related to the canary deployment be triggered during the monitoring period, an automatic rollback to the previous stable version will be initiated. Canary deployments involve pre-defined traffic routing rules, such as directing 10% of traffic to the canary version for an initial observation period (e.g. 10 minutes). This approach enables close monitoring of the new version’s performance and stability with a limited user base. Providing no CloudWatch alarms are triggered due to errors, traffic exposure will increase to 100% after 10 minutes.</p><p><strong>Benefits of usage: </strong>Canary deployment allows for implicit testing to take place by using a percentage of real traffic for a set amount of time, so that potential issues can be identified early and addressed prior to impacting all users. In addition, it also allows for the testing of potentially disruptive changes in terms of technical stability and performance.</p><figure><img alt="Diagram showing Canary deployment strategy: 90% of users receive Version 1, 10% receive Version 2. After monitoring, Version 2 is rolled out to all users." src="https://cdn-images-1.medium.com/max/1024/1*_JQ-YPFuLugSm5oXieuz_g.png" /></figure><h4>A/B Testing</h4><p><strong>Description: </strong>A/B testing is a deployment strategy where two or more versions of a feature are present simultaneously to verify against a measurable goal. Users are then chosen in real time or are randomly selected and exposed to either version A or B. The version that performs better in achieving the desired outcome, based on metrics that were defined before the testing began (e.g. clicks, conversion rate, bounce rate) will be the winning version rolled out. A/B testing is more commonly associated with evaluating changes to the user interface.</p><p><strong>Benefits of usage: </strong>A/B testing allows for data-driven decisions, as it compares the performance of different versions. It reveals which version of the feature is better at achieving the desired outcome and allows room for experimentation.</p><figure><img alt="Diagram showing A/B testing deployment: Three versions tested with 33% of users each. The winning version is rolled out to all users." src="https://cdn-images-1.medium.com/max/1024/1*1zm-rwF9fJdw4p6jtHMkdA.png" /></figure><h4>Rolling Deployment</h4><p><strong>Description: </strong>Rolling deployments can target servers or containers, gradually replacing old instances with newer versions, while keeping the application running. For example, a new update is deployed to a percentage of servers, whilst the remaining servers continue to use the old stable version. If health checks confirm that the new version is stable/performing at an optimal level (no CloudWatch alarms relating to the deployment have been triggered) then the deployment proceeds to the next percentage of servers, and so on, until all servers are running on the new version. If health checks fail or unexpected behaviour occurs, then deployment is paused, and rollback to the previous version is initiated.</p><p><strong>Benefits of usage: </strong>Rolling deployment facilitates a controlled deployment that allows for early detection of potential bugs, minimising downtime and user impact. This approach simplifies the rollback process for affected servers to the previous stable version. By incrementally deploying updates to a subset of servers or instances, issues can be isolated and addressed more rapidly, as only the affected instances require rollback.</p><figure><img alt="Diagram showing a rolling deployment strategy where a new version is rolled out to servers in 10% increments until 100% of users have the update." src="https://cdn-images-1.medium.com/max/1024/1*i4B5lxz2Raplmek4BAe6tg.png" /></figure><p><strong>After exploring the various deployment strategies, this article will specifically focus on Canary Deployment¹</strong></p><p>Canary Deployment is a strategy for incrementally releasing application or service changes. It allows for direct verification within the production environment by routing a percentage of real users to a new version for a predetermined period. Initially the current version of the service is used by 100% of all users and if the deployment is successfully used without any errors being triggered, all user traffic is routed to the new version.</p><p><strong>What might a typical canary deployment look like?</strong></p><ol><li>Initially, 100% of traffic uses the current version of the service.</li><li>A canary deployment is initiated, routing 10% of traffic for example, to the new version for a specified time (e.g. 10 minutes) while the remaining 90% of users will continue to use the old version of the service. There are multiple deployment preference types such as:</li></ol><ul><li>Canary10Percent30Minutes</li><li>Canary10Percent15Minutes</li><li>Canary10Percent10Minutes</li><li>Canary10Percent5Minutes</li><li>AllAtOnce</li></ul><p>3. If no CloudWatch alarms are triggered, the remaining 90% of traffic is transitioned to the new version.</p><p>4. However, if issues arise, CloudWatch alarms are triggered and the deployment is automatically rolled back, and the working version will remain.</p><p>Since this article focuses on Lambda functions triggered by Step Functions, it’s essential to understand the difference between aliases and versions first.</p><h4><strong>What are Lambda Function versions?</strong></h4><p>A version, in a Lambda function, is a snapshot of your published Lambda code and configuration, such as env var values. This snapshot is immutable. However, a Lambda can have many versions deployed.</p><p>How it works:</p><ol><li>You make a change to your Lambda and publish.</li><li>Your Lambda is published and assigned version 1.</li><li>You make another change to your Lambda and publish.</li><li>Your Lambda is now published as version 2, and the pattern follows.</li></ol><p>Each Lambda version has its own unique ARN displayed like this:</p><pre>arn:aws:lambda:eu-west-2:1234678910:function:myfunction:3</pre><p>By enabling versioning, you can keep a record of all previous Lambda updates.</p><figure><img alt="A screenshot of example published lambda versions" src="https://cdn-images-1.medium.com/max/1024/1*aRuMEIzRjp4xxPJ3zZ8jIQ.png" /><figcaption>Example of Lambda Versions Published</figcaption></figure><h4><strong>What are Lambda Functions Aliases?</strong></h4><p>An alias is a pointer to a specific version of your Lambda. You can edit the alias to point to any version.</p><p><strong><em>How?</em></strong></p><p>Navigate to your Lambda function, click on the <strong>Aliases tab</strong> and <strong>click the circle</strong> next to the Name of your alias, in this instance it’s called <em>live </em>then click <strong>Edit</strong> to point to any published version of your Lambda.</p><figure><img alt="A screenshot of Lambda Alias pointing to a specific version" src="https://cdn-images-1.medium.com/max/1024/1*bhkVn2b30GKnuD65Nl21dA.png" /><figcaption>Example of Lambda Alias pointing to a specific version</figcaption></figure><p><em>Note: Versioning and alias’s also work in the same manner for Step Functions.</em></p><h4><strong>What is Step Functions default strategy, and what is the impact when an error occurs in a live production environment?</strong></h4><p>When changes are made to a Step Function, such as an update to its state machine’s definition, AWS publishes a new version, and all new executions will use the updated definition. If the <a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html"><strong>AutoPublishAlias</strong></a><strong>² </strong>property is set to <em>live</em>, then the Step Function will automatically update the alias to point to the new version, directing all subsequent executions to it.</p><p>While this process is designed to be seamless, potential risks may arise within a live production environment. If the updated version contains an unexpected error, it can cause executions to stop and fail, thus disrupting the traffic and the user experience. To restore service functionality, the alias pointing to the faulty version must be manually updated to a previous stable version of the Step Function. Concurrently, a pull request should be created to address the underlying issue.</p><h4><strong>Why it’s recommended to use versioning instead of Aliases for Lambda’s triggered by Step Functions in canary deployments?</strong></h4><p>When it comes to canary deployments, using versioning for lambda functions is preferred over aliases. Here is why:</p><ol><li><strong>Immutability for reliable rollbacks</strong></li></ol><p>Versioning is preferred over aliases due to its immutable nature. Immutability is crucial for reliable rollbacks and ensures that when a Step Function reverts, it triggers the exact Lambda version originally specified in its configuration. This reduces the risk of unintended behaviour or errors associated with mutable aliases. In contrast, aliases are mutable and can be updated at any time. Consequently, during a rollback, an alias might point to a different Lambda version than intended, preventing the rollback from functioning as expected. As a result, the Step Function would use a newer version of the Lambda associated with that alias.</p><p>2. <strong>Precise version control</strong></p><p>Directly referencing specific Lambda versions within a Step Function ensures consistent execution of the intended Lambda code and infrastructure. This is because the Step Function is directly linked to a specific, immutable version. This decoupling prevents changes to aliases from impacting already deployed and stable Step Function versions, as the Step Function will always use the exact Lambda version specified.</p><p>3. <strong>Avoiding Canary deployment pitfalls</strong></p><p>When a Step Function references a Lambda via an alias such as <em>live, </em>both the stable version and the new canary version of the Step Function rely on the same Lambda alias during a canary deployment phase. This defeats the purpose of a canary deployment, because traffic cannot be split between the new and old version effectively. Moreover, if an error occurs during a canary deployment, and the deployment is required to roll back to a previous stable version, the alias may have already been updated to point to the new broken version. This would necessitate manually reverting the Lambda to the previous version to ensure the correct alias is referenced — introducing delays and risks.</p><h4><strong>Now let’s illustrate the difference when using versioning and aliases to highlight the risks associated.</strong></h4><p>For the scenarios, we are using a canary deployment strategy (Canary10Percent10Minutes — directs 10% of traffic to the new version for a 10-minute monitoring period, and if no issues are detected, it shifts 100% of traffic to the new version).</p><h4><strong>Scenario </strong>1️⃣</h4><p>We have a Step Function, Version 1. Version 1 is configured to trigger a Lambda that uses the alias name “live”.</p><p><strong>Step Function Version 1</strong></p><p>Step Function Version 1 points to the Lambda via the <em>“live”</em> alias. 90% of the traffic remains routed at the current stable version of the Step Function and attached Lambda.</p><p><strong>Step Function Version 2</strong></p><p>Also points to the Lambda via the “live” alias. 10% of the traffic is routed here.</p><p><strong>The problem</strong></p><p>That both Step Function versions reference the Lambda using the shared <em>live </em>alias, in other words, they are executing the same Lambda code.</p><p>In this case, the Lambda code corresponding to Step Function Version 2 is not truly being tested during the canary phase.</p><p>The issue persists, because the alias won’t point to the new version of the Lambda function until after the canary deployment is complete and the new Step Function version is published. As a result, potential errors in the new lambda code could go undetected, resulting in a post-canary deployment situation where broken code could be deployed to 100% of the production traffic.</p><h4><strong>Scenario </strong>2️⃣</h4><p>The next scenario is using specific Lambda versions, which would ensure a reliable Step Function canary deployment.</p><p>We have a Step Function, Version 1. Version 1 is configured to trigger a specific Lambda version.</p><p><strong>Step Function Version 1</strong></p><p>Step Function version 1 points to the specific Lambda version, such as version 1. 90% of the production traffic is routed at this stable version.</p><p><strong>Step Function Version 2</strong></p><p>Changes to the Step Function are deployed and a new version of the Step Function is published which is configured to use the new Lambda Version 2. The remaining 10% of the traffic is routed here.</p><p>Using versioning allows for Version 1 and Version 2 of the Step Function to operate independently and trigger their intended Lambda versions, without any shared alias ambiguity. Should a CloudWatch alarm be triggered, initiating a rollback and redirecting 100% of traffic to the previous stable Step Function, we can be confident that it will revert to the correct, previously used stable Lambda version.</p><figure><img alt="Diagram showing a ‘live’ alias routing 90% of traffic to Step Function version 1 and 10% to version 2, each invoking a corresponding Lambda function version." src="https://cdn-images-1.medium.com/max/455/1*j772RGqAT502CIOjwLAggw.png" /></figure><p><strong>What would this look like as a SAM CloudFormation template?</strong></p><p><em>SAM CloudWatch Alarm³ template</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F-KIRxsSaaNSoGOhM35o9A.png" /></figure><p>Further clarity:</p><ul><li><strong>Line 8: </strong>The value chosen for the property <strong>MetricName </strong>is <strong>Errors</strong>⁴ to monitor the number of errors emitted by the lambda.</li><li><strong>Line 9: </strong>The property <strong>Dimensions</strong> holds key value pairs.</li><li><strong>Line 10: </strong>The <strong>Resource </strong>key provides the specific Lambda with reference to the <em>“live”</em> version.</li><li><strong>Line 12: </strong>The <strong>FunctionName </strong>clarifies the Lambda that should be monitored. The <strong>ExecutedVersion </strong>allows us to monitor the specific latest deployed version of the Lambda.</li><li><strong>Line 16: Namespace </strong>property specifies that the metric originates from the Lambda resource.</li></ul><p><em>SAM Step Function⁵ template:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jo4YvQs0Mm4LwlCxhsoyZw.png" /></figure><p>Further clarity:</p><ul><li><strong>Line 4: </strong>The property <strong>AutoPublishAlias</strong> creates the alias and enables versioning.</li><li><strong>Line 6: </strong>The property <strong>DeploymentPreference</strong> displays the deployment strategy configuration, in this example we are using canary, and setting the CloudWatch alarms that need to be triggered for the deployment to fail and a roll back to occur.</li><li><strong>Line 17: </strong>The property <strong>DefinitionSubstitutions</strong> allows you to pass values into the Step Function during deployment such as an ARN. In this example <strong>MyFirstLambdaFunction</strong> placeholder key is equal to <strong>!Ref MyFirstLambdaFunction.Version</strong> which references the Lambda version that will be replaced by the ARN of the Lambda with the version number appended at the end.</li></ul><p><em>SAM Lambda⁶ template:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*xts6DMstMtJN6BLNcxL1aQ.png" /></figure><p>Further clarity:</p><ul><li><strong>Line 5: </strong>The property <strong>AutoPublishAlias</strong> is set to the alias name “<em>live</em>” so that we can enable versioning. Without it, every time we would publish a new version of the Lambda an over-write woul occur to the previous version (<em>$LATEST).</em></li></ul><h4><strong>Summary:</strong></h4><p>To conclude, by using Lambda versions directly, we can explicitly specify which Lambda version each Step Function should use. This isolated approach ensures that we are correctly implementing the canary deployment strategy, as each Step Function is tied to a known and stable Lambda version. This practice not only enhances the reliability of our canary deployments, but also simplifies rollbacks, as we can confidently revert to a previous Step Function version knowing it will execute the intended Lambda code.</p><p>🍎 ️ <strong>Food for Thought:</strong></p><p>In addition to strategies like canary deployment, another innovative way to test in production without impacting real users is the Dark Read pattern. As highlighted by <a href="https://www.linkedin.com/posts/theburningmonk_everyone-knows-canary-deployments-but-do-activity-7249682581254717440-mhxS">Yan Cui</a>⁷ in a recent post, the Dark Read pattern works by serving requests from the current live version of the application while simultaneously cloning and executing those requests against the new version in the background for testing. This approach is particularly valuable as it allows you to validate the new version’s behaviour and performance under real-world conditions without impacting even 1% of real-time users, should the new version underperform. However, this setup is more complex and time-consuming compared to canary deployment, especially when dealing with interdependencies such as external APIs or third-party integrations.</p><p><strong>References:</strong></p><p>¹ Amazon.com. (2024). <em>Deployment strategies — Introduction to DevOps on AWS</em>. [online] Available at: <a href="https://docs.aws.amazon.com/whitepapers/latest/introduction-devops-aws/deployment-strategies.html#canary-deployments">https://docs.aws.amazon.com/whitepapers/latest/introduction-devops-aws/deployment-strategies.html#canary-deployments</a> [Accessed 25 Nov. 2024]</p><p>² Amazon.com. (2024). <em>AWS::Serverless::Function — AWS Serverless Application Model</em>. [online] Available at: <a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html">https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html</a>[Accessed 25 Nov. 2024]</p><p>³ docs.aws.amazon.com. (n.d.). <em>AWS::CloudWatch::Alarm — AWS CloudFormation</em>. [online] Available at: <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudwatch-alarm.html">https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudwatch-alarm.html</a></p><p>⁴ docs.aws.amazon.com. (n.d.). <em>Important metrics for CloudWatch — AWS Lambda</em>. [online] Available at: <a href="https://docs.aws.amazon.com/lambda/latest/operatorguide/important-metrics.html">https://docs.aws.amazon.com/lambda/latest/operatorguide/important-metrics.html</a></p><p>⁵ Amazon.com. (2024). <em>AWS::StepFunctions::StateMachine — AWS CloudFormation</em>. [online] Available at: <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html">https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html</a> [Accessed 25 Nov. 2024]</p><p>⁶ Amazon.com. (2024). <em>AWS::Serverless::Function — AWS Serverless Application Model</em>. [online] Available at: <a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html">https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html</a>[Accessed 25 Nov. 2024]</p><p>⁶ Cui, Y. (2024). <em>Yan Cui on LinkedIn: Everyone knows Canary Deployments, but do you know the Dark Read pattern?… | 81 comments</em>. [online] Linkedin.com. Available at: <a href="https://www.linkedin.com/posts/theburningmonk_everyone-knows-canary-deployments-but-do-activity-7249682581254717440-mhxS">https://www.linkedin.com/posts/theburningmonk_everyone-knows-canary-deployments-but-do-activity-7249682581254717440-mhxS</a></p><p><strong><em>Note</em></strong><em>: This article speaks only to my personal views / experiences and is not published on behalf of Deloitte LLP and associated firms, and does not constitute professional or legal advice. All product names, logos, and brands are property of their respective owners. All company, product and service names used in this website are for identification purposes only. Use of these names, logos, and brands does not imply endorsement.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2ff0dc56609" width="1" height="1" alt=""><hr><p><a href="https://medium.com/deloitte-uk-cloud-blog/canary-deployment-of-aws-step-functions-aliases-vs-versioning-for-lambda-functions-e2ff0dc56609">Canary Deployment of AWS Step Functions: Aliases vs Versioning for Lambda Functions</a> was originally published in <a href="https://medium.com/deloitte-uk-cloud-blog">Deloitte UK Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>