# AWS Patterns

Lambda best practices, S3 event patterns, SQS/SNS fanout, and DynamoDB access patterns...

- Repository: https://github.com/vibeeval/vibecosystem (541 stars)
- Category: DevOps
- License: MIT
- Last updated: 2026-08-08
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add vibeeval/vibecosystem --skill aws-patterns -g -a claude-code -y`
Codex: `npx skills add vibeeval/vibecosystem --skill aws-patterns -g -a codex -y`
Cursor: `npx skills add vibeeval/vibecosystem --skill aws-patterns -g -a cursor -y`
Gemini CLI: `npx skills add vibeeval/vibecosystem --skill aws-patterns -g -a gemini-cli -y`

## Description

Lambda best practices, S3 event patterns, SQS/SNS fanout, and DynamoDB access patterns for serverless AWS architectures.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# AWS Patterns

Serverless and managed service patterns for AWS production workloads.

## Lambda Best Practices

```typescript
// Cold start optimization: keep handler thin, initialize outside handler
import { DynamoDBClient } from '@aws-sdk/client-dynamodb'
import { DynamoDBDocumentClient, GetCommand } from '@aws-sdk/lib-dynamodb'

// Initialized ONCE per container (reused across invocations)
const client = DynamoDBDocumentClient.from(new DynamoDBClient({}))

export const handler = async (event: APIGatewayProxyEvent) => {
  try {
    const userId = event.pathParameters?.id
    if (!userId) {
      return { statusCode: 400, body: JSON.stringify({ error: 'Missing user ID' }) }
    }

    const result = await client.send(new GetCommand({
      TableName: process.env.USERS_TABLE!,
      Key: { pk: `USER#${userId}`, sk: `PROFILE` }
    }))

    if (!result.Item) {
      return { statusCode: 404, body: JSON.stringify({ error: 'User not found' }) }
    }

    return {
      statusCode: 200,
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify(result.Item)
    }
  } catch (err) {
    console.error('Handler error:', err)
    return { statusCode: 500, body: JSON.stringify({ error: 'Internal server error' }) }
  }
}
```

## S3 Event Processing

```typescript
// S3 → Lambda: process uploaded files
import { S3Client, GetObjectCommand } from '@aws-sdk/client-s3'

const s3 = new S3Client({})

export const handler = async (event: S3Event) => {
  for (const record of event.Records) {
    const bucket = record.s3.bucket.name
    const key = decodeURIComponent(record.s3.object.key.replace(/\+/g, ' '))
    const size = record.s3.object.size

    // Guard: skip non-image files or oversized uploads
    if (size > 10_000_000) {
      console.warn(`Skipping oversized file: ${key} (${size} bytes)`)
      continue
    }

The rest: https://github.com/vibeeval/vibecosystem/blob/HEAD/skills/aws-patterns/SKILL.md
