Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. Download free →
CLSkills
Cloud (AWS/GCP/Azure)intermediate

DynamoDB CRUD

Share

Create DynamoDB CRUD operations

Works with OpenClaude

You are an AWS DynamoDB developer. The user wants to implement complete CRUD (Create, Read, Update, Delete) operations for a DynamoDB table.

What to check first

  • Run aws dynamodb list-tables to verify your table exists and AWS credentials are configured
  • Confirm your IAM user has dynamodb:* permissions on the target table
  • Check the table's primary key structure with aws dynamodb describe-table --table-name YourTableName

Steps

  1. Install the AWS SDK v3 for JavaScript: npm install @aws-sdk/client-dynamodb @aws-sdk/util-dynamodb
  2. Initialize a DynamoDB client by creating a new DynamoDBClient with your region
  3. Use PutItemCommand to insert a new item into the table with Item parameter containing attribute values
  4. Use GetItemCommand with the Key parameter to retrieve a single item by its primary key
  5. Use UpdateItemCommand with UpdateExpression to modify specific attributes without replacing the entire item
  6. Use DeleteItemCommand with the Key parameter to remove an item from the table
  7. Use ScanCommand or QueryCommand to retrieve multiple items (ScanCommand for full table scans, QueryCommand for key-based queries)
  8. Always wrap operations in try-catch blocks and handle ResourceNotFoundException or ValidationException errors

Code

import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import {
  DynamoDBDocumentClient,
  PutCommand,
  GetCommand,
  UpdateCommand,
  DeleteCommand,
  ScanCommand,
} from "@aws-sdk/lib-dynamodb";

const client = new DynamoDBClient({ region: "us-east-1" });
const docClient = DynamoDBDocumentClient.from(client);

const TABLE_NAME = "Users";

// CREATE - Put a new item
export async function createUser(userId, userData) {
  try {
    const command = new PutCommand({
      TableName: TABLE_NAME,
      Item: {
        userId: userId,
        ...userData,
        createdAt: new Date().toISOString(),
      },
    });
    const response = await docClient.send(command);
    return { success: true, data: userData };
  } catch (error) {
    console.error("Error creating user:", error);
    throw error;
  }
}

// READ - Get a single item by key
export async function getUser(userId) {
  try {
    const command = new GetCommand({
      TableName: TABLE_NAME,
      Key: { userId: userId },
    });
    const response = await docClient.send(command);
    return response.Item || null;
  } catch (error) {
    console.error("Error getting user:", error);
    throw error;
  }
}

// UPDATE - Modify existing item attributes
export

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

Difficultyintermediate
Version1.0.0
AuthorClaude Skills Hub
cloudawsdynamodb

Install command:

curl -o ~/.claude/skills/dynamodb-crud.md https://claude-skills-hub.vercel.app/skills/cloud/dynamodb-crud.md

Related Cloud (AWS/GCP/Azure) Skills

Other Claude Code skills in the same category — free to download.

Want a Cloud (AWS/GCP/Azure) skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.