Unit 1: Development with AWS Services – Study Guide
Unit 1: Development with AWS Services
Unit 1: Development with AWS Services – Study Guide
This guide covers the core competencies required for developing applications on AWS, specifically focusing on serverless compute (Lambda), event-driven architectures, and cloud-native data stores as defined in the DVA-C02 exam domain.
Learning Objectives
After studying this unit, you should be able to:
- Design and implement event-driven patterns using Amazon EventBridge and AWS Lambda.
- Write resilient code for third-party integrations using retries, exponential backoff, and circuit breakers.
- Configure Lambda functions for performance, including VPC access, environment variables, and memory tuning.
- Optimize data access in Amazon DynamoDB using efficient partitioning, indexing, and query vs. scan operations.
- Integrate AWS SDKs into application code to interact with cloud services programmatically.
Key Terms & Glossary
- Idempotency: The property where an operation can be performed multiple times without changing the result beyond the initial application (critical for Lambda retries).
- Event-Driven Architecture: A software architecture pattern where the flow of the program is determined by events (e.g., a file upload to S3).
- Statelessness: A design principle where each request contains all the information necessary to process it, and no session data is stored on the server.
- Loose Coupling: An approach to interconnecting components in a system so that those components depend on each other to the least extent possible.
- Cold Start: The latency experienced when a Lambda function is triggered for the first time or after a period of inactivity while AWS initializes the execution environment.
The "Big Idea"
The central theme of AWS development is the transition from monolithic, synchronous systems to distributed, asynchronous, and serverless architectures. By decoupling components through messaging services (SQS, SNS) and event buses (EventBridge), developers create systems that are more fault-tolerant, easier to scale, and more cost-effective. In this paradigm, the developer's focus shifts from managing servers to writing business logic that reacts to state changes across the cloud environment.
Formula / Concept Box
| Concept | Key Constraints / Rules |
|---|---|
| Lambda Timeout | Maximum execution time is 15 minutes (900 seconds). |
| Lambda Memory | Ranges from 128 MB to 10,240 MB (10 GB); CPU scales linearly with memory. |
| DynamoDB Key | Primary Key = Partition Key (required) + Sort Key (optional). |
| Retry Logic | Always use Exponential Backoff with Jitter to prevent "thundering herd" issues. |
| Consistency | DynamoDB defaults to Eventually Consistent; Strongly Consistent must be requested. |
Hierarchical Outline
- I. Developing for AWS Hosted Applications
- Architectural Patterns: Monolithic vs. Microservices; Choreography (decentralized) vs. Orchestration (centralized via Step Functions).
- Communication: Synchronous (API Gateway) vs. Asynchronous (S3 triggers, EventBridge).
- Resiliency: Implementing Circuit Breakers to stop requests to failing downstream services.
- II. AWS Lambda Development
- Configuration: Environment variables for secrets/settings; Layers for shared libraries.
- VPC Access: Requires private subnets, NAT Gateways, and specific IAM permissions to access RDS or ElastiCache.
- Lifecycle: Handling events and utilizing Lambda Destinations for success/failure routing.
- III. Data Store Management
- DynamoDB: Choosing high-cardinality partition keys to avoid "Hot Partitions."
- Optimization: Preferring Query (efficient, targets specific keys) over Scan (expensive, reads entire table).
- S3: Using object storage for unstructured data and static website hosting.
Visual Anchors
Serverless Event Flow
This diagram illustrates a common serverless pattern: an image upload triggers a processing chain.
Synchronous vs. Asynchronous Patterns
The following TikZ diagram visualizes the difference in blocking behavior between sync and async calls.
\begin{tikzpicture}[node distance=2cm, auto] \node (client) {Client}; \node (sync_srv) [right of=client, xshift=2cm] {Sync Service}; \node (async_srv) [below of=sync_srv] {Async Service};
% Sync arrows
\draw[->, thick] (client.east) -- (sync_srv.west) node[midway, above] {Request (Wait)};
\draw[<-, thick] (client.east) ++(0,-0.2) -- (sync_srv.west) ++(0,-0.2) node[midway, below] {Response};
% Async arrows
\draw[->, thick] (client.south) |- (async_srv.west) node[near end, above] {Trigger (Immediate ACK)};
\draw[dashed, ->] (async_srv.south) -- ++(0,-0.5) node[below] {Process Later};\end{tikzpicture}
Definition-Example Pairs
- Tightly Coupled: Components are highly dependent on each other. If one fails, the other fails.
- Example: A web server that directly calls a local database service over a fixed IP address.
- Loosely Coupled: Components interact through well-defined interfaces/buffers.
- Example: A frontend sending messages to an Amazon SQS queue that a backend worker polls at its own pace.
- Fan-out Pattern: Delivering a single message to multiple subscribers simultaneously.
- Example: An SNS Topic that sends a "New Order" message to an Email service, a Shipping service, and an Analytics service at once.
Worked Examples
Example 1: Resilient Retry Logic
Problem: A Lambda function calling a 3rd-party API intermittently receives 429 Too Many Requests errors.
Solution: Implement exponential backoff.
- Initial Attempt: Call API.
- Failure (429): Sleep for seconds.
- Retry 1: Call API.
- Failure (429): Sleep for seconds.
- Success: Process response.
Example 2: DynamoDB Query Efficiency
Scenario: A table tracks Orders with UserID (Partition Key) and OrderDate (Sort Key).
- Bad Practice: Using
Scanwith a FilterExpression to find orders for User A. (This reads every item in the table first). - Best Practice: Using
QuerywhereKeyConditionExpressionisUserID = :u. (This only reads items for that specific user).
Checkpoint Questions
- What is the maximum execution duration for an AWS Lambda function?
- Why is a high-cardinality partition key important in Amazon DynamoDB?
- Which AWS service is best suited for implementing a "Choreography" pattern in an event-driven architecture?
- What is the difference between a
Scanand aQueryoperation in DynamoDB in terms of cost and performance? - How do you allow a Lambda function to access a database sitting in a private VPC subnet?
▶Click to see answers
- 15 Minutes.
- It prevents "Hot Partitions" by distributing data and requests evenly across physical storage.
- Amazon EventBridge (or SNS).
- Query is faster and cheaper as it searches based on keys; Scan reads every item in the table, consuming more RCU.
- Assign the Lambda to the VPC, provide private subnets, and ensure the Execution Role has the
AWSLambdaVPCAccessExecutionRolepolicy.