lgallard / terraform-aws-cognito-user-pool

Terraform module to create Amazon Cognito User Pools, configure its attributes and resources such as app clients, domain, resource servers. Amazon Cognito User Pools provide a secure user directory that scales to hundreds of millions of users.
Apache License 2.0
88 stars 96 forks source link

Error when running terraform apply - The plugin.(*GRPCProvider).ApplyResourceChange request was cancelled. #148

Open boerbk82 opened 2 months ago

boerbk82 commented 2 months ago

I am using the AWS provider version 5.42.0 and the latest module version (0.29.0). It is not happening for every project referencing the module but I am sometimes seeing that the "terraform apply" fails with the below error message:

module.aws_cognito_user_pool.aws_cognito_user_pool.pool[0]: Modifying... [id=us-east-1_mW0RzMqbz] ╷ │ Error: Request cancelled │ │ with module.aws_cognito_user_pool.aws_cognito_user_pool.pool[0], │ on .terraform/modules/aws_cognito_user_pool/main.tf line 1, in resource "aws_cognito_user_pool" "pool": │ 1: resource "aws_cognito_user_pool" "pool" { │ │ The plugin.(*GRPCProvider).ApplyResourceChange request was cancelled. ╵

Stack trace from the terraform-provider-aws_v5.42.0_x5 plugin:

panic: runtime error: index out of range [0] with length 0

goroutine 53 [running]: github.com/hashicorp/terraform-provider-aws/internal/service/cognitoidp.resourceUserPoolUpdate({0x12f7d928?, 0xc001dbd290}, 0xc000dff980, {0x114b87a0?, 0xc0050690a0}) github.com/hashicorp/terraform-provider-aws/internal/service/cognitoidp/user_pool.go:1035 +0x2810 github.com/hashicorp/terraform-provider-aws/internal/provider.New.(wrappedResource).Update.interceptedHandler[...].func10(0x0?, {0x114b87a0?, 0xc0050690a0?}) github.com/hashicorp/terraform-provider-aws/internal/provider/intercept.go:113 +0x283 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(Resource).update(0x12f7d928?, {0x12f7d928?, 0xc001c923c0?}, 0xd?, {0x114b87a0?, 0xc0050690a0?}) github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:807 +0x7a github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(Resource).Apply(0xc001208620, {0x12f7d928, 0xc001c923c0}, 0xc0014005b0, 0xc000dff400, {0x114b87a0, 0xc0050690a0}) github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:919 +0x83a github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(GRPCProviderServer).ApplyResourceChange(0xc005058300, {0x12f7d928?, 0xc001c922d0?}, 0xc001c90000) github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/grpc_provider.go:1078 +0xdbc github.com/hashicorp/terraform-plugin-mux/tf5muxserver.(muxServer).ApplyResourceChange(0x12f7d960?, {0x12f7d928?, 0xc001c77fb0?}, 0xc001c90000) github.com/hashicorp/terraform-plugin-mux@v0.15.0/tf5muxserver/mux_server_ApplyResourceChange.go:36 +0x193 github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(server).ApplyResourceChange(0xc000918dc0, {0x12f7d928?, 0xc001c775c0?}, 0xc000733490) github.com/hashicorp/terraform-plugin-go@v0.22.0/tfprotov5/tf5server/server.go:846 +0x3d0 github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x11261960?, 0xc000918dc0}, {0x12f7d928, 0xc001c775c0}, 0xc000d11a80, 0x0) github.com/hashicorp/terraform-plugin-go@v0.22.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:518 +0x169 google.golang.org/grpc.(Server).processUnaryRPC(0xc0016c0000, {0x12f7d928, 0xc001c77530}, {0x12fb6938, 0xc005046b60}, 0xc001c826c0, 0xc004713c80, 0x1b175a78, 0x0) google.golang.org/grpc@v1.62.0/server.go:1383 +0xe03 google.golang.org/grpc.(Server).handleStream(0xc0016c0000, {0x12fb6938, 0xc005046b60}, 0xc001c826c0) google.golang.org/grpc@v1.62.0/server.go:1794 +0x100c google.golang.org/grpc.(Server).serveStreams.func2.1() google.golang.org/grpc@v1.62.0/server.go:1027 +0x8b created by google.golang.org/grpc.(Server).serveStreams.func2 in goroutine 8 google.golang.org/grpc@v1.62.0/server.go:1038 +0x135

Error: The terraform-provider-aws_v5.42.0_x5 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely helpful if you could report the crash with the plugin's maintainers so that it can be fixed. The output above should help diagnose the issue.

lgallard commented 1 month ago

@boerbk82 not sure if this an issue in this module or something related to the AWS provider. On the other hand, if it happens in some module's references but not in others I would recommend you to check your local TF state and configuration.

Did you try increasing the log verbosity to have more info about the issue?

boerbk82 commented 1 month ago

Thanks for the reply @lgallard. I increased the log verbosity and re-ran the terraform apply. Attached are those logs.
terraform.txt

I was able to workaround the issue by deleting the user pool altogether (it is in a non-prod environment) and recreate it. Fortunately we have not seen this issue for any production user pools at this time.