Active Resources

Active Resources are provisioned and active instances of a resource. Each Environment that has been deployed to has a set of Active Resources.

Lifecycle of a Resource

Resources are provisioned at deployment time. To provision a resource, the Platform Orchestrator identifies the Resource Definition that matches the Resource Dependency and uses the Driver specified in the Resource Definition to provision the resource.

Resources are deprovisioned, under the following conditions:

  • a new resource with the same context is provisioned or
  • the environment the resource provisioned in is deleted.

This means it is not sufficient to remove a resource dependency in order for the resource to be deprovisioned. Specifically, removing a resource from the Score file and re-deploying the file it will not deprovision the resource. This behavior allows for rollbacks to previous deployments without losing state in stateful resources such as an Amazon S3 buckets or Databases.

Listing

By Environment

The Active Resources deployed in an Environment can be viewed by anyone with at least Viewer permission on the Application that the Environment is in.

In the UI, Active Resources provisioned via Private Resource Dependencies are viewable within the workload they are private to. Active Resources from Shared Resource Dependencies are viewable at the Environment level.

  1. From the Application overview, select the name of the Application in which you would like to view the Active Resources of

  2. Select the Environment in the Environment Switcher in the top left of the screen.

  3. Select the Active Deployment below the Environment switcher.

For private Resource dependencies

  1. Select the Workload the Private Dependency is associated with.

  2. The Active Resources currently in use by the workload are listed in the left-hand section of the screen.

For shared Resource dependencies

  1. Select the “Shared Resources” tab in the right-hand side.

  2. All the non-private Active Resources are listed.

humctl get active-resources

This command retrieves all the Active resources in the current environment.

curl "https://api.humanitec.io/orgs/${HUMANITEC_ORG}/apps/${HUMANITEC_APP}/envs/${HUMANITEC_ENV}/resources" \
  -H "Authorization: Bearer ${HUMANITEC_TOKEN}"

Where the following environment variables are set:

Variable Example Description
HUMANITEC_TOKEN lsakdjhcals A Humanitec token of a user with at least Developer permission on the Application.
HUMANITEC_ORG my-org The Humanitec organization the application is in.
HUMANITEC_APP my-app The Application the Environment is in.
HUMANITEC_ENV my-env The Environment to list Active Resources in.

This action cannot be performed by Terraform, as it involves fetching ephemeral objects.

By Resource Definition

The Active Resources provisioned via a particular Resource Definition can be viewed by any user with the Administrator role in the organization.

  1. From the Resource Management screen, select the Resource Definition to view the Active Resources of.

  2. Select the Usage tab.

  3. All the Active Resources provisioned via that Resource Definition are listed.

There is no specific command to list Active Resources in the CLI, but the api command can be used to retrieve the same information.

humctl api get /orgs/${HUMANITEC_ORG}/resources/defs/${RES_DEF_ID}/resources
Variable Example Description
HUMANITEC_ORG my-org The Humanitec Organization the Application is in.
RES_DEF_ID my-res-def The ID of the Resource Definition

curl "https://api.humanitec.io/orgs/${HUMANITEC_ORG}/resources/defs/${RES_DEF_ID}/resources" \
  -H "Authorization: Bearer ${HUMANITEC_TOKEN}"

Where the following environment variables are set:

Variable Example Description
HUMANITEC_TOKEN lsakdjhcals A Humanitec token of a user with an Administrator role in the Organization.
HUMANITEC_ORG my-org The Humanitec Organization the Application is in.
RES_DEF_ID my-res-def The ID of the Resource Definition.

This action cannot be performed vy Terraform, as it involves fetching ephemeral objects.

Deprovisioning

Active Resources can be explicitly deprovisioned or deleted without the Environment they have been provisioned in being deleted. This can only be done by users who have the Administrator role in the Organization.

  1. From the Resource Management screen, select the Resource Definition that provisioned the Active Resource to be deprovisioned.

  2. Select the Usage tab.

  3. Select the Trash Can icon.

  4. In the dialog, select Delete.

There is no specific command to deprovision Active Resources in the CLI, but the api command can be used to perform the same action.

humctl api delete "/orgs/${HUMANITEC_ORG}/apps/${HUMANITEC_APP}/envs/${HUMANITEC_ENV}/resources/${RES_TYPE}/${RES_ID}?force=true"
Variable Example Description
HUMANITEC_ORG my-org The Humanitec Organization the Application is in.
HUMANITEC_APP my-app The Application the Environment is in.
HUMANITEC_ENV my-env The Environment the Active Resource is in.
RES_TYPE postgres The Resource Type of the Active Resource to deprovision. Use the form {resourceType}.{resourceClass} if class is not default.
RED_ID shared.my-db The Resource ID of the Active Resource to deprovision.

curl "https://api.humanitec.io/orgs/${HUMANITEC_ORG}/apps/${HUMANITEC_APP}/envs/${HUMANITEC_ENV}/resources/${RES_TYPE}/${RES_ID}?force=true" \
  -H "Authorization: Bearer ${HUMANITEC_TOKEN}"

Where the following environment variables are set:

Variable Example Description
HUMANITEC_TOKEN lsakdjhcals A Humanitec token of a user with an Administrator role in the Organization.
HUMANITEC_ORG my-org The Humanitec Organization the Application is in.
HUMANITEC_APP my-app The Application the Environment is in.
HUMANITEC_ENV my-env The Environment the Active Resource is in.
RES_TYPE postgres The Resource Type of the Active Resource to deprovision. Use the form {resourceType}.{resourceClass} if class is not default.
RED_ID shared.my-db The Resource ID of the Active Resource to deprovision.

This action cannot be performed via Terraform, as it involves fetching ephemeral objects.

Top