# ImportSource

The data to be imported to the key value store.

Extends: ImportSource
Superclass of: AssetImportSource, InlineImportSource, S3ImportSource

- Source: [`aws-cloudfront/lib/key-value-store.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-cloudfront/lib/key-value-store.ts#L18)
- Type last changed: v2.137.0 · 11 Apr 2024

## Example

```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",
      },
    ],
  })),
});
```

## Initializer

```ts
new ImportSource()
```

## Methods

- `fromAsset(path: string, options?: AssetOptions): ImportSource // chainable` (static) — An import source that exists as a local file.

  **Parameters**

  - `path` — the path to the local file.
  - `options` — the configuration for the temporarily created S3 file.

- `fromBucket(bucket: IBucket, key: string): ImportSource // chainable` (static) — An import source that exists as an object in an S3 bucket.

  **Parameters**

  - `bucket` — the S3 bucket that contains the data.
  - `key` — the key within the S3 bucket that contains the data.

- `fromInline(data: string): ImportSource // chainable` (static) — An import source that uses an inline string.

  **Parameters**

  - `data` — the contents of the KeyValueStore.
