# ResultWriterV2

Configuration for writing Distributed Map state results to S3 The ResultWriter field cannot be empty.

You must specify one of these sets of sub-fields.
  writerConfig - to preview the formatted output, without saving the results to Amazon S3.
  bucket and prefix - to save the results to Amazon S3 without additional formatting.
  All three fields: writerConfig, bucket and prefix - to format the output and save it to Amazon S3.

- Source: [`aws-stepfunctions/lib/states/distributed-map/result-writer.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-stepfunctions/lib/states/distributed-map/result-writer.ts#L225)
- Type last changed: v2.196.0 · 16 May 2025

## Example

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

// create a bucket
const bucket = new s3.Bucket(this, 'Bucket');

// create a WriterConfig

const distributedMap = new sfn.DistributedMap(this, 'Distributed Map State', {
  resultWriterV2: new sfn.ResultWriterV2({
    bucket: bucket,
    prefix: 'my-prefix',
    writerConfig: {
      outputType: sfn.OutputType.JSONL,
      transformation: sfn.Transformation.NONE,
    },
  })
});
distributedMap.itemProcessor(new sfn.Pass(this, 'Pass State'));
```

## Initializer

```ts
new ResultWriterV2(props: ResultWriterV2Props)
```

## Properties

- `bucket`: [IBucket](/cdk/api/v2/docs/aws-cdk-lib.aws_s3.IBucket.html) — S3 Bucket in which to save Map Run results.

- `bucketNamePath`: string — S3 bucket name in which to save Map Run results, as JsonPath.

- `prefix`: string — S3 prefix in which to save Map Run results.

  **Default:** No prefix

- `writerConfig`: [WriterConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.WriterConfig.html) — Configuration to format the output of the Child Workflow executions.

## Methods

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

- `render(queryLanguage?: QueryLanguage): any` — Render ResultWriter in ASL JSON format.

- `validateResultWriter(): string[]` — Validate that ResultWriter contains exactly either.
