# ListToMapProperty

This processor takes a list of objects that contain key fields, and converts them into a map of target keys.

For more information about this processor including examples, see listToMap in the CloudWatch Logs User Guide.

- Source: [`aws-logs/lib/transformer.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-logs/lib/transformer.ts#L403)
- Type last changed: v2.207.0 · 24 Jul 2025

## Example

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_logs as logs } from 'aws-cdk-lib';
const listToMapProperty: logs.ListToMapProperty = {
  key: 'key',
  source: 'source',

  // the properties below are optional
  flatten: false,
  flattenedElement: 'flattenedElement',
  target: 'target',
  valueKey: 'valueKey',
};
```

## Properties

- `flatten`: boolean = false — A Boolean value to indicate whether the list will be flattened into single items.

- `flattenedElement`: string — If you set flatten to true, use flattenedElement to specify which element, first or last, to keep.

  **Default:** Must be specified if flatten is true and if flatten is false, has no effect

  You must specify this parameter if flatten is true.

- `key`: string (required) — The key of the field to be extracted as keys in the generated map.

- `source`: string (required) — The key in the log event that has a list of objects that will be converted to a map.

- `target`: string — The key of the field that will hold the generated map.

  **Default:** Stored at the root of the log event

- `valueKey`: string — If this is specified, the values that you specify in this parameter will be extracted from the source objects and put into the values of the generated map.

  **Default:** Original objects in the source list will be put into the values of the generated map
