I've integrated AWS Cognito User Pools into my app, as outlined in this article: http://snevsky.com/blog/dotnet-core-authentication-aws-cognito using these packages: AWSSDK.Core and AWSSDK.CognitoIdentityProvider.
In my dev environment, it works well: I can call AdminInitiateAuthAsync to authenticate a user, and I can call SignUpAsync to create a new user. Other methods work well too--in my dev environment.
However, when I deploy my code to Lambda, it doesn't work. Specifically, it's hanging on this line:
var response = await cognito.AdminInitiateAuthAsync(request);
Eventually, I get an error in CloudWatch saying Task timed out. However, it doesn't tell me why. Based on my past experience with Lambda and AWS, I assume it's a permissions issue between Lambda and Cognito, but this is just a guess.
A couple things I've tried:
- As outlined in the article, I added two dev environment settings:
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEY. However, Lambda won't let you set these specific keys as Environment Variables. So, as a test, I tried setting these explicitly in my code:
var credentials = new BasicAWSCredentials("myAccessKey", "mySecretKey");
var region = RegionEndpoint.GetBySystemName("myRegionId");
var cognito = new AmazonCognitoIdentityProviderClient(credentials, region);
- I added admin permissions to the Lambda Execution role.
Any help appreciated.