diff --git a/.changelog/38168.txt b/.changelog/38168.txt new file mode 100644 index 00000000000..79ed38b1b39 --- /dev/null +++ b/.changelog/38168.txt @@ -0,0 +1,3 @@ +```release-note:bug +data-source/aws_cognito_user_pool_client: Fix `InvalidParameterException: 2 validation errors detected` errors on Read +``` diff --git a/internal/service/cognitoidp/user_pool_client_data_source.go b/internal/service/cognitoidp/user_pool_client_data_source.go index 434d252c584..9d538f4eb9b 100644 --- a/internal/service/cognitoidp/user_pool_client_data_source.go +++ b/internal/service/cognitoidp/user_pool_client_data_source.go @@ -187,7 +187,7 @@ func dataSourceUserPoolClientRead(ctx context.Context, d *schema.ResourceData, m conn := meta.(*conns.AWSClient).CognitoIDPClient(ctx) clientID := d.Get(names.AttrClientID).(string) - userPoolClient, err := findUserPoolClientByTwoPartKey(ctx, conn, d.Get(names.AttrUserPoolID).(string), d.Id()) + userPoolClient, err := findUserPoolClientByTwoPartKey(ctx, conn, d.Get(names.AttrUserPoolID).(string), clientID) if err != nil { return sdkdiag.AppendErrorf(diags, "reading Cognito User Pool Client (%s): %s", clientID, err) diff --git a/internal/service/cognitoidp/user_pool_client_data_source_test.go b/internal/service/cognitoidp/user_pool_client_data_source_test.go index cf9b3f92ca3..e3c8b80694b 100644 --- a/internal/service/cognitoidp/user_pool_client_data_source_test.go +++ b/internal/service/cognitoidp/user_pool_client_data_source_test.go @@ -6,6 +6,7 @@ package cognitoidp_test import ( "testing" + awstypes "github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-provider-aws/internal/acctest" @@ -14,6 +15,7 @@ import ( func TestAccCognitoIDPUserPoolClientDataSource_basic(t *testing.T) { ctx := acctest.Context(t) + var client awstypes.UserPoolClientType rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "data.aws_cognito_user_pool_client.test" @@ -25,6 +27,7 @@ func TestAccCognitoIDPUserPoolClientDataSource_basic(t *testing.T) { { Config: testAccUserPoolClientDataSourceConfig_basic(rName), Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckUserPoolClientExists(ctx, resourceName, &client), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "explicit_auth_flows.#", acctest.Ct1), resource.TestCheckTypeSetElemAttr(resourceName, "explicit_auth_flows.*", "ADMIN_NO_SRP_AUTH"),