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
Copied to clipboard!
# 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
Copied to clipboard!
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'
Copied to clipboard!
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.
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
Copied to clipboard!
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
.
Default lookup tags can be used on Services, Routes, Partials, Consumers and Consumer Groups.