# KeyValueStoreProps

The properties to create a Key Value Store.

Used as props by: [KeyValueStore](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront.KeyValueStore.html)

- Source: [`aws-cloudfront/lib/key-value-store.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/aws-cloudfront/lib/key-value-store.ts#L170)
- Type last changed: v2.118.0 · 3 Jan 2024

## Example

TypeScript:

```ts
const storeAsset = new cloudfront.KeyValueStore(this, 'KeyValueStoreAsset', {
  keyValueStoreName: 'KeyValueStoreAsset',
  source: cloudfront.ImportSource.fromAsset('path-to-data.json'),
});

const storeInline = new cloudfront.KeyValueStore(this, 'KeyValueStoreInline', {
  keyValueStoreName: 'KeyValueStoreInline',
  source: cloudfront.ImportSource.fromInline(JSON.stringify({
    data: [
      {
        key: "key1",
        value: "value1",
      },
      {
        key: "key2",
        value: "value2",
      },
    ],
  })),
});
```

Python:

```python
store_asset = cloudfront.KeyValueStore(self, "KeyValueStoreAsset",
    key_value_store_name="KeyValueStoreAsset",
    source=cloudfront.ImportSource.from_asset("path-to-data.json")
)

store_inline = cloudfront.KeyValueStore(self, "KeyValueStoreInline",
    key_value_store_name="KeyValueStoreInline",
    source=cloudfront.ImportSource.from_inline(JSON.stringify({
        "data": [{
            "key": "key1",
            "value": "value1"
        }, {
            "key": "key2",
            "value": "value2"
        }
        ]
    }))
)
```

Java:

```java
KeyValueStore storeAsset = KeyValueStore.Builder.create(this, "KeyValueStoreAsset")
        .keyValueStoreName("KeyValueStoreAsset")
        .source(ImportSource.fromAsset("path-to-data.json"))
        .build();

KeyValueStore storeInline = KeyValueStore.Builder.create(this, "KeyValueStoreInline")
        .keyValueStoreName("KeyValueStoreInline")
        .source(ImportSource.fromInline(JSON.stringify(Map.of(
                "data", List.of(Map.of(
                        "key", "key1",
                        "value", "value1"), Map.of(
                        "key", "key2",
                        "value", "value2"))))))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var storeAsset = new KeyValueStore(this, "KeyValueStoreAsset", new KeyValueStoreProps {
    KeyValueStoreName = "KeyValueStoreAsset",
    Source = ImportSource.FromAsset("path-to-data.json")
});

var storeInline = new KeyValueStore(this, "KeyValueStoreInline", new KeyValueStoreProps {
    KeyValueStoreName = "KeyValueStoreInline",
    Source = ImportSource.FromInline(JSON.Stringify(new Dictionary<string, IDictionary<string, string>[]> {
        { "data", new [] { new Struct {
            Key = "key1",
            Value = "value1"
        }, new Struct {
            Key = "key2",
            Value = "value2"
        } } }
    }))
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
storeAsset := cloudfront.NewKeyValueStore(this, jsii.String("KeyValueStoreAsset"), &KeyValueStoreProps{
	KeyValueStoreName: jsii.String("KeyValueStoreAsset"),
	Source: cloudfront.ImportSource_FromAsset(jsii.String("path-to-data.json")),
})

storeInline := cloudfront.NewKeyValueStore(this, jsii.String("KeyValueStoreInline"), &KeyValueStoreProps{
	KeyValueStoreName: jsii.String("KeyValueStoreInline"),
	Source: cloudfront.ImportSource_FromInline(jSON.stringify(map[string][]map[string]*string{
		"data": []map[string]*string{
			map[string]*string{
				"key": jsii.String("key1"),
				"value": jsii.String("value1"),
			},
			map[string]*string{
				"key": jsii.String("key2"),
				"value": jsii.String("value2"),
			},
		},
	})),
})
```

## Properties

- `comment`: string — A comment for the Key Value Store.

  **Default:** No comment will be specified

- `keyValueStoreName`: string — The unique name of the Key Value Store.

  **Default:** A generated name

- `source`: [ImportSource](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront.ImportSource.html) — The import source for the Key Value Store.

  **Default:** No data will be imported to the store

  This will populate the initial items in the Key Value Store. The
  source data must be in a valid JSON format.
