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

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

Merged
merged 4 commits into from
Aug 22, 2024

Conversation

floreks
Copy link
Member

@floreks floreks commented Aug 22, 2024

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-"

Copy link

linear bot commented Aug 22, 2024

@floreks floreks self-assigned this Aug 22, 2024
@floreks floreks added the enhancement New feature or request label Aug 22, 2024
@michaeljguarino michaeljguarino merged commit 60cb34f into main Aug 22, 2024
33 checks passed
@michaeljguarino michaeljguarino deleted the sebastian/prod-2482-support-stack-variables branch August 22, 2024 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants