All exams← All AWS Developer Associate (DVA-C02) notes

Development with AWS services & SDKs: AWS Developer Associate (DVA-C02) revision notes

Revision notes

Which SDK/tool for which job

AWS gives you several ways to talk to services: the AWS SDKs (Boto3 for Python, SDK for JavaScript, Java, .NET etc), the AWS CLI, and the AWS CloudShell. For DVA-C02 you need to know how the SDKs authenticate, retry, and handle errors - not just how to call an API.

Credential chain (default provider chain)

SDKs look for credentials in this order: environment variables, then the shared credentials/config file (~/.aws/credentials), then container credentials (ECS task role), then the EC2 instance metadata service (IMDS) for an instance profile role. Always prefer IAM roles over hard-coded access keys - never bake secrets into code or AMIs.

Retries and exponential backoff

AWS SDKs retry throttled or failed requests automatically using exponential backoff with jitter. This spreads out retries so many clients do not all hammer the service at the same instant. You can tune max retry attempts and backoff strategy in the SDK config (for example retryMode 'standard' or 'adaptive' in newer SDKs). Adaptive mode also throttles the client side send rate when it detects the service is struggling.

Idempotency

Many write APIs (like EC2 RunInstances or SQS SendMessage with a deduplication ID) accept a client token so a retried request does not create duplicate resources. Always pass an idempotency token for any operation you might retry.

Waiters and paginators

Waiters poll an API until a resource reaches a desired state (e.g. waiting for an EC2 instance to reach 'running'), saving you from writing your own polling loops. Paginators automatically handle APIs that return results in pages (using NextToken/Marker), looping through all pages for you.

X-Ray for tracing

The X-Ray SDK instruments your code to trace requests across microservices, showing latency and errors per segment/subsegment. Install the X-Ray daemon (or use the CloudWatch agent) to forward trace data; on Lambda, just enable Active Tracing - no daemon needed.

Exceptions and error handling

SDK calls throw service-specific exceptions (e.g. ThrottlingException, ProvisionedThroughputExceededException for DynamoDB). Catch these and apply backoff rather than failing immediately. HTTP 400s are client errors (fix the request), 500s are server errors (safe to retry).

Common exam traps

  • Do not hard-code AWS access keys in application code - use IAM roles.
  • The default retry behaviour is already exponential backoff with jitter - you rarely need to write your own.
  • IMDSv2 requires a session token via a PUT request first, then a GET with that token header - this closes off SSRF vulnerabilities that affected IMDSv1.
  • CLI and SDKs share the same underlying credential chain and config files.

Key facts

Flashcards

What is the order of the default AWS credential provider chain?
Environment variables, then shared credentials/config file, then container role (ECS), then EC2 instance metadata (IMDS) role
tap to reveal
What retry strategy do AWS SDKs use by default?
Exponential backoff with jitter, to avoid many clients retrying at exactly the same moment
tap to reveal
What problem does IMDSv2 fix compared to IMDSv1?
It requires a PUT request for a session token before any GET, closing off SSRF-based credential theft
tap to reveal
What is an idempotency/client token used for?
Ensures a retried write API call does not create a duplicate resource
tap to reveal
What does a Waiter do in an AWS SDK?
Polls an API automatically until a resource reaches a desired state, e.g. waiting for an EC2 instance to be running
tap to reveal
What does a Paginator do?
Automatically loops through all pages of a multi-page API response using NextToken or Marker
tap to reveal
What are the three SDK retry modes?
Legacy, standard, and adaptive - adaptive also throttles the client send rate based on service health
tap to reveal
How do you enable X-Ray tracing on a Lambda function?
Turn on Active Tracing in the function configuration - no X-Ray daemon needed on Lambda
tap to reveal
Why should you avoid hard-coding AWS access keys in code?
It is a security risk - use IAM roles (instance profile, task role, or Lambda execution role) instead
tap to reveal
What does a ThrottlingException from DynamoDB mean and how should your code respond?
The request rate exceeded capacity; the SDK should retry with exponential backoff rather than failing immediately
tap to reveal
What is the difference between a 4xx and 5xx error from an AWS API?
4xx is a client-side error (fix your request); 5xx is a server-side error and generally safe to retry
tap to reveal
Do the AWS CLI and AWS SDKs use separate credential systems?
No - they share the same default credential provider chain and configuration files
tap to reveal
What AWS component do you install to forward X-Ray trace data from EC2/on-premises?
The X-Ray daemon (or the CloudWatch agent), which forwards segments to the X-Ray service
tap to reveal
Practice questions

Development with AWS services & SDKs: 5 practice questions

Q1. A developer building a Lambda function in Python wants to reuse an expensive DynamoDB client connection across invocations to reduce latency on warm starts. Where should the client be instantiated?
  • A.  In a separate Lambda layer with no code reference
  • B.  Inside the handler function so a new client is created on every invocation
  • C.  Inside a try/except block within the handler
  • D.  Outside the handler function, at global/module scope
Show answer & explanation
✓ Answer: D. Outside the handler function, at global/module scope
Code outside the handler runs once per execution environment and persists across warm invocations. Initializing SDK clients at module scope lets subsequent invocations in the same execution environment reuse the client, avoiding the overhead of re-creating it each time.
Q2. A developer configures the AWS SDK for Java with a custom RetryPolicy that increases the maximum retry attempts from the default. Which class of errors will most benefit from this change?
  • A.  AccessDenied errors caused by an incorrect IAM policy
  • B.  Malformed request syntax errors
  • C.  Transient network errors and throttling exceptions
  • D.  Errors caused by referencing a nonexistent S3 bucket
Show answer & explanation
✓ Answer: C. Transient network errors and throttling exceptions
Increasing retry attempts helps with transient issues like network timeouts and throttling, where a subsequent attempt is likely to succeed. Permission errors, malformed requests, and missing resources are deterministic failures that will not be resolved by retrying.
Q3. A developer wants CloudFormation to pass the ARN of a newly created SNS topic to a Lambda function's environment variables within the same template. Which intrinsic function should be used?
  • A.  Fn::Base64
  • B.  Ref, since for an SNS topic resource Ref returns the topic ARN directly
  • C.  Fn::Cidr
  • D.  Fn::ImportValue
Show answer & explanation
✓ Answer: B. Ref, since for an SNS topic resource Ref returns the topic ARN directly
Within the same CloudFormation template, Ref returns a resource's primary identifier. For an AWS::SNS::Topic resource specifically, Ref actually returns the topic ARN, which can be passed directly into a Lambda environment variable without needing Fn::GetAtt.
Q4. Which AWS SDK construct polls a resource until it reaches a desired state, such as waiting for an EC2 instance to reach the running state?
  • A.  Paginator
  • B.  Transformer
  • C.  Signer
  • D.  Waiter
Show answer & explanation
✓ Answer: D. Waiter
Waiters are SDK abstractions that repeatedly poll a resource's status using an underlying describe API until a specified state is reached or a timeout occurs, removing the need for developers to write manual polling loops.
Q5. A developer is troubleshooting slow response times in a microservices application composed of Lambda functions, API Gateway, and DynamoDB. Which AWS service and SDK integration provides a service map showing latency at each hop of a request?
  • A.  Amazon CloudWatch Logs Insights
  • B.  AWS X-Ray with the X-Ray SDK instrumenting each service call
  • C.  Amazon CloudWatch Synthetics
  • D.  AWS Config
Show answer & explanation
✓ Answer: B. AWS X-Ray with the X-Ray SDK instrumenting each service call
AWS X-Ray traces requests as they travel through distributed application components and, when the X-Ray SDK instruments outgoing calls (such as to DynamoDB or downstream Lambda functions), it produces a service map with per-segment latency and error data.
Test yourself
See the AWS Developer Associate (DVA-C02) page

More AWS Developer Associate (DVA-C02) topics