I've created an application that allows users to signup, which adds them into my AWS Cognito user pool. This was done using the AWS-SDK for PHP, specifically the signUp method. I've tried to create a Lambda function that triggers upon PostConfirmation that adds user details into my DynamoDB table and it works when I use the Test feature but when I set it up for live deployment, it won't add users into the table and does not give me any errors.
Here is my method's parameters:
$this->client->signUp([
'ClientId' => $this->client_id,
'Username' => $username,
'Password' => $password,
'UserAttributes' => [
[
'Name' => 'name',
'Value' => $name
],
[
'Name' => 'email',
'Value' => $email
],
]
]);
This is my Lambda function:
var aws = require('aws-sdk');
const ddb = new aws.DynamoDB({apiVersion: '2012-10-08'});
aws.config.update({region: 'us-east-1'});
exports.handler = function(event, context, callback) {
var params = {
TableName: 'RecipeUsersDB',
Item: {
'username': {S: event.request.userName},
'name': {S: event.request.userAttributes.name},
'email': {S: event.request.userAttributes.email}
}
}
ddb.putItem(params, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Exit", data);
}
});
callback(null);
};
This is the Test event parameters that work:
{
"request": {
"userName": "hrefrlo",
"userAttributes": {
"sub": "e1feer",
"name": "2srhserrh",
"email": "3srwergthgsrg"
}
},
"response": {}
}
I've given the function several different permission policies:
AmazonDynamoDBFullAccess
AmazonCognitoDeveloperAuthenticatedIdentities
AmazonCognitoPowerUser
AWSLambdaBasicExecutionRole
AWSLambdaInvocation-DynamoDB
This is just for a uni assignment so the app(website) is just going to be used for a demo, and is only going to be deployed on Beanstalk. Any help is appreciated, thank you!