Skip to main content

AWS Cognito

With this integration you can engage customers with flexible authentication, manage B2B identities, secure machine-to-machine authentication or get role-based access to AWS resources.

TagsawssecuritySaas

Credential configuration

To fill the form params you need the Access key id and the Secret access key of the Programatic access user you want to use. This user needs the permissions to have access to Lambda to work properly. If you need to create the user, you can see how to do it here.

In the extra options field you can pass any of the params you can find here.

Here you have an example of a filled credential configuration form in YepCode:

AWS Lambda snippets available in YepCode editor

note

The title is the triggering text for YepCode to autocomplete the script

Integration

New integration from credential
const ${1:awsCognitoClient} = yepcode.integration.awsCognito("${2:credential-slug}");
New integration from plain authentication data
const { CognitoIdentityProviderClient } = require("@aws-sdk/client-cognito-identity-provider");

const ${1:awsCognitoClient} = new CognitoIdentityProviderClient({
credentials: {
accessKeyId: "${2:accessKeyId}",
secretAccessKey: "${3:secretAccessKey}",
},
});

Create Identify Provider

Create identify provider
const { CreateIdentityProviderCommand } = require('@aws-sdk/client-cognito-identity-provider)
const input = {
UserPoolId: ${2:userPoolId},
ProviderName: ${3:providerName},
ProviderType: ${4:providerType},
ProviderDetails: {
${5:keys}: ${6:providerDetails},
}
};
const command = new CreateIdentityProviderCommand(input);
const response = await ${1:awsCognitoClient}.send(command);

Create User Pool

Create user pool
const { CreateUserPoolCommand } = require("@aws-sdk/client-cognito-identity-provider");

const input = {
PoolName: ${2:poolName}
LambdaConfig: {
CustomSMSSender: {
LambdaVersion: ${3:lambdaVersion},
LambdaArn: ${4:lambdaArn},
},
CustomEmailSender: {
LambdaVersion: ${3:lambdaVersion},
LambdaArn: ${4:lambdaArn},
},
},
SmsConfiguration: {
SnsCallerArn: ${5:snsCallerArn},
},
UsernameConfiguration: {
CaseSensitive: ${6:caseSensitive},
},
AccountRecoverySetting: {
RecoveryMechanisms: [
{
Priority: Number(${7:recoveryMechanismsPriority}),
Name: ${8:recoveryMechanismsName},
},
],
}
};
const command = new CreateUserPoolCommand(input);
const response = await ${1:awsCognitoClient}.send(command);

List identity providers

List identify providers
const { ListIdentityProvidersCommand } = require("@aws-sdk/client-cognito-identity-provider");
const input = {
UserPoolId: ${2:userPoolId}
};
const command = new ListIdentityProvidersCommand(input);
const response = await ${1:awsCognitoClient}.send(command);
for(const provider of response.Providers) {
console.log(provider)
}