Links

References

Resource References
Humanitec provides a way of referencing the outputs of other resources from within Resource Definitions. When provisioning a resource described by a Resource Definition containing a reference to another resource, Humanitec will ensure that the referenced resource will be provisioned first. Circular references are not allowed. References are defined using Placeholders within the resource definitions.
The concept is easily confused with Resource Dependencies. Resource Dependencies refer to resources that are required by a Workload in a Deployment Set. Humanitec will identify all Dependent Resources in a deployment set and provision them.
Resource References are references between resources.

Referencing other resources

Resources are referenced by the tuple (combination of) Resource Type and Resource ID. If Resource ID is omitted, the resource ID of the referencing resource is used. The reference is defined as a Placeholder with the following format:
resources.<TYPE>[#<ID>].outputs.<OUTPUT>[.<SUB_PROPERTY...>]
where:
  • <TYPE> is the type of the resource, e.g. dns
  • <ID> is the Resource ID, e.g. shared.api-dns
  • <OUTPUT> is an output from the resource, e.g. host
  • <SUB_PROPERTY...> can be further sub properties if the value of <OUTPUT> is a complex type.
As <ID> might contain ., it is common to write the placeholder using [] notation for the TYPE#ID tuple as follows:
${resource['dns#shared.dns'].outputs.host}
This reference will resolve to the host value as outputted by the dns resource with Resource ID of shared.api-dns.

Omitting Resource ID

Omitting the Resource ID from a reference will implicitly use the Resource ID of the resource is being provisioned. This allows for more generic configuration for commonly related Resource Types.

Example

Resources of types ingress, tls-cert and dns have natural dependencies on each other. The tls-cert needs to know the DNS name it should generate a certificate for, the ingress needs to know both the DNS name it provides routing for and where to find the certificate that it needs to serve.
If references needed to be fully qualified (include both the Resource Type and Resource ID) then 3 Resource Definition would need to be created for each dns resource that is used. This would be hard to maintain. Instead, by provisioning an ingress resource with the same ID as the dns resource it provides routing for, the referencing can be simplified.
Resource References for ingress, dns & tls resources
In the above diagram, each of the resources have the same Resource ID. By omitting the Resource ID from the reference