diff --git a/artifact-definitions/landing-zone.json b/artifact-definitions/landing-zone.json new file mode 100644 index 0000000..1e3fbad --- /dev/null +++ b/artifact-definitions/landing-zone.json @@ -0,0 +1,26 @@ +{ + "$md": { + "label": "Landing Zone", + "name": "landing-zone", + "ui": { + "connectionOrientation": "environmentDefault", + "environmentDefaultGroup": "Landing Zones" + } + }, + "$schema": "http://json-schema.org/draft-07/schema", + "description": "Example landing zone artifact - customize this schema to match your landing zone outputs", + "properties": { + "project_id": { + "type": "string", + "description": "The ID of the project" + }, + "service_account_id": { + "type": "string", + "description": "The ID of the service account" + }, + "network_id": { + "type": "string", + "description": "The ID of the network" + } + } +} diff --git a/bundles/application/massdriver.yaml b/bundles/application/massdriver.yaml index aa161bf..64ed0fd 100644 --- a/bundles/application/massdriver.yaml +++ b/bundles/application/massdriver.yaml @@ -67,7 +67,7 @@ connections: required: - network - database - # - bucket + - zone properties: network: $ref: network @@ -75,6 +75,8 @@ connections: $ref: postgres bucket: $ref: bucket + zone: + $ref: landing-zone artifacts: required: [] diff --git a/bundles/application/operator.md b/bundles/application/operator.md index 5f7e5ad..c6aed87 100644 --- a/bundles/application/operator.md +++ b/bundles/application/operator.md @@ -2,6 +2,8 @@ templating: mustache --- +Hello from {{connections.zone.project_id}} Zone! + # 🚀 Application Bundle Runbook > **Templating**: This runbook supports mustache templating. diff --git a/bundles/application/src/_massdriver_variables.tf b/bundles/application/src/_massdriver_variables.tf index 08962d8..8edb769 100644 --- a/bundles/application/src/_massdriver_variables.tf +++ b/bundles/application/src/_massdriver_variables.tf @@ -92,3 +92,8 @@ variable "port" { variable "replicas" { type = number } +// Auto-generated variable declarations from massdriver.yaml +variable "zone" { + type = any + default = null +} diff --git a/bundles/application/src/main.tf b/bundles/application/src/main.tf index af2ab21..8e64ca6 100644 --- a/bundles/application/src/main.tf +++ b/bundles/application/src/main.tf @@ -13,8 +13,9 @@ terraform { } locals { - has_database = var.database != null - has_bucket = var.bucket != null + has_database = var.database != null + has_bucket = var.bucket != null + zone_project_id = var.zone.project_id } resource "random_pet" "main" { diff --git a/bundles/landing-zone/icon.svg b/bundles/landing-zone/icon.svg new file mode 100644 index 0000000..42cbcff --- /dev/null +++ b/bundles/landing-zone/icon.svg @@ -0,0 +1,17 @@ + + + + + + diff --git a/bundles/landing-zone/massdriver.yaml b/bundles/landing-zone/massdriver.yaml new file mode 100644 index 0000000..0abf67f --- /dev/null +++ b/bundles/landing-zone/massdriver.yaml @@ -0,0 +1,30 @@ +schema: draft-07 +name: landing-zone +description: "Landing Zones" +source_url: https://github.com/YOUR_ORG/massdriver-catalog/tree/main/bundles/bucket +version: 0.0.0 + +params: + properties: + project_name: + type: string + +connections: + required: [] + properties: {} + +artifacts: + required: + - zone + properties: + zone: + $ref: landing-zone + title: Landing Zone + +steps: + - path: src + provisioner: opentofu:1.10 + +ui: + ui:order: + - "*" diff --git a/bundles/landing-zone/operator.md b/bundles/landing-zone/operator.md new file mode 100644 index 0000000..77b148f --- /dev/null +++ b/bundles/landing-zone/operator.md @@ -0,0 +1,5 @@ +--- +templating: mustache +--- + +# Landing Zone TODO diff --git a/bundles/landing-zone/src/_massdriver_variables.tf b/bundles/landing-zone/src/_massdriver_variables.tf new file mode 100644 index 0000000..dfd7a23 --- /dev/null +++ b/bundles/landing-zone/src/_massdriver_variables.tf @@ -0,0 +1,28 @@ +// Auto-generated variable declarations from massdriver.yaml +variable "md_metadata" { + type = object({ + default_tags = object({ + managed-by = string + md-manifest = string + md-package = string + md-project = string + md-target = string + }) + deployment = object({ + id = string + }) + name_prefix = string + observability = object({ + alarm_webhook_url = string + }) + package = object({ + created_at = string + deployment_enqueued_at = string + previous_status = string + updated_at = string + }) + target = object({ + contact_email = string + }) + }) +} diff --git a/bundles/landing-zone/src/artifacts.tf b/bundles/landing-zone/src/artifacts.tf new file mode 100644 index 0000000..f5dc827 --- /dev/null +++ b/bundles/landing-zone/src/artifacts.tf @@ -0,0 +1,9 @@ +resource "massdriver_artifact" "zone" { + field = "zone" + name = "Zone ${var.md_metadata.name_prefix}" + artifact = jsonencode({ + project_id = local.project_id + network_id = local.network_id + service_account_id = local.service_account_id + }) +} diff --git a/bundles/landing-zone/src/main.tf b/bundles/landing-zone/src/main.tf new file mode 100644 index 0000000..6c6502d --- /dev/null +++ b/bundles/landing-zone/src/main.tf @@ -0,0 +1,44 @@ +terraform { + required_version = ">= 1.0" + required_providers { + random = { + source = "hashicorp/random" + version = "~> 3.0" + } + massdriver = { + source = "massdriver-cloud/massdriver" + version = "~> 1.3" + } + } +} + +variable "project_name" { + type = string +} + +resource "random_pet" "project" { + keepers = { + name = var.project_name + } +} + + +resource "random_pet" "network" { + keepers = { + name = var.project_name + } +} + + +resource "random_pet" "service_account" { + keepers = { + name = var.project_name + } +} + + +locals { + project_id = random_pet.project.id + network_id = random_pet.network.id + service_account_id = random_pet.service_account.id +}