Some Score implementations require more information about a specific resource in order to provision it. Resource Annotations provide a standard way of providing implementation specific information about a resource.
How to use Resource Annotations
Use annotations to provide additional metadata for resources. Annotations are defined as a map with keys and values that provide additional information to a resource description.
To provide an annotation for a resource, specify the following:
your-resource has a single annotation with the key
your-annotation-key and the value
Why use Resource Annotations?
There are several reasons why you might want to use Resource Annotations in your Score files:
- Informational hints: Annotations are used to provide additional information to anyone or anything interacting with your resources, defined in your Score file. This could be helpful instructions for developers, or hints to tools and systems about how to handle a certain resource.
- Shared resources: Some resources may be also be used by or “shared” with other Workloads defined in different Score files or other deployment systems. The annotations could be used to track common IDs that may be used by other systems to know that this is the same instance of a resource.
- System-specific info: Some systems and tools that interact with your Score resources might require certain metadata to be present to operate correctly, such as shared resources. Annotations provide a flexible way to supply this metadata.
The following is an example of using a Resource Annotation to provide additional metadata for a database resource.
- "Hello Annotations"
Shared resource example
The following is an example of using a Resource Annotation supported by
score-humanitec to indicate that the instance of a database resource is shared via a separate common
In this example, a PostgreSQL database resource is defined with the name
score.humanitec.io/resId is used to provide an indication to Humanitec that this resources should be used with specific ID (
Any other Workload deployed into the same Humanitec application can also access the same database by adding the same annotation in their Score file.
Resource Annotations vs. extension files
Resource Annotations are used to provide additional metadata as a hint for the individual Score file instead of using the extensions file.
It is recommended to use Resource Annotations instead of extension files, as annotations help ensure consistency across your environments and deployments, since your Workload information is stored in one file.