<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: 🅷🅰🆁🅳🅸🅺 🅹🅾🆂🅷🅸</title>
    <description>The latest articles on DEV Community by 🅷🅰🆁🅳🅸🅺 🅹🅾🆂🅷🅸 (@_hardikjoshi).</description>
    <link>https://dev.to/_hardikjoshi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F634052%2Fbd0fa6f8-4234-403c-8ff5-f0b19ddafa4d.jpeg</url>
      <title>DEV Community: 🅷🅰🆁🅳🅸🅺 🅹🅾🆂🅷🅸</title>
      <link>https://dev.to/_hardikjoshi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/_hardikjoshi"/>
    <language>en</language>
    <item>
      <title>Game Creation via AWS Q CLI</title>
      <dc:creator>🅷🅰🆁🅳🅸🅺 🅹🅾🆂🅷🅸</dc:creator>
      <pubDate>Wed, 21 May 2025 12:26:01 +0000</pubDate>
      <link>https://dev.to/aws-builders/game-creation-via-aws-q-cli-55b9</link>
      <guid>https://dev.to/aws-builders/game-creation-via-aws-q-cli-55b9</guid>
      <description>&lt;p&gt;I am simply amazed by how well AWS Q CLI is operating.&lt;br&gt;
Let me show you simple steps that I took to create 3 games in sequential commplexity and how easy they were to create via help for Q CLI.&lt;/p&gt;

&lt;p&gt;I would divide the steps in 2 part.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Installation Instructions&lt;/li&gt;
&lt;li&gt;Prompts&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Installation Instructions.
&lt;/h2&gt;

&lt;p&gt;Below Step 1-5 will help installing Q CLI&lt;br&gt;
Step 5-6 are required for installation of the required python package.&lt;/p&gt;

&lt;p&gt;On a Linux Terminal -&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;wget &lt;a href="https://desktop-release.q.us-east-1.amazonaws.com/latest/amazon-q.deb" rel="noopener noreferrer"&gt;https://desktop-release.q.us-east-1.amazonaws.com/latest/amazon-q.deb&lt;/a&gt;
For other OS instructions, check &lt;a href="https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-installing.html" rel="noopener noreferrer"&gt;here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;sudo apt-get install -f&lt;/li&gt;
&lt;li&gt;sudo dpkg -i amazon-q.deb&lt;/li&gt;
&lt;li&gt;q login
Select "Use for free with builder ID" option
you will need to create a Builder ID via this &lt;a href="https://community.aws/builderid?trk=b085178b-f0cb-447b-b32d-bd0641720467&amp;amp;sc_channel=el" rel="noopener noreferrer"&gt;link&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You will be given a link which will need to be opened in another browser where you have logged in with your builder id. This will approve the use of Q.&lt;/li&gt;
&lt;li&gt;python3 -m pip install -U pygame --user&lt;/li&gt;
&lt;li&gt;python3 -m pygame.examples.aliens&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Prompts
&lt;/h2&gt;

&lt;p&gt;Now comes the wow moment. Type in your thoughts in a normal prompt and the code is auto generated and ready to play. I am giving example of 3 prompts that I have used. &lt;br&gt;
First one is a very simple prompt - &lt;br&gt;
Second one is medium prompt - &lt;br&gt;
Third one is very detailed and challenging one - Happy to say that the game turned out amazing. A Python file was generated, but also all supporting json files were generated. Simply Superb.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;q (Execute this on the linux kernel where above steps were executed).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prompt 1&lt;/strong&gt;: Create a simple tic tac toe game to be played between 2 players&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prompt 2&lt;/strong&gt;: Create a visual game with state of the art graphics which will have a person standing and needs to dodge incoming boomerangs which he throws and they are coming back to him. At each level the number of boomerangs increase by 1 until the game finishes. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prompt 3&lt;/strong&gt;: Create a puzzle game which will ask user to guess the country name based on some unique features of that country. The game should give higher points for guessing earlier in the number of hints that are given for the country and the faster that the person guesses it. You can keep it as multi choice option to select between 5 possible countries. Keep it as challenging as possible. The game can must support English, Gujarati and Hindi languages. It should be as colourful as possible and can also show country flags as option if possible in 2D format. Make it as interesting as possible.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Prompt Output for 3:&lt;/p&gt;

&lt;p&gt;I've created a colorful and challenging country puzzle game with support for English, Hindi, and Gujarati languages. Let me explain the key features:&lt;/p&gt;

&lt;h2&gt;
  
  
  Country Puzzle Game Features
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Multilingual Support:&lt;br&gt;
• Full support for English, Hindi, and Gujarati&lt;br&gt;
• All game text, country names, hints, and information are translated&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Colorful Interface:&lt;br&gt;
• Uses the termcolor library for colorful text output&lt;br&gt;
• Country flags displayed using emoji&lt;br&gt;
• Visual formatting to make the game attractive&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Challenging Gameplay:&lt;br&gt;
• Players must guess countries based on increasingly revealing hints&lt;br&gt;
• Multiple-choice format with 5 country options&lt;br&gt;
• Points system rewards:&lt;br&gt;
 • Guessing with fewer hints (70% of score)&lt;br&gt;
 • Guessing quickly (30% of score)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Game Structure:&lt;br&gt;
• Main menu with options to play, change language, view score, or exit&lt;br&gt;
• Round-based gameplay with detailed country information after each round&lt;br&gt;
• Score tracking with total points and average time statistics&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Country Database:&lt;br&gt;
• Includes 7 countries with unique hints and information&lt;br&gt;
• Each country has 5 challenging hints in all three languages&lt;br&gt;
• Country flags and basic information (capital, currency, languages)&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How to Play
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Run the game: ./country_puzzle_game.py&lt;/li&gt;
&lt;li&gt;Select your preferred language from the menu&lt;/li&gt;
&lt;li&gt;In each round, you'll see 5 country options with their flags&lt;/li&gt;
&lt;li&gt;Read each hint carefully and make your guess&lt;/li&gt;
&lt;li&gt;The faster you guess with fewer hints, the higher your score&lt;/li&gt;
&lt;li&gt;After each round, you'll learn interesting facts about the correct country&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Files Created
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;country_puzzle_game.py - Main game script&lt;/li&gt;
&lt;li&gt;language_data_en.json - English language strings&lt;/li&gt;
&lt;li&gt;language_data_hi.json - Hindi language strings&lt;/li&gt;
&lt;li&gt;language_data_gu.json - Gujarati language strings&lt;/li&gt;
&lt;li&gt;country_data.json - Database of countries with hints and information&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The game is ready to play! You can run it by executing ./country_puzzle_game.py in your terminal. The game will automatically load the necessary language and country data files.&lt;/p&gt;

&lt;p&gt;Would you like me to explain any specific part of the implementation in more detail?&lt;/p&gt;

&lt;p&gt;I am really happy and satisfied with the outputs and will continue to explore more on Q CLI.&lt;br&gt;
Let me know your thoughts on this.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>certification</category>
    </item>
    <item>
      <title>AWS ML Associate - Study Guide</title>
      <dc:creator>🅷🅰🆁🅳🅸🅺 🅹🅾🆂🅷🅸</dc:creator>
      <pubDate>Wed, 05 Feb 2025 11:10:38 +0000</pubDate>
      <link>https://dev.to/aws-builders/aws-ml-associate-study-guide-1g2j</link>
      <guid>https://dev.to/aws-builders/aws-ml-associate-study-guide-1g2j</guid>
      <description>&lt;p&gt;**Hi all, Below is a study guide for those preparing for the AWS ML Associate certification.&lt;br&gt;
**I have gone through the AWS Skill Builder traning and below are the notes from that training which I have hand written. This helps me to understand the concept better.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Unfortunately&lt;/em&gt; When pasting in dev.to the formatting is lost so I had to use a tool to retain formatting which hasn't worked as expected. If you need the raw notes then please msg me and I will send it to you.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Key Questions at Preparatory Stages
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;What data do you need to reach the intended output?&lt;/li&gt;
&lt;li&gt;Do you have access to that data? If so, how much and where is it?&lt;/li&gt;
&lt;li&gt;Which solution can you use to bring all this data into one centralized repository?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Useful Links:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/sagemaker/" rel="noopener noreferrer"&gt;Amazon SageMaker Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/ai/responsible-ai/" rel="noopener noreferrer"&gt;AWS Responsible AI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/what-is/large-language-model/" rel="noopener noreferrer"&gt;Large Language Models on AWS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/compare/the-difference-between-machine-learning-supervised-and-unsupervised/" rel="noopener noreferrer"&gt;Difference Between Machine Learning Supervised and Unsupervised&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Data Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Representative&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Relevant&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Feature Rich&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Consistent&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Data Types:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Text
&lt;/li&gt;
&lt;li&gt;Tabular
&lt;/li&gt;
&lt;li&gt;Time Series
&lt;/li&gt;
&lt;li&gt;Image
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Data Formats:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Row-based data format&lt;/strong&gt;: CSV, Avro, RecordIO
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Column-based file types&lt;/strong&gt;: Parquet, ORC
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Object notation&lt;/strong&gt;: JSON, JSONL
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Selecting Data Storage - Key Considerations:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Throughput Latency
&lt;/li&gt;
&lt;li&gt;Elasticity
&lt;/li&gt;
&lt;li&gt;Scalability
&lt;/li&gt;
&lt;li&gt;Data access patterns: Copy and Load, Sequential Streaming, Randomized Access
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Storage Solutions:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Amazon EBS&lt;/strong&gt;: Best for training workloads with frequent random I/O access
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Amazon EFS&lt;/strong&gt;: Suitable for real-time and streaming workloads requiring concurrent access
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Amazon S3&lt;/strong&gt;: Ideal for large datasets that don't need quick access (e.g., pretrained ML models)
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Data Ingestion:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Methods:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Batch Ingestion
&lt;/li&gt;
&lt;li&gt;Real-Time Ingestion
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Real-Time Use Cases with Amazon Kinesis:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Data Ingestion&lt;/strong&gt;: Kinesis Data Streams for real-time data streaming
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Processing&lt;/strong&gt;: Use Amazon Managed Service for Apache Flink for real-time processing
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real-time Inference&lt;/strong&gt;: Stream data to an Amazon SageMaker endpoint
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Tools for Data Transfer and Extraction:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;AWS CLI
&lt;/li&gt;
&lt;li&gt;AWS SDK
&lt;/li&gt;
&lt;li&gt;S3 Transfer Acceleration
&lt;/li&gt;
&lt;li&gt;AWS DMS
&lt;/li&gt;
&lt;li&gt;AWS Lambda
&lt;/li&gt;
&lt;li&gt;AWS Glue
&lt;/li&gt;
&lt;li&gt;AWS DataSync
&lt;/li&gt;
&lt;li&gt;AWS Snowball
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  AWS Data Merging:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  AWS Glue Workflow:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Identify Data Sources
&lt;/li&gt;
&lt;li&gt;Create an AWS Glue Crawler
&lt;/li&gt;
&lt;li&gt;Generate ETL Scripts and Define Jobs
&lt;/li&gt;
&lt;li&gt;Output Results
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Amazon EMR Workflow:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Ingest Streaming Data
&lt;/li&gt;
&lt;li&gt;Distribute Across EMR Clusters
&lt;/li&gt;
&lt;li&gt;Transform Data
&lt;/li&gt;
&lt;li&gt;Output to Amazon S3
&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  Data Preparation Blogs:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://aws.amazon.com/blogs/machine-learning/category/storage/" rel="noopener noreferrer"&gt;Machine Learning Storage Blogs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.aws.amazon.com/whitepapers/latest/ml-best-practices-public-sector-organizations/data-ingestion-and-preparation.html" rel="noopener noreferrer"&gt;Data Ingestion and Preparation&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Data Transformation and Validation:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Data Transformation Techniques:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Remove unnecessary data
&lt;/li&gt;
&lt;li&gt;Use Columnar Storage
&lt;/li&gt;
&lt;li&gt;Compress Data
&lt;/li&gt;
&lt;li&gt;Format Splittable Data
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Data Validation Checks:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Data Integrity
&lt;/li&gt;
&lt;li&gt;Accuracy
&lt;/li&gt;
&lt;li&gt;Completeness
&lt;/li&gt;
&lt;li&gt;Consistency
&lt;/li&gt;
&lt;li&gt;Reliability
&lt;/li&gt;
&lt;li&gt;Security
&lt;/li&gt;
&lt;li&gt;Bias Detection
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Feature Engineering:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Categorical Encoding:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Techniques&lt;/strong&gt;: Label Encoding, One-Hot Encoding
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Numeric Feature Engineering:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Feature Scaling&lt;/strong&gt;: Normalization (0-1), Standardization (-1 to 1)
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Binning&lt;/strong&gt;: Group numerical features into smaller bins
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Log Transformation&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Model Training Concepts:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Loss Functions&lt;/strong&gt;: Root Mean Square Error (RMSE), Log-Likelihood Loss
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Optimization Techniques&lt;/strong&gt;: Gradient Descent, Stochastic Gradient Descent
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compute Environments&lt;/strong&gt;: CPU Training Instances, GPU-accelerated Instances
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Model Deployment Steps:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Version Control
&lt;/li&gt;
&lt;li&gt;CI/CD Integration
&lt;/li&gt;
&lt;li&gt;ML Model Numbering and Deployment
&lt;/li&gt;
&lt;li&gt;Monitoring and Workflow Security
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Workflow Orchestration Options:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SageMaker Pipelines&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS Step Functions&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS MWAA (Managed Workflows for Apache Airflow)&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Hyperparameter Tuning:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Techniques:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Manual Selection
&lt;/li&gt;
&lt;li&gt;Grid Search
&lt;/li&gt;
&lt;li&gt;Random Search
&lt;/li&gt;
&lt;li&gt;Bayesian Optimization
&lt;/li&gt;
&lt;li&gt;SageMaker Automatic Model Tuning
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Conclusion:
&lt;/h2&gt;

&lt;p&gt;Using AWS services like SageMaker, Glue, and Kinesis, you can create scalable, efficient machine learning workflows. Leverage the right combination of data storage, processing, and model tuning to meet your business goals effectively.&lt;/p&gt;

&lt;h2&gt;
  
  
  Model Size and Performance Optimization
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Factors Affecting Model Size:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Input Data and Features
&lt;/li&gt;
&lt;li&gt;Architecture
&lt;/li&gt;
&lt;li&gt;Problem Domain
&lt;/li&gt;
&lt;li&gt;Desired Accuracy
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Model Size Reduction Techniques:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Compression&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pruning&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Quantization&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Knowledge Distillation&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Model Performance and Evaluation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Model Evaluation Techniques:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Using data you set aside: Validation % and Test %
&lt;/li&gt;
&lt;li&gt;Establishing Evaluation Metrics
&lt;/li&gt;
&lt;li&gt;Assessing Trade-offs (performance, training time, and cost)
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Common Metrics for Classification Problems:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Accuracy&lt;/strong&gt;: ( \frac{TP + TN}{Total} )
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Precision&lt;/strong&gt;: ( \frac{TP}{TP + FP} ) – Best when the cost of false positives is high
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Recall&lt;/strong&gt;: ( \frac{TP}{TP + FN} ) – Best when the cost of false negatives is high
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;F1-Score&lt;/strong&gt;: Combines Precision and Recall
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AUC-ROC&lt;/strong&gt;: Area Under the Receiver Operator Characteristic Curve
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Regression Problem Metrics:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mean Squared Error (MSE)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Root Mean Squared Error (RMSE)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;R-Squared (R²)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adjusted R-Squared&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Model Deployment and Monitoring
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Model Deployment Targets:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Amazon SageMaker Endpoints&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Amazon EKS&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Amazon ECS&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS Lambda&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Model Inference Options:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Real-time&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Serverless&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Asynchronous&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Batch Transform&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Infrastructure as Code (IaC) for ML Workflows
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Benefits of IaC:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Code Management
&lt;/li&gt;
&lt;li&gt;Repeatable Provisioning
&lt;/li&gt;
&lt;li&gt;Testing and Experimentation
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Tools:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AWS CloudFormation&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS CDK (Cloud Development Kit)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Terraform&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pulumi&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  AWS CDK Components:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;App&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stack&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Construct&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  CDK Deployment Workflow:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;cdk init &amp;lt;app&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cdk bootstrap&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cdk synth&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cdk deploy&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Continuous Delivery and Deployment
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Tools:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Git Repositories&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS CodeBuild&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS CodeDeploy&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS CodePipeline&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Deployment Strategies:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;All at Once&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Canary Deployment&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Linear Rolling Deployment&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automatic Rollback&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Retraining and Experimentation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Automatic Retraining:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Scheduled Retraining&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Drift Detection&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Incremental Learning&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Experimentation and A/B Testing:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Test model variations to find the optimal configuration for performance.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Debugging and Explainability
&lt;/h2&gt;

&lt;h3&gt;
  
  
  SageMaker Debugger:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Improved Model Performance&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explainability and Bias Detection&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automated Monitoring and Alerts&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Metrics to Monitor:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Data Quality Metrics&lt;/strong&gt;: Missing Data, Duplicate Data, Data Drift
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Model Bias Metrics&lt;/strong&gt;: Differential Validity, Differential Prediction Bias
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Model Explainability Metrics&lt;/strong&gt;: SHAP (Shapley Additive Explanations), Feature Attribution
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Building machine learning models on AWS requires careful consideration of data, model architecture, and deployment strategies. With services like Amazon SageMaker, AWS Glue, and AWS CDK, you can create robust, scalable, and well-optimized machine learning pipelines.&lt;/p&gt;

&lt;h2&gt;
  
  
  Model Deployment Steps
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Version Control&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CI/CD Integration&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ML Model Numbering&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Model Deployment&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Monitoring and Workflow Security&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Workflow Orchestration Options:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SageMaker Pipelines&lt;/strong&gt;: Integrates with SageMaker Feature Store, Amazon ECR, SageMaker Training, SageMaker Processing, and Model Registry.

&lt;ul&gt;
&lt;li&gt;Steps: &lt;code&gt;Processing -&amp;gt; Training -&amp;gt; Conditional -&amp;gt; CreateModel -&amp;gt; RegisterModel -&amp;gt; Fail&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;AWS Step Functions&lt;/strong&gt;
&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;AWS MWAA (Managed Workflows for Apache Airflow)&lt;/strong&gt;
&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Third-party Tools&lt;/strong&gt;
&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Model Deployment Targets:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Amazon SageMaker Endpoints&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Amazon EKS&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Amazon ECS&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS Lambda&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Model Inference Options:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Real-time Inference&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Serverless Inference&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Asynchronous Inference&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Batch Transform&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Infrastructure as Code (IaC)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Benefits:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Code Management&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Repeatable Provisioning&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Testing or Experimentation&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Tools for IaC:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AWS CloudFormation&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS CDK (Cloud Development Kit)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Terraform&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pulumi&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  AWS CloudFormation Structure:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;FormatVersion&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Description&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Metadata&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Parameters&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mappings&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Conditions&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resources&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Outputs&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
yaml
Resources:
  LogicalID:
    Type: "Resource Type"
    Properties:
      Key: Value

AWS CDK Components:
App: Entry point for AWS CDK apps
Stack: Represents a single unit of deployment
Construct: Reusable components (L1, L2, L3)
Deployment Workflow:
cdk init &amp;lt;app&amp;gt;
cdk bootstrap
cdk synth
cdk deploy
Continuous Delivery and Deployment
Continuous Delivery Tools:
Git Repositories
AWS CodeBuild
AWS CloudFormation
AWS CodeDeploy
AWS CodePipeline
Deployment Types:
All at Once
Canary Deployment
Linear Rolling Deployment
Automatic Rollback
Retraining and Experimentation
Retraining Strategies:
Scheduled Retraining
Drift Detection and Automatic Retraining
Incremental Learning
Experimentation and A/B Testing:
Test multiple model configurations to select the best performing one.

Debugging and Explainability
SageMaker Debugger:
Improved Model Performance
Explainability and Bias Detection
Automated Monitoring and Alerts
Metrics to Monitor:
Data Quality Metrics: Missing Data, Duplicate Data, Data Drift
Model Bias Metrics: Differential Validity, Differential Prediction Bias
Model Explainability Metrics: SHAP (Shapley Additive Explanations), Feature Attribution



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

&lt;/div&gt;

</description>
      <category>aws</category>
      <category>certification</category>
    </item>
    <item>
      <title>AWS AI Practitioner - Last Min Revision Tips</title>
      <dc:creator>🅷🅰🆁🅳🅸🅺 🅹🅾🆂🅷🅸</dc:creator>
      <pubDate>Sat, 07 Sep 2024 12:25:55 +0000</pubDate>
      <link>https://dev.to/aws-builders/aws-ai-practitioner-last-min-revision-tips-4hp0</link>
      <guid>https://dev.to/aws-builders/aws-ai-practitioner-last-min-revision-tips-4hp0</guid>
      <description>&lt;p&gt;Are you ready to give the AWS AI Practitioner Certification Exam?&lt;/p&gt;

&lt;p&gt;Below is the list of all the material and prep notes that helped me pass the exam.&lt;/p&gt;

&lt;p&gt;Hope it will be helpful to you.&lt;/p&gt;

&lt;p&gt;KEY NOTES: PLEASE READ FIRST&lt;/p&gt;

&lt;p&gt;Below are my personal notes taken from the course I have taken around this&lt;/p&gt;

&lt;p&gt;It is not exhaustive list and may not be specific sequence also&lt;/p&gt;

&lt;p&gt;Usually my idea was to write everything down while learning and then go through it again and in case I don't recall the given topic then I would go in depth to understand it further.&lt;/p&gt;

&lt;p&gt;Hope it helps you in prep, however way it can and most importantly WISH YOU GOOD LUCK..&lt;/p&gt;

&lt;p&gt;In case the indentation is not showing correctly, you can go to this &lt;a href="https://www.linkedin.com/posts/hardikhjoshi_awsaipractitioner-ai-revisionnotes-activity-7236855481523150848-x-Ok?utm_source=share&amp;amp;utm_medium=member_desktop" rel="noopener noreferrer"&gt;link&lt;/a&gt; - or message me and can send it to you.&lt;/p&gt;

&lt;p&gt;What are Transformers in Artificial Intelligence? -&amp;gt; aws.amazon.com/what-is/transformers-in-artificial-intelligence/&lt;/p&gt;

&lt;p&gt;What are Foundation Models? -&amp;gt; aws.amazon.com/what-is/foundation-models/&lt;/p&gt;

&lt;p&gt;What is Artificial Intelligence (AI)? -&amp;gt; aws.amazon.com/what-is/artificial-intelligence/ &lt;/p&gt;

&lt;p&gt;What is Machine Learning? -&amp;gt; aws.amazon.com/what-is/machine-learning/ &lt;/p&gt;

&lt;p&gt;What is Deep Learning? -&amp;gt; aws.amazon.com/what-is/deep-learning/ &lt;/p&gt;

&lt;p&gt;What is Generative AI? -&amp;gt; aws.amazon.com/what-is/generative-ai/&lt;/p&gt;

&lt;p&gt;What’s the Difference Between Supervised and Unsupervised Learning? -&amp;gt; aws.amazon.com/compare/the-difference-between-machine-learning-supervised-and-unsupervised/&lt;/p&gt;

&lt;p&gt;Machine Learning Concepts -&amp;gt; docs.aws.amazon.com/machine-learning/latest/dg/machine-learning-concepts.html&lt;/p&gt;

&lt;p&gt;AWS AI Use Case Explorer -&amp;gt; aws.amazon.com/machine-learning/ai-use-cases/?use-cases&lt;/p&gt;

&lt;p&gt;What is Amazon SageMaker? -&amp;gt; docs.aws.amazon.com/sagemaker/latest/dg/whatis.html&lt;/p&gt;

&lt;p&gt;AWS Services - Machine Learning (ML) and Artificial Intelligence (AI) -&amp;gt; docs.aws.amazon.com/whitepapers/latest/aws-overview/machine-learning.html&lt;/p&gt;

&lt;p&gt;AWS Deploy Serverless ML -&amp;gt;aws.amazon.com/blogs/machine-learning/deploy-a-serverless-ml-inference-endpoint-of-large-language-models-using-fastapi-aws-lambda-and-aws-cdk/&lt;/p&gt;

&lt;p&gt;AWS Sagemaker - API Gateway - AWS Lambda -&amp;gt; aws.amazon.com/blogs/machine-learning/call-an-amazon-sagemaker-model-endpoint-using-amazon-api-gateway-and-aws-lambda/&lt;/p&gt;

&lt;p&gt;Inference parameters -&amp;gt;docs.aws.amazon.com/bedrock/latest/userguide/inference-parameters.html&lt;/p&gt;

&lt;p&gt;Inference parameters -&amp;gt; docs.aws.amazon.com/bedrock/latest/userguide/inference-parameters.html?icmpid=docs_bedrock_help_panel_playgrounds &lt;/p&gt;

&lt;p&gt;Amazon Bedrock or Amazon SageMaker? -&amp;gt; docs.aws.amazon.com/decision-guides/latest/bedrock-or-sagemaker/bedrock-or-sagemaker.html &lt;/p&gt;

&lt;p&gt;Choosing a generative AI service -&amp;gt; docs.aws.amazon.com/decision-guides/latest/generative-ai-on-aws-how-to-choose/guide.html&lt;/p&gt;

&lt;p&gt;AWS Bedrock Agents -&amp;gt; aws.amazon.com/bedrock/agents/&lt;/p&gt;

&lt;p&gt;What is RAG? - Retrieval-Augmented Generation AI Explained - AWS (amazon.com)&lt;/p&gt;

&lt;p&gt;docs.aws.amazon.com/awscloudtrail/latest/userguide/how-cloudtrail-works.html&lt;/p&gt;

&lt;p&gt;docs.aws.amazon.com/bedrock/latest/userguide/usingVPC.html&lt;/p&gt;

&lt;p&gt;aws.amazon.com/blogs/machine-learning/use-aws-privatelink-to-set-up-private-access-to-amazon-bedrock/&lt;/p&gt;

&lt;p&gt;Known Data -&amp;gt; Features -&amp;gt; Algorithm -&amp;gt; Output&lt;/p&gt;

&lt;p&gt;Adjustments&lt;/p&gt;

&lt;p&gt;Inference&lt;/p&gt;

&lt;p&gt;ML models can be trained on various types of data.&lt;/p&gt;

&lt;p&gt;Structured data on RDS, S3 or Redshift&lt;/p&gt;

&lt;p&gt;S3 is primary source of training data&lt;/p&gt;

&lt;p&gt;Semi-structures = DynamoDB &amp;amp; DocumentDB&lt;/p&gt;

&lt;p&gt;Unstructured data - tokenization&lt;/p&gt;

&lt;p&gt;Timeseries - sequential data&lt;/p&gt;

&lt;p&gt;Model Training - Algorithm&lt;/p&gt;

&lt;p&gt;Inference 2 options&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Real time&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Low Latency

High throughput

persistent endpoint
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;-- Batch Transform&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Offline

   Large datasets

   Infrequent use
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;ML Types&lt;/p&gt;

&lt;p&gt;Supervised Learning&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Amazon Sagemaker GroundTruth -&amp;gt; Amazon Mechanical Turk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Unsupervised Learning&lt;/p&gt;

&lt;p&gt;Reinforcement Learning&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Reward - AWS DeepRacer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Overfitting&lt;/p&gt;

&lt;p&gt;Model does well on training data but not outside it&lt;/p&gt;

&lt;p&gt;Underfitting&lt;/p&gt;

&lt;p&gt;Model cannot determine meaningful results. It gives negative results for training data and new inputs&lt;/p&gt;

&lt;p&gt;Bias and fairness&lt;/p&gt;

&lt;p&gt;Diversity of training data&lt;/p&gt;

&lt;p&gt;Feature importance&lt;/p&gt;

&lt;p&gt;Fairness constraints&lt;/p&gt;

&lt;p&gt;Deep Learning&lt;/p&gt;

&lt;p&gt;Neural Networks&lt;/p&gt;

&lt;p&gt;Input Layer -&amp;gt; Hidden Layers -&amp;gt; Output Layer&lt;/p&gt;

&lt;p&gt;Machine Learning vs Deep Learning&lt;/p&gt;

&lt;p&gt;Consider alternatives when&lt;/p&gt;

&lt;p&gt;Costs outweigh the benefits&lt;/p&gt;

&lt;p&gt;Models cannot meet the interpretability requirements&lt;/p&gt;

&lt;p&gt;Systems must be deterministic rather than probabilistic&lt;/p&gt;

&lt;p&gt;ML Models are probabilistic&lt;/p&gt;

&lt;p&gt;Supervised learning -&lt;/p&gt;

&lt;p&gt;Classification&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Binary          - Diabetic or not diabetic

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

&lt;/div&gt;

&lt;p&gt;Regression&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Simple Linear regression

  Multiple Linear regression

  Logistic regression
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Unsupervised Learning&lt;/p&gt;

&lt;p&gt;Clustering&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Define features

 Similarity function

 Number of clusters
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Anomaly detection&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Data points that diverge
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Amazon Rekognition&lt;/p&gt;

&lt;p&gt;Facial comparison and analysis&lt;/p&gt;

&lt;p&gt;Text detection&lt;/p&gt;

&lt;p&gt;Object detection and labelling&lt;/p&gt;

&lt;p&gt;Content moderation&lt;/p&gt;

&lt;p&gt;Can find out explicit text from images and videos&lt;/p&gt;

&lt;p&gt;Amazon Textract&lt;/p&gt;

&lt;p&gt;Extract text from scanned documents&lt;/p&gt;

&lt;p&gt;Amazon Comprehend&lt;/p&gt;

&lt;p&gt;Extract key phrases, entities and sentiment.&lt;/p&gt;

&lt;p&gt;Main is finding PII data&lt;/p&gt;

&lt;p&gt;Amazon Lex&lt;/p&gt;

&lt;p&gt;Conversational voice and text&lt;/p&gt;

&lt;p&gt;Amazon Transcribe&lt;/p&gt;

&lt;p&gt;Converts speech to text&lt;/p&gt;

&lt;p&gt;Amazon Polly&lt;/p&gt;

&lt;p&gt;Converts Text to speech&lt;/p&gt;

&lt;p&gt;Amazon Kendra&lt;/p&gt;

&lt;p&gt;Intelligent document search&lt;/p&gt;

&lt;p&gt;Amazon Personalize&lt;/p&gt;

&lt;p&gt;Personalized product recommendations&lt;/p&gt;

&lt;p&gt;Amazon Translate&lt;/p&gt;

&lt;p&gt;Translates between 75 languages&lt;/p&gt;

&lt;p&gt;Amazon Forecast&lt;/p&gt;

&lt;p&gt;Predicts future points in time-series data&lt;/p&gt;

&lt;p&gt;Amazon Fraud Detector&lt;/p&gt;

&lt;p&gt;Detects fraud and fraudulent activities&lt;/p&gt;

&lt;p&gt;Amazon Bedrock&lt;/p&gt;

&lt;p&gt;Amazon Sagemaker&lt;/p&gt;

&lt;p&gt;ML Pipeline&lt;/p&gt;

&lt;p&gt;Identify Business Goal -&amp;gt; Frame ML Problem -&amp;gt; Collect Data -&amp;gt; Pre-process Data -&amp;gt; Engineer Features -&amp;gt; Train, Tune Evaluate -&amp;gt; Deploy -&amp;gt; Monitor&lt;/p&gt;

&lt;p&gt;Collect Data&lt;/p&gt;

&lt;p&gt;AWS Glue -&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Cloud optimized ETL service

  Contains its own data catalog

  Built in transformations
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;AWS Glue DataBrew&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Point and click data transformation

  200+ transformations
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;AWS SageMaker Ground Truth&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Uses ML to label your training data

 Can automatically label
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;AWS SageMaker Canvas&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Import, Prepare, Transform, Visualize and analyze
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;AWS Sagemaker Feature Store&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Processes raw data into features by using a processing workflow
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Amazon Sagemaker Experiments&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; visual interface
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Amazon Sagemaker automatic model tuning&lt;/p&gt;

&lt;p&gt;Deploy&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Batch inference

 Real-time inference

 Self-managed

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

&lt;/div&gt;

&lt;p&gt;Amazon Sagemaker inference&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Batch Transform

           Offline inference

           Large datasets
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Asynchronous&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;           Long processing times

           Large payloads
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Serverless&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;           Intermittent traffic

           Periods of no traffic
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Real-time&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;           Live predictions

           Sustained traffic

           Low latency

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

&lt;/div&gt;

&lt;p&gt;Monitor the model&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;         Configure alerts to notify and initiate actions if any drift

         data drift / concept drift
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Amazon Sagemaker Model Monitor&lt;/p&gt;

&lt;p&gt;MLOps&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Amazon SageMaker Model Building Pipelines

  Repository Options

         AWS Codecommit

         AWS Sagemaker feature store

         AWS Sagemaker model registry

        3rd party repository

  Orchestration options

         Amazon Sagemaker pipelines

         Amazon managed workflows for apache airflow

         AWS Step functions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Accuracy = (True Positives + Ture Negatives) / Total&lt;/p&gt;

&lt;p&gt;Precision = True Positives / (True Positivies + False Positives)&lt;/p&gt;

&lt;p&gt;Recall = True Positives / (True Positives + False Negatives)&lt;/p&gt;

&lt;p&gt;F1 = Precision  Recall  2 / (Precision + Recall)&lt;/p&gt;

&lt;p&gt;False Positive Rate FPR = False Positives / (True Negatives + False Positives)&lt;/p&gt;

&lt;p&gt;True Negative Rate = True Negatives / (True Negatives + False Positives)&lt;/p&gt;

&lt;p&gt;Area Under Curve - AUC&lt;/p&gt;

&lt;p&gt;Regression Model Errors&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Mean Squared Error

   Root mean squared error

   Mean absolute error
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;A Framework to Mitigate Bias and Improve Outcomes in the New Age of AI(opens in a new tab) (opens in a new tab) (opens in a new tab)&lt;/p&gt;

&lt;p&gt;2 What Are Transformers in Artificial Intelligence?(opens in a new tab)&lt;/p&gt;

&lt;p&gt;3 What Is Overfitting?(opens in a new tab) (opens in a new tab)&lt;/p&gt;

&lt;p&gt;4 What Are Large Language Models (LLMs)?(opens in a new tab)&lt;/p&gt;

&lt;p&gt;5 Responsible Use of Machine Learning(opens in a new tab)&lt;/p&gt;

&lt;p&gt;6 Easily Add Intelligence to Your Applications(opens in a new tab)&lt;/p&gt;

&lt;p&gt;7 What Is MLOps?(opens in a new tab) (opens in a new tab) (opens in a new tab)&lt;/p&gt;

&lt;p&gt;8 Amazon SageMaker MLOps: From Idea to Production in Six Steps(opens in a new tab)&lt;/p&gt;

&lt;p&gt;9 Machine Learning Lens&lt;/p&gt;

&lt;p&gt;Domain 2::&lt;/p&gt;

&lt;p&gt;AI - ML - DL - GAI&lt;/p&gt;

&lt;p&gt;Model&lt;/p&gt;

&lt;p&gt;In-context learning&lt;/p&gt;

&lt;p&gt;Prompts, prompt tuning, prompt engineering&lt;/p&gt;

&lt;p&gt;Every NLP has a tokenizer which converts texts into token ID's.&lt;/p&gt;

&lt;p&gt;Vector - ordered list of numbers.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     Ability to encode related relationships and collect associations
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Embeddings&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      Numerical vectorized representations of type that capture the semantic meaning of the token
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Self-attention&lt;/p&gt;

&lt;p&gt;LLMs&lt;/p&gt;

&lt;p&gt;Deep learning foundation models&lt;/p&gt;

&lt;p&gt;Transformers&lt;/p&gt;

&lt;p&gt;Unimodal or multimodal&lt;/p&gt;

&lt;p&gt;Multimodal use cases&lt;/p&gt;

&lt;p&gt;Multimodal tasks&lt;/p&gt;

&lt;p&gt;Diffusion Models&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Forward Diffusion

   Reverse Diffusion

  Stable Diffusion

          Does not use pixel space of the image, uses a reduced-definition latent space
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;SageMaker + Amazon Q Developer&lt;/p&gt;

&lt;p&gt;Amazon Nimble studio and amazon samarian&lt;/p&gt;

&lt;p&gt;Gen AI Architectures&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    Generative Adversarial Networks GANs

    Variational autoencoders VAE

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

&lt;/div&gt;

&lt;p&gt;AI Project lifecycle&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Identify User case

   Experiment and select

   Adapt, align and augment

   Evaluate

   Deploy and integrate

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

&lt;/div&gt;

&lt;p&gt;Interpretability&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Intrinsic analysis

   Post hoc analysis
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;ML outputs are deterministic&lt;/p&gt;

&lt;p&gt;Gen AI outputs are non-deterministic&lt;/p&gt;

&lt;p&gt;Gen AI Performance metrics&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    Recall - Oriented Understudy for Gisting Evaluation (ROUGE)

    Bilingual Evaluation Understudy (BLEU)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Transfer learning&lt;/p&gt;

&lt;p&gt;SageMaker JumpStart&lt;/p&gt;

&lt;p&gt;Selecting the Right Foundation Model for Your Startup(opens in a new tab) (opens in a new tab) (opens in a new tab) (opens in a new tab)&lt;/p&gt;

&lt;p&gt;2 Generative Adversarial Networks Applications and its Benefits (opens in a new tab)&lt;/p&gt;

&lt;p&gt;3 The Complete Guide to Generative AI Architecture(opens in a new tab) (opens in a new tab)&lt;/p&gt;

&lt;p&gt;4 PartyRock.aws(opens in a new tab)&lt;/p&gt;

&lt;p&gt;5 Monitoring Generative AI Applications Using Amazon Bedrock and Amazon CloudWatch Integration(opens in a new tab)&lt;/p&gt;

&lt;p&gt;6 What Is a GAN?(opens in a new tab)&lt;/p&gt;

&lt;p&gt;7 AWS Cloud Adoption Framework for Artificial Intelligence, Machine Learning, and Generative AI&lt;/p&gt;

&lt;p&gt;Considerations&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Architecture

   Complexity

   Availability

  Compatibility

  Explainability

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

&lt;/div&gt;

&lt;p&gt;Inference&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   It is the process of generating an output from an input that you provided to the model.

   Input = Prompt and inference parameters

  Randomness and Diversity

         Temperature  (Lower value = high probability outputs and Higher value = Low probability outputs)

         Top K (Lower value = decrease the size of pool)

         Top P

   Length

         Response Length

        Penalties

        Stop sequences

  Prompt

        A specific set of inputs to guide LLMs to generate an appropriate output or completion

  RAG - Retrieval Augmented Generation (RAG)

         Prompt enrichment and appending external data to your prompt

         Vector Database

               Collection of data stored as mathematical representations



  AWS Services for Vector search databases

          Amazon OpenSearch Service

         Amazon OpenSearch Serverless

         Amazon Aurora PostgreSQL

         Amazon RDS PostgreSQL

        Amazon Aurora

       Amazon Neptune

      Amazon DocumentDB [with MongoDB compatibility]



 Amazon Bedrock AGENTS

     Orchestrate prompt completion workflows



Prompt

    Zero shot prompting

    Few shot prompting

    Prompt Template

   Chain-of-thought prompting

   Prompt tuning



Latent space

      The encoded knowledge of language in LLMs or the stored patterns of data that capture relationships and reconstruct the language from the patterns when prompted

      Statistical database
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Prompt Engineering risks and limitations&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     Exposure

     Prompt Injection

     Jailbreaking

    Hijacking

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

&lt;/div&gt;

&lt;p&gt;Training process for foundation models&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     Pretraining         - Self supervised learning

    Fine-tuning        - Supervised learning            :: Catastrophic forgetting

    Continuous pre-training



Fine-tuning techniques

     Parameter-efficient fine-tuning (PEFT)

     Low-Rank Adaptation (LoRA)

     Representation fine-tuning (ReFT)

    Multitask fine-tuning

    Domain adaption fine-tuning

    Reinforcement learning from human feedback (RLHF)



Data preparation fine-tuning

     Prepare your training data

    Select prompts

   Calculate loss

   Update weights

  Define evaluation steps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Data preparation AWS Services&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Amazon SageMaker Canvas

  Open-source frameworks

  Amazon Sagemaker studio - integration with EMR, can use jupyter labs

 Amazon Glue

 Amazon SageMaker Feature Store

 Amazon SageMaker Clarify  -- if you have bias in your data

Amazon SageMaker Ground Truth  -- manage data labelling
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Model performance&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    One option to reduce inference latency is to decrease the size of LLMs but might decrease its performance
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Gen AI Performance Metrics&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    Recall Oriented Understudy for Gisting Evaluation (ROUGE)

            Automatic summarization tasks

           Machine translation software

  Bilingual Evaluation Understudy (BLEU)

           Used for translation tasks

  General Language Understanding Evaluation (GLUE)

         Compare against benchmarks set by the experts

        Access model generalization across multiple tasks

Holistic Evaluation of Language Models (HELM)

      Help improve model transparency

Massive Multitask Language Understanding (MMLU)

     Evaluates knowledge and problem solving capabilities of the model

    Tested against history, mathematics, laws, computer science and more

Beyond the Imitation Game Benchmark (BIG-bench)

    Focuses on tasks that are beyond the capabilities of the current language models
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;AWS Services for model evaluation&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Amazon SageMaker JumpStart

 Amazon SageMaker Clarify
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Review these materials to learn more about the topics covered in this exam domain: &lt;/p&gt;

&lt;p&gt;1 What Are Foundation Models?(opens in a new tab) (opens in a new tab) (opens in a new tab)&lt;/p&gt;

&lt;p&gt;2 Inference Parameters(opens in a new tab)&lt;/p&gt;

&lt;p&gt;3 Knowledge Bases for Amazon Bedrock(opens in a new tab) (opens in a new tab)&lt;/p&gt;

&lt;p&gt;4 Agents for Amazon Bedrock(opens in a new tab)&lt;/p&gt;

&lt;p&gt;5 Amazon OpenSearch Service’s Vector Database Capabilities Explained(opens in a new tab)&lt;/p&gt;

&lt;p&gt;6 The Role of Vector Datastores in Generative AI Applications(opens in a new tab)&lt;/p&gt;

&lt;p&gt;7 Vector Engine for Amazon OpenSearch Serverless (opens in a new tab) (opens in a new tab) (opens in a new tab)&lt;/p&gt;

&lt;p&gt;8 What Is Prompt Engineering?(opens in a new tab)&lt;/p&gt;

&lt;p&gt;9 Domain-Adaptation Fine-Tuning of Foundation Models in Amazon SageMaker JumpStart on Financial Data(opens in a new tab) (opens in a new tab)&lt;/p&gt;

&lt;p&gt;10 Metric: bleu(opens in a new tab)&lt;/p&gt;

&lt;p&gt;11 Metric: rouge(opens in a new tab)&lt;/p&gt;

&lt;p&gt;12 ReFT: Representation Fine-Tuning for Language Models&lt;/p&gt;

&lt;p&gt;Responsible AI&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    Fairness

   Explainability

  Robustness

  Privacy and security

 Governance

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

&lt;/div&gt;

&lt;p&gt;Effects of bias and variance&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Demographic disparities

  Inaccuracy

 Overfitting

 Underfitting

User Trust
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Responsible datasets&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Inclusivity

 Diversity

 Balanced datasets

 Privacy protection

 Consent and transparency

 Regular audits
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Responsible practices&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Environmental considerations

  Sustainability

  Transparency

  Accountability

 Stakeholder engagement
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;AWS service for this&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Amazon SageMaker Clarify

   Detect bias

  Explainability

 SageMaker Processing jobs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;SageMaker pre-training bias analysis &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Class imbalance

 Label imbalance

 Demographic disparity

Difference in positive proportions

Specificity difference

Recall difference

Accuracy difference
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Treatment equality&lt;/p&gt;

&lt;p&gt;Gen AI Risks&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hallucinations

Intellectual Property
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Bias&lt;/p&gt;

&lt;p&gt;Toxicity&lt;/p&gt;

&lt;p&gt;Data privacy&lt;/p&gt;

&lt;p&gt;Guardrails for Amazon Bedrock&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hate

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

&lt;/div&gt;

&lt;p&gt;Sexual&lt;/p&gt;

&lt;p&gt;Violence&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Denied topics&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Model transparency&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Interpretability   - Deep analysis
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Explainability      - black box analysis&lt;/p&gt;

&lt;p&gt;AI Service Card&lt;/p&gt;

&lt;p&gt;Amazon SageMaker Model Cards&lt;/p&gt;

&lt;p&gt;Sagemaker provides&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    Feature attributions - SHAP Values

   Partial dependence plots
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Amazon Augmented AI (A2I) - send data to human reviewers to review random predictions.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Use your own reviewers or use mechanical turf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Responsible AI in the Generative Era(opens in a new tab) (opens in a new tab) (opens in a new tab)&lt;/p&gt;

&lt;p&gt;2 Transform Responsible AI from Theory into Practice(opens in a new tab)&lt;/p&gt;

&lt;p&gt;3 Tools and Resources to Build AI Responsibly(opens in a new tab) (opens in a new tab)&lt;/p&gt;

&lt;p&gt;4 What Is RLHF?(opens in a new tab)&lt;/p&gt;

&lt;p&gt;5 Responsible AI Best Practices: Promoting Responsible and Trustworthy AI Systems&lt;/p&gt;

&lt;p&gt;IAM Identity Center&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      Workforce users, Workforce identities
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Logging with CloudTrail&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     Captures API calls and related events

     Integrated with SageMaker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Amazon SageMaker Role Manager&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Preconfigured permissions for 12 activities
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Encryption at rest&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Amazon SageMaker

       Data is encrypted by default on ML storage volumes

      Notebook instances, SageMaker jobs, and endpoints
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;AWS Key Management Service - KMS&lt;/p&gt;

&lt;p&gt;Amazon Macie&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    Identifies and alerts you to sensitive data

   Remove PII during ingestion
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;AI System Vulnerabilities&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Training Data

   Input Data

  Output Data

  Models

      Inversion

     Theft

LLM's

     Prompt Injection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Amazon SageMaker Model Monitor&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Capture data

  Create a baseline

  Define data quality monitoring jobs

  Evaluate statistics
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Amazon SageMaker Model Registry&lt;/p&gt;

&lt;p&gt;Amazon SageMaker Model Cards&lt;/p&gt;

&lt;p&gt;Amazon SageMaker ML Lineage Tracking&lt;/p&gt;

&lt;p&gt;Amazon SageMaker Feature Store&lt;/p&gt;

&lt;p&gt;Amazon SageMaker Model Dashboard&lt;/p&gt;

&lt;p&gt;Emerging AI compliance standards&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   ISO 42001 and ISO 23894

  EU Artificial Intelligence Act

 NIST AI Risk Management Framework (RMF)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;AI Risk Management&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Probability of occurrence

 Severity of occurrence
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Algorithmic Accountability Act&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Transparency and explainability

 Monitor for Bias
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;AWS Audit Manager&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Audits AWS usage to assess compliance

 Choose a framework

       Gen AI

      Customer frameworks
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Collect evidence and add to audit report&lt;/p&gt;

&lt;p&gt;Guardrails for Amazon Bedrock&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Apply guardrails to any foundation model and agents for Amazon Bedrock

 Configure harmful content filtering

 Define and disallow denied topics

 PII data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;AWS Config&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Continuously monitors and records configurations

 AWS Config rules

Conformance packs

        Operational best practices for AI and ML

       Security best practices for Amazon SageMaker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Amazon Inspector&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Works at application level

  Performs automated security assessments on your applications
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;AWS Trusted Advisor&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Provides guidance to help you

      Reduce cost

      Increase performance

      Improve security
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Data Governance&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Curation

  Discovery and understanding

 Protection

Define roles

    Data steward

   Data owner

   IT Roles
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;AWS Glue DataBrew for data goverance&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Data profiling

 Data Lineage

AWS Glue Data Catalog

AWS Glue Data Quality
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Curation&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    Data Quality Management

   Data Integration

   Data Management
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Protection&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Data Security

 Data Compliance

 Data Lifecycle management
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Review these materials to learn more about the topics covered in this exam domain: &lt;/p&gt;

&lt;p&gt;1 Shared Responsibility Model(opens in a new tab) (opens in a new tab) (opens in a new tab)&lt;/p&gt;

&lt;p&gt;2 Securing Generative AI: Applying Relevant Security Controls(opens in a new tab)&lt;/p&gt;

&lt;p&gt;3 AWS Cloud Adoption Framework for Artificial Intelligence, Machine Learning, and Generative AI(opens in a new tab)&lt;/p&gt;

&lt;p&gt;4 AWS Compliance(opens in a new tab)&lt;/p&gt;

&lt;p&gt;5 Customer Compliance Center(opens in a new tab) (opens in a new tab) (opens in a new tab)&lt;/p&gt;

&lt;p&gt;6 NIST Artificial Intelligence Risk Management Framework(opens in a new tab)&lt;/p&gt;

&lt;p&gt;7 ISO 42001: A New Foundational Global Standard to Advance Responsible AI(opens in a new tab)&lt;/p&gt;

&lt;p&gt;8 The EU Artificial Intelligence Act(opens in a new tab) (opens in a new tab)&lt;/p&gt;

&lt;p&gt;9 Learn How to Assess the Risk of AI Systems(opens in a new tab)&lt;/p&gt;

&lt;p&gt;10 What Is Data Governance?(opens in a new tab)&lt;/p&gt;

&lt;p&gt;11 Data Governance in the Age of Generative AI&lt;/p&gt;

&lt;p&gt;How to Choose a Machine Learning Algorithm? (serokell.io&lt;/p&gt;

</description>
      <category>aws</category>
      <category>awsaipractitioner</category>
    </item>
    <item>
      <title>Using Custom Authorization - Request based for AWS Lambda</title>
      <dc:creator>🅷🅰🆁🅳🅸🅺 🅹🅾🆂🅷🅸</dc:creator>
      <pubDate>Sat, 23 Mar 2024 08:44:44 +0000</pubDate>
      <link>https://dev.to/aws-builders/using-custom-authorization-request-based-for-aws-lambda-2d04</link>
      <guid>https://dev.to/aws-builders/using-custom-authorization-request-based-for-aws-lambda-2d04</guid>
      <description>&lt;p&gt;Many a time we face a challenge for our Lambda function endpoints where a customer autorization is required. &lt;br&gt;
Below is a post which shows how to implement a Request based Custom Authorization for AWS Lambda.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;Lambda authorizer&lt;/strong&gt;, formerly known as custom authorizer, controls API access using a Lambda function. It's beneficial for custom authorization with bearer token authentication like OAuth or SAML OR request parameter based authentications. It processes the caller's identity and returns an IAM policy. There are two types: &lt;strong&gt;TOKEN authorizer&lt;/strong&gt; for bearer tokens and &lt;strong&gt;REQUEST authorizer&lt;/strong&gt; for parameters. WebSocket APIs only support REQUEST authorizers. You can use Lambda functions across AWS accounts for authorizers.&lt;/p&gt;

&lt;p&gt;In this part, I will show you how to create a request based token.&lt;/p&gt;

&lt;p&gt;It will cover 3 high level steps&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a sample Lambda REST API&lt;/li&gt;
&lt;li&gt;Create a trigger on API Gateway&lt;/li&gt;
&lt;li&gt;Create the customer Authorizer and attach it to API and test it.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;*&lt;em&gt;Step 1 *&lt;/em&gt;- Go to AWS Console, select Lambda and click on '&lt;em&gt;Create Function&lt;/em&gt;'&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1oy2tl3inlaxgs1b1nv7.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1oy2tl3inlaxgs1b1nv7.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt; - Author from scratch and API, Give it any name and create a new role for Lambda execution&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F231tzss6svxv9i1gub9o.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F231tzss6svxv9i1gub9o.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt; - Customize the output message with your favourite Hello world message. My sample as below&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

export const handler = async (event) =&amp;gt; {
  // TODO implement
  const response = {
    statusCode: 200,
    body: JSON.stringify('You have called My Rest API!'),
  };
  return response;
};


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

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 4&lt;/strong&gt; - Once the Lambda is created we will create an API Gateway trigger which will basically call this Lambda on the endpoint invocation&lt;/p&gt;

&lt;p&gt;a. Click on add trigger&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqj0kc6ycl3bkun0iyz9z.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqj0kc6ycl3bkun0iyz9z.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;b. Select the source as API Gateway&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftew15mo5vytadqcffge7.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftew15mo5vytadqcffge7.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;c. Fill in the required Trigger parameters to expose it as a REST API and click on Create. Note the security parameter is kept as &lt;strong&gt;OPEN&lt;/strong&gt;. This is specifically to test our scenarios&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2hgbmpz1pnyezuwo80s0.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2hgbmpz1pnyezuwo80s0.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5&lt;/strong&gt; - On the API, click on Configuration tab and click on Triggers, Note the API Endpoint and click on it to open it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2fvucla4r8apsmp8edr3.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2fvucla4r8apsmp8edr3.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6&lt;/strong&gt; - You will be able to view the result from the endpoint.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkwxzha55zk43ptnh9it9.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkwxzha55zk43ptnh9it9.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7&lt;/strong&gt; - Now we will create the authorizer function, Go back to Lambda function, and click on '&lt;em&gt;Create Function&lt;/em&gt;'. Fill in the details as below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffifyoq1fe1xtyhj5xfkw.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffifyoq1fe1xtyhj5xfkw.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 8&lt;/strong&gt; - Now under the code section, fill in the below code.&lt;br&gt;
This is a sample code from AWS blogs. Importantly look for the Header, QueryParam and StageVariable validation conditions.&lt;br&gt;
This will be the one which will be request-based authorizer.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

   // A simple request-based authorizer example to demonstrate how to use request 
    // parameters to allow or deny a request. In this example, a request is  
    // authorized if the client-supplied headerauth1 header, QueryString1
    // query parameter, and stage variable of StageVar1 all match
    // specified values of 'headerValue1', 'queryValue1', and 'stageValue1',
    // respectively.

export const handler = function(event, context, callback) {
    console.log('Received event:', JSON.stringify(event, null, 2));

    // Retrieve request parameters from the Lambda function input:
    var headers = event.headers;
    var queryStringParameters = event.queryStringParameters;
    var pathParameters = event.pathParameters;
    var stageVariables = event.stageVariables;

    // Parse the input for the parameter values
    var tmp = event.methodArn.split(':');
    var apiGatewayArnTmp = tmp[5].split('/');
    var awsAccountId = tmp[4];
    var region = tmp[3];
    var restApiId = apiGatewayArnTmp[0];
    var stage = apiGatewayArnTmp[1];
    var method = apiGatewayArnTmp[2];
    var resource = '/'; // root resource
    if (apiGatewayArnTmp[3]) {
        resource += apiGatewayArnTmp[3];
    }

    // Perform authorization to return the Allow policy for correct parameters and 
    // the 'Unauthorized' error, otherwise.
    var authResponse = {};
    var condition = {};
    condition.IpAddress = {};

    if (headers.headerauth1 === "H1"
        || queryStringParameters.QueryString1 === "Q1"
        || stageVariables.StageVar1 === "S1") {
        callback(null, generateAllow('me', event.methodArn));
    }  else {
        callback("Unauthorized");
    }
}

// Help function to generate an IAM policy
var generatePolicy = function(principalId, effect, resource) {
    // Required output:
    var authResponse = {};
    authResponse.principalId = principalId;
    if (effect &amp;amp;&amp;amp; resource) {
        var policyDocument = {};
        policyDocument.Version = '2012-10-17'; // default version
        policyDocument.Statement = [];
        var statementOne = {};
        statementOne.Action = 'execute-api:Invoke'; // default action
        statementOne.Effect = effect;
        statementOne.Resource = resource;
        policyDocument.Statement[0] = statementOne;
        authResponse.policyDocument = policyDocument;
    }
    // Optional output with custom properties of the String, Number or Boolean type.
    authResponse.context = {
        "stringKey": "stringval",
        "numberKey": 123,
        "booleanKey": true
    };
    return authResponse;
}

var generateAllow = function(principalId, resource) {
    return generatePolicy(principalId, 'Allow', resource);
}

var generateDeny = function(principalId, resource) {
    return generatePolicy(principalId, 'Deny', resource);
}


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

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 9&lt;/strong&gt; - Add the code and now click '&lt;em&gt;Deploy&lt;/em&gt;'&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frcvmwuumu9d7mkptxihr.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frcvmwuumu9d7mkptxihr.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 10&lt;/strong&gt; - Now, go to &lt;strong&gt;API Gateway&lt;/strong&gt; and click on the API Name. NOTE:- you need to go to API Gateway not AWS Lambda.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp2zbadw44opsjqopfnp8.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp2zbadw44opsjqopfnp8.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 11&lt;/strong&gt; - Now go to &lt;em&gt;Authorizers _and click on _Create authorizer&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh488wbprumv0y87bwu67.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh488wbprumv0y87bwu67.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 12&lt;/strong&gt; - Next up, we need to create the autorizer with the right Identify source type and the key values.&lt;br&gt;
One which we are doing here are Header, Query String and StageVariable. There are few others also based on which you can perform the authorization&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ch70w71haqzqv2hezw7.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ch70w71haqzqv2hezw7.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 13&lt;/strong&gt; - Now go back to the authorizer that is created and click on its details&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3dz3rn6fyy9822eki0yg.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3dz3rn6fyy9822eki0yg.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 14&lt;/strong&gt; - Next screen will give you the option to test the authorization, &lt;/p&gt;

&lt;p&gt;a. if you give any values that are acceptable then it will return a 200&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fht4a3w4nvly9g8j6a3og.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fht4a3w4nvly9g8j6a3og.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;b. if you give any values that are not acceptable then it will return a 401&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F04vw8ixchuydp1ct23uh.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F04vw8ixchuydp1ct23uh.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So in this way you can achieve custom authorization for your code very quickly.&lt;/p&gt;

&lt;p&gt;Hope this was useful to you. And in the next blog I will show creation of a token based authorizer. &lt;/p&gt;

</description>
      <category>awslambda</category>
      <category>apisecurity</category>
      <category>customauthorization</category>
      <category>aws</category>
    </item>
    <item>
      <title>AWS Amplify : Website Migration</title>
      <dc:creator>🅷🅰🆁🅳🅸🅺 🅹🅾🆂🅷🅸</dc:creator>
      <pubDate>Sat, 23 Mar 2024 04:06:49 +0000</pubDate>
      <link>https://dev.to/aws-builders/aws-amplify-website-migration-4jc6</link>
      <guid>https://dev.to/aws-builders/aws-amplify-website-migration-4jc6</guid>
      <description>&lt;p&gt;I have a custom web app which would help me track buses around my area and to also give me a clear view on where they current GPS location, letting me leave out at a precise time. &lt;/p&gt;

&lt;p&gt;This Website was earlier hosted on Heroku and was working fine. However, recently Heroku has taken away the free tier and I was exploring alternate web hosting options for my site. &lt;/p&gt;

&lt;p&gt;I gave a go with AWS Amplify web hosting and I am very impressed with the ease of getting it done. Took me less than 5 mins to complete the whole process.&lt;/p&gt;

&lt;p&gt;I will document here the full journey on AWS Amplify Web hosting.&lt;/p&gt;

&lt;p&gt;Firstly, &lt;strong&gt;what is AWS Amplify?&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;AWS Amplify is a set of products and tools that enable mobile and front-end web developers to build and deploy secure, scalable full-stack applications, powered by AWS.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;AWS Amplify provides two components &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Amplify Studio&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Build an app backend with auth, data, and storage, and create custom UI components. Then integrate them in your app with just a few steps.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Amplify Hosting&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Connect your Git repository to continuously deploy your frontend and backend. Host it on a globally available CDN.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Pre-requisites:&lt;/strong&gt;&lt;br&gt;
For this you will need a repo with a bitbucket URL (and optionally may be already deployed earlier or at least locally tested). &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Steps:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt; - Open the AWS Amplify homepage&lt;br&gt;
   eg:- &lt;a href="https://ap-southeast-console.aws.amazon.com/amplify/home?region=ap-southeast-2#/" rel="noopener noreferrer"&gt;https://ap-southeast-console.aws.amazon.com/amplify/home?region=ap-southeast-2#/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3e4r2eegvplgf5wngbh7.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3e4r2eegvplgf5wngbh7.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
  This will open the Amplify Homepage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt; - Scroll down to Amplify Hosting and click 'Get Started'. This will start the webhosting process.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp2i4dj1g4q0epb1ogdfc.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp2i4dj1g4q0epb1ogdfc.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt; -  Choose an existing repo. In my case the repo was hosted on bitbucket. In my case, its currently in GitHub (planning to migrate it to AWS CodeCommit).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdbmw3atfpeg8ghkoq4oe.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdbmw3atfpeg8ghkoq4oe.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
  This step will initiate the steps required for linking the repo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4&lt;/strong&gt; - Authorize this access request by AWS Amplify on Github by &lt;br&gt;
a. signing in with the GitHub credentials,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fajzsl3spwsdxswtqf06k.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fajzsl3spwsdxswtqf06k.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
b. entering the 2FA&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F78f5h9orlgp6m8h9ucyp.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F78f5h9orlgp6m8h9ucyp.JPG" alt="Image description"&gt;&lt;/a&gt; &lt;br&gt;
c. authorizing the access&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd7c7fe90obdd2m7pq9qx.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd7c7fe90obdd2m7pq9qx.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This step will build a connection with your dev work&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5&lt;/strong&gt; - Next provide the permissions to access all repos or selective repos.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8l7i9xh5gzvrrdt1tswl.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8l7i9xh5gzvrrdt1tswl.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click 'Install &amp;amp; authorize'&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6&lt;/strong&gt; - Now under recently updated repos, select the repo &amp;amp; branch that you want to get published.&lt;/p&gt;

&lt;p&gt;a. select the repo&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx7wa68co0bfe1bob39rg.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx7wa68co0bfe1bob39rg.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
b. select the branch&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F643sxf2ysmwyvc5lw41f.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F643sxf2ysmwyvc5lw41f.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7&lt;/strong&gt; - Next select the build setting. Here you can define the app name and additionally you can configure the advanced settings if required. I didnt had that much need so went with the default one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fglvlvwuuze838qvbx6dt.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fglvlvwuuze838qvbx6dt.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 8&lt;/strong&gt; - Now, review all the settings and click 'Save and Deploy'&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fer3kfo5tv9z32att5epp.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fer3kfo5tv9z32att5epp.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 9&lt;/strong&gt; - Monitor the deployment for Provision - Build and then Deploy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv4lsgzx801iuicsn925e.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv4lsgzx801iuicsn925e.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it.&lt;br&gt;
You will get the deployment URL and once the deploy step is successful you will be able to access it.&lt;/p&gt;

&lt;p&gt;It was really easy and straightforward to migrate my website on AWS Amplify.&lt;/p&gt;

&lt;p&gt;Hope you had a good read and can try this out now.&lt;/p&gt;

</description>
      <category>awsamplify</category>
      <category>webdev</category>
      <category>aws</category>
    </item>
    <item>
      <title>Create a Telegram Bot with AWS Lambda Integration - Part 2</title>
      <dc:creator>🅷🅰🆁🅳🅸🅺 🅹🅾🆂🅷🅸</dc:creator>
      <pubDate>Mon, 13 Mar 2023 11:53:04 +0000</pubDate>
      <link>https://dev.to/aws-builders/create-a-telegram-bot-with-aws-lambda-integration-part-2-5dp1</link>
      <guid>https://dev.to/aws-builders/create-a-telegram-bot-with-aws-lambda-integration-part-2-5dp1</guid>
      <description>&lt;p&gt;Hello and welcome back to the Part -2 of the AWS Lambda and Telegram Bot interaction. For the next step, I was exploring on the integration options that can be trialled for taking this a step further. Below are the use cases for which this integration can be used.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Serverless Notifications:&lt;/strong&gt; By integrating Telegram with AWS Lambda, you can create a serverless notification system that sends messages to Telegram whenever certain events occur in your AWS infrastructure. For example, you could set up a Lambda function to send a message to a Telegram group whenever a new EC2 instance is launched.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Chatbot:&lt;/strong&gt; You can use AWS Lambda to build a chatbot that responds to user queries in Telegram. For example, you could create a Lambda function that uses natural language processing to answer questions about your products or services, and then integrate it with Telegram so that users can interact with the chatbot through the Telegram app.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Content Distribution:&lt;/strong&gt; By integrating Telegram with AWS Lambda, you can create a system for distributing content to users through Telegram. For example, you could set up a Lambda function to generate daily news summaries or weather updates, and then use Telegram to distribute them to subscribers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Event Monitoring:&lt;/strong&gt; You can use AWS Lambda to monitor events in your Telegram groups or channels. For example, you could create a Lambda function that analyzes messages in a Telegram group and sends an alert to a designated user if certain keywords or phrases are detected.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Analytics:&lt;/strong&gt; By integrating Telegram with AWS Lambda, you can create a system for analyzing user behavior in Telegram. For example, you could set up a Lambda function to track how often users interact with your Telegram bot, what kinds of questions they ask, and how long they spend chatting. This data can then be used to optimize your chatbot and improve user engagement.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Firstly, I tried to create a chatbot which will respond to commands typed on telegram and for now it is sending a sample response back for acknowledgement&lt;/p&gt;

&lt;p&gt;Assuming you have followed all the required steps from Part - 1, below is the code that you will be required to update in the lambda handler for this&lt;/p&gt;

&lt;p&gt;&lt;code&gt;import json&lt;br&gt;
import os&lt;br&gt;
import requests&lt;br&gt;
def lambda_handler(event, context):&lt;br&gt;
    request_body = json.loads(event['body'])                            # EXtract the Body from the call&lt;br&gt;
    request_msg = json.dumps(request_body['message'])#['chat']['id']    # Extract the message object which contrains chat id and text&lt;br&gt;
    chat_id = json.dumps(request_body['message']['chat']['id'])         # Extract the chat id from message&lt;br&gt;
    command = json.dumps(request_body['message']['text']).strip('"')    # Extract the text from the message&lt;br&gt;
    # TODO implement&lt;br&gt;
    BOT_TOKEN = os.environ.get('TOKEN')&lt;br&gt;
    BOT_CHAT_ID = os.environ.get('CHATID')&lt;br&gt;
    BOT_CHAT_ID = chat_id                                               # Updating the Bot Chat Id to be dynamic instead of static one earlier&lt;br&gt;
    command = command[1:]                                               # Valid input command is /start or /help. however stripping the '/' here as it was having some conflict in execution.&lt;br&gt;
    if command == 'start':&lt;br&gt;
        message = "Welcome to my bot! How can I help you today?"        # Sample Response on start command&lt;br&gt;
    elif command == 'help':&lt;br&gt;
        message = "Here are the available commands: /start, /help"&lt;br&gt;
    else:&lt;br&gt;
        message = "I'm sorry, I didn't understand that command. Please try again."&lt;br&gt;
    send_text = 'https://api.telegram.org/bot' + BOT_TOKEN + '/sendMessage?chat_id=' + BOT_CHAT_ID + \&lt;br&gt;
                '&amp;amp;parse_mode=HTML&amp;amp;text=' + message&lt;br&gt;
    response = requests.get(send_text)&lt;br&gt;
    print(send_text)            &lt;br&gt;
    print(response)    &lt;br&gt;
    return {&lt;br&gt;
        'statusCode': 200,&lt;br&gt;
        'body': json.dumps('Hello from Lambda!')&lt;br&gt;
    }&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;For the above chatbot to work, we need to have an active connection between Telegram and Lambda. For this, we need to set a webhook. Below is the command to set webhook&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://api.telegram.org/bot" rel="noopener noreferrer"&gt;https://api.telegram.org/bot&lt;/a&gt;&amp;lt;&amp;gt;/setWebhook?url=&amp;lt;&amp;gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Here the BOT ID is your Bot ID&lt;/li&gt;
&lt;li&gt;The Lambda Function URL is the URL obtained from the Lambda description page.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3cj2et3rix584ilautb2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3cj2et3rix584ilautb2.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After updating the above code, below is the result that I have got&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fypbn5vbfhpsaxf4dqd65.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fypbn5vbfhpsaxf4dqd65.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it for the Part 2. &lt;br&gt;
Next I want to try the below for Part 3.&lt;br&gt;
a. Create a chatbot quiz which will have questions from Dynamo DB and scorecard in DynamoDB and hosted via Telegram.&lt;br&gt;
b. Some live score or ticker updates via Telegram. This will involve in CORS functionality and https calls via Lambda.&lt;/p&gt;

</description>
      <category>awslambda</category>
      <category>telegram</category>
      <category>aws</category>
      <category>integration</category>
    </item>
    <item>
      <title>Create a Telegram Bot with AWS Lambda Integration - Part 1</title>
      <dc:creator>🅷🅰🆁🅳🅸🅺 🅹🅾🆂🅷🅸</dc:creator>
      <pubDate>Mon, 16 Jan 2023 19:05:06 +0000</pubDate>
      <link>https://dev.to/aws-builders/create-a-telegram-bot-with-aws-lambda-integration-part-1-4616</link>
      <guid>https://dev.to/aws-builders/create-a-telegram-bot-with-aws-lambda-integration-part-1-4616</guid>
      <description>&lt;p&gt;Hi all, recently over the Christmas break, I wanted to explore a telegram bot automation for a personal project. As part of that, I went through learning all the steps required and going over multiple iterations to optimize the code and also get it working.&lt;/p&gt;

&lt;p&gt;And with the this post, I want to share my learning with you all. Below is the step by step guide to create a Telegram Bot with AWS Lambda Integration.&lt;/p&gt;

&lt;p&gt;This will be a multi-part blog. Part 1 below is focusing on getting the basics done and then Part 2 will go for advanced interactions.&lt;/p&gt;

&lt;p&gt;I hope this helps you.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Firstup, we will create a bot in Telegram. All conversations will be done via this bot over telegram.&lt;br&gt;
For creating bot, telegram has this really cool feature &lt;a class="mentioned-user" href="https://dev.to/botfather"&gt;@botfather&lt;/a&gt;, Search for botfather and you can start interacting to create new bot&lt;br&gt;
"Seach BotFather and message /start"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type "/newbot" to create a new bot&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose the name of the bot&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose the username of the bot&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0rehx86fq770xb5b9kpf.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0rehx86fq770xb5b9kpf.JPG" alt="Telegram Bot Image" width="800" height="465"&gt;&lt;/a&gt;&lt;br&gt;
** This step will generate a TOKEN. Save this token for future &lt;br&gt;
use.**&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Next click on the link for your new bot generated above (t.me/##yourbotname##) and start a conversation. Text "Hi"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once you send a message to the bot, the chat will get an ID which will be used for the conversation. To retrieve the ChatID, we will use the Telegram API.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Replace your TOKENid below and call the below URL &lt;a href="https://api.telegram.org/bot##yourTOKENid##/getUpdates" rel="noopener noreferrer"&gt;https://api.telegram.org/bot##yourTOKENid##/getUpdates&lt;/a&gt; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Extract the ChatID from the response. Look for the below tag in response: "chat":{"id": "&lt;strong&gt;xxxxxxx&lt;/strong&gt;"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now send a sample message to this chat with Web (Later on we will do it via AWS Lambda) &lt;a href="https://api.telegram.org/bot##yourTOKENid##/sendMessage?chat_id=##yourChatID##&amp;amp;text=Hello" rel="noopener noreferrer"&gt;https://api.telegram.org/bot##yourTOKENid##/sendMessage?chat_id=##yourChatID##&amp;amp;text=Hello&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;HURRAY.. You should have got a text from the Bot already. Now lets build the integration with AWS Lambda&lt;/strong&gt; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Go to AWS Console -&amp;gt; AWS Lambda -&amp;gt; Click on 'Create Function'&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8993v9yrizjhpjbeexuq.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8993v9yrizjhpjbeexuq.JPG" alt="Create Function Help" width="800" height="89"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now, give a valid function name and select the suitable runtime, then go to advance setting and select the checkbox of 'Enable Function URL' and 'None' for the IAM setting (This is great feature and elimiates API Gateway setting altogether), keep rest settings as default and click on 'Create Function'. I chose python in this case&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwbmmrstymtkzn4difq27.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwbmmrstymtkzn4difq27.JPG" alt="Create Function1" width="800" height="346"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkmp4vmdr0n1bqr8yv0my.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkmp4vmdr0n1bqr8yv0my.JPG" alt="Create Function2" width="800" height="333"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When the sample function is created. Copy the Function URL and open it in a new tab. You should get a response as below.&lt;br&gt;
If you are getting unauthorize error, then recheck if you had selected 'None' in function URL which ensures unathenticated access. &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwybprqrrqa12oq220945.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwybprqrrqa12oq220945.JPG" alt="Function URL" width="800" height="341"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It's best practice to define the secure information as Environment Variable (or for advanced uses you can use other secure stores). Go to 'Configuration' tab and click on 'Environment Variables' and add 2 variables&lt;br&gt;
'TOKEN' = Value is ##yourTOKENid##&lt;br&gt;
'CHATID' = Value is ##yourCHATid## (In future, we can retrieve chatid from request to make it dynamic) &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7lbpbsgui2qze9bh5liz.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7lbpbsgui2qze9bh5liz.JPG" alt="Set Env Variable" width="800" height="574"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9kviia3dau3z46cs0wr6.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9kviia3dau3z46cs0wr6.JPG" alt="Set Env Variable2" width="641" height="857"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now we will add the functionality to send the message via Lambda. For python, this usually requires importing 'requests' module which is not available out of the box.&lt;br&gt;
Hence, for this, we will choose to create a layer in Lambda which will host this library.&lt;br&gt;
Download the Requests tar from &lt;a href="https://github.com/TryNErr/TryNErr/blob/main/requests.zip" rel="noopener noreferrer"&gt;https://github.com/TryNErr/TryNErr/blob/main/requests.zip&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Once downloaded tar will have to be convered to ZIP with below folder structure&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For Python, create the below folder structure + download required libraries &lt;br&gt;
  python / &lt;br&gt;
         certifi-2021.10.8.dist-info&lt;br&gt;
         certifi&lt;br&gt;
         charset_normalizer&lt;br&gt;
         charset_normalizer-2.0.12.dist-info&lt;br&gt;
         idna&lt;br&gt;
         idna-3.3.dist-info&lt;br&gt;
         requests&lt;br&gt;
         requests-2.27.1.dist-info&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;you can alternately take it from your python project libraries and zip these files OR contact me and I can send it to you.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Click on 'Layers' on the Lambda function&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv0n09r6r31en0pgme0m2.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv0n09r6r31en0pgme0m2.JPG" alt="Layers" width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on 'Add a Layer'&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1oli2xq3y4uczl6nqooa.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1oli2xq3y4uczl6nqooa.JPG" alt="Add a Layer" width="800" height="297"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Next, we will create a new layer, click on 'Create a New Layer'&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp6f45q0escodt50mnyib.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp6f45q0escodt50mnyib.JPG" alt="Create a New Layer" width="800" height="577"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provide the required details, Upload the requests.zip file, click on 'Create'&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkrzb26mszay6154crkqu.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkrzb26mszay6154crkqu.JPG" alt="Create Layer" width="800" height="763"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Post creation, Go back to the Lambda function and click on Add a Layer to add the newly created layer, click 'Add'&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7zd6bw1tws4z6dztawo7.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7zd6bw1tws4z6dztawo7.JPG" alt="Add Created Layer" width="800" height="104"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa37mu7ev1l3nh4o5qh7m.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa37mu7ev1l3nh4o5qh7m.JPG" alt="Add Created Layer2" width="800" height="648"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now, update your lambda function with the below code:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import json
import os
import requests

def lambda_handler(event, context):
    # TODO implement
    BOT_TOKEN = os.environ.get('TOKEN')
    BOT_CHAT_ID = os.environ.get('CHATID')
    #BOT_CHAT_ID = chat_id
    bot_message = "Hello, this is the bot from telegram"
    send_text = 'https://api.telegram.org/bot' + BOT_TOKEN + '/sendMessage?chat_id=' + BOT_CHAT_ID + \
                '&amp;amp;parse_mode=HTML&amp;amp;text=' + bot_message
    response = requests.get(send_text)
    print(response)    
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  This should send a message to your telegram chat...
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Thats the end of Part 1.&lt;br&gt;
For Part 2, I will try to a) add more functionality to the bot and b) schedule the bot to trigger message in set frequency.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>cloudcomputing</category>
      <category>devops</category>
    </item>
    <item>
      <title>AWS Step Functions - Simple Order Flow</title>
      <dc:creator>🅷🅰🆁🅳🅸🅺 🅹🅾🆂🅷🅸</dc:creator>
      <pubDate>Mon, 13 Sep 2021 08:34:04 +0000</pubDate>
      <link>https://dev.to/aws-builders/aws-step-functions-simple-order-flow-6gn</link>
      <guid>https://dev.to/aws-builders/aws-step-functions-simple-order-flow-6gn</guid>
      <description>&lt;h2&gt;
  
  
  AWS Step Functions - Simple Order Flow Example (Step by Step Guide)
&lt;/h2&gt;

&lt;h2&gt;
  
  
  What is &lt;a href="https://aws.amazon.com/step-functions/" rel="noopener noreferrer"&gt;AWS Step Functions?&lt;/a&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;AWS Step Functions is a fully managed service that makes it easy to coordinate the components of distributed applications and microservices using visual workflows. &lt;/li&gt;
&lt;li&gt;Building applications from individual components that each perform a discrete function lets you scale easily and change applications quickly. &lt;/li&gt;
&lt;li&gt;Step Functions is a reliable way to coordinate components and step through the functions of your application. Step Functions provides a graphical console to arrange and visualize the components of your application as a series of steps. &lt;/li&gt;
&lt;li&gt;This makes it simple to build and run multi-step applications. Step Functions automatically triggers and tracks each step, and retries when there are errors, so your application executes in order and as expected. &lt;/li&gt;
&lt;li&gt;Step Functions logs the state of each step, so when things do go wrong, you can diagnose and debug problems quickly. &lt;/li&gt;
&lt;li&gt;You can change and add steps without even writing code, so you can easily evolve your application and innovate faster.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Order Flow - Design Details
&lt;/h2&gt;

&lt;p&gt;For this example, I will demo how step functions can help to manage a order flow once user has submitted the order. Here, for this example, I am taking an online bookstore which will ship books based on the order submission. It should perform the below steps as part of Order Handling&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;On Order Submit, system will check the &lt;strong&gt;available inventory&lt;/strong&gt; of the book.&lt;/li&gt;
&lt;li&gt;If inventory available, then proceed further. If not available, then trigger a &lt;strong&gt;printOrder&lt;/strong&gt; and &lt;strong&gt;wait&lt;/strong&gt; for the book to be printed.&lt;/li&gt;
&lt;li&gt;Once the book is printed, the system will &lt;strong&gt;prepare order&lt;/strong&gt; for delivery and trigger the &lt;strong&gt;send shipment&lt;/strong&gt; flow.&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;parallel&lt;/strong&gt;, System will

&lt;ul&gt;
&lt;li&gt;Update Loyalty Points for the Customer&lt;/li&gt;
&lt;li&gt;Check future discount eligibility and send discount code for future order&lt;/li&gt;
&lt;li&gt;Update Recommendation Engine&lt;/li&gt;
&lt;li&gt;Send a free eBook for Tips to Better Life&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Order Flow - Steps
&lt;/h2&gt;

&lt;p&gt;For creating a Step Function, below are the steps required which I will show in details&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create an IAM Role for the AWS Step function to be able to execute the AWS Services ( eg:- Lambda in this case)&lt;/li&gt;
&lt;li&gt;Create Lambda Executor Functions&lt;/li&gt;
&lt;li&gt;Create AWS Step Functions with the flow as highlighted above&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Order Flow - Step 1 - IAM Roles
&lt;/h3&gt;

&lt;p&gt;1 In the AWS Console, go to &lt;strong&gt;Identity and Access Management (IAM)&lt;/strong&gt;, click on &lt;strong&gt;Roles&lt;/strong&gt; in the left hand pane&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmjp9av6ec8lig90z9voe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmjp9av6ec8lig90z9voe.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Click on &lt;strong&gt;Create Role&lt;/strong&gt; &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx6f7ccp4q49coyhvqu7d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx6f7ccp4q49coyhvqu7d.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On the next screen, keep the default &lt;strong&gt;AWS Service&lt;/strong&gt; option selected and under the list of Services choose &lt;strong&gt;Step Functions&lt;/strong&gt; &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2For19ibmny0vusu7ja9kr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2For19ibmny0vusu7ja9kr.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Leave the rest as default and click Next on next 3 screens, Give a &lt;strong&gt;Role Name&lt;/strong&gt; and click &lt;strong&gt;Create Role&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiq6khkcf40x5x0sk4i8g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiq6khkcf40x5x0sk4i8g.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Great! Step 1 has been completed and we are now ready for Step 2 on creation of the required Lambda functions&lt;/p&gt;

&lt;h3&gt;
  
  
  Order Flow - Step 2 - Create Lambda
&lt;/h3&gt;

&lt;p&gt;Next step is to create below Lambda functions as per the requirement of our code.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the IAM console, search &lt;strong&gt;Lambda&lt;/strong&gt; and click on &lt;strong&gt;Create Function&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Author from scratch&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Give &lt;strong&gt;Function name&lt;/strong&gt; as per below function names&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Runtime&lt;/strong&gt; as Node.js 14.x&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Permissions&lt;/strong&gt;, select &lt;strong&gt;Use and Existing Role&lt;/strong&gt; and select the role created at &lt;strong&gt;Step 1&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Copy-Paste the below code for checkInventory (1 below)&lt;/li&gt;
&lt;li&gt;Click Deploy&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now repeat this step for (2-8 lambda code below)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;1 - checkInventory&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log('Loading function checkInventory');

exports.handler = async (event, context) =&amp;gt; {

    var x = {ItemStock: 0};

    if (event.bookId == 343222)
      x = {ItemStock: 20};

    return x;  
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;2 - OrderToPrint
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log('Loading function orderToPrint');

exports.handler = async (event, context) =&amp;gt; {
    console.log('Printing the Order Book');

    var retJson = { TotalValue: 500 };

    return retJson;  
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;3 - checkFurtherDiscountEligibility
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log('Loading function check Further Discount');

exports.handler = async (event, context) =&amp;gt; {
    var TotalDiscount = { Discount: 10 };

    if (event.TotalValue &amp;gt; 400){
        TotalDiscount = { Discount: 20 };
    }

    return TotalDiscount; 
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;4 - generateDiscountCode
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log('Loading function generate Discount Code');

exports.handler = async (event, context) =&amp;gt; {
    //console.log('Received event:', JSON.stringify(event, null, 2));
    var Disc = { DiscountCode: "Hello10" };
    if (event.Discount &amp;gt;20 )
       Disc = { DiscountCode: "Hello20" };

    return Disc; 
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;5 - updateLoyaltyPoints
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log('Loading function update Loyalty Points');

exports.handler = async (event, context) =&amp;gt; {
    var LoyaltyPoints = { LoyaltyPoints: event.TotalValue };

    return LoyaltyPoints;  
};

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;6 - prepareOrder
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log('Loading function prepare Order');

exports.handler = async (event, context) =&amp;gt; {

    var shipmsg = { Shipmsg: "Order Prepared - Ready for Shipment"};

    console.log(' Order Prepared - Ready for Shipment');

    return shipmsg;  
};

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;7 - sendToShipment
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log('Loading function send to shipment');

exports.handler = async (event, context) =&amp;gt; {
    //console.log('Received event:', JSON.stringify(event, null, 2));

    var shipment = { ShipmentSent : "True" };

    return shipment; 
};

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;8 - updateRecoEngine
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log('Loading function update Reco Engine');

exports.handler = async (event, context) =&amp;gt; {
    var Reco = { RecoengineUpdated : "True"};
    return Reco;
};

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Order Flow - Step 3 - Create Step Functions
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;In the AWS Console, search &lt;strong&gt;Step Functions&lt;/strong&gt;, click on &lt;strong&gt;State Machines&lt;/strong&gt; in the left hand pane&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffjczoeae5px6rkzlvai7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffjczoeae5px6rkzlvai7.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on 'Create State Machine' Button&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flspermgvmg4qx7934bvy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flspermgvmg4qx7934bvy.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose Authoring method as &lt;strong&gt;Design you workflow visually&lt;/strong&gt; and select Type as &lt;strong&gt;Standard&lt;/strong&gt;, Click Next&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fek5vzqmk81ilp66wvnqo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fek5vzqmk81ilp66wvnqo.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On the Next Screen, you can choose to design the workflow by using the Lambda &lt;strong&gt;Actions&lt;/strong&gt; and decision making &lt;strong&gt;Flow&lt;/strong&gt; as per our example statement or you can use the code below&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "Comment": "An Order Flow example of the Amazon States Language using Lambda",
  "StartAt": "Order Handling",
  "States": {
    "Order Handling": {
      "Type": "Pass",
      "Next": "CheckInventory"
    },
    "CheckInventory": {
      "Type": "Task",
      "Resource": "arn:aws:states:::lambda:invoke",
      "OutputPath": "$.Payload",
      "Parameters": {
        "Payload.$": "$"
      },
      "Retry": [
        {
          "ErrorEquals": [
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException"
          ],
          "IntervalSeconds": 2,
          "MaxAttempts": 6,
          "BackoffRate": 2
        }
      ],
      "Next": "Choice"
    },
    "Choice": {
      "Type": "Choice",
      "Choices": [
        {
          "Variable": "$.ItemStock",
          "NumericGreaterThan": 0,
          "Next": "Pass"
        }
      ],
      "Default": "OrderPrint"
    },
    "Pass": {
      "Type": "Pass",
      "Next": "Parallel"
    },
    "OrderPrint": {
      "Type": "Task",
      "Resource": "arn:aws:states:::lambda:invoke",
      "OutputPath": "$.Payload",
      "Parameters": {
        "Payload.$": "$"
      },
      "Retry": [
        {
          "ErrorEquals": [
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException"
          ],
          "IntervalSeconds": 2,
          "MaxAttempts": 6,
          "BackoffRate": 2
        }
      ],
      "Next": "Parallel"
    },
    "Parallel": {
      "Type": "Parallel",
      "Branches": [
        {
          "StartAt": "CheckFurtherDiscountEligibility",
          "States": {
            "CheckFurtherDiscountEligibility": {
              "Type": "Task",
              "Resource": "arn:aws:states:::lambda:invoke",
              "OutputPath": "$.Payload",
              "Parameters": {
                "Payload.$": "$"
              },
              "Retry": [
                {
                  "ErrorEquals": [
                    "Lambda.ServiceException",
                    "Lambda.AWSLambdaException",
                    "Lambda.SdkClientException"
                  ],
                  "IntervalSeconds": 2,
                  "MaxAttempts": 6,
                  "BackoffRate": 2
                }
              ],
              "Next": "GenerateDiscountCode"
            },
            "GenerateDiscountCode": {
              "Type": "Task",
              "Resource": "arn:aws:states:::lambda:invoke",
              "OutputPath": "$.Payload",
              "Parameters": {
                "Payload.$": "$"
              },
              "Retry": [
                {
                  "ErrorEquals": [
                    "Lambda.ServiceException",
                    "Lambda.AWSLambdaException",
                    "Lambda.SdkClientException"
                  ],
                  "IntervalSeconds": 2,
                  "MaxAttempts": 6,
                  "BackoffRate": 2
                }
              ],
              "End": true
            }
          }
        },
        {
          "StartAt": "UpdateLoyaltyPoints",
          "States": {
            "UpdateLoyaltyPoints": {
              "Type": "Task",
              "Resource": "arn:aws:states:::lambda:invoke",
              "OutputPath": "$.Payload",
              "Parameters": {
                "Payload.$": "$"
              },
              "Retry": [
                {
                  "ErrorEquals": [
                    "Lambda.ServiceException",
                    "Lambda.AWSLambdaException",
                    "Lambda.SdkClientException"
                  ],
                  "IntervalSeconds": 2,
                  "MaxAttempts": 6,
                  "BackoffRate": 2
                }
              ],
              "End": true
            }
          }
        },
        {
          "StartAt": "PrepareOrder",
          "States": {
            "PrepareOrder": {
              "Type": "Task",
              "Resource": "arn:aws:states:::lambda:invoke",
              "OutputPath": "$.Payload",
              "Parameters": {
                "Payload.$": "$"
              },
              "Retry": [
                {
                  "ErrorEquals": [
                    "Lambda.ServiceException",
                    "Lambda.AWSLambdaException",
                    "Lambda.SdkClientException"
                  ],
                  "IntervalSeconds": 2,
                  "MaxAttempts": 6,
                  "BackoffRate": 2
                }
              ],
              "Next": "SendToShipment"
            },
            "SendToShipment": {
              "Type": "Task",
              "Resource": "arn:aws:states:::lambda:invoke",
              "OutputPath": "$.Payload",
              "Parameters": {
                "Payload.$": "$"
              },
              "Retry": [
                {
                  "ErrorEquals": [
                    "Lambda.ServiceException",
                    "Lambda.AWSLambdaException",
                    "Lambda.SdkClientException"
                  ],
                  "IntervalSeconds": 2,
                  "MaxAttempts": 6,
                  "BackoffRate": 2
                }
              ],
              "End": true
            }
          }
        },
        {
          "StartAt": "UpdateRecoEngine",
          "States": {
            "UpdateRecoEngine": {
              "Type": "Task",
              "Resource": "arn:aws:states:::lambda:invoke",
              "OutputPath": "$.Payload",
              "Parameters": {
                "Payload.$": "$"
              },
              "Retry": [
                {
                  "ErrorEquals": [
                    "Lambda.ServiceException",
                    "Lambda.AWSLambdaException",
                    "Lambda.SdkClientException"
                  ],
                  "IntervalSeconds": 2,
                  "MaxAttempts": 6,
                  "BackoffRate": 2
                }
              ],
              "End": true
            }
          }
        }
      ],
      "Next": "Order Handled"
    },
    "Order Handled": {
      "Type": "Pass",
      "End": true
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Replace the &lt;strong&gt;arn:aws:states:::lambda:invoke&lt;/strong&gt; with lambda that you specifically created in Step 2.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click &lt;strong&gt;Next&lt;/strong&gt;, review generated code&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click &lt;strong&gt;Next&lt;/strong&gt; and Specify state name, under permissions, select the existing role that you had created earlier, keep the rest setting as default and click &lt;strong&gt;create state machine&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fna04tnrhpevzn9egcux0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fna04tnrhpevzn9egcux0.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Order Flow - Final Testing.
&lt;/h3&gt;

&lt;p&gt;So now you are ready with a working state machine and it's time to test.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;State Machine&lt;/strong&gt; and click on &lt;strong&gt;View Details&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Click on &lt;strong&gt;Start Execution&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;For the test, i have created two types of inputs, book id = 343222 which has inventory and any other number which will not have inventory, lets try it out now.&lt;/li&gt;
&lt;li&gt;Enter the below input: (With Inventory)
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "orderId": "123",
  "bookId": "343222"
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result is:&lt;br&gt;
** Note it goes to inventory Available flow **&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff2o9t261rvcm3o0pe7k7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff2o9t261rvcm3o0pe7k7.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now lets try another input without inventory
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "orderId": "124",
  "bookId": "343122"
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result is:&lt;br&gt;
** Note it goes to the book printing flow**&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frxlewboul549vnzqah11.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frxlewboul549vnzqah11.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Thanks a lot. Hope this helps you with more learning on Step functions. Would love to hear your comments.
&lt;/h2&gt;

</description>
      <category>aws</category>
      <category>lambda</category>
      <category>node</category>
    </item>
  </channel>
</rss>
