juju_application (Resource)

A resource that represents a single Juju application deployment from a charm. Deployment of bundles is not supported.

Example Usage

resource "juju_application" "this" {
  name = "my-application"

  model = juju_model.development.name

  charm {
    name     = "ubuntu"
    channel  = "edge"
    revision = 24
    series   = "trusty"
  }

  resources = {
    gosherve-image = "gatici/gosherve:1.0"
  }

  units = 3

  placement = "0,1,2"

  storage_directives = {
    files = "101M"
  }

  config = {
    external-hostname = "..."
  }
}

Schema

Required

  • model (String) The name of the model where the application is to be deployed. Changing this value will cause the application to be destroyed and recreated by terraform.

Optional

  • charm (Block List) The charm installed from Charmhub. (see below for nested schema)

  • config (Map of String) Application specific configuration. Must evaluate to a string, integer or boolean.

  • constraints (String) Constraints imposed on this application. Changing this value will cause the application to be destroyed and recreated by terraform.

  • endpoint_bindings (Attributes Set) Configure endpoint bindings (see below for nested schema)

  • expose (Block List) Makes an application publicly available over the network (see below for nested schema)

  • machines (Set of String) Specify the target machines for the application’s units. The number of machines in the set indicates the unit count for the application. Removing a machine from the set will remove the application’s unit residing on it. machines is mutually exclusive with units and placement (which is deprecated).

  • name (String) A custom name for the application deployment. If empty, uses the charm’s name.Changing this value will cause the application to be destroyed and recreated by terraform.

  • placement (String, Deprecated) Specify the target location for the application’s units. Changing this value will cause the application to be destroyed and recreated by terraform.

  • resources (Map of String) Charm resources. Must evaluate to a string. A resource could be a resource revision number from CharmHub or a custom OCI image resource. Specify a resource other than the default for a charm. Note that not all charms have resources.

Notes:

  • A resource can be specified by a revision number or by URL to a OCI image repository. Resources of type ‘file’ can only be specified by revision number. Resources of type ‘oci-image’ can be specified by revision number or URL.

  • A resource can be added or changed at any time. If the charm has resources and None is specified in the plan, Juju will use the resource defined in the charm’s specified channel.

  • If a charm is refreshed, by changing the charm revision or channel and if the resource is specified by a revision in the plan, Juju will use the resource defined in the plan.

  • Resources specified by URL to an OCI image repository will never be refreshed (upgraded) by juju during a charm refresh unless explicitly changed in the plan.

  • storage (Attributes Set) Storage used by the application. (see below for nested schema)

  • storage_directives (Map of String) Storage directives (constraints) for the juju application. The map key is the label of the storage defined by the charm, the map value is the storage directive in the form ,,. Changing an existing key/value pair will cause the application to be replaced. Adding a new key/value pair will add storage to the application on upgrade.

  • trust (Boolean) Set the trust for the application.

  • units (Number) The number of application units to deploy for the charm.

Read-Only

  • id (String) The ID of this resource.

  • model_type (String) The type of the model where the application is deployed. It is a computed field and is needed to determine if the application should be replaced or updated in case of base updates.

  • principal (Boolean, Deprecated) Whether this is a Principal application

Nested Schema for charm

Required:

  • name (String) The name of the charm to be deployed. Changing this value will cause the application to be destroyed and recreated by terraform.

Optional:

  • base (String) The operating system on which to deploy. E.g. ubuntu@22.04. Changing this value for machine charms will trigger a replace by terraform.

  • channel (String) The channel to use when deploying a charm. Specified as <track>/<risk>/<branch>.

  • revision (Number) The revision of the charm to deploy. During the update phase, the charm revision should be update before config update, to avoid issues with config parameters parsing.

  • series (String, Deprecated) The series on which to deploy.

Nested Schema for endpoint_bindings

Required:

  • space (String) Name of the space to bind the endpoint to.

Optional:

  • endpoint (String) Name of the endpoint to bind to a space. Keep null (or undefined) to define default binding.

Nested Schema for expose

Optional:

  • cidrs (String) A comma-delimited list of CIDRs that should be able to access the application ports once exposed.

  • endpoints (String) Expose only the ports that charms have opened for this comma-delimited list of endpoints

  • spaces (String) A comma-delimited list of spaces that should be able to access the application ports once exposed.

Nested Schema for storage

Read-Only:

  • count (Number) The number of volumes.

  • label (String) The specific storage option defined in the charm.

  • pool (String) Name of the storage pool.

  • size (String) The size of each volume.

Import

Import is supported using the following syntax:

# Applications can be imported using the format: `model_name:application_name`, for example:
$ terraform import juju_application.wordpress development:wordpress