hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.86k stars 9.21k forks source link

[Bug]: elasticache_serverless_cache fails to modify the snapshot_retention_limit #37499

Open hugomcfonseca opened 6 months ago

hugomcfonseca commented 6 months ago

Terraform Core Version

1.6.6

AWS Provider Version

5.37.0

Affected Resource(s)

Expected Behavior

After running terraform apply trying to disable the snapshots on an existing aws_elasticache_serverless_cache resource, the system should modify the resource and not result in an error.

Actual Behavior

The apply was not succeeded and it returned an error ("InvalidParameterCombination: Serverless Cache modifications only support modifying one field per request").

I've tried to replicate the same API_ModifyServerlessCache via AWS CLI, and I've got success only if I've removed the UserGroupId from the request (even though it is not part of the changes on Terraform plan).

From the AWS Documentation, there is no reference about possible constraints about this.

Relevant Error/Panic Output Snippet

╷
│ Error: updating ElastiCache Serverless Cache (xxx-xxx-xxx)
│ 
│   with aws_elasticache_serverless_cache.this,
│   on main.tf line 1, in resource "aws_elasticache_serverless_cache" "this":
│    1: resource "aws_elasticache_serverless_cache" "this" {
│ 
│ operation error ElastiCache: ModifyServerlessCache, https response error
│ StatusCode: 400, RequestID: 3c9d437b-2af7-4c32-b0e7-79d351a01ebe,
│ InvalidParameterCombination: Serverless Cache modifications only support
│ modifying one field per request.

Terraform Configuration Files

image

Steps to Reproduce

  1. Modify the value of snapshot_retention_limit
  2. Apply it (it will error)

Debug Output

2024-05-14T10:58:55.105+0100 [INFO]  Starting apply for aws_elasticache_serverless_cache.this
2024-05-14T10:58:55.110+0100 [DEBUG] aws_elasticache_serverless_cache.this: applying the planned Update change
2024-05-14T10:58:55.114+0100 [DEBUG] provider.terraform-provider-aws_v5.37.0_x5: HTTP Request Sent: http.request.header.x_amz_security_token="*****" rpc.system=aws-api tf_mux_provider="*proto5server.Server" tf_provider_addr=registry.terraform.io/hashicorp/aws @caller=github.com/hashicorp/aws-sdk-go-base/v2@v2.0.0-beta.47/logging/tf_logger.go:45 http.url=https://elasticache.eu-west-1.amazonaws.com/ net.peer.name=elasticache.eu-west-1.amazonaws.com rpc.service=ElastiCache tf_aws.sdk=aws-sdk-go-v2 aws.region=eu-west-1 http.request_content_length=282 tf_req_id=7cd9d932-efcf-d6d3-6126-34ceaf074649 http.request.header.amz_sdk_invocation_id=982d1bae-fa86-4628-a989-8ac5dd31e55d http.request.header.authorization="AWS4-HMAC-SHA256 Credential=ASIA************PENL/20240514/eu-west-1/elasticache/aws4_request, SignedHeaders=amz-sdk-invocation-id;amz-sdk-request;content-length;content-type;host;x-amz-date;x-amz-security-token, Signature=*****" @module=aws http.request.header.content_type=application/x-www-form-urlencoded tf_resource_type=aws_elasticache_serverless_cache tf_rpc=ApplyResourceChange tf_aws.signing_region="" http.method=POST
  http.request.body=
  | Action=ModifyServerlessCache&DailySnapshotTime=03%3A00&Description=Service+XXXX+cache&SecurityGroupIds.SecurityGroupId.1=sg-xxxxxxxx&ServerlessCacheName=service-xxxx-xxxx&SnapshotRetentionLimit=0&UserGroupId=service-xxxx-xxxx&Version=2015-02-02
   http.request.header.amz_sdk_request="attempt=1; max=25" http.request.header.x_amz_date=20240514T095855Z rpc.method=ModifyServerlessCache http.user_agent="APN/1.0 HashiCorp/1.0 Terraform/1.6.6 (+https://www.terraform.io) terraform-provider-aws/5.37.0 (+https://registry.terraform.io/providers/hashicorp/aws) aws-sdk-go-v2/1.25.0 os/macos lang/go#1.21.7 md/GOOS#darwin md/GOARCH#arm64 api/elasticache#1.35.0" timestamp="2024-05-14T10:58:55.114+0100"
2024-05-14T10:58:55.615+0100 [DEBUG] provider.terraform-provider-aws_v5.37.0_x5: HTTP Response Received: rpc.service=ElastiCache tf_provider_addr=registry.terraform.io/hashicorp/aws @caller=github.com/hashicorp/aws-sdk-go-base/v2@v2.0.0-beta.47/logging/tf_logger.go:45 http.response.header.date="Tue, 14 May 2024 09:58:55 GMT" rpc.method=ModifyServerlessCache tf_aws.signing_region="" tf_mux_provider="*proto5server.Server" tf_resource_type=aws_elasticache_serverless_cache @module=aws aws.region=eu-west-1 rpc.system=aws-api tf_aws.sdk=aws-sdk-go-v2 tf_req_id=7cd9d932-efcf-d6d3-6126-34ceaf074649 tf_rpc=ApplyResourceChange http.duration=498 http.response.header.content_type=text/xml http.response.header.x_amzn_requestid=da52722d-bccd-4ba1-bdf2-7cd4e81fbb73 http.response_content_length=342 http.status_code=400
  http.response.body=
  | <ErrorResponse xmlns="http://elasticache.amazonaws.com/doc/2015-02-02/">
  |   <Error>
  |     <Type>Sender</Type>
  |     <Code>InvalidParameterCombination</Code>
  |     <Message>Serverless Cache modifications only support modifying one field per request.</Message>
  |   </Error>
  |   <RequestId>da52722d-bccd-4ba1-bdf2-7cd4e81fbb73</RequestId>
  | </ErrorResponse>
   timestamp="2024-05-14T10:58:55.614+0100"
2024-05-14T10:58:55.618+0100 [DEBUG] provider.terraform-provider-aws_v5.37.0_x5: request failed with unretryable error https response error StatusCode: 400, RequestID: da52722d-bccd-4ba1-bdf2-7cd4e81fbb73, InvalidParameterCombination: Serverless Cache modifications only support modifying one field per request.: rpc.service=ElastiCache tf_req_id=7cd9d932-efcf-d6d3-6126-34ceaf074649 rpc.system=aws-api tf_aws.sdk=aws-sdk-go-v2 tf_resource_type=aws_elasticache_serverless_cache rpc.method=ModifyServerlessCache tf_provider_addr=registry.terraform.io/hashicorp/aws @caller=github.com/hashicorp/aws-sdk-go-base/v2@v2.0.0-beta.47/logging/tf_logger.go:45 @module=aws aws.region=eu-west-1 tf_mux_provider="*proto5server.Server" tf_rpc=ApplyResourceChange timestamp="2024-05-14T10:58:55.616+0100"
2024-05-14T10:58:55.618+0100 [ERROR] provider.terraform-provider-aws_v5.37.0_x5: Response contains error diagnostic: diagnostic_detail="operation error ElastiCache: ModifyServerlessCache, https response error StatusCode: 400, RequestID: da52722d-bccd-4ba1-bdf2-7cd4e81fbb73, InvalidParameterCombination: Serverless Cache modifications only support modifying one field per request." diagnostic_summary="updating Amazon ElastiCache Serverless Cache (service-xxxx-xxxx): operation error ElastiCache: ModifyServerlessCache, https response error StatusCode: 400, RequestID: da52722d-bccd-4ba1-bdf2-7cd4e81fbb73, InvalidParameterCombination: Serverless Cache modifications only support modifying one field per request." @caller=github.com/hashicorp/terraform-plugin-go@v0.21.0/tfprotov5/internal/diag/diagnostics.go:62 @module=sdk.proto tf_proto_version=5.4 tf_req_id=7cd9d932-efcf-d6d3-6126-34ceaf074649 tf_rpc=ApplyResourceChange diagnostic_severity=ERROR tf_provider_addr=registry.terraform.io/hashicorp/aws tf_resource_type=aws_elasticache_serverless_cache timestamp="2024-05-14T10:58:55.616+0100"
2024-05-14T10:58:55.621+0100 [DEBUG] State storage *remote.State declined to persist a state snapshot
2024-05-14T10:58:55.622+0100 [ERROR] vertex "aws_elasticache_serverless_cache.this" error: updating Amazon ElastiCache Serverless Cache (service-xxxx-xxxx): operation error ElastiCache: ModifyServerlessCache, https response error StatusCode: 400, RequestID: da52722d-bccd-4ba1-bdf2-7cd4e81fbb73, InvalidParameterCombination: Serverless Cache modifications only support modifying one field per request.

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

No

github-actions[bot] commented 6 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

Tiago-FM commented 1 day ago

I've came across the same bug while modifying the security group for the elasticache. Changing in the console caused no issues (modified successfully)