Articles → AWS → Lambda Function In AWS
Lambda Function In AWS
Serverless Computing Model
What Is A Lambda Function?
How To Create A Lambda Function In AWS?
- Verify emails in Simple Email Service (SES)
- Create a lambda function
- Write code to send an email
- Change the policy
- Invoke the function
Verify Emails In Simple Email Service (SES)
Create A Lambda Function
Click to Enlarge
Click to Enlarge
- Function name
- Runtime
- Architecture
- Execution role
Click to Enlarge
Write Code To Send An Email
var aws = require('aws-sdk');
aws.config.getCredentials(function (err) {
if (err) console.log(err.stack);
else {
//console.log("Access key:", aws.config.credentials.accessKeyId);
}
});
var ses = new aws.SES({
region: 'ap-south-1'
});
exports.handler = function () {
//console.log("Incoming: ", event);
var eParams = {
Destination: {
ToAddresses: ["SESverifiedemail@gmail.com"]
},
Message: {
Body: {
Text: {
Data: "Lambda is working"
}
},
Subject: {
Data: "Mail From SES"
}
},
Source: "SESverifiedemail@gmail.com"
};
console.log('===Sending Email====');
var email = ses.sendEmail(eParams, function (err, data) {
//console.log(eParams);
if (err) console.log(err);
else {
console.log('===Email Sent====');
//context.succeed(event);
}
});
};
exports.handler();
Click to Enlarge
Click to Enlarge
Change The Policy
- Add SES:SendEmail and SES:SendRawEmail inside the Action
- Set the value of Resource to *
Click to Enlarge
Invoke The Function
Click to Enlarge
Click to Enlarge
Click to Enlarge
What Is The Maximum Execution Time Of Lambda Function?