Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
Associate a key value store with a
function
After you create your key value store, you can update your function to associate it
with your key value store. You must make this association to use the key-value pairs
from that store in that function. The following rules apply:
- Console
-
To associate a key value store with a function
-
Sign in to the CloudFront console at https://console.amazonaws.cn/cloudfront/v4/home#/functions and choose the
Functions page.
-
Choose the function name.
-
Go to the Associate KeyValueStore section
and choose Associate existing
KeyValueStore.
-
Select the key value store that contains the key-value pairs
in the function, and then choose Associate
KeyValueStore.
CloudFront immediately associates the store with the function. You
don't need to save the function.
-
To specify a different key value store, choose Update
associated KeyValueStore, select another
key value store name, and then choose Associate
KeyValueStore.
For more information, see Update functions.
- Amazon CLI
-
To associate a key value store with a function
-
Run the following command to update the
MaxAge
function
and associate a key value store resource.
aws cloudfront update-function \
--name MaxAge \
--function-config '{"Comment":"Max Age 2 years","Runtime":"cloudfront-js-2.0","KeyValueStoreAssociations":{"Quantity":1,"Items":[{"KeyValueStoreARN":"arn:aws:cloudfront::123456789012:key-value-store/8aa76c93-3198-462c-aaf6-example"}]}}' \
--function-code fileb://function-max-age-v1.js \
--if-match ETVABCEXAMPLE
-
To associate a key value store with a function, specify the
KeyValueStoreAssociations
parameter and the
key value store ARN.
-
To change the association, specify another key value store ARN.
-
To remove the association, remove the
KeyValueStoreAssociations
parameter.
For more information, see Update functions.
- API
-
To associate a key value store with a function
-
If you modify a key value store without changing the key-value pairs,
or if you only modify the key-value pairs in the key value store, you
don't need to associate the key value store again. You also don't need to
republish the function.
However, we recommend that you test the function to verify that it
works as expected. For more information, see Test functions.
-
You can view all the functions that use specific key value stores. On
the CloudFront console, choose the key value store details page.