# AWS S3 Event

> AWS S3 event notification with bucket and object details per record.

- Name: `aws-s3-event`
- Categories: aws
- Detail page: https://open-types.dev/types/aws-s3-event

## Install

```bash
# Types only
npx shadcn add @open-types/aws-s3-event

# Types + Zod v4 validators
npx shadcn add @open-types/aws-s3-event-zod

# Types + real-world examples
npx shadcn add @open-types/aws-s3-event-examples
```

## Types

```typescript
export interface AWSS3Bucket {
  name: string;
  arn: string;
}

export interface AWSS3Object {
  key: string;
  size: number;
  eTag: string;
  sequencer: string;
}

export interface AWSS3Detail {
  bucket: AWSS3Bucket;
  object: AWSS3Object;
}

export interface AWSS3EventRecord {
  eventVersion: string;
  eventSource: string;
  awsRegion: string;
  eventTime: string;
  eventName: string;
  s3: AWSS3Detail;
}

export interface AWSS3Event {
  Records: AWSS3EventRecord[];
}
```

## Zod validator

```typescript
import * as z from "zod";
import type {
  AWSS3Bucket,
  AWSS3Object,
  AWSS3Detail,
  AWSS3EventRecord,
  AWSS3Event,
} from "../types/aws-s3-event";

export const awsS3BucketSchema = z.object({
  name: z.string(),
  arn: z.string(),
}) satisfies z.ZodType<AWSS3Bucket>;

export const awsS3ObjectSchema = z.object({
  key: z.string(),
  size: z.number(),
  eTag: z.string(),
  sequencer: z.string(),
}) satisfies z.ZodType<AWSS3Object>;

export const awsS3DetailSchema = z.object({
  bucket: awsS3BucketSchema,
  object: awsS3ObjectSchema,
}) satisfies z.ZodType<AWSS3Detail>;

export const awsS3EventRecordSchema = z.object({
  eventVersion: z.string(),
  eventSource: z.string(),
  awsRegion: z.string(),
  eventTime: z.string(),
  eventName: z.string(),
  s3: awsS3DetailSchema,
}) satisfies z.ZodType<AWSS3EventRecord>;

export const awsS3EventSchema = z.object({
  Records: z.array(awsS3EventRecordSchema),
}) satisfies z.ZodType<AWSS3Event>;

export type {
  AWSS3Bucket,
  AWSS3Object,
  AWSS3Detail,
  AWSS3EventRecord,
  AWSS3Event,
} from "../types/aws-s3-event";
```

## Examples

```typescript
// Source: https://docs.aws.amazon.com/AmazonS3/latest/userguide/notification-content-structure.html
// Captured: 2026-05
import type {
  AWSS3Bucket,
  AWSS3Object,
  AWSS3Detail,
  AWSS3EventRecord,
  AWSS3Event,
} from "../types/aws-s3-event";

const bucket = {
  name: "photo-uploads-prod",
  arn: "arn:aws:s3:::photo-uploads-prod",
} as const satisfies AWSS3Bucket;

export const awsS3BucketExamples = {
  prod: bucket,
  staging: {
    name: "photo-uploads-staging",
    arn: "arn:aws:s3:::photo-uploads-staging",
  } satisfies AWSS3Bucket,
} as const;

const object = {
  key: "users/42/avatar.png",
  size: 204800,
  eTag: "9b2cf535f27731c974343645a3985328",
  sequencer: "0065B0D8F26D9A5C1F",
} as const satisfies AWSS3Object;

export const awsS3ObjectExamples = {
  smallAvatar: object,
  largeUpload: { ...object, key: "exports/2026-05-16.csv", size: 104857600 } satisfies AWSS3Object,
  emptyObject: { ...object, key: "tombstone.txt", size: 0 } satisfies AWSS3Object,
} as const;

const detail = { bucket, object } as const satisfies AWSS3Detail;

export const awsS3DetailExamples = {
  smallAvatar: detail,
} as const;

const putRecord = {
  eventVersion: "2.1",
  eventSource: "aws:s3",
  awsRegion: "us-east-1",
  eventTime: "2026-04-13T18:31:22.123Z",
  eventName: "ObjectCreated:Put",
  s3: detail,
} as const satisfies AWSS3EventRecord;

export const awsS3EventRecordExamples = {
  put: putRecord,
  delete: {
    ...putRecord,
    eventName: "ObjectRemoved:Delete",
  } satisfies AWSS3EventRecord,
  copy: { ...putRecord, eventName: "ObjectCreated:Copy" } satisfies AWSS3EventRecord,
  multipartComplete: {
    ...putRecord,
    eventName: "ObjectCreated:CompleteMultipartUpload",
  } satisfies AWSS3EventRecord,
} as const;

export const awsS3EventExamples = {
  single: { Records: [putRecord] } satisfies AWSS3Event,
  batch: {
    Records: [putRecord, awsS3EventRecordExamples.delete, awsS3EventRecordExamples.copy],
  } satisfies AWSS3Event,
} as const;
```
