Reputation: 901
I'm trying to connect to aws cognito from a java backend, but when it comes to testing it inside AWS Lambda, it throws me an exception with the following message:
"errorMessage": "User pool XXXXX does not exist. (Service: AWSCognitoIdentityProvider; Status Code: 400; Error Code: ResourceNotFoundException; Request ID: -------------)"
The credentials that I have entered are correct, because I have tested them in a python code and it works correctly.
this is the code with which I made the connection:
private AdminInitiateAuthRequest buildAuhtRequest(String email, String password){
Map<String,String> authParams = new HashMap<String,String>();
authParams.put("email", email);
authParams.put("password", password);
return new AdminInitiateAuthRequest()
.withAuthFlow(AuthFlowType.ADMIN_NO_SRP_AUTH)
.withAuthParameters(authParams)
.withClientId(credentials.getClientId())
.withUserPoolId(credentials.getPoolId());
}
and this is the class of credentials, although it is super simple:
public class CognitoClientCredentials {
private String poolId = "xxxxxxxxx";
private String clientId = "xxxxxxxxxxxxxxxx";
public String getPoolId(){
return this.poolId;
}
public String getClientId(){
return this.clientId;
}
}
Upvotes: 2
Views: 10479
Reputation: 15
I had multiple AWS profiles setup, so I had to change my default one to be the AWS instance I wanted to connect to and that worked
Upvotes: 0
Reputation: 843
This answer is for someone who could be having an user pool related error. Such error started to appear to me after I changed the verification type from 'code' to 'link' in AWS Cognito. The issue got solved by just setting up a domain name in the 'App Integration' tab in my user pool settings.
This thread helped me to solve my issue -> https://github.com/amazon-archives/amazon-cognito-identity-js/issues/512
Upvotes: 2
Reputation: 66
What happened to me was...
the AWS.Config grabbed my profile from my Windows 10 user account (.aws/credentials).
So, programatically I had to modify the AWS.config.credentials
Upvotes: 0
Reputation: 153
It's possible that locally you have already setup the aws environment with a default region, access key and access secret; while you lambda role is not authorizes to handle that Cognito Pool that you are specifying. Try to augment the permissions of you lambda role.
Upvotes: 1
Reputation: 556
Set the region and try so your function identify which region to check under the cognito.
Upvotes: 1