Monday, June 29, 2026

AWS AI Professional - When to use which AWS Lex vs AWS Bedrock Agents

 QBased on everything you've covered in both parts of your blog, here's a comprehensive summary that captures both the **fundamentals** and the **AI-specific capabilities** of OpenTelemetry.


Exam Decision Table

Requirement Choose Reason

Intent-based chatbot Amazon Lex Purpose-built for conversational workflows

Multi-turn slot filling Amazon Lex Native dialog management

Retrieve order status AWS Lambda Calls enterprise systems securely

Generate natural explanations Amazon Bedrock LLM reasoning and text generation

Summarize conversations Amazon Bedrock LLM summarization

Execute business logic AWS Lambda Orchestration and integration

Build a customer support bot with both transactional and generative capabilities Lex + Lambda + Bedrock Best of both worlds

An exam tip


A useful way to think about these services is:


Amazon Lex = How do I conduct the conversation? (intents, slots, dialog flow)

AWS Lambda = How do I retrieve or update enterprise data?

Amazon Bedrock = How do I reason over information or generate natural language?


If a scenario emphasizes structured conversations, slot filling, and predictable workflows, Lex is usually the stronger choice. If it emphasizes open-ended questions, summarization, content generation, or reasoning, Bedrock becomes the key service. Many real-world AWS architectures combine all three.

AWS AI Professional : Differences between Amazon Lex vs Bedrock Agent based chat

Excellent question. This is exactly the kind of architectural trade-off the **AWS Certified AI Engineer/AI Professional** exam tests.


The short answer is:


**Yes, Amazon Lex can absolutely be used in Scenario 2.** In fact, if the question is "build a chatbot", Lex is often the best answer. My previous architecture focused on a **Generative AI chatbot using Bedrock**, whereas **Lex is a conversational interface service**. They solve different parts of the problem.


Let's compare them.


---


# Option 1: Bedrock + Lambda (What I showed)


```

User

   │

API Gateway

   │

Lambda

   │

Order Database

   │

Bedrock

   │

Response

```


Lambda performs:


* User authentication

* Order lookup

* Prompt construction

* Calls Bedrock


This is ideal when responses require:


* reasoning

* summarization

* natural conversation

* generation


Example


Customer asks


> I ordered a laptop last week. Can you tell me when it'll arrive, and if it's delayed, explain why?


The application retrieves the order details and Bedrock generates a natural response such as:


> Your laptop was shipped yesterday and is expected to arrive on Thursday. The one-day delay was caused by severe weather affecting the regional distribution center.


This type of response benefits from an LLM.


---


# Option 2: Amazon Lex


```

Customer


   Lex Bot


Intent


Lambda


Order DB


Return Status


Lex Response

```


Lex understands:


* intents

* slots

* conversation flow


For example:


Customer:


> Where is my order?


Lex:


"What is your Order ID?"


Customer:


> 12345


Lex invokes Lambda.


Lambda queries the database.


Lex replies:


> Your order is shipped.


No LLM is required.


---


# Can Lex access enterprise systems?


Yes.


This is one of its primary capabilities.


The typical flow is:


```

Lex



Lambda



ERP



CRM



SAP



Salesforce



Order Database



Return result

```


Lex itself doesn't directly connect to databases.


Instead, it invokes Lambda, which integrates with enterprise systems.


---


# When is Lex the better choice?


Suppose your call center only needs to answer:


* Order status

* Reset password

* Account balance

* Cancel order

* Book appointment


These are deterministic workflows.


Lex is ideal because:


* Lower cost

* Lower latency

* Predictable responses

* Built-in dialog management

* Slot filling

* Intent recognition


No hallucination risk.


---


# Where Lex struggles


Imagine the customer asks:


> My package is delayed. Based on my purchase history, what would you recommend while I wait?


Lex cannot generate rich, contextual answers.


It relies on predefined intents and responses.


A foundation model such as Bedrock excels here.


---


# The modern AWS architecture


Increasingly, enterprises combine both services.


```

                 Customer

                     │

                 Amazon Lex

                     │

         Understand Intent

                     │

                Invoke Lambda

                     │

          ┌──────────┴───────────┐

          │                      │

     Order Database         Amazon Bedrock

          │                      │

          └──────────┬───────────┘

                     │

              Final Response

```


For example:


Customer:


> I ordered a phone two weeks ago. Is it delayed? If so, write an apology email that I can send to my manager because I won't have the device before my business trip.


Flow:


1. Lex identifies the intent ("Order Inquiry").

2. Lambda retrieves the order information.

3. Lambda sends the order details and the user's request to Bedrock.

4. Bedrock generates a personalized explanation and apology email.

5. Lex delivers the response.


Lex manages the conversation, while Bedrock provides reasoning and content generation.


---


# Exam Decision Table


| Requirement                                                                      | Choose                 | Reason                                     |

| -------------------------------------------------------------------------------- | ---------------------- | ------------------------------------------ |

| Intent-based chatbot                                                             | Amazon Lex             | Purpose-built for conversational workflows |

| Multi-turn slot filling                                                          | Amazon Lex             | Native dialog management                   |

| Retrieve order status                                                            | AWS Lambda             | Calls enterprise systems securely          |

| Generate natural explanations                                                    | Amazon Bedrock         | LLM reasoning and text generation          |

| Summarize conversations                                                          | Amazon Bedrock         | LLM summarization                          |

| Execute business logic                                                           | AWS Lambda             | Orchestration and integration              |

| Build a customer support bot with both transactional and generative capabilities | Lex + Lambda + Bedrock | Best of both worlds                        |


### An exam tip


A useful way to think about these services is:


* **Amazon Lex** = *How do I conduct the conversation?* (intents, slots, dialog flow)

* **AWS Lambda** = *How do I retrieve or update enterprise data?*

* **Amazon Bedrock** = *How do I reason over information or generate natural language?*


If a scenario emphasizes **structured conversations, slot filling, and predictable workflows**, Lex is usually the stronger choice. If it emphasizes **open-ended questions, summarization, content generation, or reasoning**, Bedrock becomes the key service. Many real-world AWS architectures combine all three.



AWS AI professional Use Case 2: Customer Support Chatbot

Business Problem


Customers ask:


Where is my order?

Refund status?

Cancel order


Some answers require company data.


Architecture

Customer


   API Gateway


      Lambda


 ┌──────────────┐

 │ Order System │

 └──────────────┘


      │


 Amazon Bedrock


      │


Claude / Nova Model


      │


Customer

Flow


User:


Where is my order 123?


Lambda



Order database lookup



Send order details



Prompt Bedrock



Generate response


Services

API Gateway

Lambda

DynamoDB

Bedrock

IAM

CloudWatch

Why Lambda?


LLMs should not directly access databases.


Lambda


validates user

retrieves order

formats prompt

Exam Twist


Which component should retrieve customer order?


Correct answer:


Lambda


NOT


Foundation model



AWS profession - Use Case 1: Enterprise Document Q&A (RAG)

Business Problem


A company has thousands of internal PDFs containing HR policies, legal documents, engineering manuals, and SOPs.


Employees ask:


"How many vacation days can I carry forward?"


The LLM should answer only from company documents.


Architecture

                User

                  │

           API Gateway

                  │

              Lambda

                  │

          Amazon Bedrock

                  │

        Knowledge Base

                  │

        Vector Database

              │

      S3 Document Store

Flow

PDFs uploaded to S3

Bedrock Knowledge Base automatically

parses documents

chunks text

generates embeddings

stores embeddings

User asks question

API Gateway invokes Lambda

Lambda calls Bedrock

Bedrock retrieves relevant chunks

Foundation model generates answer

Answer returned

AWS Services

Service Purpose

S3 Document storage

Bedrock Knowledge Base RAG

Bedrock Foundation Model Answer generation

Lambda Business logic

API Gateway REST endpoint

IAM Permissions

CloudWatch Logs

Why This Architecture?


Advantages


No model training

Hallucination reduced

Documents stay private

Serverless

Easy scaling

Common Exam Question


Why not fine-tune?


Answer:


Because company documents change frequently.


Knowledge Bases update automatically while fine-tuning requires retraining.


Sunday, June 28, 2026

OpenTelemetry Summary

OpenTelemetry (OTel) has become the de facto open standard for collecting telemetry data from modern distributed applications. Instead of relying on vendor-specific SDKs, OpenTelemetry provides a common framework for generating **Traces**, **Metrics**, and **Logs**, allowing organizations to export observability data to a wide variety of backends such as Jaeger, Grafana Tempo, Prometheus, Elastic, Datadog, Splunk, Dynatrace, Honeycomb, AWS X-Ray, Azure Monitor, and many others.


For traditional applications, OpenTelemetry helps developers understand request flows across multiple microservices, identify performance bottlenecks, detect failures, and correlate metrics with logs and traces. As AI applications have evolved into distributed, multi-agent systems, OpenTelemetry has naturally extended to become one of the strongest foundations for **AI Observability**.


Unlike conventional applications, AI workloads involve several additional dimensions that require observability:


* Agent orchestration

* Multiple LLM invocations

* RAG retrieval pipelines

* MCP tool execution

* Prompt engineering

* Token consumption

* AI cost

* Model selection

* User conversations

* AI quality metrics


OpenTelemetry allows all of these to be attached as **trace attributes**, **events**, and **child spans**, giving developers complete end-to-end visibility into an AI request.


---


# What we built


Across the two blog articles, we progressively evolved a simple FastAPI application into a production-inspired AI system instrumented with OpenTelemetry.


We covered:


## Part 1


* Installing OpenTelemetry SDK

* Configuring the OpenTelemetry Collector

* Running Jaeger using Docker Compose

* Creating spans

* Exporting traces

* Viewing traces in Jaeger

* Instrumenting a simple AI endpoint


This established the foundation for distributed tracing.


---


## Part 2


We then enhanced the same application to instrument advanced AI workflows.


### Q2 — Multi-Agent Reasoning Chains


We traced


* Supervisor agent

* Research agent

* Retriever agent

* Tool agent

* Validation agent

* Summarizer agent


while recording


* Agent handoffs

* Workflow execution

* Reasoning events

* Token usage

* Cost

* Execution latency


This allows engineers to understand exactly how an agentic workflow executed.


---


### Q3 — Prompt Explosion Detection


Instead of only measuring token usage, we monitored


* Original prompt size

* Expanded prompt size

* Prompt amplification ratio

* Additional tokens introduced

* Source responsible for prompt growth


This helps identify unnecessary prompt expansion before it causes excessive cost and latency.


---


### Q4 — AI Cost Attribution


We demonstrated cost tracking at multiple levels.


* Per span

* Per conversation

* Per user

* Per tenant

* Total request


This makes it possible to answer questions like


* Which tenant spends the most?

* Which conversation exceeded budget?

* Which agent is most expensive?


---


### Q5 — RAG Retrieval Quality


Rather than treating retrieval as a black box, we monitored


* Retrieved documents

* Retrieved chunks

* Similarity score

* Retrieval latency

* Context utilization

* Retrieval quality


This provides visibility into whether poor LLM responses are caused by retrieval rather than the model itself.


---


### Q6 — MCP Tool Usage


We instrumented every MCP invocation.


For each tool execution we captured


* MCP Server

* Tool Name

* Transport

* Latency

* Retry count

* Status

* Response size

* Request ID


This allows developers to identify unreliable external dependencies in an agentic workflow.


---


# Important AI Observability Principles


Throughout the examples we also introduced several production best practices.


### Attribute useful metadata


Rather than storing only latency, record


* model

* provider

* tokens

* cost

* conversation ID

* tenant

* user

* workflow


---


### Use events for reasoning


Instead of creating unnecessary spans, capture


* reasoning decisions

* handoffs

* retries

* validation

* planning


as events inside spans.


---


### Avoid high-cardinality attributes


Avoid storing


* Full prompts

* Complete documents

* Entire conversations


inside spans.


Instead prefer


* Prompt hash

* Prompt size

* Token count

* Conversation ID


to reduce storage cost.


---


### Aggregate intelligently


Record detailed information at the span level while also aggregating key metrics at the overall trace or conversation level.


Examples include


* Total tokens

* Total cost

* Total latency

* Total tool calls

* Number of agent hops


This provides both fine-grained diagnostics and high-level operational insights.


---


# Why OpenTelemetry is an Excellent Foundation for AI


OpenTelemetry is not an AI observability product—it is an observability framework. That distinction is important because it means you can instrument your AI applications once and send the telemetry to virtually any backend or AI observability platform. As the ecosystem evolves, your instrumentation remains stable while your choice of backend can change.


It also integrates naturally with modern AI frameworks such as:


* LangChain

* LangGraph

* LlamaIndex

* AutoGen

* CrewAI

* Semantic Kernel

* OpenAI Agents SDK

* Amazon Bedrock Agents


This makes it an ideal foundation for enterprise AI systems.


---


# What's Next


OpenTelemetry provides the raw telemetry, but many AI-specific platforms build on top of it to offer higher-level capabilities such as prompt management, evaluations, hallucination analysis, experiment tracking, model comparisons, and dataset management.


The natural next step is to explore how OpenTelemetry integrates with tools such as **Langfuse**, **LangSmith**, **OpenLIT**, **Arize Phoenix**, **MLflow**, **Helicone**, and **Traceloop**, combining standard observability with AI-native analytics for a complete view of modern AI applications.


**One key takeaway:** treat OpenTelemetry as the **observability backbone** of your AI platform. Instrument once, enrich traces with AI-specific metadata, and build increasingly sophisticated monitoring—from simple request tracing to comprehensive visibility into multi-agent reasoning, RAG quality, costs, governance, and production reliability.


Saturday, June 27, 2026

AWS Developer AI Professional Tips

AWS Developer AI Professional Tips

Remember these common patterns:

Security Groups are instance-level, stateful, and allow-only.

Network ACLs are subnet-level, stateless, and support both allow and deny rules.

Use Security Group references instead of IP addresses whenever possible.

RDS should never be opened to 0.0.0.0/0; allow access only from the application Security Group.

AWS evaluates both the NACL and the Security Group—traffic must be permitted by both.

Security Groups are commonly used to secure Lambda ENIs, ECS tasks, EKS worker nodes, and Interface VPC Endpoints used by services like Amazon Bedrock

Tuesday, June 23, 2026

VPC details 1


Withtin AWS we have region, and inside various availability zones, and we can create AWS Account within and within that VPC. VPC can have multiple rules, can it have inbound and outbound internet access, With VPCs, we can connect between VPCs. By default two VPCs are not allowed to talk to each other. We can connect VPCs together with various mechanisms. We can also have multiple VPCs in single AWS Account. These also not allowed to talk to each other unless we do a VPC peering. 


How VPCs work? 


AWS Cloud 

 - Region

- Availability Zone 1

- Availability Zone 2

- Availability Zone 3


When we create VPC, it is mostly created to span across various availability zone 


Within VPC, we can have Public and Private Subnets . We don't necessarily need both of them. Public subnet we can put resource within it to make outbound internet calls. It is also be able to receiving inbound traffic from outside world. We can keep things like EC2 with web portal etc. The Public Subnet communicate with the outside world via the Internet gateway . Traffic coming from outside will also flow through the Internet gateway 


Private Subnets can be used for any resource that need not have the direct access to outside world such as RDS , databases etc. However, we can still have the Private subnet entities to talk to the outside world although inbound traffic is not allowed. 


Two public subnets within VPC can interact each other. Public and private subnets component can take to each other, Multiple private subnets can talk to each other as well.