juju_credential (Resource)

A resource that represent a credential for a cloud.

Note On Credential Owner

Credentials are tied to the user that created them. This implies that changing the authentication details in your plan will influence what credentials the provider sees. To avoid unexpected behaviour, creating a credential records the owner in its read-only owner attribute and rejects refreshes, updates, and deletions under a different user. This prevents accidentally managing another user’s credential with the same cloud and name.

For state created by older provider versions and newly imported credentials, the owner is recorded after the first successful refresh. Run the first refresh as the intended owner. Subsequent runs enforce the recorded owner.

Example Usage

resource "juju_credential" "this" {
  name = "creddev"

  cloud {
    name = "localhost"
  }

  auth_type = "certificate"

  attributes = {
    client-cert    = "/srv/cert.crt"
    client-key     = "/srv/cert.key"
    trust-password = "S0m3P@$$w0rd"
  }
}

Schema

Required

  • auth_type (String) Credential authorization type.

  • name (String) The name to be assigned to the credential. Changing this value will cause the credential to be destroyed and recreated by terraform.

Optional

  • attributes (Map of String, Sensitive) Credential attributes accordingly to the cloud

  • client_credential (Boolean) Add credentials to the client.

  • cloud (Block List) Juju Cloud where the credentials will be used to access. (see below for nested schema)

  • controller_credential (Boolean) Add credentials to the controller.

Read-Only

  • id (String) The ID of this resource.

  • owner (String) The authenticated Juju user who owns the controller credential. Subsequent operations must use this user. For existing state and imports, ownership is recorded after the first successful refresh. Client-only credentials (i.e. modifying the CLI store when client_credential is true) have no owner.

Nested Schema for cloud

Required:

  • name (String) The name of the cloud

Import

Import is supported using the following syntax:

The terraform import command can be used, for example:

# Credentials can be imported by using the following pattern: 
# credentialname:cloudname:false:true
# Where false means that is not a client credential
# and true means that is a Controller credential
$ terraform import juju_credential.credential creddev:localhost:false:true