Error writing state file: Error uploading state: 409 Conflict

Hi,

When I do am import of the resource from the Okta server like below, I get the following Error.

terraform import okta_app_signon_policy.consumer_app_policy xxxxxxxxxxxxx

Error: Error locking state: Error acquiring the state lock: resource not found

Terraform acquires a state lock to protect the state from being written

by multiple users at the same time. Please resolve the issue above and try

again. For most commands, you can disable locking with the “-lock=false”

flag, but this is not recommended.

After disabling locking and I get this error:

terraform import -lock=false okta_app_signon_policy.consumer_app_policy rst62jkyh6HbYb94R1d7

okta_app_signon_policy.consumer_app_policy: Importing from ID “rst62jkyh6HbYb94R1d7”…

okta_app_signon_policy.consumer_app_policy: Import prepared!

Prepared okta_app_signon_policy for import

okta_app_signon_policy.consumer_app_policy: Refreshing state… [id=rst62jkyh6HbYb94R1d7]

Error writing state file: Error uploading state: 409 Conflict

Here is the Trace output snippet of the same command execution:

……

2024-08-08T16:20:00.350-0400 [DEBUG] plugin.terraform-provider-okta_v4.9.1: -----------------------------------------------------

2024-08-08T16:20:00.351-0400 [TRACE] plugin.terraform-provider-okta_v4.9.1: Called downstream: @caller=github.com/hashicorp/terraform-plugin-sdk/v2@v2.30.0/helper/schema/resource.go:1090 @module=sdk.helper_schema tf_mux_provider=*schema.GRPCProviderServer tf_provider_addr=okta/okta tf_req_id=2b8527bf-72be-1265-b4b2-aca0c9676e58 tf_resource_type=okta_app_signon_policy tf_rpc=ReadResource timestamp=2024-08-08T16:20:00.351-0400

2024-08-08T16:20:00.352-0400 [TRACE] plugin.terraform-provider-okta_v4.9.1: Received downstream response: tf_req_id=2b8527bf-72be-1265-b4b2-aca0c9676e58 @caller=github.com/hashicorp/terraform-plugin-go@v0.22.2/tfprotov5/internal/tf5serverlogging/downstream_request.go:42 @module=sdk.proto diagnostic_error_count=0 diagnostic_warning_count=0 tf_proto_version=5.4 tf_req_duration_ms=712 tf_resource_type=okta_app_signon_policy tf_rpc=ReadResource tf_provider_addr=okta/okta timestamp=2024-08-08T16:20:00.351-0400

2024-08-08T16:20:00.352-0400 [TRACE] plugin.terraform-provider-okta_v4.9.1: Served request: @module=sdk.proto tf_proto_version=5.4 tf_rpc=ReadResource @caller=github.com/hashicorp/terraform-plugin-go@v0.22.2/tfprotov5/tf5server/server.go:789 tf_provider_addr=okta/okta tf_req_id=2b8527bf-72be-1265-b4b2-aca0c9676e58 tf_resource_type=okta_app_signon_policy timestamp=2024-08-08T16:20:00.351-0400

2024/08/08 16:20:00 [WARN] Provider “Terraform Registry” produced an unexpected new value for okta_app_signon_policy.consumer_app_policy during refresh.

  • .description: was null, but now cty.StringVal(“Default paLoginCloud sign-on policy for consumers (e.g. students and professionals).\n”)

  • .name: was null, but now cty.StringVal(“Consumer App Policy - Default”)

2024/08/08 16:20:00 [TRACE] EvalWriteState: writing current state object for okta_app_signon_policy.consumer_app_policy

2024/08/08 16:20:00 [TRACE] vertex “import okta_app_signon_policy.consumer_app_policy result”: visit complete

2024/08/08 16:20:00 [TRACE] vertex “okta_app_signon_policy.consumer_app_policy (import id "rst62jkyh6HbYb94R1d7")”: dynamic subgraph completed successfully

2024/08/08 16:20:00 [TRACE] vertex “okta_app_signon_policy.consumer_app_policy (import id "rst62jkyh6HbYb94R1d7")”: visit complete

2024/08/08 16:20:00 [TRACE] dag/walk: visiting “provider["registry.terraform.io/okta/okta"] (close)”

2024/08/08 16:20:00 [TRACE] vertex “provider["registry.terraform.io/okta/okta"] (close)”: starting visit (*terraform.graphNodeCloseProvider)

2024/08/08 16:20:00 [TRACE] GRPCProvider: Close

2024-08-08T16:20:00.354-0400 [WARN] plugin.stdio: received EOF, stopping recv loop: err=“rpc error: code = Unavailable desc = transport is closing”

2024-08-08T16:20:00.357-0400 [DEBUG] plugin: plugin process exited: path=.terraform/providers/registry.terraform.io/okta/okta/4.9.1/darwin_amd64/terraform-provider-okta_v4.9.1 pid=64190

2024-08-08T16:20:00.357-0400 [DEBUG] plugin: plugin exited

2024/08/08 16:20:00 [TRACE] vertex “provider["registry.terraform.io/okta/okta"] (close)”: visit complete

2024/08/08 16:20:00 [TRACE] dag/walk: visiting “root”

2024/08/08 16:20:00 [TRACE] vertex “root”: starting visit (*terraform.nodeCloseModule)

2024/08/08 16:20:00 [TRACE] vertex “root”: visit complete

2024/08/08 16:20:00 [INFO] Writing state output to:

Error writing state file: Error uploading state: 409 Conflict

==========================================
I am not sure why it’s having issue to write to the remote state file.

Thanks,

J. George