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.
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:
<TYPE>is the type of the resource, e.g.
<ID>is the Resource ID, e.g.
<OUTPUT>is an output from the resource, e.g.
<SUB_PROPERTY...>can be further sub properties if the value of
<OUTPUT>is a complex type.
., it is common to write the placeholder using
notation for the
TYPE#IDtuple as follows:
This reference will resolve to the
hostvalue as outputted by the
dnsresource with Resource ID of
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.
Resources of types
dnshave natural dependencies on each other. The
tls-certneeds to know the DNS name it should generate a certificate for, the
ingressneeds 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
dnsresource that is used. This would be hard to maintain. Instead, by provisioning an
ingressresource with the same ID as the
dnsresource 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