-
Notifications
You must be signed in to change notification settings - Fork 24
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
Using a dynamic block cause unrelated environments to be part of changes #151
Comments
Hey @rickardp, Thanks for bringing this to our attention. I've created an internal ticket to investigate what is happening here. We'll be sure to update this issue as we learn more. Thanks, |
Hello @ldhenry , Thanks for investigating the issue, we seem to be experiencing the same behaviours. Would you have any update on it? |
By default, the Here's an example config that show how to scaffold a LaunchDarkly project with a set of environments that are defined in a loop: locals {
envs = {
prod = {
name = "Production"
key = "production"
}
staging_uat = {
name = "Staging UAT"
key = "staging-uat"
}
}
}
resource "launchdarkly_project" "project" {
key = "my-project"
name = "My Project"
# At lest one environment needs to be specified in the LaunchDarkly project block
environments {
key = "test"
name = "Test"
color = "000000"
}
# Use the ignore_changes lifecycle meta-argument to prevent changes to
# environments managed elsewhere from interring with the Terraform plan.
lifecycle {
ignore_changes = [environments]
}
}
resource "launchdarkly_environment" "env" {
for_each = local.envs
project_key = "my-project"
name = each.value.name
key = each.value.key
color = endswith(each.value.name, "-live") ? "ff0000" : endswith(each.value.key, "-uat") ? "0000ff" : "00ff00"
}
Please note the use of the Please let me know if this solves the issue for you. Thanks, |
At least in my case, I am managing all of the environments in Terraform and use the nested environment block as per the recommendation in the docs. |
Could this be related to #154? Maybe pagination is why updating the environments get the provider confused. There were more than 20 environments in the original case when I reported this issue |
Hello @ldhenry , Our scenario is when a project is created with like 2 environments, if you add a new block for an environment in the middle of the list, then the following happens. Existing environments: New environment block creation with the new list and order as per below: env1
Then the plan highlight it will rename the current env2 to env1b and will create a brand new env2.
Thanks |
I upgraded our provider to version 2.13.2, Terraform to 1.5.3 and we see the same result, when removing an environment block in the middle of the list, it renames all the environments from that block and delete the last one.
|
Hey @Gilles95, I did some investigation and you are seeing this plan change because the Alternatively, you should not see a diff if you add the new environment to the bottom of the list. I know this is not ideal but it I did find a possible solution for suppressing the diff if the environments are reordered but this would not solve the case where a new environment is added to the middle of the list. I know this is not ideal, but unfortunately we couldn't find a better solution as we are constrained by Terraform's schema limitations. Thanks, |
Hey @rickardp, we released v2.13.3 with a fix for the 20+ environment issue (#154 ). Please give it a try and let me know if you run into any issues. |
Thanks for looking into it! Actually we just confirmed the apply did what was expected. |
Nice! I'm going to close this issue but feel free to re-open it if needed. |
Nice, will check internally if an upgrade fixed the problem. As for the plan changes, shouldn't it be a TypeMap with the env key as key (it is immutable after all, isn't it)? I think the impact is not irrelevant, it will scare the release reviewers on our side as we use the output from terraform plan as part of our deployment pipelines. Would it be possible to fix? |
Hey @rickardp, I think a TypeMap sounds like a good change in the future. Unfortunately this would constitute a breaking change so we would have to deprecate the existing I'll also reopen this issue so others can follow along more easily. Thanks, |
Example terraform code
When the list of environments change, all the environments diff, e.g.
When trying to apply this
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
The text was updated successfully, but these errors were encountered: