Why Dependencies?
Most applications have either explicit or implicit dependencies between the different components that comprise them.
For example, given an app that comprises a Helm chart component and a Terraform component:
name = "helm"
type = "helm_chart"
chart_name = "helm"
dependencies = ["database"]
[connected_repo]
directory = "components/helm"
repo = "<your-org>/<your-repo>"
branch = "main"
[values]
database_url = "{{.nuon.components.database.outputs.database_url}}"
name = "database"
type = "terraform_module"
terraform_version = "1.11.3"
[connected_repo]
directory = "components/database"
repo = "<your-org>/<your-repo>"
branch = "main"
In this example, the helm
chart requires that the database be provisioned before it is deployed. Otherwise, the
database will not exist yet, and the database_url
output will not be defined.
When deprovisioning the install, the helm
chart must be deprovisioned before the database, to ensure no active
dependencies exist, preventing the database from being shut down.
Defining Component Dependencies
To support this, you can define one or more dependencies on each component, telling Nuon what other components it relies on.
Nuon will use your configuration to build a dependency graph, to ensure components are provisioned and deprovisioned in the correct order.
The dependency graph is directed and acyclic, which means circular dependencies are not supported.
Nuon checks for cycles and will error if you attempt to define one.
Dependencies can be explicitly defined using the dependencies
field in each component’s configuration file.
You can specify which components a given component depends on by listing their names in the dependencies
array.
Taking the example above, you can make the Helm chart depend on the database by adding it to the dependencies list.
With the directory-based approach, you can specify dependencies explicitly in each component file:
name = "database"
type = "terraform_module"
terraform_version = "1.11.3"
[connected_repo]
directory = "components/database"
repo = "<your-org>/<your-repo>"
branch = "main"
name = "helm"
type = "helm_chart"
chart_name = "helm"
dependencies = ["database"]
[connected_repo]
directory = "components/helm"
repo = "<your-org>/<your-repo>"
branch = "main"
[values]
database_url = "{{.nuon.components.database.outputs.database_url}}"
Install Provisioning
When an install is provisioned, Nuon will generate a graph of the app based on the defined dependencies.
Nuon will automatically deploy the latest build of each component to the install. In the previous example, this means
that the database component would be deployed before the Helm chart.
For example, when you create a new install, each component will automatically be deployed:
To check the status of each component on the install:
Install Deprovisioning
When an install is deprovisioned, Nuon will generate a graph of all the deployed components on the install, and walk
them in reverse, to deprovision them properly. In the previous example, this means the helm component would be
deprovisioned before the database.