Skip to content
v2.277.0

ImportSource Class ​

The data to be imported to the key value store.

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

Initializer ​

ts
new ImportSource()
python
ImportSource()
java
new ImportSource()
csharp
new ImportSource()
go
NewImportSource()

Methods ​

fromAsset(path: string, options?: AssetOptions): ImportSource // chainable@staticmethod def from_asset(path: str, options: typing.Optional[AssetOptions] = None) -> ImportSourcepublic static ImportSource fromAsset(String path, AssetOptions options)public static ImportSource FromAsset(string path, AssetOptions? options = null)func FromAsset(Path *string, Options AssetOptions) ImportSource static #
An import source that exists as a local file.
2 parameters

Parameters

  • pathpathpathpathPath — the path to the local file.
  • optionsoptionsoptionsoptionsOptions — the configuration for the temporarily created S3 file.
fromBucket(bucket: IBucket, key: string): ImportSource // chainable@staticmethod def from_bucket(bucket: IBucket, key: str) -> ImportSourcepublic static ImportSource fromBucket(IBucket bucket, String key)public static ImportSource FromBucket(IBucket bucket, string key)func FromBucket(Bucket IBucket, Key *string) ImportSource static #
An import source that exists as an object in an S3 bucket.
2 parameters

Parameters

  • bucketbucketbucketbucketBucket — the S3 bucket that contains the data.
  • keykeykeykeyKey — the key within the S3 bucket that contains the data.
fromInline(data: string): ImportSource // chainable@staticmethod def from_inline(data: str) -> ImportSourcepublic static ImportSource fromInline(String data)public static ImportSource FromInline(string data)func FromInline(Data *string) ImportSource static #
An import source that uses an inline string.
1 parameter

Parameters

  • datadatadatadataData — the contents of the KeyValueStore.