Skip to content

Commit

Permalink
Update authentication methods and the list of supported resources and
Browse files Browse the repository at this point in the history
data sources.
  • Loading branch information
hmlanigan committed Feb 2, 2024
1 parent e368186 commit 25e3a80
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 44 deletions.
36 changes: 0 additions & 36 deletions examples/provider/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,6 @@ terraform {
}
}

# This is a fully configured provider containing all the
# relevant information to connect to a Juju controller.
# This information can be collected by checking the local
# juju folder (~/.local/share/juju/), or by querying the
# controller using `juju show-controller --show-password`.
# If you have already installed and configured a local
# Juju CLI or prefer to use a configuration using environment
# variables, you can use an empty provider. See the next
# example for more details.

#provider "juju" {
# controller_addresses = "10.225.205.241:17070,10.225.205.242:17070"
#
# username = "jujuuser"
# password = "password1"
#
# ca_certificate = file("~/ca-cert.pem")
#}


# When an empty provider is indicated, the Juju
# provider automatically sets the corresponding values
# by checking:
# **First**: the following environment variables that correspond
# to the configuration fields indicated above.
# JUJU_CONTROLLER_ADDRESSES
# JUJU_USERNAME
# JUJU_PASSWORD
# JUJU_CA_CERT
# **Second**: by using a locally installed Juju CLI client.
# This is the most straight-forward solution. Remember, that
# it will use the configuration used by the CLI at that
# moment. The fields are populated using the output
# from running the command:
# `juju show-controller --show-password`

provider "juju" {}

resource "juju_model" "development" {
Expand Down
56 changes: 48 additions & 8 deletions templates/index.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,24 @@ description: |-

The provider can be used to interact with [Juju][0] - a model-driven Operator Lifecycle Manager (OLM) by Canonical.

Initially this provider allows you to:
The provider only interacts with a single controller.

* Manage models,
* Manage applications and deploy charms from CharmHub,
* Manage integrations.
Today this provider allows you to manage the following via resources:

* Applications and deploy charms from CharmHub
* Credentials for existing clouds.
* Integrations
* Machines
* Models
* Model ssh keys
* Offers
* Users

and refer to the follow via data sources:

* Machines
* Models
* Offers

In future the provider will be extended to support more of Juju's capabilities.

Expand All @@ -26,12 +39,39 @@ In future the provider will be extended to support more of Juju's capabilities.

The provider has a dependency on Juju CLI configuration store.

In order to operate, the provider expects configuration to be found in one of the following locations:
## Authentication

There are 3 ways to define credentials for authentication with the juju controller you wish to use. They are displayed in order in which the provider looks for credentials.

### Static credentials

Define the juju controller credentials in the provider definition in your terraform plan.

``` terraform
provider "juju" {
controller_addresses = "10.225.205.241:17070,10.225.205.242:17070"
username = "jujuuser"
password = "password1"
ca_certificate = file("~/ca-cert.pem")
}
```

### Environment variables

Define the juju controller credentials in the provider definition via environment variables. These can be setup as follows:

```shell
export CONTROLLER=$(juju whoami | yq .Controller)
export JUJU_CONTROLLER_ADDRESSES="$(juju show-controller | yq '.[$CONTROLLER]'.details.\"api-endpoints\" | tr -d "[]' "|tr -d '"'|tr -d '\n')"
export JUJU_USERNAME="$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.user|tr -d '"')"
export JUJU_PASSWORD="$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.password|tr -d '"')"
export JUJU_CA_CERT="$(juju show-controller $(echo $CONTROLLER|tr -d '"') | yq '.[$CONTROLLER]'.details.\"ca-cert\"|tr -d '"'|sed 's/\\n/\n/g')"
```

* `$XDG_DATA_HOME/juju`
* `~/.local/share/juju`
### Populated by provider via the juju cli client.

The intention is to remove this dependency in future.
This is the most straight-forward solution. Remember, that it will use the configuration used by the CLI at that moment. The fields are populated using the output from running the command:
`juju show-controller --show-password`

{{ if .HasExample -}}
## Example Usage
Expand Down

0 comments on commit 25e3a80

Please sign in to comment.