|
| 1 | +# Terraform module for Charmed PostgreSQL |
| 2 | + |
| 3 | +This is a Terraform module facilitating the deployment of Charmed PostgreSQL, |
| 4 | +using the [Terraform juju provider](https://github.com/juju/terraform-provider-juju/). |
| 5 | +For more information, refer to the provider |
| 6 | +[documentation](https://registry.terraform.io/providers/juju/juju/latest/docs) |
| 7 | +and [deployment tutorial](https://charmhub.io/postgresql/docs/h-deploy-terraform). |
| 8 | + |
| 9 | +## Requirements |
| 10 | + |
| 11 | +| Name | Version | |
| 12 | +|------|---------| |
| 13 | +| terraform | >= 1.6.6 | |
| 14 | +| juju provider | >= 0.14.0 | |
| 15 | + |
| 16 | +## Usage |
| 17 | + |
| 18 | +Users should ensure that Juju model has been created to deploy into: |
| 19 | +``` |
| 20 | +juju add-model welcome |
| 21 | +``` |
| 22 | + |
| 23 | +To deploy Charmed PostgreSQL into the model `welcome`, run: |
| 24 | +``` |
| 25 | +terraform apply -var='juju_model_name=welcome' -auto-approve |
| 26 | +``` |
| 27 | + |
| 28 | +By default, this Terraform module will deploy PostgreSQL with `1` unit only. |
| 29 | +To configure the module to deploy `3` units, run: |
| 30 | +``` |
| 31 | +terraform apply -var='juju_model_name=welcome' -var='units=3' -auto-approve |
| 32 | +``` |
| 33 | + |
| 34 | +The juju storage directives config example: |
| 35 | +``` |
| 36 | +terraform apply -var='juju_model_name=welcome' -auto-approve \ |
| 37 | + -var='storage={data="10G", archive="2G,lxd", logs="3G", temp="tmpfs,2G"}' |
| 38 | +``` |
| 39 | + |
| 40 | +The juju constraints example: |
| 41 | +``` |
| 42 | +terraform apply -var='juju_model_name=welcome' -auto-approve \ |
| 43 | + -var='constraints=arch=amd64 cores=4 mem=4096M virt-type=virtual-machine' |
| 44 | +``` |
| 45 | + |
| 46 | +Example of deploying to the specific Juju machine: |
| 47 | +``` |
| 48 | +juju add-machine |
| 49 | +> created machine 19 |
| 50 | +
|
| 51 | +terraform apply -var='juju_model_name=welcome' -var='machine=19' |
| 52 | +``` |
| 53 | +Note: the module variables `units` and `machine` are self-exclusive. |
| 54 | + |
| 55 | +Check [Charmed PostgreSQL Deployment How-to](https://charmhub.io/postgresql/docs/h-deploy-terraform) for more examples. |
| 56 | + |
| 57 | +## Inputs |
| 58 | + |
| 59 | +| Name | Description | Type | Default | Required | |
| 60 | +|------|-------------|------|---------|:--------:| |
| 61 | +| juju_model_name | Juju model name (to deployed into) | `string` | n/a | yes | |
| 62 | +| charm_name | Name of the charm on charmhub.io to deploy | `string` | `postgresql` | no | |
| 63 | +| app_name | Name of the deployed application in the Juju model | `string` | `postgresql` | no | |
| 64 | +| channel | Charm channel to use when deploying | `string` | `16/stable` | no | |
| 65 | +| revision | Revision number to deploy charm | `number` | n/a | no | |
| 66 | +| base | Application base | `string` | `[email protected]` | no | |
| 67 | +| machine | Target Juju machine to deploy on | `string` | n/a | no | |
| 68 | +| units | Number of units to deploy | `number` | `1` | no | |
| 69 | +| constraints | Juju constraints to apply for this application | `string` | `arch=amd64` | no | |
| 70 | +| storage | Storage directive | `map(string)` | `{}` | no | |
| 71 | +| config | Application configuration. Details at https://charmhub.io/postgresql/configurations | `map(string)` | n/a | no | |
| 72 | +| enable_expose | Whether to expose the application | `bool` | `true` | no | |
| 73 | + |
| 74 | +## Outputs |
| 75 | + |
| 76 | +| Name | Description | |
| 77 | +|------|-------------| |
| 78 | +| application_name | Application name which make up this product module | |
| 79 | +| provides | Endpoints charm provides | |
| 80 | +| requires | Endpoints charm requires | |
| 81 | + |
0 commit comments