Skip to content

Commit eb83e6b

Browse files
authored
Merge pull request #18 from canonical/update-terraform-files
chore: Housekeeping Terraform modules mostly to spec
2 parents 50e401b + b26ef1a commit eb83e6b

File tree

5 files changed

+85
-16
lines changed

5 files changed

+85
-16
lines changed

charmcraft.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@ charm-libs:
2222
config:
2323
options:
2424
config-file:
25-
description: |
26-
Text contents of the conserver.cf config file.
25+
description: Base64 encoded contents of the conserver.cf configuration file.
2726
type: string
2827
passwd-file:
29-
description: |
30-
Base64 encoded contents of the passwd file.
28+
description: Base64 encoded contents of the conserver.passwd file.
3129
default: "IyBDb25zZXJ2ZXIgcGFzc3dkIGZpbGUKIyBGb3JtYXQ6IHVzZXJuYW1lOiQxJFkwWmpNbTJoJG9NWDVVeUxpMS95MFE5SVJXZjN2LzAKIyB5b3UgY2FuIGdlbmVyYXRlIHRoZSBoYXNoZWQgcGFzc3dvcmQgdXNpbmcgYG9wZW5zc2wgcGFzc3dkIC0xYAo="
3230
type: string
3331

terraform/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Terraform Module for Conserver
2+
3+
This is a Terraform module facilitating the deployment of the Conserver charm,
4+
using the [Terraform Juju provider][juju-provider]. For more information, refer
5+
to the provider [documentation][juju-provider-docs].
6+
7+
## Requirements
8+
9+
This module requires a `juju` model to be available. Refer to the
10+
[usage section](#usage) below for more details
11+
12+
## API
13+
14+
### Inputs
15+
16+
| Name | Type | Description | Default |
17+
| ------------- | ------ | --------------------------------------------------------------------------------- | ------------- |
18+
| app_name | string | Name to give the deployed application | conserver |
19+
| charm_channel | string | Channel of the charm | latest/stable |
20+
| config_file | string | Base64 encoded contents of conserver.cf | |
21+
| constraints | string | String listing constraints for this application | arch=amd64 |
22+
| juju_model | string | Reference to an existing model resource or data source for the model to deploy to | |
23+
| passwd_file | string | Base64 encoded contents of conserver.passwd | |
24+
| revision | number | Revision number of the charm | null |
25+
26+
### Outputs
27+
28+
| Name | Type | Description |
29+
| -------- | ------ | -------------------------------- |
30+
| app_name | string | Name of the deployed application |
31+
32+
## Usage
33+
34+
### Basic Usage
35+
36+
Users should ensure that Terraform is aware of the `juju_model` dependency of
37+
the charm module.
38+
39+
To deploy this module, you can run
40+
41+
```shell
42+
terraform apply -var="juju_model=<MODEL_NAME>" -auto-approve
43+
```
44+
45+
[juju-provider]: https://github.com/juju/terraform-provider-juju/
46+
[juju-provider-docs]: https://registry.terraform.io/providers/juju/juju/latest/docs

terraform/main.tf

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
resource "juju_application" "conserver" {
2-
name = "conserver"
3-
model = var.juju_model
4-
5-
units = 1
2+
name = var.app_name
3+
constraints = var.constraints
4+
model = var.juju_model
5+
units = 1
66

77
charm {
8-
name = "conserver"
9-
10-
channel = var.charm_channel
8+
name = "conserver"
9+
10+
channel = var.charm_channel
11+
revision = var.revision
1112
}
1213

1314
config = {

terraform/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "app_name" {
2+
description = "Name of the deployed application"
3+
value = juju_application.conserver.name
4+
}

terraform/variables.tf

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,40 @@
1-
variable "juju_model" {
2-
description = "Name of the Juju model to deploy into"
1+
variable "app_name" {
2+
description = "Name to give the deployed application"
33
type = string
4+
default = "conserver"
45
}
56

67
variable "charm_channel" {
7-
description = "Channel to use for the charm (e.g., 'latest/stable')"
8+
description = "Channel of the charm"
89
type = string
910
default = "latest/stable"
1011
}
1112

1213
variable "config_file" {
13-
description = "Content for the conserver.cf configuration file"
14+
description = "Base64 encoded content for the conserver.cf configuration file"
15+
type = string
16+
}
17+
18+
variable "constraints" {
19+
description = "String listing constraints for this application"
20+
type = string
21+
default = "arch=amd64"
22+
}
23+
24+
variable "juju_model" {
25+
description = "Reference to an existing model resource or data source for the model to deploy to"
1426
type = string
1527
}
1628

1729
variable "passwd_file" {
1830
description = "Base64 encoded content for the conserver.passwd file"
1931
type = string
20-
}
32+
sensitive = true
33+
}
34+
35+
variable "revision" {
36+
description = "Revision number of the charm"
37+
type = number
38+
nullable = true
39+
default = null
40+
}

0 commit comments

Comments
 (0)