Linking resources

Wire resources in a Facets blueprint so they share values: connect them through the form, or dollar-reference one resource's output in another's JSON.

Linking connects resources so they share values: a service reads its database's credentials, an ingress routes to a service. You link them two ways, connect them through the form, or dollar-reference one resource's output in another's JSON. Both write the same wiring.

Using prompt

Wire the main-db postgres into service/api in myproject.

or

Using command

raptor apply resource service/api -p myproject --input db=postgres/main-db

# Drop a wiring
raptor apply resource service/api -p myproject --unset-input db

--input takes INPUT_NAME=TYPE/RESOURCE, and a third segment picks one output when the module exposes more than one. raptor get resource-type-inputs lists the inputs a module declares. To see existing wiring, raptor impact service/api -p myproject --reverse lists what a resource depends on, and without --reverse, what breaks if you change it.

New to the CLI? Install it first.

Postgres into a Service, using environment variables:

  1. In the Blueprint tab, select the Service resource you want to connect to the Postgres resource.

    Selecting the Service resource in the Facets Blueprint tab to connect it to a Postgres resource
  2. Select Connect with other resource in the drop-down.

    The Connect with other resource option in the resource drop-down menu
  3. Select the Postgres database, enter the Key, and select the Value.

    Selecting the Postgres database and entering the environment variable Key and Value to link it to the Service
  4. Click Save.

Service into an Ingress, using ingress rules:

  1. In the Blueprint tab, select the Ingress resource you want to connect to the Service.

  2. Select Configure from the drop-down.

  3. Under Ingress Rules, click Add New Entry.

  4. Enter the Service Name, Path, and Port.

    Adding an Ingress Rule entry with the Service Name, Path, and Port fields
  5. Click Save Changes.

    Saving the Ingress configuration after adding the ingress rule that links the Service

Dollar referencing

Reference one resource's output value in another's JSON with ${} notation. The JSON editor autocompletes the available paths, so you pick one rather than guess.

Using prompt

What can I reference from postgres/default-db in myproject?

or

Using command

# Every valid ${} path in the project, with the type each returns
raptor describe expressions -p myproject

# Narrowed to one resource, or one kind
raptor describe expressions -p myproject postgres/default-db
raptor describe expressions -p myproject --kind postgres

This is the terminal equivalent of the editor's autocomplete. Blueprint variables and secrets are in the list too, and --include TYPE/FLAVOR/VERSION:NAME adds a resource you have not created yet. Once you know the path, write it in with raptor apply resource ... --set-string, since a ${} reference is a literal string that must not be type-inferred.

New to the CLI? Install it first.

  1. Open the resource's Configurations tab and switch to JSON mode.
  2. Type the reference where you need the value; autocomplete suggests the available paths as you go. You can also copy a reference from the Reference Resource section of the Configurations tab.
  3. Save the changes.

Note: dollar references resolve only after the environment is launched.

Syntax: ${<resource_type>.<resource_name>.out.<attributes>}, for example ${postgres.default-db.out.interfaces.writer.host}.

For example, to give a Service the connection details of a default-db Postgres, set these under spec.env in the Service's JSON:

"POSTGRES_URL": "jdbc:postgresql://${postgres.default-db.out.interfaces.writer.host}/postgres",
"POSTGRES_USER": "${postgres.default-db.out.interfaces.writer.username}",
"POSTGRES_PASS": "${postgres.default-db.out.interfaces.writer.password}"

FAQ

What if a dollar reference is wrong?

Incorrect references cause misconfigurations. Confirm a path with the editor's autocomplete or raptor describe expressions -p <project> before using it, and check the Validations panel in the Releases tab, which flags bad references.

Can I define custom references?

No. References are predefined by the blueprint's structure.