Skip to content

Commit 55d4720

Browse files
authored
tf module on charm (#643)
1 parent 2e96ca2 commit 55d4720

File tree

4 files changed

+98
-0
lines changed

4 files changed

+98
-0
lines changed

terraform/main.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
resource "juju_application" "machine_postgresql" {
2+
name = var.app_name
3+
model = var.juju_model_name
4+
5+
charm {
6+
name = "postgresql"
7+
channel = var.channel
8+
revision = var.revision
9+
base = var.base
10+
}
11+
12+
storage_directives = {
13+
pgdata = var.storage_size
14+
}
15+
16+
units = var.units
17+
constraints = var.constraints
18+
config = var.config
19+
}

terraform/outputs.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
output "application_name" {
2+
value = juju_application.machine_postgresql.name
3+
}
4+
5+
6+
output "provides" {
7+
value = {
8+
database = "database",
9+
cos_agent = "cos-agent",
10+
}
11+
}
12+
13+
output "requires" {
14+
value = {
15+
certificates = "certificates"
16+
s3_parameters = "s3-parameters"
17+
}
18+
}

terraform/variables.tf

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
variable "juju_model_name" {
2+
description = "Juju model name"
3+
type = string
4+
}
5+
6+
variable "app_name" {
7+
description = "Name of the application in the Juju model."
8+
type = string
9+
default = "postgresql"
10+
}
11+
12+
variable "channel" {
13+
description = "Charm channel to use when deploying"
14+
type = string
15+
default = "14/stable"
16+
}
17+
18+
variable "revision" {
19+
description = "Revision number to deploy charm"
20+
type = number
21+
default = null
22+
}
23+
24+
variable "base" {
25+
description = "Application base"
26+
type = string
27+
default = "[email protected]"
28+
}
29+
30+
variable "units" {
31+
description = "Number of units to deploy"
32+
type = number
33+
default = 1
34+
}
35+
36+
variable "constraints" {
37+
description = "Juju constraints to apply for this application."
38+
type = string
39+
default = "arch=amd64"
40+
}
41+
42+
variable "storage_size" {
43+
description = "Storage size"
44+
type = string
45+
default = "10G"
46+
}
47+
48+
variable "config" {
49+
description = "Application configuration. Details at https://charmhub.io/postgresql/configurations"
50+
type = map(string)
51+
default = {}
52+
}

terraform/versions.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
terraform {
2+
required_version = ">= 1.6.6"
3+
required_providers {
4+
juju = {
5+
source = "juju/juju"
6+
version = ">= 0.14.0"
7+
}
8+
}
9+
}

0 commit comments

Comments
 (0)