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

How do you specify HCL in the env0_enviroment resource configuration? #390

Closed
mmclane opened this issue May 20, 2022 · 4 comments · Fixed by #398
Closed

How do you specify HCL in the env0_enviroment resource configuration? #390

mmclane opened this issue May 20, 2022 · 4 comments · Fixed by #398
Assignees
Labels
enhancement New feature or request

Comments

@mmclane
Copy link

mmclane commented May 20, 2022

I have a module I use to create all of my projects and environments. My environments sub-module looks like this:

data "env0_template" "this" {
  name = var.template
}

data "env0_project" "this" {
  name = var.project
}

resource "env0_environment" "this" {
  name                       = var.name
  project_id                 = data.env0_project.this.id
  template_id                = data.env0_template.this.id
  workspace                  = var.workspace == "---" ? var.name : var.workspace
  approve_plan_automatically = var.approve_plan_automatically
  deploy_on_push             = var.deploy_on_push
  force_destroy              = var.force_destroy
  run_plan_on_pull_requests  = var.run_plan_on_pull_requests

  dynamic "configuration" {
    for_each = var.configuration
    content {
      name  = configuration.key
      value = configuration.value
      type  = "terraform"
    }
  }
}

I have recently create a template that has HCL formatted variables. When I create the environment by hand I can input a multi-line list and everything is good. How can I achieve the same thing with the terraform provider? So far I have tried to something like this:

config = {
    items =<<END
    [
    "item1",
    "item2",
    "item3"
    ]
   END
}

But when env0 runs that deployment the format is switch to String and I think the formatting is getting in the way.

I have tried a few things including creating a second dynamic configuration block and setting format = "HCL" or schema_format= "HCL" but got an error about it not being appropriate or valid or something.

How can I achieve this? The documentation doesn't have an example.

@yaronya
Copy link
Contributor

yaronya commented May 22, 2022

Hi @mmclane
Thanks for reaching out on this one!

This is indeed unsupported at the moment, but we'll make sure to add such support soon in the upcoming version

@yaronya yaronya added the enhancement New feature or request label May 22, 2022
@yaronya yaronya added this to To do in Ongoing Issues via automation May 22, 2022
@TomerHeber TomerHeber moved this from To do to In progress in Ongoing Issues May 23, 2022
@TomerHeber
Copy link
Collaborator

@mmclane

Could you please retry?

I can confirm the following example now works:

resource "env0_environment" "environment123" {
  name                             = "environment"
  project_id                       = "3189ee49-5093-4790-951d-c89f98f8fe13"
  template_id                      = "565e8626-8c2e-4174-a8b8-a1de259376f3"
  workspace                        = "env04d60cf"
  auto_deploy_on_path_changes_only = false

  configuration {
    name          = "TEST1234"
    type          = "terraform"
    value         = <<EOF
      {
        a = "world11111"
        b = {
          c = "d"
        }
      }
    EOF
    schema_format = "HCL"
  }
}

@mmclane
Copy link
Author

mmclane commented May 27, 2022

I can verify that what you have works with the latest version of the provider. Thanks

@TomerHeber
Copy link
Collaborator

@mmclane thank you for confirming.
I will add this example to the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging a pull request may close this issue.

3 participants