terraform-provider-launchdarkly icon indicating copy to clipboard operation
terraform-provider-launchdarkly copied to clipboard

launchdarkly_environment resource produces "Provider produced inconsistent Result after apply"

Open wondersd opened this issue 5 years ago • 9 comments

Every once in a while this comes up during creation of a new launchdarkly_environment resource.

Error: Provider produced inconsistent result after apply

When applying changes to
launchdarkly_environment.environment,
provider "registry.terraform.io/-/launchdarkly" produced an unexpected new
value for was present, but now absent.

This is a bug in the provider, which should be reported in the provider's own issue tracker.
resource "launchdarkly_environment" "environment" {
  name = "name"
  key   = "key"
  color = "color"
  tags  = [ "tag" ]
  project_key = "default"
}

wondersd avatar Jul 28 '20 20:07 wondersd

Thanks @wondersd, this is not ideal. When you get a chance can you you share the output of terraform -v to help me reproduce this issue?

Thanks, Henry

ldhenry avatar Jul 29 '20 17:07 ldhenry

@ldhenry I cranked the logs on our process when we create the environment. This one doesn't happen as often as the other issue i opened (#30), when it happens again I'll post the logs.

wondersd avatar Jul 31 '20 19:07 wondersd

I'll prioritize #30 for now since it is affecting you more frequently. However, I do want to get to the bottom of this so please do post any logs if possible.

Thanks, Henry

ldhenry avatar Jul 31 '20 20:07 ldhenry

I was able to reproduce using:

resource "launchdarkly_environment" "test" {
  count = 200
  name = format("%v%v", "foo", count.index)
  key = format("%v%v", "foo", count.index)
  color = 200596
  project_key = "default"
}

it took several iterations of terraform apply and terraform destroy but eventually the problem appeared.

Some of the more notable sections (most of the log looks like regular log output)

2020/08/03 14:01:32 [DEBUG] launchdarkly_environment.test[60]: applying the planned Create change
2020/08/03 14:01:32 [WARN] Provider "registry.terraform.io/-/launchdarkly" produced an unexpected new value for launchdarkly_environment.test[57], but we are tolerating it because it is using the legacy plugin SDK.
    The following problems may be the cause of any confusing errors from downstream operations:
      - .default_track_events: was null, but now cty.False
      - .default_ttl: was null, but now cty.NumberIntVal(0)
      - .require_comments: was null, but now cty.False
      - .confirm_changes: was null, but now cty.False
      - .secure_mode: was null, but now cty.False

This is seen on successful and failed attempts and the order displayed is inconsistent

2020/08/03 14:01:14 [DEBUG] launchdarkly_environment.test[28]: applying the planned Create change
2020-08-03T14:01:14.517-0400 [DEBUG] plugin.terraform-provider-launchdarkly_v1.3.2_x4: 2020/08/03 14:01:14 [WARN] failed to find environment with key "foo145" in project "default", removing from state
2020/08/03 14:01:14 [DEBUG] launchdarkly_environment.test[145]: apply errored, but we're indicating that via the Error pointer rather than returning it: Provider produced inconsistent result after apply: When applying changes to launchdarkly_environment.test[145], provider "registry.terraform.io/-/launchdarkly" produced an unexpected new value for was present, but now absent.

This is a bug in the provider, which should be reported in the provider's own issue tracker.
2020/08/03 14:01:14 [ERROR] <root>: eval: *terraform.EvalApplyPost, err: Provider produced inconsistent result after apply: When applying changes to launchdarkly_environment.test[145], provider "registry.terraform.io/-/launchdarkly" produced an unexpected new value for was present, but now absent.

This is a bug in the provider, which should be reported in the provider's own issue tracker.
2020/08/03 14:01:14 [ERROR] <root>: eval: *terraform.EvalSequence, err: Provider produced inconsistent result after apply: When applying changes to launchdarkly_environment.test[145], provider "registry.terraform.io/-/launchdarkly" produced an unexpected new value for was present, but now absent.

This is a bug in the provider, which should be reported in the provider's own issue tracker.

wondersd avatar Aug 03 '20 18:08 wondersd

Excellent. Thanks for the resource and logs. This should help narrow things down.

ldhenry avatar Aug 03 '20 18:08 ldhenry

Hey @ldhenry! I'm running into a similar issue at the moment. Have you managed to find the root cause?

disposedtrolley avatar Apr 14 '22 05:04 disposedtrolley

Hi @disposedtrolley,

We have been having trouble reproducing this error on our side. If possible can you share any relevant resource config and the output of terraform -v?

Thanks, Henry

ldhenry avatar Apr 14 '22 12:04 ldhenry

Hello @ldhenry

I am currently using terraform provider version v2.8.0 and it looks like I am encountering same issue when using dynamic environments blocks Here is the terraform -v result :

terraform -v
Terraform v1.2.3
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v4.26.0
+ provider registry.terraform.io/hashicorp/time v0.8.0
+ provider registry.terraform.io/launchdarkly/launchdarkly v2.8.0

Your version of Terraform is out of date! The latest version
is 1.2.7. You can update by downloading from https://www.terraform.io/downloads.html

In my situation, I am adding some new dynamic environments into an already existing project, and I am expecting to retrieve the client_side_id, api_key and mobile_key to store those into secrets manager.

When running a terraform apply with debug information, here is the log lines catching the issue.

022-08-16T17:21:32.287+0200 [WARN]  Provider "provider[\"registry.terraform.io/launchdarkly/launchdarkly\"]" produced an unexpected new value for module.vault_launchdarkly.launchdarkly_project.test["test"], but we are tolerating it because it is using the legacy plugin SDK.
    The following problems may be the cause of any confusing errors from downstream operations:
      - .environments[1].client_side_id: inconsistent values for sensitive attribute
      - .environments[1].api_key: inconsistent values for sensitive attribute
      - .environments[1].mobile_key: inconsistent values for sensitive attribute

It appears those values are empty.

When applying a second time consecutively then it's working fine.

Would it be possible to investigate on that one ? Do you need me to open another ticket ? Do you want more information to reproduce that issue ?

rjauregui-ledger avatar Aug 16 '22 15:08 rjauregui-ledger

Hey @rjauregui-ledger,

I'm sorry to hear you're running into this issue. Would it be possible to provide us with a snippet of the resource that is causing you problems to help us better reproduce this issue?

By the way, if you are just looking to the client_side_id, api_key and mobile_key to store those into a secret manager have you considered using our luaunchdarkly_environment data source?

ldhenry avatar Aug 17 '22 09:08 ldhenry

Closing because this issue is 5 years old.

sloloris avatar Feb 06 '25 18:02 sloloris