Skip to content

Instantly share code, notes, and snippets.

@vvuksan
Created December 22, 2017 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vvuksan/a8f861c12c20d50fd36fe9b931d14234 to your computer and use it in GitHub Desktop.
Save vvuksan/a8f861c12c20d50fd36fe9b931d14234 to your computer and use it in GitHub Desktop.
Dictionary creation

To make it work correctly all these environment variables need to be set

export SERVICE_ID=XXXXX
export API_KEY="XXXX"
export VERSION="XXXXX"

Create a dictionary

Next step is to add a dictionary. To add it please run

http POST https://api.fastly.com/service/$SERVICE_ID/version/$VERSION/dictionary Fastly-Key:$API_KEY name=logging_options

This will create an edge dictionary called logging_options. If successful you should see

{
    "created_at": "2017-11-22T17:10:05Z",
    "deleted_at": null,
    "id": "DDDDDDDDDDDDDDDDD",
    "name": "io_config_options",
    "service_id": "AAAAAAAAAAAAAAAAa",
    "updated_at": "2017-11-22T17:10:05Z",
    "version": 30,
    "write_only": false
}

Please note the id value in the payload above. You will need it to set the DICTIONARY_ID environment variable as it's going to be used in the next step e.g.

export DICTIONARY_ID="DDDDDDDDDDDDDDDDD"

Add dictionary values

Next step is to add dictionary id values e.g.

http POST https://api.fastly.com/service/$SERVICE_ID/dictionary/$DICTIONARY_ID/item Fastly-Key:$API_KEY item_key=sampling_static item_value=10
http POST https://api.fastly.com/service/$SERVICE_ID/dictionary/$DICTIONARY_ID/item Fastly-Key:$API_KEY item_key=sampling_dynamic item_value=60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment