<?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 Biswanath Mukherjee on Medium]]></title>
        <description><![CDATA[Stories by Biswanath Mukherjee on Medium]]></description>
        <link>https://medium.com/@biswanath.ita?source=rss-893e0d23d555------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Biswanath Mukherjee on Medium</title>
            <link>https://medium.com/@biswanath.ita?source=rss-893e0d23d555------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 07:49:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@biswanath.ita/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[Generating blog content from image using Claude 3 sonnet on Amazon Bedrock]]></title>
            <link>https://medium.com/@biswanath.ita/generating-blog-content-from-image-using-claude-3-sonnet-on-amazon-bedrock-5dcbeef0c09a?source=rss-893e0d23d555------2</link>
            <guid isPermaLink="false">https://medium.com/p/5dcbeef0c09a</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[bedrock]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[anthropic-claude]]></category>
            <dc:creator><![CDATA[Biswanath Mukherjee]]></dc:creator>
            <pubDate>Sun, 10 Mar 2024 02:24:45 GMT</pubDate>
            <atom:updated>2024-03-10T02:24:45.589Z</atom:updated>
            <content:encoded><![CDATA[<p>The generative AI space is evolving rapidly, with new models being released that push the boundaries of intelligence, speed, and safety. Amazon Web Services has been at the forefront of making these innovations available to customer at a single place through Amazon Bedrock. The latest addition is the newly launched Claude 3 Sonnet model from Anthropic.</p><p>In this post, I’ll provide a hands-on tutorial for getting started with Claude 3 Sonnet on Bedrock. We’ll cover signing up for access, integrating with other AWS services using Amazon Bedrock AP and evaluating the model’s outputs.</p><p>Claude 3 Sonnet balances intelligence and speed, making it an ideal jumping off point for many applications. It builds on the strengths of previous Claude versions with upgrades like 2x faster performance. I’m excited to take it for a spin and demonstrate how you can leverage Claude 3 Sonnet on Bedrock to start building the next generation of AI-powered apps.</p><p>Whether you’re an AI researcher, developer, or a decision make, this post will equip you with the fundamentals of using this new model. Let’s dive in!</p><p><strong>Prerequisites</strong></p><ul><li><a href="https://portal.aws.amazon.com/gp/aws/developer/registration/index.html">Create an AWS account</a> if you do not already have one.</li><li>Access to AWS account via AWS Console and CLI. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources mentioned in this post.</li><li><a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">Git Installed</a></li><li><a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html">AWS Serverless Application Model</a> (AWS SAM) installed</li><li>You must enable the Claude 3 Sonnet Model access in the Amazon Bedrock console in the region where you are going to run the SAM template. Please refer to the<a href="https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html"> Amazon Bedrock user guide</a> for instruction on model access.</li></ul><p><strong>Architecture</strong></p><figure><img alt="Fig 1. Demo Architecture" src="https://cdn-images-1.medium.com/max/654/1*3SF6n2uAyoznec9ExAODXw.jpeg" /><figcaption>Fig 1. Demo Architecture</figcaption></figure><p>This demonstration architecture utilizes several AWS services to automatically generate blog content from uploaded image files:</p><ul><li>User uploads an architecture image file into the Amazon S3 input bucket.</li><li>An AWS Lambda function is invoked when a new object is uploaded to the S3 input bucket. This serverless function handles the core processing:</li><li>Reading the image file from S3 and converting it to a Base64 encoded string</li><li>Calling the Amazon Bedrock API with the encoded image and a prompt requesting a blog post</li><li>Receiving the generated blog post content JSON from Bedrock</li><li>Creating a PDF document with the content</li><li>Saving the PDF to the S3 output bucket</li><li>Amazon Bedrock provides API access to the Claude v3 Sonnet large language model from Anthropic. The Lambda function calls this API with the encoded image and prompt to generate a blog post based on the architecture diagram.</li></ul><p><strong>Demo Preparation</strong></p><p>The resources in this demonstration will be provisioned in the US East (N. Virginia) AWS region (us-east-1). We will walk through the following phases to execute our machine learning workflow:</p><ol><li>Deploy the solution using AWS Serverless Application Model (SAM) Template</li><li>Create AWS Lambda layer for pdf generation functionality</li><li>Upload architecture diagram for which draft blog post/ content to be generated</li><li>Validate the pdf file with generated draft blog content</li><li>Cleaning up</li></ol><p><strong>Step 1: Deploy the solution using AWS Serverless Application Model (SAM) Template</strong></p><p>We will deploy the prerequisite infrastructure such as AWS Lambda Function, Amazon S3 bucket, IAM roles using AWS SAM.</p><p>i. Create a new directory, navigate to that directory in a terminal and clone the GitHub repository:</p><pre>git clone https://github.com/biswanathmukherjee/s3-lambda-bedrock-sam.git</pre><p>ii. Change directory to the solution directory:</p><pre>cd s3-lambda-bedrock-sam</pre><p>iii. From the command line, use AWS SAM to deploy the AWS resources for the pattern as specified in the template.yml file:</p><pre>sam deploy --guided</pre><p>Provide the below inputs when requested:</p><pre>- Enter a stack name. <br>   - Enter the desired AWS Region.<br>   - Leave rest of the options as default.</pre><p>iv. Note the outputs from the SAM deployment process. These contain the resource names and/or ARNs which are used in the subsequent steps.</p><p><strong>Step 2: Create AWS Lambda layer for pdf generation functionality</strong></p><p>For pdf generation in the AWS Lambda function we will be using <a href="https://pypi.org/project/fpdf2/">fpdf2 library</a>. This library is not available by default in AWS Lambda Python runtime. Hence, we will create a Lambda layer and associate it with our Lambda function.</p><p>i. Run the create_lambda_layer.sh. You may have to change the file permission to make it executable. This will create the lambda layer with necessary boto3 api for bedrock.</p><pre>bash create_lambda_layer.sh</pre><p>When asked, provide a name for the Lambda layer and the region.<br>Example output:</p><pre>{<br>    &quot;Content&quot;: {<br>      .....<br>      .....<br>    },<br>    &quot;LayerArn&quot;: &quot;arn:aws:lambda:us-east-1:xxxxxxxxxxxx:layer:fpdf2_layer&quot;,<br>    &quot;LayerVersionArn&quot;: &quot;arn:aws:lambda:us-east-1:xxxxxxxxxxxx:layer:fpdf2_layer:1&quot;,<br>    &quot;Description&quot;: &quot;&quot;,<br>    &quot;CreatedDate&quot;: &quot;YYYY-MM-DDT10:47:36.983+0000&quot;,<br>    &quot;Version&quot;: 1<br>   }</pre><p>You may have to press q to come out of the output.</p><p>ii. Copy the value of LayerVersionArn from the above output and provide it into the next step. Such as:</p><pre>Enter the LayerVersionArn from the above command: arn:aws:lambda:us-east-1:xxxxxxxxxxxx:layer:fpdf2_layer:1</pre><p>iii. Please copy the value of `InvokeBedrockClaudeV3Function` from the `sam deploy — guided` output and provide that as response to next question. Such as:</p><pre>Enter the Lambda function name from the SAM deploy output: your-stack-name-InvokeBedrockClaudeV3Function-xxxxxxxxxxxx</pre><p>The script will now run aws cli command to add the newly created layer to the Lambda function.<br>It will show output like below:</p><pre>Adding the new layer to your Lambda function&#39;s configuration. Please wait ...<br>   {<br>      &quot;FunctionName&quot;: &quot;your-stack-name-InvokeBedrockClaudeV3Function-xxxxxxxxxxxx&quot;,<br>      ......<br>      ......<br>      &quot;State&quot;: &quot;Active&quot;,<br>      &quot;LastUpdateStatus&quot;: &quot;InProgress&quot;,<br>      &quot;LastUpdateStatusReason&quot;: &quot;The function is being created.&quot;,<br>      &quot;LastUpdateStatusReasonCode&quot;: &quot;Creating&quot;,<br>      &quot;PackageType&quot;: &quot;Zip&quot;,<br>      &quot;Architectures&quot;: [<br>         &quot;arm64&quot;<br>      ],<br>      &quot;EphemeralStorage&quot;: {<br>         &quot;Size&quot;: 512<br>      }<br>   }</pre><p>You may have to press q to come out of the output. The setup is ready for testing.</p><p><strong>Step 3: Upload architecture diagram for which draft blog post/ content to be generated</strong></p><figure><img alt="Fig 2. Sample Architecture" src="https://cdn-images-1.medium.com/max/1024/1*uLimtaBbekr84rYrmILe0g.jpeg" /><figcaption>Fig 2. Sample Architecture (input)</figcaption></figure><p>i. From the command line, please execute the below command to upload the sample-architecture.jpeg file into the Amazon S3 bucket. Please replace MyInputBucketName from the sam deploy output and also your region:</p><pre>aws s3 cp sample-architecture.jpeg s3://{MyInputBucketName}/sample-architecture.jpeg --region {your-region}</pre><p>ii. Log into <a href="https://s3.console.aws.amazon.com/s3/buckets">Amazon S3 Console</a>, within a few seconds, you should see a draft-blog.pdf file uploaded into the the MyOutputBucketName S3 bucket. Download the file from the bucket using the below command and validate the content.</p><pre>aws s3 cp s3://{MyOutputBucketName}/draft-blog.pdf ./draft-blog.pdf</pre><p><strong>Step 4: Validate the pdf file with generated draft blog content</strong></p><p>Here is a screenshot of the draft content generated from the sample architecture diagram. Please note, while the LLM generates the basic content from the architecture diagram, the author is responsible for validating and altering as required.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1nkPRSBwIXb-4V6OLO6EzQ.jpeg" /><figcaption>Fig 3. Generated Draft Blog (output)</figcaption></figure><p><strong>Step 5: Cleaning up</strong></p><p>Properly decommissioning provisioned AWS resources is an important best practice to optimise costs and enhance security posture after concluding proofs of concept and demonstrations. The following steps will tear down the infrastructure components deployed earlier in this post:</p><p>i. Delete the content in the Amazon S3 bucket using the following command. Please update MyInputBucketName from the sam deploy output. Please <strong><em>ensure</em></strong> that the correct bucket name is provided to avoid accidental data loss::</p><pre>aws s3 rm s3://{MyInputBucketName} --recursive --region {your-region}<br>   aws s3 rm s3://{MyOutputBucketName} --recursive --region {your-region}</pre><p>ii. Delete the AWS Lambda layer using the following command. Please provide the layer name, version and the AWS region as inputs:</p><pre>bash delete_lambda_layer.sh</pre><p>iii. Delete the content in the Amazon S3 bucket using the following command. Please *ensure* that the correct bucket name is provided to avoid accidental data loss:</p><pre>aws s3 rm s3://{BedrockModelCustomisationS3Bucket} —recursive</pre><p>iv. To delete the resources deployed to your AWS account via AWS SAM, run the following command:</p><pre>sam delete</pre><p><strong>Conclusion</strong></p><p>In this post, we walked through a hands-on tutorial for utilizing the new Claude 3 Sonnet model from Anthropic on Amazon Bedrock. We covered the process of gaining access to Bedrock, making API calls, and generating content from architecture diagram.</p><p>The availability of Claude 3 Sonnet on Amazon Bedrock provides access to Anthropic’s latest innovations in safe, high-performance generative AI. As we saw from experimenting with sample prompts, Claude 3 Sonnet generates coherent, relevant text while minimizing hallucinated content.</p><p>Bedrock makes it easy to use Claude 3 Sonnet model and integrate its power into your own applications. The full capabilities of the model are available through robust APIs for a wide range of easy integrations with AWS services .</p><p>As generative AI progresses, Amazon Bedrock will continue providing access to leading models like Claude. Stay tuned for updates on new versions and capabilities! I hope this post provided a valuable introduction to get started building with Claude 3 Sonnet. Let me know in the comments if you have any other topics you’d like to see covered.</p><p><strong>Further study</strong></p><ul><li><a href="https://docs.aws.amazon.com/bedrock/latest/userguide/custom-models.html">Amazon Bedrock User Guide</a></li><li><a href="https://aws.amazon.com/blogs/aws/anthropics-claude-3-sonnet-foundation-model-is-now-available-in-amazon-bedrock/">AWS launch blog on Anthropic’s Claude 3 Sonnet foundation model</a></li><li>Input architecture image credit: <a href="https://aws.amazon.com/blogs/big-data/increase-apache-kafkas-resiliency-with-a-multi-region-deployment-and-mirrormaker-2/">AWS Blog</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5dcbeef0c09a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build Asynchronous Workflows with Wait For Callback in AWS Step Functions]]></title>
            <link>https://medium.com/@biswanath.ita/build-asynchronous-workflows-with-wait-for-callback-in-aws-step-functions-59f6cd7f1d31?source=rss-893e0d23d555------2</link>
            <guid isPermaLink="false">https://medium.com/p/59f6cd7f1d31</guid>
            <category><![CDATA[event-driven-architecture]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[step-functions]]></category>
            <dc:creator><![CDATA[Biswanath Mukherjee]]></dc:creator>
            <pubDate>Sun, 21 Jan 2024 02:12:08 GMT</pubDate>
            <atom:updated>2024-01-21T02:15:50.471Z</atom:updated>
            <content:encoded><![CDATA[<h3>Build Event Driven Workflows with Wait For Callback in AWS Step Functions</h3><p>Imagine a world where everything was synchronous — completely linear and sequential. No concurrency, no parallelism, just one rigid process after another. According to Amazon CTO Dr. Werner Vogels, this would be a nightmare! In his legendary opening speech at <a href="https://www.youtube.com/watch?v=RfvL_423a-I">AWS re:Invent 2022</a>, Vogels painted a picture of an alternate reality devoid of the event-driven architectures that enable companies like Amazon to operate at global scale. Dr. Vogels’ talk was a reminder that our messy, asynchronous reality enables the incredible innovations we often take for granted.</p><p>Asynchronous workflows are common in serverless applications built with AWS. Often you need to wait for an external process to complete before continuing the execution of your workflow. AWS Step Functions provides a powerful “wait for callback” feature that allows you to pause execution and wait for an external process to invoke a callback API indicating it has finished. <br>In this post, I’ll demonstrate how to implement wait for callback in Step Functions using an AWS SAM template. We’ll build a simple workflow that sends messages to SQS, waits for it to be processed asynchronously, and then continues once the function invokes a callback API. This avoids having to poll or wait using timers. The callback approach is more efficient, elegant, and robust.</p><p>Let’s get started!</p><p><strong>Prerequisites</strong></p><ul><li><a href="https://portal.aws.amazon.com/gp/aws/developer/registration/index.html">Create an AWS account</a> if you do not already have one.</li><li>Access to AWS account via <a href="http://console.aws.amazon.com/">AWS Console</a> and <a href="https://aws.amazon.com/cli/">AWS CLI</a>. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources mentioned in this post.</li><li>Access to a terminal with <a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html">AWS SAM CLI</a> installed and configured.</li><li><a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">Git Installed</a></li></ul><p><strong>Architecture</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*OPN5J0tnbeRZ7miueS-zDg.jpeg" /></figure><p>I am taking a very simplified order payment use case for the demonstration of the wait for callback functionality of AWS Step Function. Here are the details of different AWS services and their purpose in this demo architecture</p><ul><li>An AWS Step Functions workflow with 3 states:</li></ul><ol><li>Charge customer — this takes an order details in JSON payload and sends a message to a Amazon SQS Queue which contains the original payload and the task token. This step waits for the message to be processed from the SQS Queue by an AWS Lambda Function. Only when the Lambda Function calls back AWS Step Functions with the task token, the Step Function moves to either of step b or c depending on the nature of the callback.</li><li>Notify Payment Success — this step publishes a success message into an Amazon SNS Topic.</li><li>Notify Payment Failure — this step publishes a payment failure message into an Amazon SNS Topic.</li></ol><ul><li>An Amazon SQS Queue to store the messages until they are processed.</li><li>An AWS Lambda Function to simulate asynchronous payment processing and calls back AWS Step Function with the same task token available within the payload. The Lambda function calls back the Step Function either using task success or task failure APIs randomly.</li><li>An Amazon SNS Topic to send notification to end customer. Amazon SNS can send <a href="https://docs.aws.amazon.com/sns/latest/dg/sns-user-notifications.html">notification</a> via Mobile SMS, push notification or email to end customer. However, for this demonstration I have subscribed a test SQS Queue to the SNS topic. We will read from this SQS Queue to validate the notification messages.</li></ul><p><strong>Implementation Details:</strong></p><ol><li>The state machine will take the following JSON payload as input:</li></ol><pre>{<br>&quot;orderId&quot;: &quot;1234567&quot;,<br>&quot;customerId&quot;: &quot;98766&quot;,<br>&quot;orderDate&quot;: &quot;2024-01-14&quot;,<br>&quot;amount&quot;: 100,<br>&quot;nameOnCard&quot;: &quot;FIRSTNAME LASTNAME&quot;,<br>&quot;creditCardNumber&quot;: &quot;1234 1234 1234 1234&quot;,<br>&quot;expiry&quot;: &quot;XX/YY&quot;,<br>&quot;cvv&quot;: &quot;123&quot;<br>}</pre><p>2. In order to configure the wait for callback option from the <strong>Charge Customer</strong> state within AWS Step Function, we need to pass the task token. Please note the syntax of passing the token along with other attributes from the step input. Select the checkbox <strong>Wait for call</strong> under <strong>Additional Configuration</strong>. This is how it is done:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9EkeR8oEqMK9WviLwtu9FA.jpeg" /></figure><p>3. Configure the error flow on the <strong>Error Handling</strong> tab of the <strong>Charge Customer</strong> state:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*YFlTt5AynAJo8N35202Zyg.jpeg" /></figure><p>4. For the full implementation of the state machine, please refer <a href="https://github.com/biswanathmukherjee/stepfunctions-callback-sam/blob/main/statemachine/wait-for-callback.asl.json">here</a>.</p><p>5. The AWS Lambda function is a simple Python program that uses boto3 library to callback the Step Functions workflow either using send_task_success or send_task_failure API calls at random. The full implementation can be referred <a href="https://github.com/biswanathmukherjee/stepfunctions-callback-sam/blob/main/source/app.py">here</a>.</p><p>6. All AWS Services involved in this architecture including the IAM permission using AWS SAM template which can be referred from <a href="https://github.com/biswanathmukherjee/stepfunctions-callback-sam/blob/main/template.yaml">here</a>.</p><p><strong>Deployment of the Solution</strong></p><p>We will deploy the solution using <a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification.html">AWS Serverlesss Application Model</a> (SAM) template. Please follow the steps mentioned below:</p><ol><li>Create a new directory, navigate to that directory in a terminal and clone the GitHub repository:</li></ol><pre>git clone https://github.com/biswanathmukherjee/stepfunctions-callback-sam.git</pre><p>2. Change directory to the pattern directory:</p><pre>cd stepfunctions-callback-sam</pre><p>3. From the command line, use AWS SAM to deploy the AWS resources for the pattern as specified in the template.yml file:</p><pre>sam deploy —guided</pre><p>4. During the prompts:</p><ul><li>Enter a stack name</li><li>Enter us-east-1 or any AWS Region where you have access.</li><li>Allow SAM CLI to create IAM roles with the required permissions.</li></ul><p>Once you have run sam deploy --guided mode once and saved arguments to a configuration file (samconfig.toml), you can use sam deploy in future to use these defaults.</p><p>5. Note the outputs from the SAM deployment process. These contain the resource names and/or ARNs which are used for testing.</p><p><strong>Testing</strong></p><ol><li>Run the following AWS CLI command to start the Step Functions workflow. Note, you must edit the {StateMachineWaitForCallbackArn} placeholder with the ARN of the deployed Step Functions workflow. This is provided in the stack outputs. Please replace {your-region} with the region selected at the time of deployment.</li></ol><pre>aws stepfunctions start-execution --state-machine-arn &quot;{StateMachineWaitForCallbackArn}&quot; --input &quot;{\&quot;orderId\&quot;: \&quot;1234567\&quot;,\&quot;customerId\&quot;: \&quot;98766\&quot;,\&quot;orderDate\&quot;: \&quot;2024-01-14\&quot;,\&quot;amount\&quot;: 100,\&quot;nameOnCard\&quot;: \&quot;FIRSTNAME LASTNAME\&quot;,\&quot;creditCardNumber\&quot;: \&quot;1234 1234 1234 1234\&quot;,\&quot;expiry\&quot;: \&quot;XX/YY\&quot;,\&quot;cvv\&quot;: \&quot;123\&quot;}&quot; --region {your-region}</pre><p>Example output:</p><pre>{<br>    &quot;executionArn&quot;: &quot;arn:aws:states:{your-region}:123456789012:execution:StateMachineWaitForCallback-mnZFTe6jJSDu:40e520d2-4d3e-42ce-a8e3-b33bfed22fc1&quot;,<br>    &quot;startDate&quot;: &quot;2024-01-10T20:06:47.616000+05:30&quot;<br>}</pre><p>2. Run the above commands a few more times. As we can test both the success and failure task callbacks.</p><p>3. Run the following AWS CLI command to receive messages from the test SQS queue. Note, you must edit the {WaitForCallbackDemoNotificationTestQueueUrl} placeholder with the deployed Amazon SQS Test Queue URL. This is provided in the stack outputs. Please replace {your-region} with the region selected at the time of deployment.</p><pre>aws sqs receive-message --queue-url {WaitForCallbackDemoNotificationTestQueueUrl} --max-number-of-messages 10 --wait-time-seconds 20 --region {your-region}</pre><p>Example output:</p><pre>{<br>    &quot;Messages&quot;: [<br>        {<br>            &quot;MessageId&quot;: &quot;40fc7cbd-2dd5-440c-9092-0da1ef992a99&quot;,<br>            &quot;ReceiptHandle&quot;: &quot;AQEB+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/V6VkU8lWzDreKWDc9JJzDBx9oqnE3nY/TQBqr4hxX26D76KN5PZ+3fXatZ7RRoA9QSx71rpTzoX/e5AvHOqCuJyKKmQ408LUoEcvInnbl/ANYT+qTKEqGusGmITEObBeGrc/H0JVobIkMt7U/fPwDAsSuM+iPEh27y6sPvdt82UVZCjckckjwmSH7yTG+snp8HJBgCw9LEwS54dMcIfp59mCjde50XWEN4B0rKgRIOgouCMA/V1jb0tyNQ/VHCtMGmZn51NmS6N1g6hCVrSJ8j00nq0/1sSxfkgrL+CV3ACDO7F17QwjKK7aGjcku1qKDzvy884OAY+F/ulneGfSSXJA8bepMs3wjtS5pCF+xnw2t0eKwxB37t1b2FVtEsQutiqhmel9ZH++0bWfTNtRrn&quot;,<br>            &quot;MD5OfBody&quot;: &quot;e1xxxxxxxxxxxxxxd0df952be3c2b2&quot;,<br>            &quot;Body&quot;: &quot;{\n  \&quot;Type\&quot; : \&quot;Notification\&quot;,\n  \&quot;MessageId\&quot; : \&quot;f5fe5954-183e-5a42-bfc5-074cb45d6aab\&quot;,\n  \&quot;TopicArn\&quot; : \&quot;arn:aws:sns:REGION:123456789012:WaitForCallbackTopic\&quot;,\n  \&quot;Message\&quot; : \&quot;{\\\&quot;Error\\\&quot;:\\\&quot;Failed to process payment\\\&quot;,\\\&quot;Cause\\\&quot;:\\\&quot;Invalid Credit Card\\\&quot;}\&quot;,\n  \&quot;Timestamp\&quot; : \&quot;2024-01-10T14:30:59.435Z\&quot;,\n  \&quot;SignatureVersion\&quot; : \&quot;1\&quot;,\n  \&quot;Signature\&quot; : \&quot;E8Zxxxxxxxxxxxxxxxxxxxxxxxxx0k1XoAWKo5wm3S01xur2Kr2OYkBn1f19TTWDp6hA6n90yIgei6iMrhxDalGrMY3f5iVtbgayvfsH5jzxdY3AS8uKSGt54fQ0pRpzt/y81itrNFnOW/e8He0l3vGTTYAliGHY4PrUtHEoQxvAv79RST7mnt9bCDKHqAQEfbC84YGjJcDBR3Dm3IAF4FxW5lhGSQ9PNvkWYYUeUgdS2jSNq6yNsLQXVBKSfkKCCzT6O7U8GYJY897VPQfAgo6gI5qQHx8yjU6r9YdKJp8Zni4uWXN6DN6+WsD5DJoh9N86I0dXhzA==\&quot;,\n  \&quot;SigningCertURL\&quot; : \&quot;https://sns.REGION.amazonaws.com/SimpleNotificationService-60eadc530605d63b8e62a523676ef735.pem\&quot;,\n  \&quot;UnsubscribeURL\&quot; : \&quot;https://sns.REGION.amazonaws.com/?Action=Unsubscribe&amp;SubscriptionArn=arn:aws:sns:REGION:123456789012:WaitForCallbackTopic:406e2ec2-9d6d-41dc-8ec5-6691c25eca1c\&quot;\n}&quot;<br>        },<br>        {<br>            &quot;MessageId&quot;: &quot;0fb65f5c-2bac-4c99-be10-49eb02adfad4&quot;,<br>            &quot;ReceiptHandle&quot;: &quot;AQEB6HZh3uKmx/GYbxxxxxxxxxxxxxxxxxxxu7a6tt0eVz9TJ4tF541PC7krkbMzno1sf1GMRouZDaua63S5GfpQDlpiMtDk9c6dx61YVlW621hLFGFCH+UB0LrDgUkvqQspjGpSd5K4HOsn341Y0BwiGsEsUMVkkZ7xkc8vK6fdFuqKKASJwWXdgWl1xyp2zp6HeSvyrriErac2gfzwde0cW1zabA/RPzkfd1qsMaqmKy/fh7wyYSQHvii9vIYPksSEf0LdyHb11SJPu0hKEdNKyULVzlYCDj2QoBnM+yJOrzEGhE9lxH/idwc1+8ALVoD4dlnbtqbx7ZH7seqoU1qvpAfWKxV8bMwwjBiUsbVBJD9SxBFjmffnyQ5IS/GRDiSYGIaZdWFj79i/SZBvR67gdIG5Z17FKClQb8ufMSmHLkb8mmQXc1xT/4RM5z&quot;,<br>            &quot;MD5OfBody&quot;: &quot;09a8xxxxxxxxxxxxxxxxxxac&quot;,<br>            &quot;Body&quot;: &quot;{\n  \&quot;Type\&quot; : \&quot;Notification\&quot;,\n  \&quot;MessageId\&quot; : \&quot;8e486acc-919d-52b4-8d70-34d429c0e6ca\&quot;,\n  \&quot;TopicArn\&quot; : \&quot;arn:aws:sns:REGION:123456789012:WaitForCallbackTopic\&quot;,\n  \&quot;Message\&quot; : \&quot;Payment processed successfully.\&quot;,\n  \&quot;Timestamp\&quot; : \&quot;2024-01-10T15:22:05.949Z\&quot;,\n  \&quot;SignatureVersion\&quot; : \&quot;1\&quot;,\n  \&quot;Signature\&quot; : \&quot;X/xxxxxxxxxxxxxxxxxxxx/l1uVaUQsqk2rEvdKOsgpt5BFYAVa5SB1tPfPrFYa3y32bDdZdKdthZH6+ShIE/oS9qJ0UtRgHc7UTkmZOs5AsjPOOL/TDF/dzutZC6E4BL/pU5ED3QKaV262rhs7xgD1FtRcO7PgrdWWAPg3UAuNIhs3VlvmjCVJRu6agt2liME2uPCN9FYElxUIG3UEJSI08/4j354k7mSXZcfzIVU4ghTL0bQxxxxxxxxxxxxxxxxxxxxxxxxFRUhl1tlQudL3E+AY5ILTwfdNTk1nTaKkrDrdt6M4oqg==\&quot;,\n  \&quot;SigningCertURL\&quot; : \&quot;https://sns.REGION.amazonaws.com/SimpleNotificationService-60eadc530605d63b8e62a523676ef735.pem\&quot;,\n  \&quot;UnsubscribeURL\&quot; : \&quot;https://sns.REGION.amazonaws.com/?Action=Unsubscribe&amp;SubscriptionArn=arn:aws:sns:REGION:123456789012:WaitForCallbackTopic:406e2ec2-9d6d-41dc-8ec5-6691c25eca1c\&quot;\n}&quot;<br>        }<br>    ]<br>}</pre><p>The output shows the successful and failed notification messages.</p><p><strong>Cleanup</strong><br>Delete the stack using below command</p><pre>sam delete</pre><p><strong>Conclusion</strong></p><p>And that wraps up our tutorial on implementing wait for callback in AWS Step Functions. In this post we built and deployed a simple workflow with AWS SAM that leveraged the power of wait for callback to process messages asynchronously via an SQS queue.</p><p>By having Step Functions pause execution and wait for the callback API, we avoided inefficient polling or hardcoded timers. The callback approach allows for more robust and resilient workflows.</p><p>We saw how to configure the Wait state, pass the task token to AWS Lambda function, implement the callback API, and handle errors. With these best practices you can integrate wait for callback into your own serverless applications.</p><p>The wait for callback pattern unlocks many possibilities for integrating AWS Step Functions with distributed systems, human approvals, and external processes. It provides efficiency, flexibility, and sequencing to orchestrate complex workflows.</p><p>I hope you now feel empowered to leverage wait for callback in your Step Functions to build asynchronous, event-driven architectures at scale. Please let me know in the comments if you have any other use cases where you could use this powerful feature!</p><p><strong>Further study</strong></p><ul><li><a href="https://docs.aws.amazon.com/step-functions/latest/dg/connect-to-resource.html#connect-wait-token">AWS Step Functions Developer Guide</a></li><li><a href="https://docs.aws.amazon.com/step-functions/latest/dg/callback-task-sample-sqs.html">Callback Pattern Example</a></li><li><a href="https://aws.amazon.com/blogs/compute/integrating-aws-step-functions-callbacks-and-external-systems/">Integrating AWS Step Functions callbacks and external systems</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59f6cd7f1d31" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[New Redrive Feature in AWS Step Functions Saves Time and Money]]></title>
            <link>https://medium.com/@biswanath.ita/new-redrive-feature-in-aws-step-functions-saves-time-and-money-4a0d7492fe1e?source=rss-893e0d23d555------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a0d7492fe1e</guid>
            <category><![CDATA[aws-step-functions]]></category>
            <category><![CDATA[redrive]]></category>
            <dc:creator><![CDATA[Biswanath Mukherjee]]></dc:creator>
            <pubDate>Sun, 14 Jan 2024 03:25:44 GMT</pubDate>
            <atom:updated>2024-01-14T03:25:44.487Z</atom:updated>
            <content:encoded><![CDATA[<p>On November 15, 2023 AWS Introduced a <a href="https://docs.aws.amazon.com/step-functions/latest/dg/redrive-executions.html">new redrive feature</a> in AWS Step Function which helps customer restart the workflow from the failed state instead of restarting the workflow from beginning or writing completed logic to achieve the same outcome. At the time of writing this post, here are some of the key points of this feature:</p><ul><li>The redrive feature in AWS Step Function is currently available for <strong>standard workflows only</strong>.</li><li>This can be used for executions that <strong>failed in the last 14 days</strong>.</li><li>Available for the execution <strong>on or after November 15, 2023</strong>.</li><li>The state machine level workflow <strong>timeout is reset to 0</strong> when using redrive.</li></ul><p>For the full and latest list of eligibility criteria, please refer to AWS documentation <a href="https://docs.aws.amazon.com/step-functions/latest/dg/redrive-executions.html#redrive-eligibility">Redrive eligibility for unsuccessful executions</a>.</p><p>When you use redrive, the workflow continues from the failed step using the same input data and execution ID as the original. Steps that already succeeded are not rerun. Only the failed step is retried. This saves time and cost compared to restarting the full workflow. Also, your use case might not allow restart the workflow beginning.</p><p>In this post we are going to create simple workflow to demonstrate this new feature from AWS Console.</p><p><strong>Solution Overview</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*mcTjJ5TusmPHBs_bTvtz8g.jpeg" /></figure><p>We are going to build the above super simple workflow to demonstrate the AWS Step Function redrive feature. The workflow involves invocation of two AWS Lambda functions along with a data insert into an Amazon DynamoDB table. We will similate a failure on the second AWS Lambda and test the redrive functionality from AWS Console.</p><p><strong>Prerequisites</strong></p><ul><li><a href="https://portal.aws.amazon.com/gp/aws/developer/registration/index.html">Create an AWS account</a> if you do not already have one.</li></ul><p><strong>Demo Preparation</strong></p><p>We will create the following resources for this demo:</p><ol><li>Create an Amazon DynamoDB Table</li><li>Create Calculate Price Lambda Function</li><li>Create Charge Customer Lambda Function</li><li>Create the Step Function Workflow</li></ol><p><strong>Step 1: Create an Amazon DynamoDB Table</strong></p><p>Lets create a DynamoDB table with the following details:<br><strong>Table Name:</strong> OderDetails<br><strong>Partition Key: </strong>customerId<br><strong>Type:</strong> String<br><strong>Sort Key:</strong> orderId<br><strong>Type:</strong> String<br><strong>Table class:</strong> DynamoDB Standard<br><strong>Read/write capacity settings:</strong> On-demand</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pCMrrdDJHQhmJJ8ix5ewQA.jpeg" /></figure><p>Click <strong>Create table</strong> at the bottom of the page.</p><p><strong>Step 2: Create Calculate Price AWS Lambda Function</strong></p><p>Lets create an AWS Lambda Function with the following details to simulate the calculate of price:</p><p><strong>Function Name:</strong> calculate-product-price<br><strong>Runtime:</strong> Python 3.12<br><strong>Function Code:</strong></p><pre>import json<br>import random<br><br>def lambda_handler(event, context):<br>    print(event)<br>    <br>    # Generate a random number between 100-1000<br>    rand_price = random.randint(100,1000)<br>    return {<br>        &#39;statusCode&#39;: 200,<br>        &quot;orderTotal&quot;: str(rand_price),<br>        &#39;body&#39;: json.dumps(&#39;Hello from Lambda!&#39;)<br>    }</pre><p><strong>Step 3: Create Charge Customer AWS Lambda Function</strong></p><p>Lets create another AWS Lambda Function with the following details to simulate charging the customer. This Lambda function is intensionally meant to throw Exception 20% of the time. This will be used to test the redrive feature of AWS Step Function.</p><p><strong>Function Name:</strong> charge-customer<br><strong>Runtime:</strong> Python 3.12<br><strong>Function Code:</strong></p><pre>import random<br>import json</pre><pre>def lambda_handler(event, context):</pre><pre>    # Generate a random number between 1-10<br>    rand_num = random.randint(1,10)<br>    <br>    if rand_num &lt;= 2:<br>        # Throw exception if number &lt;= 2 (20% probability)<br>        raise Exception(&#39;Random exception!&#39;)</pre><pre>    return {<br>        &#39;statusCode&#39;: 200,<br>        &#39;body&#39;: json.dumps(&#39;Hello from Lambda!&#39;)<br>    }</pre><p><strong>Step 4: Create an AWS Step Function Workflow</strong></p><p>i. Now it is time to create the workflow in the AWS Step Function with the following details.</p><p><strong>State machine name:</strong> redrive-demo<br><strong>Type:</strong> Standard<br><strong>Log level: </strong>ALL</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UPKclbfj8s42FQzfgjah9Q.jpeg" /></figure><p>ii. <strong>State Machine Code:</strong><br>Click on the <strong>{} Code </strong>tab and paste the below content. This will create the state function workflow.</p><pre>{<br>  &quot;Comment&quot;: &quot;A Simple State Machine to test redrive feature&quot;,<br>  &quot;StartAt&quot;: &quot;Calculate Price&quot;,<br>  &quot;States&quot;: {<br>    &quot;Calculate Price&quot;: {<br>      &quot;Type&quot;: &quot;Task&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:states:::lambda:invoke&quot;,<br>      &quot;Parameters&quot;: {<br>        &quot;Payload.$&quot;: &quot;$&quot;,<br>        &quot;FunctionName&quot;: &quot;arn:aws:lambda:us-east-1:796495736600:function:calculate-product-price:$LATEST&quot;<br>      },<br>      &quot;Retry&quot;: [<br>        {<br>          &quot;ErrorEquals&quot;: [<br>            &quot;Lambda.ServiceException&quot;,<br>            &quot;Lambda.AWSLambdaException&quot;,<br>            &quot;Lambda.SdkClientException&quot;,<br>            &quot;Lambda.TooManyRequestsException&quot;<br>          ],<br>          &quot;IntervalSeconds&quot;: 1,<br>          &quot;MaxAttempts&quot;: 3,<br>          &quot;BackoffRate&quot;: 2<br>        }<br>      ],<br>      &quot;Next&quot;: &quot;Create Order&quot;,<br>      &quot;ResultPath&quot;: &quot;$.result&quot;,<br>      &quot;ResultSelector&quot;: {<br>        &quot;orderTotal.$&quot;: &quot;$.Payload.orderTotal&quot;<br>      }<br>    },<br>    &quot;Create Order&quot;: {<br>      &quot;Type&quot;: &quot;Task&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:states:::dynamodb:putItem&quot;,<br>      &quot;Parameters&quot;: {<br>        &quot;TableName&quot;: &quot;OderDetails&quot;,<br>        &quot;Item&quot;: {<br>          &quot;customerId&quot;: {<br>            &quot;S.$&quot;: &quot;$.customerId&quot;<br>          },<br>          &quot;orderId&quot;: {<br>            &quot;S.$&quot;: &quot;$.orderId&quot;<br>          },<br>          &quot;orderTotal&quot;: {<br>            &quot;N.$&quot;: &quot;$.result.orderTotal&quot;<br>          }<br>        }<br>      },<br>      &quot;Next&quot;: &quot;Charge Customer&quot;,<br>      &quot;ResultPath&quot;: &quot;$.createOrderStatus&quot;,<br>      &quot;ResultSelector&quot;: {<br>        &quot;httpStatusCode.$&quot;: &quot;$.SdkHttpMetadata.HttpStatusCode&quot;<br>      }<br>    },<br>    &quot;Charge Customer&quot;: {<br>      &quot;Type&quot;: &quot;Task&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:states:::lambda:invoke&quot;,<br>      &quot;Parameters&quot;: {<br>        &quot;Payload.$&quot;: &quot;$&quot;,<br>        &quot;FunctionName&quot;: &quot;arn:aws:lambda:us-east-1:796495736600:function:charge-customer:$LATEST&quot;<br>      },<br>      &quot;Retry&quot;: [<br>        {<br>          &quot;ErrorEquals&quot;: [<br>            &quot;Lambda.ServiceException&quot;,<br>            &quot;Lambda.AWSLambdaException&quot;,<br>            &quot;Lambda.SdkClientException&quot;,<br>            &quot;Lambda.TooManyRequestsException&quot;<br>          ],<br>          &quot;IntervalSeconds&quot;: 1,<br>          &quot;MaxAttempts&quot;: 3,<br>          &quot;BackoffRate&quot;: 2<br>        }<br>      ],<br>      &quot;End&quot;: true<br>    }<br>  }<br>}</pre><p>iii. Click the <strong>Create</strong> button. AWS Step function will create the IAM Role with required permission to integrate with the DynamoDB table, AWS Lambda functions, CloudWatch and AWS X-Ray.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*94skl9N61qg_Rt59LGaaDg.jpeg" /></figure><p>iv. Click <strong>Confirm</strong>.</p><p>It will take a few seconds to create the state machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nHz36MMzABsM4zLaMWBo3A.jpeg" /></figure><p><strong>Test</strong></p><p>i. Click on the <strong>Start execution</strong> button.</p><p>ii. On the <strong>Input</strong> field provide the below JSON content</p><pre>{<br>    &quot;orderId&quot;: &quot;1234567&quot;,<br>    &quot;customerId&quot;: &quot;98766&quot;,<br>    &quot;orderDate&quot;: &quot;2024-01-14&quot;,<br>    &quot;productId&quot;: &quot;44444&quot;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T0stLKneSQcKaDilS4rFiw.jpeg" /></figure><p>iii. Click <strong>Start execution</strong>. The workflow will start executing. Remember that our Charge Customer AWS Lambda function throws Exception 20% of the time. So we may have to try a few times to get the exception. If the previous attempt was successful, click the <strong>New execution</strong> at the top of the page to start a new execution. Repeat this until an exception is encountered in the Charge Customer AWS Lambda function.</p><p>When you encounter the Exception, the execution <strong>Details</strong> tab will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aAeLDDPnnZCN9FUWmDlimQ.jpeg" /></figure><p>iv. Right in the middle of the page, under the Exception block, we have a <strong>Recover</strong> button. If you click the arrow next to it, you get the new option <strong>Redrive from failure</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ya-36rlAxwlaVIDnic_gfg.jpeg" /></figure><p>Our Step Function may run successfully, assuming no Exception was encountered in the next attempt. Let’s try. Yes, it is!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XarcyE3F7Nx11BIqP0t0kA.jpeg" /></figure><p>v. If you check the <strong>Executions</strong> tab of our state machine, then you will find the previously failed execution is now successful (i.e. it is not a new execution).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F5OytnOVqSKEqVat_FeiFg.jpeg" /></figure><p>vi. Also you have an option to start the redrive on a failed execution from the execution list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ax4geuX5A_yaJzCpZEwLyw.jpeg" /></figure><p>vii. Also as mentioned before, if your execution does not meet redrive criteria then you will not be able to redrive the execution. For example, I have some old failed execution for which I get the following error message:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SwYSiQBsrvkylgbzmFi0TQ.jpeg" /></figure><p>or</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8j298PF9vRhfcXLajKu9Jw.jpeg" /></figure><p><strong>Cleaning up</strong><br>Once you are done with your PoC, it is already better to clean up the resources to avoid accidental misuse or charges.</p><ul><li>Delete the Amazon DynamoDB table OderDetails</li><li>Delete the AWS Lambda functions calculate-product-price and charge-customer</li><li>Delete the AWS Step Function work flow redrive-demo</li></ul><p><strong>Conclusion</strong></p><p>The above demonstration illustrates the appropriate timing and methodology for utilising the recently released AWS Step Functions feature to restart the step function from the failure state, rather than restarting the entire workflow. I demonstrated this capability through the AWS console, however it can also be done using Amazon EventBridge and an AWS Lambda function as detailed in the below blog post. This new feature primarily provides the following benefits:</p><ul><li>Reduces complexity of developing custom code for use cases that prohibit re-execution of previously successful steps, such as non-idempotent transactions.</li><li>Saves costs by minimising state transitions and avoiding unnecessary invocations of AWS services which are already in successful state.</li><li>Saves execution time by preventing re-running of steps that already completed successfully.</li></ul><p><strong>Further study</strong></p><ul><li>AMP Developer Guide for <a href="https://docs.aws.amazon.com/step-functions/latest/dg/redrive-executions.html">AWS Step Functions</a>.</li><li><a href="https://aws.amazon.com/blogs/compute/introducing-aws-step-functions-redrive-a-new-way-to-restart-workflows/">Introducing AWS Step Functions redrive to recover from failures more easily</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a0d7492fe1e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlock High-Speed Access to Amazon S3 Objects from Kubernetes with Mountpoint for S3 CSI Driver]]></title>
            <link>https://medium.com/@biswanath.ita/unlock-high-speed-access-to-amazon-s3-objects-from-kubernetes-with-mountpoint-for-s3-csi-driver-4a5a450037a4?source=rss-893e0d23d555------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a5a450037a4</guid>
            <dc:creator><![CDATA[Biswanath Mukherjee]]></dc:creator>
            <pubDate>Sun, 07 Jan 2024 09:41:15 GMT</pubDate>
            <atom:updated>2024-03-31T15:46:07.682Z</atom:updated>
            <content:encoded><![CDATA[<p>During re:Invent 2023, AWS has made <a href="https://aws.amazon.com/about-aws/whats-new/2023/11/mountpoint-amazon-s3-csi-driver/">Mountpoint for Amazon S3 Container Storage Interface (CSI) driver generally available</a>. Amazon S3 CSI uses <a href="https://aws.amazon.com/s3/features/mountpoint/">Mountpoint</a> for Amazon S3 under the hood. Applications running on Amazon Elastic Kubernetes Service (EKS) or self-managed Kubernetes clusters can access (read and write) objects through a file system interface when mountpoint for Amazon S3 CSI driver is configured. This allows high throughput access without changes to the application code.</p><p>In this post we are going to create an end to end demo to configure Mountpoint for Amazon S3 CSI driver in an Amazon EKS cluster (Kubernetes version 1.27) and then read and write from objects on an Amazon S3 Bucket. All the detailed instructions, configuration steps and code are referred from the below AWS documentation:</p><ul><li><a href="https://docs.aws.amazon.com/eks/latest/userguide/s3-csi.html">Mountpoint for Amazon S3 CSI driver</a></li><li><a href="https://github.com/awslabs/mountpoint-s3-csi-driver">Mountpoint for Amazon S3 Container Storage Interface (CSI) driver</a></li></ul><p><strong>Prerequisites</strong></p><ul><li><a href="https://portal.aws.amazon.com/gp/aws/developer/registration/index.html">Create an AWS account</a> if you do not already have one.</li><li>Access to AWS account via AWS Console and CLI. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources mentioned in this post.</li><li>Access to a terminal with <a href="https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html">Kubectl</a> and <a href="https://docs.aws.amazon.com/eks/latest/userguide/eksctl.html">Amazon EKS command line tool</a> (<a href="https://eksctl.io/">eksctl</a> version 0.165.0 or greater), installed and configured.</li><li>Additionally, please refer to the Considerations and Prerequisites sections of the <a href="https://docs.aws.amazon.com/eks/latest/userguide/s3-csi.html">Amazon EKS User Guide</a>.</li></ul><p><strong>Demo Preparation</strong></p><p>The the resources in this demo will be created in the us-east-1 region. I have created this demo from my MacBook. Please refer to AWS documentation wherever required for equivalent commands for other operating system. We will follow the below steps:</p><ol><li>Create an Amazon EKS cluster</li><li>Create Amazon S3 buckets</li><li>Create an IAM policy to allow access to Amazon S3 buckets</li><li>Create an IAM OIDC provider for the EKS Cluster</li><li>Create an IAM role, Service Account and link them</li><li>Install Mountpoint for Amazon S3 CSI driver</li><li>Deploy a sample application and Test</li><li>Cleaning up</li></ol><p><strong>Step 1: Create an Amazon EKS cluster</strong></p><p>i. There are different methods that can be followed to create Amazon EKS cluster as described in <a href="https://docs.aws.amazon.com/eks/latest/userguide/getting-started.html">Getting started with Amazon EKS</a> user guide. I am using <a href="https://eksctl.io/">eksctl</a> to create the cluster:</p><pre>eksctl create cluster —name eks-s3-mountpoint-csi —region us-east-1</pre><p>The cluster creation took me about 15mins to complete. The command will complete with output like below:</p><pre>2024-01-03 19:39:37 [✔] all EKS cluster resources for &quot;eks-s3-mountpoint-csi&quot; have been created<br>2024-01-03 19:39:39 [ℹ] nodegroup &quot;ng-0e4dd6cb&quot; has 2 node(s)<br>2024-01-03 19:39:39 [ℹ] node &quot;ip-xxx-xxx-xx-90.ec2.internal&quot; is ready<br>2024-01-03 19:39:39 [ℹ] node &quot;ip-xxx-xxx-xx-116.ec2.internal&quot; is ready<br>2024-01-03 19:39:39 [ℹ] waiting for at least 2 node(s) to become ready in &quot;ng-0e4dd6cb&quot;<br>2024-01-03 19:39:40 [ℹ] nodegroup &quot;ng-0e4dd6cb&quot; has 2 node(s)<br>2024-01-03 19:39:40 [ℹ] node &quot;ip-xxx-xxx-xx-90.ec2.internal&quot; is ready<br>2024-01-03 19:39:40 [ℹ] node &quot;ip-xxx-xxx-xx-116.ec2.internal&quot; is ready<br>2024-01-03 19:39:41 [ℹ] kubectl command should work with &quot;/Users/awsbiswa/.kube/config&quot;, try &#39;kubectl get nodes&#39;<br>2024-01-03 19:39:41 [✔] EKS cluster &quot;eks-s3-mountpoint-csi&quot; in &quot;us-east-1&quot; region is ready</pre><p>ii. Let’s check that we are able to connect the newly created Amazon EKS cluster from CLI:</p><pre>xxxx$ kubectl get ns         <br>NAME                STATUS      AGE<br>default             Active       5m<br>kube-node-lease     Active       5m<br>kube-public         Active       5m<br>kube-system         Active       5m</pre><p><strong>Step 2: Create Amazon S3 buckets</strong></p><p>i. Open Amazon S3 Service from AWS console and click the <strong>Create bucket</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8SOkbyjwoHROnrlvU3EVxA.jpeg" /></figure><p>ii. Select <strong>us-east-1</strong> as the region, select <strong>General Purpose</strong> as Bucket type and provide a <strong>bucket name</strong>. Leave all other settings to default and click the <strong>Create bucket</strong> button at the bottom of the page. My bucket name is: eks-s3-csi-driver-demo</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DLuiCSBbXmR2-oShBwyuzw.jpeg" /></figure><p>iii. Now, we will create Amazon S3 Express One Zone bucket. Go to the Create bucket page, Select <strong>us-east-1</strong> as the region, this time select Bucket type as <strong>Directory</strong>, <strong>use1-az6</strong> as the Availability Zone. Acknowledge the warning and provide a base name of the bucket. Please note the full bucket name is derived based on the chosen Availability Zone. Leave all other settings to default and click the <strong>Create bucket</strong> button at the bottom of the page. My Express One Zone bucket name is: eks-s3-csi-driver-demo--use1-az6--x-s3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mcYM0IkqkYY8cEl-6RSZQQ.jpeg" /></figure><p><strong>Step 3: Create an IAM policies to allow access to Amazon S3 buckets</strong></p><p>Let us first create the IAM policy to provide access to the General purpose bucket. Open the <a href="https://console.aws.amazon.com/iam/">IAM console</a>, choose <strong>Policies </strong>from In the left navigation pane. Click <strong>Create policy</strong>. For <strong>Policy editor</strong>, choose <strong>JSON</strong>. Under <strong>Policy editor</strong>, copy and paste the following:<br>Please note, for this demo purpose I am giving access to all the buckets. Ideally we should be giving access to only the required buckets.</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Sid&quot;: &quot;MountpointFullBucketAccess&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;s3:ListBucket&quot;<br>            ],<br>            &quot;Resource&quot;: [<br>                &quot;arn:aws:s3:::*&quot;<br>            ]<br>        },<br>        {<br>            &quot;Sid&quot;: &quot;MountpointFullObjectAccess&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;s3:GetObject&quot;,<br>                &quot;s3:PutObject&quot;,<br>                &quot;s3:AbortMultipartUpload&quot;,<br>                &quot;s3:DeleteObject&quot;<br>            ],<br>            &quot;Resource&quot;: [<br>                &quot;arn:aws:s3:::*/*&quot;<br>            ]<br>        }<br>    ]<br>}</pre><p>Choose <strong>Next</strong>. On the <strong>Review and create</strong> page, name your policy. I have used AmazonS3CSIDriverPolicy<br>as the policy name. Choose <strong>Create policy</strong>.</p><p>Now, let create another policy to provide access to Amazon S3 Express One Zone bucket. Follow the steps as before and create a policy with name S3ExpressFullAccess with the following JSON:</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Sid&quot;: &quot;AllowAccessRegionalEndpointAPIs&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;s3express:DeleteBucket&quot;,<br>                &quot;s3express:DeleteBucketPolicy&quot;,<br>                &quot;s3express:CreateBucket&quot;,<br>                &quot;s3express:PutBucketPolicy&quot;,<br>                &quot;s3express:GetBucketPolicy&quot;,<br>                &quot;s3express:ListAllMyDirectoryBuckets&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;arn:aws:s3express:*:*:bucket/*/*&quot;<br>        },<br>        {<br>            &quot;Sid&quot;: &quot;AllowCreateSession&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: &quot;s3express:CreateSession&quot;,<br>            &quot;Resource&quot;: &quot;*&quot;<br>        }<br>    ]<br>}</pre><p><strong>Step 4: Create an IAM OIDC provider for the EKS Cluster</strong></p><p>One of the prerequisites is to have an existing AWS Identity and Access Management (IAM) OpenID Connect (OIDC) provider for the EKS cluster. Now lets create an IAM OIDC provider for our EKS cluster. It can be done via eksctl or AWS Management Console following the AWS Documentation <a href="https://docs.aws.amazon.com/eks/latest/userguide/enable-iam-roles-for-service-accounts.html">Creating an IAM OIDC provider for your cluster</a>.</p><p>Lets run the following command:</p><pre>eksctl utils associate-iam-oidc-provider --region=us-east-1 --cluster=eks-s3-mountpoint-csi --approve</pre><p>It gives an output as follows:</p><pre>2024-01-03 21:37:38 [ℹ] will create IAM Open ID Connect provider for cluster &quot;eks-s3-mountpoint-csi&quot; in &quot;us-east-1&quot;<br>2024-01-03 21:37:41 [✔] created IAM Open ID Connect provider for cluster &quot;eks-s3-mountpoint-csi&quot; in &quot;us-east-1&quot;</pre><p>Open the <a href="https://console.aws.amazon.com/iam/">IAM console</a>. In the left navigation pane, choose <strong>Identity Providers</strong> under <strong>Access management</strong>. Validate the provide is created. It should match <strong>OpenID Connect provider URL </strong>of the EKS cluster (without the <a href="https://)./">https://).</a></p><p><strong>Step 5: Create an IAM role, Service Account and link them</strong></p><p>This is step can be performed via eksctl or IAM Console or AWS CLI. This step is a bit tricky and contains multiple substeps if you doing it via IAM Console or AWS CLI. Please refer to AWS <a href="https://docs.aws.amazon.com/eks/latest/userguide/s3-csi.html#s3-create-iam-role">documentation</a> for detailed steps.</p><p>Run the following commands:</p><pre>CLUSTER_NAME=eks-s3-mountpoint-csi<br>REGION=us-east-1<br>ROLE_NAME=AmazonEKS_S3_CSI_Driver_Role<br>POLICY_ARN1=arn:aws:iam::123456789012:policy/AmazonS3CSIDriverPolicy<br>POLICY_ARN2=arn:aws:iam::123456789012:policy/S3ExpressFullAccess</pre><pre>eksctl create iamserviceaccount \<br>    --name s3-csi-driver-sa \<br>    --namespace kube-system \<br>    --cluster $CLUSTER_NAME \<br>    --attach-policy-arn $POLICY_ARN1 \<br>    --attach-policy-arn $POLICY_ARN2 \<br>    --approve \<br>    --role-name $ROLE_NAME \<br>    --region $REGION</pre><p>The output should be as follows:</p><pre>2024-01-03 21:50:20 [ℹ] 1 iamserviceaccount (kube-system/s3-csi-driver-sa) was included (based on the include/exclude rules)<br>2024-01-03 21:50:20 [!] serviceaccounts that exist in Kubernetes will be excluded, use —override-existing-serviceaccounts to override<br>2024-01-03 21:50:20 [ℹ] 1 task: { <br> 2 sequential sub-tasks: { <br> create IAM role for serviceaccount &quot;kube-system/s3-csi-driver-sa&quot;,<br> create serviceaccount &quot;kube-system/s3-csi-driver-sa&quot;,<br> } }2024-01-03 21:50:20 [ℹ] building iamserviceaccount stack &quot;eksctl-eks-s3-mountpoint-csi-addon-iamserviceaccount-kube-system-s3-csi-driver-sa&quot;<br>2024-01-03 21:50:20 [ℹ] deploying stack &quot;eksctl-eks-s3-mountpoint-csi-addon-iamserviceaccount-kube-system-s3-csi-driver-sa&quot;<br>2024-01-03 21:50:21 [ℹ] waiting for CloudFormation stack &quot;eksctl-eks-s3-mountpoint-csi-addon-iamserviceaccount-kube-system-s3-csi-driver-sa&quot;<br>2024-01-03 21:50:52 [ℹ] waiting for CloudFormation stack &quot;eksctl-eks-s3-mountpoint-csi-addon-iamserviceaccount-kube-system-s3-csi-driver-sa&quot;<br>2024-01-03 21:50:53 [ℹ] created serviceaccount &quot;kube-system/s3-csi-driver-sa&quot;</pre><p>The above command will perform the following tasks:</p><ul><li>Create IAM role named AmazonEKS_S3_CSI_Driver_Role and attach policies AmazonS3CSIDriverPolicy and S3ExpressFullAccess. Please log into IAM Console to validate it.</li><li>Create a Kubernetes service account named s3-csi-driver-sa and annotate it with the ARN of the IAM role. Please run the below command to validate it.</li></ul><pre>kubectl -n kube-system describe sa s3-csi-driver-sa</pre><p>The output should be as follows:</p><pre>Name:                s3-csi-driver-sa<br>Namespace:           kube-system<br>Labels:              app.kubernetes.io/managed-by=eksctl<br>Annotations:         eks.amazonaws.com/role-arn: arn:aws:iam::123456789012:role/AmazonEKS_S3_CSI_Driver_Role<br>Image pull secrets:  &lt;none&gt;<br>Mountable secrets:   &lt;none&gt;<br>Tokens:              &lt;none&gt;<br>Events:              &lt;none&gt;</pre><p><strong>Step 6: Install Mountpoint for Amazon S3 CSI driver</strong></p><p>Now we will install the Mountpoint for Amazon S3 CSI driver. It can be done using eksctl or AWS Management Console or AWS CLI. Please refer to AWS <a href="https://docs.aws.amazon.com/eks/latest/userguide/managing-add-ons.html#creating-an-add-on">documentation</a> for detailed steps using different methods.</p><p>I am doing it via eksctl as I created the service account using eksctl. Please note: I tried to create it via AWS Management Console but it failed with conflict error that service account was managed by eksctl.</p><p>Run the following command:. Replace the IAM Role ARN.</p><pre>eksctl create addon --cluster eks-s3-mountpoint-csi --name aws-mountpoint-s3-csi-driver --version latest --service-account-role-arn arn:aws:iam::123456789012:role/AmazonEKS_S3_CSI_Driver_Role --force</pre><p>The command should give output as follows:</p><pre>2024-01-03 23:44:09 [ℹ] Kubernetes version &quot;1.27&quot; in use by cluster &quot;eks-s3-mountpoint-csi&quot;<br>2024-01-03 23:44:10 [ℹ] using provided ServiceAccountRoleARN &quot;arn:aws:iam::123456789012:role/AmazonEKS_S3_CSI_Driver_Role&quot;<br>2024-01-03 23:44:10 [ℹ] creating addon<br>2024-01-03 23:44:52 [ℹ] addon &quot;aws-mountpoint-s3-csi-driver&quot; active</pre><p>Also validate it from AWS Console. Open Amazon EKS Console and select the cluster. Go to <strong>Add-ons</strong> tab:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z_Ozl1icoqsfOTZhL7X70g.jpeg" /></figure><p><strong>Step 7: Deploy a sample application and Test</strong></p><p>Now deploy sample application from awslabs Github <a href="https://github.com/awslabs/mountpoint-s3-csi-driver/tree/main/examples/kubernetes/static_provisioning">repository</a> to test the setup.</p><p>i. Let us first try with static_provisioning.yam . I have modified the bucket name as per my setup.</p><pre>apiVersion: v1<br>kind: PersistentVolume<br>metadata:<br>  name: s3-pv<br>spec:<br>  capacity:<br>    storage: 1200Gi # ignored, required<br>  accessModes:<br>    - ReadWriteMany # supported options: ReadWriteMany / ReadOnlyMany<br>  mountOptions:<br>    - allow-delete<br>    - region us-east-1<br>  csi:<br>    driver: s3.csi.aws.com # required<br>    volumeHandle: s3-csi-driver-volume<br>    volumeAttributes:<br>      bucketName: eks-s3-csi-driver-demo<br>---<br>apiVersion: v1<br>kind: PersistentVolumeClaim<br>metadata:<br>  name: s3-claim<br>spec:<br>  accessModes:<br>    - ReadWriteMany # supported options: ReadWriteMany / ReadOnlyMany<br>  storageClassName: &quot;&quot; # required for static provisioning<br>  resources:<br>    requests:<br>      storage: 1200Gi # ignored, required<br>  volumeName: s3-pv<br>---<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: s3-app<br>spec:<br>  containers:<br>    - name: app<br>      image: centos<br>      command: [&quot;/bin/sh&quot;]<br>      args: [&quot;-c&quot;, &quot;echo &#39;Hello from the container!&#39; &gt;&gt; /data/$(date -u).txt; tail -f /dev/null&quot;]<br>      volumeMounts:<br>        - name: persistent-storage<br>          mountPath: /data<br>  volumes:<br>    - name: persistent-storage<br>      persistentVolumeClaim:<br>        claimName: s3-claim</pre><p>ii. Create resources based on the above yaml file:</p><pre>kubectl apply -f static_provisioning.yaml</pre><p>iii. Check the status of the pod:</p><pre>kubectl get po</pre><pre>NAME   READY STATUS   RESTARTS AGE<br>s3-app 1/1   Running  0        24s</pre><p>iv. Open the bucket eks-s3-csi-driver-demo from the AWS Console and validate a new file has been created by the pod:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uYPMl1jUlbxsYAXz0IVcpg.jpeg" /></figure><p>v. Log into the pod and create another file.</p><pre>kubectl exec -it pod/s3-app -- /bin/bash<br>cd data<br>ls</pre><p>vi. Create another file here and validate the same is also reflected under S3 bucket.</p><pre>echo &quot;Hello world.&quot; &gt; helloworld.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mh3syHEhTLofe_8TQHxdtQ.jpeg" /></figure><p>Validate the new file is visible on Amazon S3 using AWS Console.</p><p>vi. Now a upload a new file into the Amazon S3 bucket. The same should be visible from inside the container.</p><p>vii. Delete the pod and associated resources:</p><pre>kubectl delete -f static_provisioning.yaml</pre><p>viii. Now lets modify s3_express_specify_az.yaml based on our bucket name and Availability Zone.</p><pre>apiVersion: v1<br>kind: PersistentVolume<br>metadata:<br>  name: s3-pv<br>spec:<br>  capacity:<br>    storage: 1200Gi # ignored, required<br>  accessModes:<br>    - ReadWriteMany # supported options: ReadWriteMany / ReadOnlyMany<br>  mountOptions:<br>    - allow-delete<br>    - region us-east-1<br>  csi:<br>    driver: s3.csi.aws.com # required<br>    volumeHandle: s3-csi-driver-volume<br>    volumeAttributes:<br>      bucketName: eks-s3-csi-driver-demo--use1-az6--x-s3<br>  nodeAffinity:<br>    required:<br>      nodeSelectorTerms:<br>        - matchExpressions:<br>          - key: topology.kubernetes.io/zone<br>            operator: In<br>            values:<br>            - us-east-1a<br>---<br>apiVersion: v1<br>kind: PersistentVolumeClaim<br>metadata:<br>  name: s3-claim<br>spec:<br>  accessModes:<br>    - ReadWriteMany # supported options: ReadWriteMany / ReadOnlyMany<br>  storageClassName: &quot;&quot; # required for static provisioning<br>  resources:<br>    requests:<br>      storage: 1200Gi # ignored, required<br>  volumeName: s3-pv<br>---<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: s3-app<br>spec:<br>  containers:<br>    - name: app<br>      image: centos<br>      command: [&quot;/bin/sh&quot;]<br>      args: [&quot;-c&quot;, &quot;echo &#39;Hello from the container!&#39; &gt;&gt; /data/$(date -u).txt; tail -f /dev/null&quot;]<br>      volumeMounts:<br>        - name: persistent-storage<br>          mountPath: /data<br>  volumes:<br>    - name: persistent-storage<br>      persistentVolumeClaim:<br>        claimName: s3-claim</pre><p>ix. Apply the yaml file and check the pod status like before. Wait until the pod status is running.</p><pre>kubectl apply -f s3_express_specify_az.yaml</pre><p>x. Check that new file created by pod is visible from the AWS Web Console. You can also perform additional tests like before by creating different files from within Pod or through AWS console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BMo8o7P-kyojqjh5rtSgcg.jpeg" /></figure><p><strong>Step 8: Cleaning up</strong><br>Once you are done with your PoC, please don’t forget to clean up the AWS resources created to avoid accidental misuse or charges.</p><ul><li>Delete the Amazon S3 buckets from AWS web console.</li><li>Delete the pod created on the EKS cluster</li></ul><pre>kubectl delete -f s3_express_specify_az.yaml<br>or<br>kubectl delete -f static_provisioning.yaml</pre><ul><li>Delete the Amazon EKS cluster from CLI using eksctl.</li></ul><pre>eksctl delete cluster —name eks-s3-mountpoint-csi —region us-east-1</pre><ul><li>Optionally, delete the IAM Policies and Roles created through AWS web console.</li></ul><p><strong>Limitations</strong></p><p>At the time of writing, Mountpoint for Amazon S3 CSI driver has the following limitations. Please refer to AWS <a href="https://docs.aws.amazon.com/eks/latest/userguide/s3-csi.html">documentation</a> for the latest and full list of limitations:</p><ul><li>Compatible with Kubernetes versions v1.23+. The driver supports x86–64 and arm64 architectures.</li><li>Not compatible with Windows based container images.</li><li>Does not support AWS Fargate. Amazon EKS or self-managed Kubernetes clusters running on EC2 instances are supported.</li><li>The Amazon S3 bucket must be pre-created.</li><li>Volumes mounted with the Mountpoint for Amazon S3 CSI driver don’t support all POSIX file-system features. Detail<a href="https://github.com/awslabs/mountpoint-s3/blob/main/doc/SEMANTICS.md"> here</a>.</li></ul><p><strong>Conclusion</strong></p><p>In this tutorial, we walked through the steps to deploy the Mountpoint for Amazon S3 CSI driver on an Amazon EKS cluster and verified the read and write access to Amazon S3 objects through a pod running on the Amazon EKS cluster. <br>In summary, the new Mountpoint for Amazon S3 CSI driver unlocks the ability for Kubernetes applications to directly access S3 objects as files. This removes the barrier of having to build complex integrations or write intermediary code to enable S3 access. With a simple CSI driver installation, developers can mount S3 buckets as volumes in Amazon EKS and self-managed Kubernetes clusters.<br>As cloud-native applications continue to drive more value from data in S3, the Mountpoint for S3 CSI driver removes a key friction point in enabling performant access. This means reduced development effort and easier data pipelines to power machine learning and analytics use cases on Kubernetes.</p><p><strong>Further study</strong></p><ul><li>AMP User Guide for <a href="https://docs.aws.amazon.com/eks/latest/userguide/s3-csi.html">Mountpoint for Amazon S3 CSI driver</a>.</li><li><a href="https://github.com/awslabs/mountpoint-s3/blob/main/doc/SEMANTICS.md">Mountpoint for Amazon S3 file system behavior</a>.</li><li><a href="https://docs.aws.amazon.com/eks/latest/userguide/managing-add-ons.html">Managing Amazon EKS add-ons</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a5a450037a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Purpose of AWS Messaging Services and Choosing the Right One]]></title>
            <link>https://medium.com/@biswanath.ita/the-purpose-of-aws-messaging-services-and-choosing-the-right-one-759fadbf59a5?source=rss-893e0d23d555------2</link>
            <guid isPermaLink="false">https://medium.com/p/759fadbf59a5</guid>
            <category><![CDATA[messaging]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[architecture]]></category>
            <dc:creator><![CDATA[Biswanath Mukherjee]]></dc:creator>
            <pubDate>Mon, 01 Jan 2024 03:57:28 GMT</pubDate>
            <atom:updated>2024-01-01T03:57:28.441Z</atom:updated>
            <content:encoded><![CDATA[<p>Whether you are building a simple website, a complex web application, a mobile app or implementing Internet of Things (IoT) solutions, messaging plays an important role. Building scalable, resilient and cost-effective distributed applications often requires asynchronous messaging capabilities to decouple system components, increase throughput, enable parallel fan-out and implement advanced data streaming pipelines. The ability to efficiently pass messages between application components with low latency and high reliability is critical for good user experience and overall system resilience.</p><p>AWS provides a range of fully managed cloud native messaging services to meet various use cases — from simple queue services for workflows, background jobs etc. to complex publish-subscribe systems, streaming data pipelines, near real-time analytics and others. The core purpose of these AWS messaging solutions is to enable decoupled system architectures by separating message producers from consumers. Producers publish messages to a broker without knowledge of what systems may subscribe to or process that data. Likewise, consumers receive messages without insight into the publisher. This loose coupling facilitates asynchronous, scalable distributed systems. Introducing a dedicated messaging layer instead of direct API calls allows workloads to progress independently. Producers can emit data at high volumes or rates while consumers process messages at their own pace, scaling resource usage up or down as needed. Consumers are not directly blocked or constrained by how fast producers generate messages. Though these AWS services share common messaging models and architectural benefits like asynchronous communication and loose coupling, each option offers distinct features and capabilities. Choosing the right messaging service for your architecture can have significant impacts on cost, performance, scalability and ease of operations.</p><p>This comprehensive blog post compares the popular AWS messaging options across dimensions like ordering, delivery guarantees, security, integrations and streaming analytics to guide your choice based on specific use cases and architecture.</p><p>Accordingly, when evaluating AWS messaging services for a workload, the specific technical requirements, business use case, and application patterns determine the ideal solution. Architects must assess needs around message ordering, replay, retention policy, security, integrations and streaming analytics to inform the optimal service selection.</p><h4><strong>Overview of AWS Messaging Services</strong></h4><p>Here is a quick introduction to the major managed messaging services available on AWS:</p><ol><li><strong>Amazon Simple Queue Service (SQS)</strong></li></ol><p><a href="https://aws.amazon.com/sqs/">Amazon SQS</a> is a fully-managed message queuing service that enables decoupling and scaling of distributed applications and microservices. Messages are stored in highly available queues until processed. Amazon SQS achieves horizontal scale-out via distributed queues. Amazon SQS allows multiple distributed producers to push high volumes of messages into a durable queue. At the same time, parallel consumer processes can <strong>poll</strong> and process messages from the queue. However, <strong>each message is processed by only one consumer</strong>. Please refer to the AWS documentation for details about different <a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/features-capabilities.html">features and capabilities</a> of Amazon SQS.</p><p><strong>2. Amazon Simple Notification Service (SNS)</strong></p><p><a href="https://aws.amazon.com/sns/">Amazon SNS</a> is a high throughput, fully managed pub/sub messaging service to deliver application-to-application (A2A) notifications as well as application-to-person (A2P) notifications. Amazon SNS allows for parallel fan-out messaging to a dynamic group of recipients (subscribers) like sending alerts or notifications to sent to many subscribed endpoints like email, SMS or HTTP. Unlike Amazon SQS, SNS can send the <strong>same message to multiple subscribers</strong>. Subscribers do <strong>not need to poll</strong> for message from Amazon SNS. Please refer to the AWS documentation for details about different <a href="https://docs.aws.amazon.com/sns/latest/dg/welcome-features.html">features and capabilities</a> of Amazon SNS.</p><p><strong>3. Amazon MQ</strong></p><p><a href="https://aws.amazon.com/amazon-mq/">Amazon MQ</a> is a fully managed message broker service for popular brokers like ActiveMQ and RabbitMQ. Useful for migrating existing MQ deployments to AWS with minimal changes to application that rely on compatibility with APIs such as JMS or protocols such as AMQP 0–9–1, AMQP 1.0, MQTT, OpenWire, WebSocket and STOMP. So if your use case does not have hard dependency on aforementioned message brokers or protocols, Amazon SQS and Amazon SNS will be a better choice to take advantage of nearly unlimited scalability and simple APIs. Please refer to the AWS documentation for details about different <a href="https://aws.amazon.com/amazon-mq/features/">features and capabilities</a> of Amazon MQ.</p><p><strong>4. Amazon EventBridge</strong></p><p><a href="https://aws.amazon.com/eventbridge/">Amazon EventBridge</a> is a serverless event bus service that makes it easy to connect applications together using data from your applications, integrated Software-as-a-Service (SaaS) applications, custom applications and AWS services. Useful for building event-driven architectures. Amazon EventBridge follows pub/sub model i.e. the subscribers does not need to poll rather events are pushed to them. We can create rules. filter logic, schedule event, configure schema for events and lot more in Amazon EventBrige. Please refer to the AWS documentation for details about different <a href="https://aws.amazon.com/eventbridge/features/">features and capabilities</a> of Amazon MQ.</p><p><strong>5. Amazon Managed Streaming for Apache Kafka (MSK)</strong></p><p><a href="https://aws.amazon.com/msk/">Amazon MSK</a> is a fully managed, highly available Apache Kafka clusters for building near real-time streaming data pipelines and applications. Kafka provides distributed, partitioned, replicated commit log service with pub/sub semantics. Please refer to the AWS documentation for details about different <a href="https://aws.amazon.com/msk/features/">features and capabilities</a> of Amazon MSK.</p><p><strong>6. Amazon Kinesis Data Streams (KDS)</strong></p><p><a href="https://aws.amazon.com/kinesis/">Amazon Kinesis</a> is a fully managed serverless service for streaming data on AWS, offering capabilities like data and video streams ingestions, processing and analysing streaming data in real time from hundreds of thousands of sources. Useful for rapidly moving data from producers and then continuously processing the data streams. There are four different offerings under Amazon Kinesis:<br><a href="https://docs.aws.amazon.com/streams/latest/dev/key-concepts.html">Kinesis Data Streams</a> — Collects streaming data with a data stream.<br><a href="https://docs.aws.amazon.com/firehose/latest/dev/what-is-this-service.html#key-concepts">Kinesis Data Firehose</a> — Processes and delivers streaming data with data delivery stream.<br><a href="https://docs.aws.amazon.com/managed-flink/latest/java/how-it-works.html">Managed Apache Flink </a>(Formerly Kinesis Data Analytics) — Analyses streaming data with data analytics application.<br><a href="https://docs.aws.amazon.com/kinesisvideostreams/latest/dg/how-it-works.html">Kinesis Video Stream</a> — Captures, processes and stores Video Streams for Analytics and Machine Learning.</p><p>Please refer to the AWS documentations for key concepts and terminologies uses in these services.</p><p>In this post we will be comparing with Amazon Kinesis Data Streams (KDS) only. The consumers have options to pull messages from Amazon KDS using GetRecords API or SubscribeToShard API that uses the HTTP/2 protocol to deliver data to registered consumers whenever new data arrives on the shard. Same messages can be processed by multiple independent consumers. Each consumer controls the position from where they want to read messages.</p><h4><strong>Key Feature Comparison between AWS Messaging Services</strong></h4><p>Here is a feature matrix comparing some key aspects of the different AWS messaging options. Caveat: AWS being very dynamic cloud platform, new features get released throughout the year. This table will be outdated sooner than later! It is always advisable to refer to the latest AWS documentation for these (and any other) AWS services to make informed decision.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JA38_llGl71VYlIzhjnmDQ.png" /></figure><p>* Please refer to this blog how to <a href="https://aws.amazon.com/blogs/compute/implementing-fifo-message-ordering-with-amazon-mq-for-apache-activemq/">implement FIFO messages ordering with Amazon MQ for Apache ActiveMQ</a>.<br>** To send messages larger than 256 KiB, you can use the <a href="https://github.com/awslabs/amazon-sqs-java-extended-client-lib">Amazon SQS Extended Client Library for Java</a>. This library allows you to send an Amazon SQS message that contains a reference to a message payload in Amazon S3. The maximum payload size is 2 GB. Similarly for SNS, please refer AWS documentation on how to handle <a href="https://docs.aws.amazon.com/sns/latest/dg/large-message-payloads.html">large messages in SNS</a>.<br>*** Well, the actual answer is “It depends” on your use case. Instead of providing that answer I put forward some comparative indicator but they should not be the deciding factor for choosing the right messaging solution for your use case. (In fact, I may remove this row in future.)<br>The pricing models for each AWS messaging service differ and can be found in their respective documentation. To accurately estimate costs for your architecture, I recommend referring to the service pricing details and leveraging the <a href="https://calculator.aws/#/">AWS Pricing Calculator</a>. Your specific use case and workload variables will enable you to holistically assess the overall spend across the services under consideration, rather than looking at any single one in isolation. <br># AWS Service integration list — <a href="https://aws.amazon.com/amazon-mq/faqs/">Amazon MQ</a>, <a href="https://aws.amazon.com/msk/faqs/#Integrations">Amazon MSK</a>, <a href="https://aws.amazon.com/kinesis/data-streams/integrations/">Amazon KDS</a> <br>## Security measures — <a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-security.html">Amazon SQS</a>, <a href="https://docs.aws.amazon.com/sns/latest/dg/sns-security.html">Amazon SNS</a>, <a href="https://docs.aws.amazon.com/amazon-mq/latest/developer-guide/security.html">Amazon MQ, </a><a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-security.html">Amazon EventBridge</a>, <a href="https://docs.aws.amazon.com/msk/latest/developerguide/security.html">Amazon MSK</a>, <a href="https://docs.aws.amazon.com/streams/latest/dev/security.html">Amazon KDS</a><br>### Pricing — <a href="https://aws.amazon.com/sqs/pricing/">Amazon SQS</a>, <a href="https://aws.amazon.com/sns/pricing/">Amazon SNS</a>, <a href="https://aws.amazon.com/amazon-mq/pricing/">Amazon MQ</a>, <a href="https://aws.amazon.com/eventbridge/pricing/">Amazon EventBridge</a>, <a href="https://aws.amazon.com/msk/pricing/">Amazon MSK</a>, <a href="https://aws.amazon.com/kinesis/data-streams/pricing/">Amazon KDS</a></p><h4><strong>Which AWS Service is right for my use case</strong></h4><p>Navigating the range of AWS messaging options to find the optimal AWS service can be challenging at times, requiring a comprehensive evaluation of the trade-offs involved. Though I can offer directional advice, ultimately the ideal solution depends on your specific use case and priorities. Carefully weighing factors like performance, cost, and ease-of-management across the available approaches — whether an individual service or combination thereof — allows for an informed decision tailored to your needs. By taking a consultative view of the pros and cons across AWS services, the below diagram can provide guidance as you determine the appropriate path forward for your architecture. However the final messaging architecture decisions reside with your technical teams’ in-depth understanding of your workloads and objectives.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1KPUh9beixJC-8G3Y5aKGw.png" /></figure><h4><strong>Conclusion</strong></h4><p>AWS provides a spectrum of messaging models ranging from simple queuing (Amazon SQS) to notify fan-out (Amazon SNS), in-order event streaming (Amazon Kinesis Data Streams, Amazon MSK) and rules-based event routing (Amazon EventBridge) in a resilient, enterprise-grade cloud environment. Amazon SQS and SNS are simple, scalable building blocks applicable for a wide variety of distributed workloads with minimal operational overheads like de-coupling workload components, buffering requests or sending notifications. Amazon MSK is focused on streaming complex events that needs strong ordering and replay capabilities. Amazon MQ assists migrations of existing message broker deployment to cloud while Amazon EventBridge simplifies building event-driven serverless architectures using events from SaaS applications, AWS services and custom application. Amazon Kinesis Data Streams collects streaming data with a data stream.</p><p>Hence, when evaluating AWS messaging services for a workload, the specific technical requirements, business use case, and application patterns determine the ideal solution. Architects must assess needs around message ordering, replay, retention policy, security, integrations and streaming analytics to select the optimal service for the use case. By combining messaging models like queuing, pub/sub, streaming and event buses provided by SQS, SNS, Kinesis, MSK and EventBridge, developers can build a variety of reliable, scalable, secure and cost-optimized distributed cloud-native applications.</p><p>This comprehensive post aimed to highlight key technical differentiators, typical use cases and summary guidelines on choosing the appropriate AWS messaging service based on your specific application needs.</p><p>Please feel free to provide any feedback or if any questions.</p><p><strong>Further Studies</strong></p><ul><li><a href="https://aws.amazon.com/getting-started/decision-guides/application-integration-on-aws-how-to-choose/">Choosing an AWS application integration service</a></li><li><a href="https://serverlessland.com/patterns/sns-sqs-fanout">SNS SQS Fan-out pattern</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=759fadbf59a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simplified Observability for Amazon EKS with the new Amazon Managed Service for Prometheus…]]></title>
            <link>https://medium.com/@biswanath.ita/simplified-observability-for-amazon-eks-with-the-new-amazon-managed-service-for-prometheus-3d97d14ecad0?source=rss-893e0d23d555------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d97d14ecad0</guid>
            <category><![CDATA[amg]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[amp]]></category>
            <category><![CDATA[ek]]></category>
            <dc:creator><![CDATA[Biswanath Mukherjee]]></dc:creator>
            <pubDate>Sun, 17 Dec 2023 16:16:59 GMT</pubDate>
            <atom:updated>2023-12-27T04:50:13.301Z</atom:updated>
            <content:encoded><![CDATA[<h3>Simplified Observability for Amazon EKS with the new Amazon Managed Service for Prometheus agentless collector</h3><p>During re:Invent 2023, AWS has <a href="https://aws.amazon.com/about-aws/whats-new/2023/11/amazon-managed-service-prometheus-agentless-collector-metrics-eks/">launched</a> a new fully-managed, agentless Amazon Managed Service for Prometheus collector that automatically discovers and scapes Prometheus metrics from workloads running on Amazon EKS. This eliminates the burden of having to self-manage monitoring agents. Key benefits include automatic discovery of EKS metrics without installing agents, a reliable and secure multi-AZ service, and simplified management through Amazon EKS console, CLI, SDK and Amazon Managed Service for Prometheus APIs.</p><p>In this post we are going to create an end to end demo to monitor the EKS Cluster metrics. We will configure an Amazon Managed Service for Prometheus collector to scrape metrics from the Amazon EKS cluster. The collected metrics will be displayed in a dashboard created in Amazon Managed Grafana.</p><p><strong>Solution Overview</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e4fgT6O-k2oT19gTkCh9wg.png" /><figcaption>Demo Architecture</figcaption></figure><p>We are going to build the above architecture in this demo. The Amazon Managed Service for Prometheus collector creates an Elastic Network Interface (ENI) for each subnet specified when provisioning the scraper. Metrics scraping occurs through these ENIs, while remote_write pushes the data to your Amazon Managed Service for Prometheus workspace over a VPC endpoint. Amazon Managed Grafana automatically uses PrivateLink VPC endpoints to query metrics from Amazon Managed Prometheus. This architecture ensures that the scraped data remains within the private network and is never transmitted over public internet.</p><p><strong>Prerequisites</strong></p><ul><li><a href="https://portal.aws.amazon.com/gp/aws/developer/registration/index.html">Create an AWS account</a> if you do not already have one.</li><li>Access to AWS account via AWS Console and CLI. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources mentioned in this post.</li><li>Access to a terminal with <a href="https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html">Kubectl</a> and <a href="https://docs.aws.amazon.com/eks/latest/userguide/eksctl.html">Amazon EKS command line tool</a> (<a href="https://eksctl.io/">eksctl</a> version 0.165.0 or greater), installed and configured.</li><li><a href="https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-compatible-APIs.html">awscurl</a> to query Amazon Managed Service for Promethus.</li><li>Amazon EKS cluster must have cluster endpoint access control set to include private access. It can include private and public, but must include private. In this demo, we will make this configuration change while creating the cluster.</li></ul><p><strong>Demo Preparation</strong></p><p>The the resources in this demo will be created in the us-east-1 region. I have created this demo from my MacBook. Please refer to AWS documentation wherever required for equivalent commands for other operating system. At the time of writing this post, the Amazon EKS cluster, managed scraper, Amazon Managed Service for Prometheus must all be in the same AWS region and account. Please refer to AWS documentation for additional details on <a href="https://us-east-1.console.aws.amazon.com/prometheus/home?region=us-east-1#/">scraper limitations</a>. We will follow the below steps:</p><ol><li>Create an Amazon EKS cluster</li><li>Create Amazon Managed Service for Prometheus (AMP) workspace and AWS managed collector</li><li>Configure Amazon EKS cluster for managed metric scraping</li><li>Create Amazon Managed Grafana (AMG) Workspace</li><li>Configure AMG Dashboard to visualise Amazon EKS cluster metrics collected by AMP</li></ol><p><strong>Step 1: Create an Amazon EKS cluster</strong></p><p>i. There are different methods that can be followed to create Amazon EKS cluster as described in <a href="https://docs.aws.amazon.com/eks/latest/userguide/getting-started.html">Getting started with Amazon EKS</a> user guide. I am using <a href="https://eksctl.io/">eksctl</a> to create the cluster:</p><pre>eksctl create cluster —name eks-prometheus —region us-east-1</pre><p>The cluster creation took me about 15mins to complete. The command will complete with output like below:</p><pre>2023-12-15 09:27:47 [ℹ] nodegroup &quot;ng-xxxxxxxx&quot; has 2 node(s)<br>2023-12-15 09:27:47 [ℹ] node &quot;ip-xxx-xxx-xxx-xxx.ec2.internal&quot; is ready<br>2023-12-15 09:27:47 [ℹ] node &quot;ip-xxx-xxx-xxx-xxx.ec2.internal&quot; is ready<br>2023-12-15 09:27:48 [ℹ] kubectl command should work with &quot;/Users/xxxxxx/.kube/config&quot;, try &#39;kubectl get nodes&#39;<br>2023-12-15 09:27:48 [✔] EKS cluster &quot;eks-prometheus&quot; in &quot;us-east-1&quot; region is ready</pre><p>ii. Let’s check that we are able to connect the newly created Amazon EKS cluster from CLI:</p><pre>xxxx$ kubectl get ns         <br>NAME                STATUS      AGE<br>default             Active       5m<br>kube-node-lease     Active       5m<br>kube-public         Active       5m<br>kube-system         Active       5m</pre><p>iii. Lets create namespace named <strong>prometheus</strong>:</p><pre>xxxx$ kubectl create ns prometheus<br>namespace/prometheus created</pre><p>iv. Open Amazon EKS from AWS Console. Click on the cluster name to get the details of the newly created EKS cluster. Capture <strong>Cluster ARN</strong>, <strong>Security Groups</strong>, <strong>Subnets</strong> from Overview and Networking tabs. These will be used in the subsequent steps.</p><p>v. As mentioned in the prerequisite section, we must enable private endpoint access for the Amazon EKS cluster to configure the AWS managed collector. So, lets open the Amazon EKS cluster from the AWS console, go to the <strong>Networking</strong> tab and click <strong>Manage endpoint access</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8DRGv3lThBjh695Hr_tkUA.jpeg" /></figure><p>On the Cluster endpoint access page, please select <strong>Public and private</strong> option and then click the <strong>Save changes</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4sFAhzk07KMOVcwanifRjg.jpeg" /></figure><p><strong>Step 2: Create Amazon Managed Service for Prometheus (AMP) workspace and AWS managed collector</strong></p><p>i. Open Amazon Managed Service for Prometheus from AWS console and click the <strong>Create</strong> button under Create workspace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BSz6qnu7VO9Ybp0VFUjv3g.jpeg" /></figure><p>ii. Provide a workspace name and click the <strong>Create Workspace</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IBw3wOnOWUbGC6mZpHhmjQ.jpeg" /></figure><p>iii. Once the workspace is created it will show under workspaces section. Click on the <strong>Workspace ID</strong> link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RTMLTa2XwiQaMhMubo0f0w.jpeg" /></figure><p>iv. Make a note of the <strong>ARN</strong>, <strong>Endpoint — query URL</strong> and <strong>Workspace ID</strong> from the Summary section which will be used in the subsequent steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cb7Gh-U6tOwCQDDFaCgekg.jpeg" /></figure><p>v. The next step is to create the scraper. Let us download a general purpose scraper configuration with the GetDefaultScraperConfiguration API operation.</p><pre>xxxx$ aws amp get-default-scraper-configuration —region us-east-1</pre><p>The above command will return the default configuration in base64 encoded format which will be used in the next step.</p><p>vi. Update the parameters in the below command and execute to create the scrapper:</p><pre>aws amp create-scraper \ --source eksConfiguration=&quot;{clusterArn=&#39;arn:aws:eks:us-west-2:account-id:cluster/cluster-name&#39;, securityGroupIds=[&#39;sg-security-group-id&#39;],subnetIds=[&#39;subnet-subnet-id-1&#39;, &#39;subnet-subnet-id-2&#39;]}&quot; \ --scrape-configuration configurationBlob=&lt;base64-encoded-blob&gt; \ --destination ampConfiguration=&quot;{workspaceArn=&#39;arn:aws:aps:us-west-2:account-id:workspace/ws-workspace-id&#39;}&quot;</pre><ul><li>clusterArn, securityGroupIds, subnetIds — as noted from the step 1. Please take only one subnet from each availability zone, otherwise, you may get a ValidationException.</li><li>configurationBlob — the base64 encoded default configuration from the previous command. Please use the encoded string without the quotes (“”).</li><li>ampConfiguration — AMP workspace Id as noted earlier in this post.</li></ul><p>The command returns output similar to the below snippet:</p><pre>{<br>    &quot;scraperId&quot;: &quot;s-abcdefghi-jklm-1234-5678-nopqrstuvwxyz&quot;,<br>    &quot;arn&quot;: &quot;arn:aws:aps:us-east-1:123456789012:scraper/s-abcdefghi-jklm-1234-5678-nopqrstuvwxyz&quot;,<br>    &quot;status&quot;: {<br>        &quot;statusCode&quot;: &quot;CREATING&quot;<br>    },<br>    &quot;tags&quot;: {}<br>}</pre><p>vii. The following can be used to check the available scrappers along with the status. Wait till the <strong>statusCode</strong> changes to <strong>ACTIVE</strong>.</p><pre>xxxx$ aws amp list-scrapers</pre><p>The command outputs is similar to the below screenshot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OD5WHQV-qMxDrLbQrtnBrw.jpeg" /></figure><p>Make a note of <strong>scraperId</strong> and <strong>roleArn</strong> from the output. This will be used later in the setup.</p><p><strong>Step 3: Configure Amazon EKS cluster for managed metric scraping</strong></p><p>Now we need to create ClusterRole, ClusterRoleBinding, IAM Identity mapping to allow the scraper to access the Amazon EKS cluster to collect metrics. Please follow the steps outlined in <a href="https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-collector-how-to.html#AMP-collector-eks-setup">configuring your Amazon EKS cluster</a> documentation to make this configuration.<br>i. Create the ClusterRole and ClusterRoleBinding:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gFb_1KnQKkWu3WkFuZjZtA.jpeg" /></figure><p>ii. Create the IAM Identity Mapping:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MQZoVfs4Y2AoDtlxpIoS-Q.jpeg" /></figure><p>iii. Let us <a href="https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-compatible-APIs.html">query Prometheus-compatible APIs </a>using awscurl . The AMP_QUERY_ENDPOINT was noted in Step 2. The response should be similar to the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XvDaZVONZ59iJs9egATdbg.jpeg" /></figure><p><strong>Step 4: Create Amazon Managed Grafana (AMG) Workspace</strong></p><p>Follow the Amazon Managed Grafana <a href="https://docs.aws.amazon.com/grafana/latest/userguide/getting-started-with-AMG.html">getting started</a> user guide to create a workspace.</p><p>i. Open Amazon Managed Grafana from AWS Console and click the <strong>Create workspace</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IlXA5SbwW3DqmuDeqoJ21w.jpeg" /></figure><p>ii. Provide <strong>Workspace name</strong> and click <strong>Next</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TFQZOUUXG5RONmi62ttirQ.jpeg" /></figure><p>iii. One the Configure setting page select the appropriate authentication method and Permission type. Do not change any other configuration on this page. If you are using IAM Identity Center for the first time, then you will need to create a user. Click <strong>Next</strong> at the bottom of the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n3NB79JWv3mIni1rWld3pw.jpeg" /></figure><p>iv. In the Next step select the <strong>Current account</strong> in the IAM permission access settings and the data source select <strong>Amazon Managed Service for Prometheus</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FZKaQ_YF8M4O3PtDd_dtEA.jpeg" /></figure><p>v. Click on the <strong>Create workspace </strong>button on Review and create page.</p><p>Once the workspace status changes to <strong>Active</strong>, from the Authentication tab of the AMG workspace, add the required user with and assign <strong>Admin</strong> role.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w8iYVdYWW1IugqOv4ArBzQ.jpeg" /></figure><p>vi. Click on the <strong>Grafana workspace URL</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A4FONecUR8t63GXeDoG-ng.jpeg" /></figure><p>vii. Click on the <strong>Sing in with AWS IAM Identity Center</strong> button. For the first time login, use the email id and password configured for the user in AWS IAM Identity Center in the previous step. These credentials only work if you have responded to the email from Amazon Managed Grafana that prompted you to create a password for IAM Identity Center.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vcfu3agoc3lBcL595xup-w.jpeg" /></figure><p>One successful login, you will land on Amazon Managed Grafana home screen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ow3TeLpZCOTdRPNtwd6pyg.jpeg" /></figure><p><strong>Step 5: Configure AMG Dashboard to visualise Amazon EKS cluster metrics collected by AMP </strong><br>Now we will configure the AMP Data Source in AMG and create the dashboard to visualise the collected metrics from Amazon EKS cluster matrices.</p><p>i. Click on the <strong>Hamburger</strong> menu at the top left corner and choose <strong>AWS Data Sources</strong> from under <strong>App</strong> section.<br>ii. Choose <strong>Amazon Managed Service for Prometheus</strong> from the list of AWS services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-lGAwBYbjQC7o_vtXKGWhQ.jpeg" /></figure><p>iii. On the next page select the AWS region the we have been using (in my case us-east-1), then select the AMP workspace. Then click on the <strong>Add 1 data source</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8XS466EwoekHNgx6xNFTeA.jpeg" /></figure><p>You will get a Data Source successfully added message.</p><p>iv. Now navigate to Explore from the left navigation bar to query metrics. Select the newly created AMP datasource and set any desired metric e.g. apiserver_current_inflight_requests<strong> </strong>or anything that you like for <strong>Metrics</strong> fields. Please change the duration to get graphs for desired duration. Then click the <strong>Run Query</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qYs-90rTOHS4MuiCPCkMJA.jpeg" /></figure><p>v. Now, let us import an existing Grafana dashboard. From left hand hand navigation bar, select <strong>Dashboards, </strong>click the down arrow next to <strong>New</strong> button and select <strong>Import</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R95CTQ5cDgSCtsmrC6-oKw.jpeg" /></figure><p>vi. Enter <strong>3119</strong> and click <strong>Load</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IRTrWiMYi76gYMzoxSKDXA.jpeg" /></figure><p>vii. Enter <strong>Name</strong>, select the Prometheus Data Source and the click the <strong>Import</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HKiOcn18lVj8jVcwE57NCA.jpeg" /></figure><p>viii. After the dashboard is imported successfully, metrics collected from the Amazon EKS cluster through the Amazon Managed Service for Prometheus will be displayed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l_CYrK4mSjUYGxs1hZ6IBQ.jpeg" /></figure><p><strong>Cleaning up</strong><br>Once you are done with your PoC, please don’t forget to clean up the AWS resources created to avoid accidental misuse or charges.</p><ul><li>Delete the Amazon Managed Grafana workspace from AWS web console.</li><li>Delete the Amazon Managed Service for Prometheus workspace from web console.</li><li>Delete the Amazon EKS cluster from CLI using eksctl.</li></ul><pre>eksctl delete cluster —name eks-prometheus —region us-east-1</pre><p><strong>Conclusion</strong></p><p>In summary, Amazon Managed Service for Prometheus collector provides a fully-managed, efficient way to monitor your Amazon EKS clusters. As highlighted in this demo, enabling the collector allows automatic discovery and collection of key metrics from EKS workloads and infrastructure.</p><p>The collector eliminates the operational overhead of installing and managing your own Prometheus agents. As a secure, reliable, and highly available service, it seamlessly integrates monitoring capabilities without needing to provision infrastructure.</p><p>With metric data flowing into Amazon Managed Grafana, you can now easily visualize cluster health and performance. Going forward, Amazon Managed Service for Prometheus collector paves the way for gaining observability insights that can drive optimizations and improvements across your Amazon EKS deployments.</p><p><strong>Further study</strong></p><ul><li>AMP User Guide for <a href="https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-collector.html">AWS managed collectors</a> configuration.</li><li>AMG User Guide to <a href="https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-amg.html">Set up Amazon Managed Grafana for use with Amazon Managed Service for Prometheus</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d97d14ecad0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>