# ListToMapProperty

Struct · External

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](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CloudWatch-Logs-Transformation.html#CloudWatch-Logs-Transformation-listToMap) in the *CloudWatch Logs User Guide* .

- Source: Generated at build time
- Type last changed: v2.174.0 · 4 Jan 2025

## Example

TypeScript:

```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.CfnTransformer.ListToMapProperty = {
  key: 'key',
  source: 'source',

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

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_logs as logs

list_to_map_property = logs.CfnTransformer.ListToMapProperty(
    key="key",
    source="source",

    # the properties below are optional
    flatten=False,
    flattened_element="flattenedElement",
    target="target",
    value_key="valueKey"
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.logs.*;

ListToMapProperty listToMapProperty = ListToMapProperty.builder()
        .key("key")
        .source("source")

        // the properties below are optional
        .flatten(false)
        .flattenedElement("flattenedElement")
        .target("target")
        .valueKey("valueKey")
        .build();
```

C#:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Logs;

var listToMapProperty = new ListToMapProperty {
    Key = "key",
    Source = "source",

    // the properties below are optional
    Flatten = false,
    FlattenedElement = "flattenedElement",
    Target = "target",
    ValueKey = "valueKey"
};
```

Go:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

listToMapProperty := &ListToMapProperty{
	Key: jsii.String("key"),
	Source: jsii.String("source"),

	// the properties below are optional
	Flatten: jsii.Boolean(false),
	FlattenedElement: jsii.String("flattenedElement"),
	Target: jsii.String("target"),
	ValueKey: jsii.String("valueKey"),
}
```

## Properties

- `flatten`: boolean | [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) — A Boolean value to indicate whether the list will be flattened into single items.

  Specify `true` to flatten the list. The default is `false`

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

  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.

- `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.

  Otherwise, original objects in the source list will be put into the values of the generated map.
