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

Nested environments are not imported with project resource #67

Closed
bubalush opened this issue Sep 3, 2021 · 3 comments · Fixed by #68
Closed

Nested environments are not imported with project resource #67

bubalush opened this issue Sep 3, 2021 · 3 comments · Fixed by #68

Comments

@bubalush
Copy link

bubalush commented Sep 3, 2021

Description

I imported Project resource to Terraform with nested environment block. But Terraform wants to create those environments after plan.

Terraform CLI and Terraform AWS Provider Version

Terraform v1.0.5
on darwin_amd64
+ provider registry.terraform.io/launchdarkly/launchdarkly v2.0.0

Affected Resource(s)

  • resource "launchdarkly_project"

Terraform Configuration Files

module "example" {
  source = "./modules/project"

  nested_environments = [
    {
      name  = "Production"
      key   = "production"
      color = "417505"
    },
    {
      name  = "Test"
      key   = "test"
      color = "F5A623"
    },
  ]
  
resource "launchdarkly_project" "this" {
  key                = "example"
  name               = "Example test"
  include_in_snippet = true
  tags               = ["terraform-managed"]

  dynamic "environments" {
    for_each = var.nested_environments
    content {
      name  = environments.value["name"]
      key   = lower(environments.value["name"])
      color = environments.value["color"]
      tags = [
        "terraform-managed",
      ]
    }
  }
}

Expected Behavior

Terraform should import project resource with nested environments.

Actual Behavior

  ~ resource "launchdarkly_project" "this" {
        id                 = "example"
        name               = "Example test"
      ~ tags               = [
          + "terraform-managed",
        ]
        # (2 unchanged attributes hidden)

      + environments {
          + color                = "417505"
          + confirm_changes      = false
          + default_track_events = false
          + default_ttl          = 0
          + key                  = "production"
          + name                 = "Production"
          + require_comments     = false
          + secure_mode          = false
          + tags                 = [
              + "terraform-managed",
            ]
        }
      + environments {
          + color                = "F5A623"
          + confirm_changes      = false
          + default_track_events = false
          + default_ttl          = 0
          + key                  = "test"
          + name                 = "Test"
          + require_comments     = false
          + secure_mode          = false
          + tags                 = [
              + "terraform-managed",
            ]
        }
    }

Steps to Reproduce

    terragrunt import module.example.launchdarkly_project.this example
    terragrunt plan
@ldhenry
Copy link
Collaborator

ldhenry commented Sep 7, 2021

Hey @bubalush,

Thanks for bringing this to our attention. I've created an internal ticket and will be sure to update this issue when a fix is out.

Thanks,
Henry

@bubalush
Copy link
Author

bubalush commented Sep 7, 2021

@ldhenry Thanks.
I edited terraform state manually to add nested environments as a workaround for now.

@sloloris
Copy link
Contributor

Hi @bubalush,
As you can see above, we have addressed this bug in the v2.0.1 release. Please let us know if you encounter any other unexpected behavior and thank you for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants