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

bug - configuration variable that overrides a template variable in env0_environment shows drift #894

Open
away168 opened this issue Jul 10, 2024 · 1 comment · Fixed by #889
Assignees
Labels
bug Something isn't working

Comments

@away168
Copy link
Contributor

away168 commented Jul 10, 2024

Describe the bug
A variable defined in the env0_template is being overwritten | specified in env0_environment that uses the template.

the plan shows drift of parameters that are not meant to be re-configured (e.g. regex, is_required, description

  ~ resource "env0_environment" "default_projects" {
        id                               = "f29bfdca-1a77-49dd-b197-f2f0c4913a99"
        name                             = "Skunkworks Project"
      ~ variable_sets                    = [
          - "69cfcac0-5135-4967-a9d5-c6166f216f4c",
        ]
        # (13 unchanged attributes hidden)

      ~ configuration {
          - description  = "main project name for team" -> null
          ~ is_required  = true -> false
            name         = "team_name"
          - regex        = "[a-zA-Z0-9-_]*" -> null
            # (6 unchanged attributes hidden)
        }
    }

To Reproduce

  1. Create an env0_template and env0_configuration_variable attached to template.
  2. Create an env0_environment that is deployed from template with a configuration variable that overrides the template variable.

Expected behavior
the env0_environment should not show drift.

Provider Version
v1.19.1

Screenshots

Additional context
Sample code:

resource "env0_template" "projects" {
  name                   = "Team Projects"
  type                   = "opentofu"
  description            = "Project Factory for onboarding new teams"
  opentofu_version       = "latest"
  repository             = data.env0_template.this.repository
  path                   = "env0/projects"
  github_installation_id = data.env0_template.this.github_installation_id
}

resource "env0_template_project_assignment" "projects" {
  template_id = env0_template.projects.id
  project_id  = data.env0_environment.this.project_id
}

resource "env0_configuration_variable" "team_name" {
  template_id = env0_template.projects.id
  name        = "team_name"
  description = "main project name for team"
  is_required = true
  regex       = "[a-zA-Z0-9-_]*"
  type        = "terraform"
}

resource "env0_environment" "default_projects" {
  count = var.create_projects ? 1 : 0

  name                       = "${var.default_team_name} Project"
  project_id                 = data.env0_environment.this.project_id
  template_id                = env0_template.projects.id
  approve_plan_automatically = true
  is_remote_backend          = true
  removal_strategy           = "mark_as_archived"
  workspace                  = "${var.default_team_name}_project"

  configuration {
    name        = "team_name"
    value       = var.default_team_name
    type        = "terraform"
  }

  depends_on = [env0_configuration_variable.team_name]
}
@away168 away168 added the bug Something isn't working label Jul 10, 2024
@TomerHeber TomerHeber reopened this Jul 11, 2024
@TomerHeber
Copy link
Collaborator

re-opened. This is a different issue than the variable set issue.
Will reviewe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: In progress
Development

Successfully merging a pull request may close this issue.

2 participants