Skip to content

Using a dynamic block cause unrelated environments to be part of changes #151

Open
@rickardp

Description

@rickardp

Example terraform code

resource "launchdarkly_project" "project" {
  key  = "my-project"
  name = "My Project"

  dynamic "environments" {
    for_each = local.environments
    content {
      name  = environments.value.name
      key   = environments.key
      color = endswith(environments.key, "-live") ? "ff0000" : endswith(environments.key, "-uat") ? "0000ff" : "00ff00"
    }
  }
}

When the list of environments change, all the environments diff, e.g.

# launchdarkly_project.project will be updated in-place
      ~ resource "launchdarkly_project" "project" {
            key  = "my-project"
            name = "My Project"
            # (2 unchanged attributes hidden)
          ~ environments {
              + color                = "00ff00"
              + default_ttl          = 0
              + key                  = "(key of unchanged environment)"
              + name                 = "...."
              ....
            }
          ~ environments {
              .... // other unchanged environment
            }
          ~ environments {
              .... // added environment
            }

When trying to apply this

Error: failed to create environment "(key of uncahnged environment)" in project "us-client": 409 Conflict: {"code":"conflict","message":"Project already has an environment with key \"(key of unchanged environment)\""}

This is reasonable, because the environment exists in the LD UI. But expectation is for the unchanged environment to not be modified at all and not be part of the plan output.

This was attempted with the latest provider, 2.12.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions