Fadi saadeldin
09/08/2021, 4:54 AMUnrecognizedClientException: The security token included in the request is not valid , i can do that in terminal bit not in lambda.Frank
npm run start?Fadi saadeldin
09/08/2021, 5:28 AMFrank
Frank
Frank
Fadi saadeldin
09/08/2021, 5:10 PMconst api = new sst.ApolloApi (this, 'Api', {
});
api.attachPermissions([
"cognito-identity:*",
"cognito-idp:*",
"cognito-sync:*",
"iam:ListRoles",
"iam:ListOpenIdConnectProviders",
"iam:GetRole",
"iam:ListSAMLProviders",
"iam:GetSAMLProvider",
"kinesis:ListStreams",
"lambda:GetPolicy",
"lambda:ListFunctions",
"sns:GetSMSSandboxAccountStatus",
"sns:ListPlatformApplications",
"ses:ListIdentities",
"ses:GetIdentityVerificationAttributes",
"mobiletargeting:GetApps",
"acm:ListCertificates"
])Fadi saadeldin
09/08/2021, 5:10 PMFrank
adminCreateUser in ur Lambda code.Fadi saadeldin
09/08/2021, 8:43 PMconst cognitoIdentityService = new aws.CognitoIdentityServiceProvider ({ apiVersion: '2016-04-19' });
const userData = {
UserPoolId: app.aws.cognito.userPoolId,
Username: email,
DesiredDeliveryMediums: ['EMAIL'],
UserAttributes: [
{ Name: 'email', Value: email },
{ Name: 'email_verified', Value: 'true' },
],
};
const data = await cognitoIdentityService.adminCreateUser (userData).promise ();
await cognitoIdentityService.adminAddUserToGroup ({
UserPoolId: app.aws.cognito.userPoolId,
Username: email,
GroupName: group,
}).promise ();Abdul Taleb
09/09/2021, 3:01 AMFrank
{ data: { invitedUser: null }, error: ..}? (cc @Jay do you recognize these errors? Are they coming from Cognito?)Fadi saadeldin
09/11/2021, 1:27 PMcatch (error) {throw new ApolloError (error);}Frank
Frank
Api and an Auth, and when curling the Api’s endpoint, the Lambda function calls adminCreateUser, and returns the created user.Frank
Api instead of ApolloApi, but the idea is the same.Frank
Abdul Taleb
09/12/2021, 8:15 PMFadi saadeldin
09/13/2021, 6:05 AMAbdul Taleb
09/14/2021, 2:44 AMAbdul Taleb
09/14/2021, 2:46 AMnew cognito.UserPool construct and then I pass it to the Auth constructAbdul Taleb
09/14/2021, 2:47 AMconst auth = new sst.Auth(this, 'Auth', {
cognito: { userPoolId: myUserPool.userPoolId, clientId: .... }
});Frank
sst-triage-admin-create-user repo work for you (without changing anything)?Abdul Taleb
09/14/2021, 2:54 AMconst auth = new Auth(this, 'auth', { cognito: true }): it workedFrank
new cognito.UserPool and pass that into the Auth construct (while keeping the Api, don’t make the ApolloApi change yet).Frank
Abdul Taleb
09/14/2021, 3:09 AMAbdul Taleb
09/14/2021, 3:10 AMconst tempAuth = new sst.Auth(this, 'temp-auth', {
cognito: {
userPool: new cognito.UserPool(this, 'test-user-pool'),
}
})Frank
Abdul Taleb
09/14/2021, 3:59 AMAbdul Taleb
09/14/2021, 4:00 AMAbdul Taleb
09/14/2021, 7:17 AMFrank