Skip to content

[Bug] aws_elasticache_user triggers infinite loop during plan phase when the user has been deleted out of band #43305

Open
@jaloren

Description

@jaloren

Terraform and AWS Provider Version

[workload-prod]$ terraform --version
v1.9.0
on darwin_arm64
+ provider registry.opentofu.org/hashicorp/aws v6.0.0
+ provider registry.opentofu.org/hashicorp/cloudinit v2.3.2
+ provider registry.opentofu.org/hashicorp/random v3.6.2
+ provider registry.opentofu.org/hashicorp/tls v4.0.6
+ provider registry.opentofu.org/viktorradnai/bcrypt v0.1.2

Affected Resource(s) or Data Source(s)

  • aws_elasticache_user

Expected Behavior

If an elasticache user has been deleted and the terraform resource has been removed, then the provider should update the state file by removing the resource

Actual Behavior

run a terraform plan and the plan ends up hung:

Relevant Error/Panic Output

Joe
  [11:27 AM](https://pandemicballpunch.slack.com/archives/D02CX73SJ0K/p1751992073022579)
2025-07-08T11:26:47.023-0500 [DEBUG] provider.terraform-provider-aws: HTTP Response Received: rpc.method=DescribeUsers tf_mux_provider="*schema.GRPCProviderServer" tf_resource_type=aws_elasticache_user @caller=/home/runner/go/pkg/mod/github.com/hashicorp/aws-sdk-go-base/v2@v2.0.0-beta.65/logging/tf_logger.go:45 @module=aws aws.region=us-east-2
  http.response.body=
  | <ErrorResponse xmlns="http://elasticache.amazonaws.com/doc/2015-02-02/">
  |   <Error>
  |     <Type>Sender</Type>
  |     <Code>UserNotFound</Code>
  |     <Message>User prod-nautobot-t4pwt86rh6mb not found.</Message>
  |   </Error>
  |   <RequestId>53d96645-e04f-41da-9774-efb758ab0270</RequestId>
  | </ErrorResponse>
   tf_aws.sdk=aws-sdk-go-v2 tf_aws.signing_region="" http.response.header.date="Tue, 08 Jul 2025 16:26:47 GMT" http.status_code=404 http.response_content_length=293 rpc.system=aws-api tf_provider_addr=registry.terraform.io/hashicorp/aws tf_req_id=8eb00dab-0ca2-d03c-024d-87571f2953eb http.duration=61 http.response.header.content_type=text/xml http.response.header.x_amzn_requestid=53d96645-e04f-41da-9774-efb758ab0270 tf_rpc=ReadResource rpc.service=ElastiCache timestamp=2025-07-08T11:26:47.023-0500
2025-07-08T11:26:47.023-0500 [DEBUG] provider.terraform-provider-aws: request failed with unretryable error https response error StatusCode: 404, RequestID: 53d96645-e04f-41da-9774-efb758ab0270, UserNotFound: User prod-nautobot-t4pwt86rh6mb not found.: @module=aws tf_aws.sdk=aws-sdk-go-v2 tf_provider_addr=registry.terraform.io/hashicorp/aws rpc.method=DescribeUsers rpc.system=aws-api tf_mux_provider="*schema.GRPCProviderServer" tf_req_id=8eb00dab-0ca2-d03c-024d-87571f2953eb tf_resource_type=aws_elasticache_user rpc.service=ElastiCache @caller=/home/runner/go/pkg/mod/github.com/hashicorp/aws-sdk-go-base/v2@v2.0.0-beta.65/logging/tf_logger.go:45 tf_rpc=ReadResource aws.region=us-east-2 timestamp=2025-07-08T11:26:47.023-0500

Sample Terraform Configuration

Click to expand configuration

Steps to Reproduce

  1. add an aws_elasticache_user resource
  2. terraform apply and verify the user has been created.
  3. in the web console for elasticache delete the user
  4. remove the aws_elasticache_user resource from the terraform workspace
  5. run terraform apply again.

Debug Logging

Click to expand log output

GenAI / LLM Assisted Development

n/a

Important Facts and References

No response

Would you like to implement a fix?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAddresses a defect in current functionality.service/elasticacheIssues and PRs that pertain to the elasticache service.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions