Linked resources for Fastly services

WARNING: This information is part of a beta release, which may be subject to breaking changes and improvements over time. For more information, see our product and feature lifecycle descriptions.

Some features of Fastly can be used to create resources that are sharable between Fastly services in the same account. Where resources are sharable (such as KV stores), you must create a resource link to connect them to each service from which you want to use that resource. Non-sharable resources (such as backends) are created and managed directly on the service to which they belong.

Shared resourcesNon-shared resources
KV stores
Secret stores
Config stores
Backends
Dictionaries
ACLs
Domains
Health checks
Compute packages

Any number of services in the same account can be linked to any number of resources in the same account, using the Resource API.

Create the shared resource, such as a KV store, and the Fastly service on which you wish to use that resource. For example, if you created a KV store, you could check that it exists by querying the KV stores API:

$ curl -X GET "https://api.fastly.com/resources/stores/kv" -H "Fastly-Key: YOUR_FASTLY_TOKEN" -H "Accept: application/json"
{
"data": [
{
"id": "5lom7wyacubg7hw0w3ulfb",
"name": "users-store",
"created_at": "2022-11-15T16:52:21.834Z",
"updated_at": "2022-11-15T16:52:21.834Z"
}
],
"meta": {
"limit": 100,
"total": 1
}
}

Armed with the id of the resource you want to link (from the output above) and the service ID of the service you want to link it to, the example below will create such a link:

$ curl -i -X POST "https://api.fastly.com/service/YOUR_FASTLY_SERVICE_ID/version/YOUR_FASTLY_SERVICE_VERSION/resource" -H "Fastly-Key: YOUR_FASTLY_TOKEN" -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" -d "name=users-store-linked-to-service-a&resource_id=5lom7wyacubg7hw0w3ulfb"
{
"id": "faF035op515mAy6FsRFqx0",
"name": "users-store-linked-to-service-a",
"service_id": "u4t1yYeyWKXxvcbfM0qml5",
"version": 1,
"created_at": "2022-11-16T11:58:43Z",
"updated_at": "2022-11-16T11:58:43Z",
"deleted_at": null,
"resource_id": "5lom7yacubg7hw0w3ulfb",
"resource_type": "kv-store",
"href": null
}

Note that the resource link itself also has a unique ID, separate from the service ID and KV store ID. When referencing the KV store from your code, use the link name, not the store name. See the Resource API documentation for more information.

HINT: It is possible to use the same name for the resource link as for the resource itself. For example, you could have a config store called config and also use that same name for the resource links that connect the config store to each service. However, if you rename the underlying resource, the name of the resource link will not change.

Limitations and constraints

The following limitations apply to resource links:

  • One service can have a maximum of 50 resource links
  • The name of a resource link has the same naming constraints as the underlying resource that it connects to. For example a resource link for a config store cannot contain dashes (-) but those for a KV store, can.

User contributed notes

BETA

Do you see an error in this page? Do you have an interesting use case, example or edge case people should know about? Share your knowledge and help people who are reading this page! (Comments are moderated; for support, please contact Fastly support)