Deploy a Serverless API¶
In this lab you will use your AI coding agent to build and deploy a complete serverless REST API with CRUD operations. The agent will discover and use deployment skills to create a Lambda function, API Gateway REST API, and DynamoDB table — following AWS best practices automatically.
Overview¶
Rather than manually writing CloudFormation templates or clicking through the console, you will give your agent a high-level goal and let it determine the best approach. With skills available through the MCP Server, your agent can follow proven deployment patterns that include proper IAM configuration, error handling, and resource naming.
What You'll Learn¶
- How to prompt your agent to build multi-service AWS architectures
- How skills guide the agent toward production-ready configurations
- How the agent creates Lambda functions, API Gateway APIs, and DynamoDB tables through the MCP Server
Instructions¶
Explore¶
Tell your agent to build a serverless REST API with CRUD operations for a tasks table. Observe how it discovers and applies deployment skills to create properly configured resources.
Desired outcome: A working REST API backed by Lambda and DynamoDB, with proper IAM roles and error handling, deployed in your account.
Hints:
- Give your agent a clear, high-level goal — don't over-specify implementation details
- Watch how the agent discovers deployment skills and applies best practices for resource naming, IAM least-privilege, and error handling
- The resources should be named with a
serverless-prefix so the validation dashboard can detect them
Step-by-Step Walkthrough
-
Open your AI coding agent's chat interface
-
Enter the following prompt:
Build me a serverless REST API with CRUD operations for a tasks table following AWS best practices. Name the resources with a "serverless-" prefix (e.g., serverless-api-tasks for the Lambda, serverless-tasks for the DynamoDB table). Deploy everything in us-east-1.
- Your agent should discover a relevant deployment skill and begin creating resources. Watch for it to:
- Create a DynamoDB table with appropriate key schema
- Create a Lambda function with CRUD handler code
- Set up an API Gateway REST API with routes for each operation
-
Configure IAM roles with least-privilege permissions
-
As the agent works, observe the skill-guided decisions:
- IAM: The role should grant only the specific DynamoDB actions needed (GetItem, PutItem, UpdateItem, DeleteItem, Scan) scoped to the specific table ARN
- Error handling: The Lambda code should include try/catch blocks and return appropriate HTTP status codes
-
Resource naming: Resources should follow the
serverless-prefix convention -
Once deployment completes, test the API by asking your agent:
Test the serverless API by creating a task, then retrieving it. Show me the API Gateway endpoint URL and the responses.
- Verify the API works end-to-end:
- A POST request creates an item in DynamoDB
- A GET request retrieves it
- The Lambda logs show successful execution in CloudWatch
Validation¶
Your progress is tracked on the CloudWatch dashboard. Module 2 completion requires:
- ✅ A Lambda function exists matching
serverless-api-* - ✅ At least one API Gateway REST API exists
- ✅ A DynamoDB table exists matching
serverless-*
To run validation manually, ask your agent:
Check if a Lambda function named "serverless-api-" exists, if there's an API Gateway REST API, and if a DynamoDB table named "serverless-" exists. Tell me the status of each.
Agent-Specific Tips¶
Claude Code will automatically discover deployment skills when you ask it to build AWS infrastructure. It can create resources directly through MCP Server API calls.
For a more iterative approach, you can break the task into steps:
First, create the DynamoDB table. Then create the Lambda function. Finally, set up API Gateway.
Claude Code maintains context across the conversation, so it will wire the resources together correctly.
Kiro can leverage specs and hooks to provide additional structure around deployments. After the agent builds the serverless API, you could create a spec to capture the architecture for future reference.
For auto-validation, Kiro hooks can be configured to run the Module 2 validation script whenever you deploy new resources — giving you immediate feedback on completion status.
Cursor will discover and use deployment skills through the MCP Server connection when you ask it to build AWS resources. The agent handles the full deployment workflow conversationally.
If you prefer working with files, you can ask Cursor to generate a CloudFormation template first, review it, and then deploy:
Generate a CloudFormation template for this serverless API, then deploy it.
Codex discovers deployment skills at runtime through the MCP Server. Ask it to build the serverless API and it will create the necessary resources.
:::alert{type="info"} Codex may handle multi-step deployments in a single pass. If you want to review resources before creation, ask it to describe its plan first, then confirm deployment.
:::