Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DPE-6089] Update Terraform to new scheme #520

Merged
merged 10 commits into from
Dec 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
replica-set terraform basics
MiaAltieri committed Dec 3, 2024
commit 3778b22ee4c5ef8d57ded62919502aa9355f37d0
58 changes: 0 additions & 58 deletions terraform/README.md

This file was deleted.

25 changes: 14 additions & 11 deletions terraform/main.tf
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.

resource "juju_application" "mongodb" {
resource "juju_application" "machine_mongodb" {
name = var.app_name
model = var.model_name
model = var.juju_model_name

charm {
name = "mongodb"
channel = var.channel
base = "[email protected]"
name = "mongodb"
channel = var.channel
revision = var.revision
base = var.base
MiaAltieri marked this conversation as resolved.
Show resolved Hide resolved
}

storage_directives = {
mongodb = var.storage_size
}
config = var.config
units = 1
trust = true

units = var.units
constraints = var.constraints
config = var.config
}
74 changes: 12 additions & 62 deletions terraform/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,67 +1,17 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.

output "app_name" {
description = "Name of the deployed application."
value = juju_application.mongodb.name
}

# Provided integration endpoints

output "database_endpoint" {
description = "Name of the endpoint to provide the mongodb_client interface."
value = "database"
}

output "obsolete_endpoint" {
description = "Name of the endpoint to provide the mongodb interface."
value = "obsolete"
}

output "cos_agent_endpoint" {
description = "Name of the endpoint to provide the cos_agent interface."
value = "cos-agent"
}

output "config_server_endpoint" {
description = "Name of the endpoint to provide the shards interface."
value = "config-server"
}

output "cluster_endpoint" {
description = "Name of the endpoint to provide the config-server interface."
value = "cluster"
}

output "metrics_endpoint" {
description = "Name of the endpoint to provide the prometheus_scrape interface."
value = "metrics-endpoint"
}

output "grafana_dashboard_endpoint" {
description = "Name of the endpoint to provide the grafana_dashboard interface."
value = "grafana-dashboard"
}

output "logging_endpoint" {
description = "Name of the endpoint to provide the loki_push_api relation interface."
value = "logging"
}
MiaAltieri marked this conversation as resolved.
Show resolved Hide resolved


# Required integration endpoints

output "certificates_endpoint" {
description = "Name of the endpoint to provide the tls-certificates interface."
value = "certificates"
output "application_name" {
value = juju_application.machine_mongodb.name
}

output "s3_credentials_endpoint" {
description = "Name of the endpoint to provide the s3 interface."
value = "s3-credentials"
output "provides" {
value = {
database = "database",
cos_agent = "cos-agent",
}
}

output "sharding_endpoint" {
description = "Name of the endpoint to provide the shards interface."
value = "sharding"
output "requires" {
value = {
certificates = "certificates"
s3_parameters = "s3-parameters"
}
}
11 changes: 0 additions & 11 deletions terraform/terraform.tf

This file was deleted.

48 changes: 37 additions & 11 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -1,26 +1,52 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.

variable "model_name" {
description = "Name of Juju model to deploy application to"
variable "juju_model_name" {
description = "Juju model name"
type = string
default = ""
}

variable "app_name" {
description = "Name of the application in the Juju model"
description = "Name of the application in the Juju model."
type = string
default = "mongodb"
}

variable "channel" {
description = "The channel to use when deploying a charm"
description = "Charm channel to use when deploying"
type = string
default = "6/stable"
}

variable "revision" {
description = "Revision number to deploy charm"
type = number
default = null
}

variable "base" {
description = "Application base"
type = string
default = "6/beta"
default = "[email protected]"
}

variable "units" {
description = "Number of units to deploy"
type = number
default = 1
}

variable "constraints" {
description = "Juju constraints to apply for this application."
type = string
default = "arch=amd64"
}

variable "storage_size" {
description = "Storage size"
type = string
default = "10G"
}

variable "config" {
description = "Additional configuration for the MongoDB. Details about available options can be found at https://charmhub.io/mongodb/configure?channel=6/beta."
description = "Application configuration. Details at https://charmhub.io/mongodb/configurations"
type = map(string)
default = {}
}
}
9 changes: 9 additions & 0 deletions terraform/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_version = ">= 1.6.6"
required_providers {
juju = {
source = "juju/juju"
version = ">= 0.14.0"
}
}
}