# S3JsonItemReader

Item Reader configuration for iterating over items in a JSON array stored in a S3 file.

Extends: S3JsonItemReader
Implements: IItemReader

- Source: [`aws-stepfunctions/lib/states/distributed-map/item-reader.ts`](https://github.com/aws/aws-cdk/blob/v2.273.0/packages/aws-cdk-lib/aws-stepfunctions/lib/states/distributed-map/item-reader.ts#L327)
- Type last changed: v2.180.0 · 21 Feb 2025

## Example

```ts
import * as s3 from 'aws-cdk-lib/aws-s3';

/**
 * Tree view of bucket:
 *  my-bucket
 *  |
 *  +--input.json
 *  |
 *  ...
 *
 * File content of input.json:
 *  [
 *    "item1",
 *    "item2"
 *  ]
 */
const bucket = new s3.Bucket(this, 'Bucket', {
  bucketName: 'my-bucket',
});

const distributedMap = new sfn.DistributedMap(this, 'DistributedMap', {
  itemReader: new sfn.S3JsonItemReader({
    bucket,
    key: 'input.json',
  }),
});
distributedMap.itemProcessor(new sfn.Pass(this, 'Pass'));
```

## Initializer

```ts
new S3JsonItemReader(props: S3FileItemReaderProps)
```

## Properties

- `bucket`: [IBucket](/cdk/api/v2/docs/aws-cdk-lib.aws_s3.IBucket.html) (required) — S3 Bucket containing a file with a list to iterate over.

- `bucketNamePath`: string — S3 bucket name containing objects to iterate over or a file with a list to iterate over, as JsonPath.

- `key`: string (required) — S3 key of a file with a list to iterate over.

- `maxItems`: number = No maxItems — Limits the number of items passed to the Distributed Map state.

- `resource`: string (required) — ARN for the `getObject` method of the S3 API This API method is used to iterate all objects in the S3 bucket/prefix.

## Methods

- `providePolicyStatements(): PolicyStatement[]` — Compile policy statements to provide relevent permissions to the state machine.

- `render(queryLanguage?: QueryLanguage): any` — Renders the ItemReader configuration as JSON object.

  **Returns:** - JSON object

- `validateItemReader(): string[]` — Validate that ItemReader contains exactly either.
