Create a key value store
You can create a key value store and its key-value pairs at the same time. You can
also create an empty key value store now and then add the key-value pairs later.
If you specify your data source from an Amazon S3 bucket, you must have the
s3:GetObject
and s3:GetBucketLocation
permissions
to that bucket. If you don't have these permissions, CloudFront can't successfully
create your key value store.
Prerequisites
Decide if you want to add key-value pairs at the same time when you create the
key value store. You can import your key-value pairs by using the CloudFront console,
CloudFront API, and AWS SDKs. However, you can only import your file of key-value
pairs when you initially create the key value store.
If you want to create a file of key-value pairs first, see File format for key-value
pairs.
- Console
-
To create a key value store
-
Sign in to the AWS Management Console and open the
Functions page in the CloudFront console at
https://console.aws.amazon.com/cloudfront/v4/home#/functions.
-
Choose the KeyValueStores tab, and then
choose Create KeyValueStore.
-
Enter a name and optional description for the key value store.
-
Complete S3 URI:
-
If you have a file of key-value pairs, enter the path
to the Amazon S3 bucket where you stored the file.
-
Leave this field blank if you plan to enter the
key-value pairs manually.
-
Choose Create. The key value store now
exists.
The details page for the new key value store appears. The
information on the page includes the ID and the ARN of the key
value store.
-
Look at the Key value pairs section. If
you imported a file, this section shows some key-value pairs.
You can do the following:
-
If you imported a file, you can also add more values
manually.
-
If you didn't import a file from an Amazon S3 bucket, and
if you want to add key-value pairs now, you can complete
the next step.
-
You can skip this step and add the key-value pairs
later.
-
To add the pairs now:
-
Choose Add key-value pairs.
-
Choose Add pair and enter a name
and value. Repeat this step to add more pairs.
-
When you're finished, choose Save
changes to save all the key-value pairs
in the key value store. On the dialog box that appears,
choose Done.
-
To associate the key value store with a function now, complete
the Associated functions section. For more
information, see Create functions or Update functions.
You can also associate the function later, either from this
key value store details page, or from the function's details
page.
- Programmatically
-
To create a key value store
-
Use the CloudFront
CreateKeyValueStore. The operation
takes several parameters:
-
A name.
-
A configuration
parameter that includes a
comment.
-
An import-source
parameter that lets you
import key-value pairs from a file that is stored in an
Amazon S3 bucket. Note that you can import from a file only
on initial creation of the key value stores. For
information about the format of the file, see File format for key-value
pairs.
The operation response includes the following information:
-
The values passed in the request, including the name that you
assigned.
-
Data such as the creation time.
-
An ETag (for example, ETVABCEXAMPLE2), the ARN that includes
the name of the key value stores (for example,
arn:aws:cloudfront::111122223333:key-value-store/MaxAge
).
You will use some combination of the ETag, the ARN, and the
name to work with the key value store programmatically.
Key value store statuses
When you create a key value store, the data store can have the following status
values.
Value |
Description |
Provisioning
|
The key value store was created and CloudFront is processing the
data source that you specified.
|
Ready
|
The key value store was created and CloudFront successfully
processed the data source that you specified.
|
Import failed
|
CloudFront wasn't able to process the data source that you
specified. This status can appear if your file format isn't
valid or that it exceeds the size limit. For more
information, see File format for key-value
pairs.
|