decK lets you specify entity relationships using foreign keys. For example, look at the following files that manage Consumers and Consumer Groups:
# consumers.yaml
_format_version: "3.0"
_info:
select_tags:
- billing-consumers
consumers:
- username: alice
groups:
- name: finance
keyauth_credentials:
- key: hello_world
# consumer-groups.yaml
_format_version: "3.0"
_info:
select_tags:
- billing-groups
consumer_groups:
- name: finance
plugins:
- name: rate-limiting
config:
minute: 5
limit_by: consumer
policy: local
The consumer-groups.yaml
file syncs as expected as it doesn’t contain any foreign key references. However, you will get an error when syncing consumers.yaml
as the finance
Consumer Group won’t be available:
deck gateway sync consumers.yaml
Error: building state: consumer-group 'finance' not found for consumer '093645f9-e189-47ba-bc9e-f4e9b09325eb'
You have two options to resolve this issue:
- Ensure that all resources use the same
select_tags
.
- Use
default_lookup_tags
to load additional resources without including them in your state file. Default lookup tags can be used on Services, Routes, Partials, Consumers, and Consumer Groups.
Update consumers.yaml
now to specify default_lookup_tags.consumer_groups
:
# consumers.yaml
_format_version: "3.0"
_info:
select_tags:
- billing-consumers
default_lookup_tags:
consumer_groups:
- billing-groups
consumers:
- username: alice
groups:
- name: finance
keyauth_credentials:
- key: hello_world
This loads all consumer_groups
with the tag billing-groups
in to memory and decK can successfully resolve the foreign keys used in consumers.yaml
.
If the entity has multiple tags, all tags must be added to default_lookup_tags
. For example, if the finance
Consumer Group had tags for billing-groups
and demo
, then consumer.yaml
would need both tags listed:
# consumers.yaml
_format_version: "3.0"
_info:
select_tags:
- billing-consumers
default_lookup_tags:
consumer_groups:
- billing-groups
- demo
consumers:
- username: alice
groups:
- name: finance
keyauth_credentials:
- key: hello_world