pluralsh / deployment-operator

thin kubernetes agent to execute deployments of plural services
1 stars 1 forks source link

feat(harness): add stackrun variables support to terraform #251

Closed floreks closed 1 month ago

floreks commented 1 month ago

Tested with the following stack.

Terraform (main.tf)

resource "random_string" "random" {
  length  = var.random_string_length
  upper   = var.random_string_upper
  special = var.random_string_special
}

resource "null_resource" "default" {
  provisioner "local-exec" {
    command = "${var.null_resource_command} ${random_string.random.result}"
  }
}

output "test" {
  value = random_string.random.result
}

Terraform (variables.tf)

variable "random_string_length" {
  type = number
  default = 5
}

variable "random_string_upper" {
  type = bool
  default = false
}

variable "random_string_special" {
  type = bool
  default = false
}

variable "null_resource_command" {
  type = string
  default = "echo"
}

InfrastructureStack CRD

apiVersion: deployments.plural.sh/v1alpha1
kind: InfrastructureStack
metadata:
  name: floreks-stack-variables-basic
  namespace: default
spec:
  detach: true
  type: TERRAFORM
  approval: true
  workdir: variables
  configuration:
    image: ghcr.io/pluralsh/harness
    version: sha-e9b2089-terraform-1.8
  repositoryRef:
    name: tf-test
    namespace: default
  clusterRef:
    name: existing
    namespace: default
  git:
    ref: main
    folder: terraform
  variables:
    random_string_length: 10
    random_string_upper: true
    null_resource_command: "echo prefix-"
linear[bot] commented 1 month ago

PROD-2482 support stack variables