{"id":3737,"date":"2015-11-05T10:38:09","date_gmt":"2015-11-05T10:38:09","guid":{"rendered":"http:\/\/blog.cloudthat.com\/?p=3737"},"modified":"2024-06-25T11:13:15","modified_gmt":"2024-06-25T11:13:15","slug":"lambda-new-features","status":"publish","type":"blog","link":"https:\/\/www.cloudthat.com\/resources\/blog\/aws-lambda-the-future-of-event-driven-automation","title":{"rendered":"AWS Lambda &#8211; the future of event driven automation"},"content":{"rendered":"<p style=\"text-align: justify;\">Lambda is a compute service in Amazon Web Services, which triggers actions based on the events. Lambda is efficient and event driven which responses to events from either objects added or removed from S3, updating to DynamoDB tables, SNS, data in Kinesis Stream, Cloudwatch logs, In-App activity etc. Once our code is uploaded to Lambda, this service handles all the capacity, scaling, patching and administration of the infrastructure needed to run our code and also provides us with greater visibility of performance by publishing us with logs and metrics to Amazon CloudWatch.Lambda is cost- effective as it helps in running our code without any provisioning and managing servers with high availability. \u00a0AWS has been adding a lot of new features. AWS Lambda supports only 4 AWS regions, which include US-East (North Virginia), US-West (Oregon), EU-West (Ireland) and Asia Pacific (Tokyo). AWS provided support for writing Lambda functions in Node.js language and added Java Programming Language recently this year. New features are added in Lambda to help developers and other community people to make life much simpler and easy.<\/p>\n<p>Recently, AWS Lambda function has brought in <strong>new features<\/strong>;<\/p>\n<ul>\n<li>Functions can now be written in Python Programming Language.<\/li>\n<li>Lambda functions now support Versioning and aliases.<\/li>\n<li>It can also perform scheduled tasks (similar to cron jobs).<\/li>\n<li>The execution time has been increased to 300sec (5 min).<\/li>\n<\/ul>\n<p>Lambda is all about functions, so let\u2019s take a look at each of these new features<\/p>\n<p><strong>Lambda functions support Python Programming Language:<\/strong><\/p>\n<p>As we know that <a href=\"https:\/\/www.cloudthat.com\/consulting\/service-delivery-program\/aws-lambda\/\">AWS Lambda<\/a> has support for writing functions in Node.js and Java, recently Python is added to that list which is very easy to learn and use. Python 2.7 comes with in-built\u00a0access for AWS SDK for python. Python code must be zipped together with dependencies and uploaded to AWS Lambda using AWS CLI\u00a0or using console. <span style=\"color: #222222;\">\u00a0<\/span><\/p>\n<p><span id=\":1ry\" dir=\"ltr\" style=\"color: #222222;\">[showhide type=&#8221;qs&#8221; more_text=&#8221;Click here for the detailed Lab for Python.. &#8221; less_text=&#8221;Hide Details&#8221; hidden=&#8221;yes&#8221;]<\/span><\/p>\n<p><strong>Lab for stopping the particular instances based on Tags with Role-Based in Python language.<\/strong><\/p>\n<p><strong>Task 1<\/strong><\/p>\n<ul>\n<li>Launch an EC2 instance and give the key name (i.e, key name of the instance) as <strong>TagName<\/strong><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/screenshot-eu-west-1.console.aws_.amazon.com-2015-11-05-13-15-08.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3829 \" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/screenshot-eu-west-1.console.aws_.amazon.com-2015-11-05-13-15-08.png\" alt=\"screenshot-eu-west-1.console.aws.amazon.com 2015-11-05 13-15-08\" width=\"636\" height=\"119\" \/><\/a><\/li>\n<li>Download the zipped file from the given link.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/s3-ap-northeast-1.amazonaws.com\/srihari-bucket\/srihari-blog\/ec2listinpython.zip\">https:\/\/s3-ap-northeast-1.amazonaws.com\/srihari-bucket\/srihari-blog\/ec2listinpython.zip<\/a><\/p>\n<p><strong>NOTE : <\/strong>There is no need to hard code by adding your access key and secret key because Lambda works on Role-Based. <strong>Task 2<\/strong><\/p>\n<p><strong>Create a Lambda Function.<\/strong> In this task you are going to create the Lambda function.<\/p>\n<p>1. Click on <strong>Lambda <\/strong>under <strong>Compute<\/strong> section. <a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/Capture6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3741 size-full\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/Capture6.png\" alt=\"\" width=\"581\" height=\"327\" \/><\/a><\/p>\n<ol start=\"2\">\n<li>Select <strong>Tokyo<\/strong> Region.(Any region of your choice)<\/li>\n<li>Click on <strong>Create a Lambda function<\/strong>.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/26.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3743 size-full\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/26.png\" alt=\"2\" width=\"613\" height=\"186\" \/><\/a><\/p>\n<ol start=\"4\">\n<li>Click on <strong>Skip<\/strong> option.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/310.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3744 size-full\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/310.png\" alt=\"\" width=\"591\" height=\"315\" \/><\/a> <strong>\u00a0\u00a0<\/strong><\/p>\n<p><strong>\u00a0 Note: <\/strong>Do not select any Blueprint. <strong>\u00a0<\/strong><\/p>\n<ol start=\"5\">\n<li>Configure the Lambda function.\n<ul>\n<li>Enter the <strong>Name<\/strong> for Lambda function.<\/li>\n<li>Give the <strong>Description <\/strong>for Lambda function.(Optional)<\/li>\n<li><strong>Runtime<\/strong> should be <strong>Python 2.7 <\/strong>from the Drop Down list<strong>.<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/41.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3745 size-full\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/41.png\" alt=\"4\" width=\"613\" height=\"151\" \/><\/a><\/p>\n<ol start=\"6\">\n<li>Perform the following steps as shown<\/li>\n<\/ol>\n<ul>\n<li>Click on <strong>Upload a zip file<\/strong><\/li>\n<li>Click on <strong>upload<\/strong><\/li>\n<\/ul>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/Screenshot-from-2016-08-18-20-34-51.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3746 size-full\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/Screenshot-from-2016-08-18-20-34-51.png\" alt=\"5\" width=\"469\" height=\"111\" \/><\/a><\/p>\n<p>7.\u00a0 Update the <strong>Handler<\/strong> as shown below(ec2listinpython.lambda_handler)<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/5-Tech-Areas-that-are-Changed-Forever-after-AWS-reInvent-20162.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3747 size-full\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/5-Tech-Areas-that-are-Changed-Forever-after-AWS-reInvent-20162.png\" alt=\"6\" width=\"459\" height=\"189\" \/><\/a><\/p>\n<p>8. Creating a IAM Role for Lambda.<\/p>\n<ul>\n<li>Click on <strong>Role<\/strong> Drop down List.<\/li>\n<li>Select <strong>Basic execution <\/strong>from the drop down list.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/72.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3748 size-full\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/72.png\" alt=\"7\" width=\"469\" height=\"95\" \/><\/a><\/p>\n<p>9. AWS Lambda uses a role. Create your role from the following steps.<\/p>\n<ul>\n<li>Select \u201c<strong>Create a new IAM Role\u201d<\/strong> from Drop down list of <strong>IAM Role.<\/strong><\/li>\n<li>Give\u00a0 <strong>Role Name<\/strong>.<\/li>\n<li>Click on <strong>Hide Policy Document<\/strong><\/li>\n<li>Then Click on <strong>Edit.<\/strong><\/li>\n<\/ul>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/122.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3766 \" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/122.png\" alt=\"12\" width=\"519\" height=\"359\" \/><\/a><\/p>\n<ul>\n<li>Click on <strong>OK<\/strong><\/li>\n<\/ul>\n<p><strong><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/1200x628_CloudThat_131.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3767 \" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/1200x628_CloudThat_131.png\" alt=\"13\" width=\"490\" height=\"204\" \/><\/a><\/strong><\/p>\n<ul>\n<li>Add the following Policy to the Role and click on <strong>Allow<\/strong>.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<pre class=\"lang:default decode:true \">{\"Version\": \"2012-10-17\",\"Statement\": [{\"Sid\": \"Stmt1445236134000\",\"Effect\": \"Allow\",\"Action\": [\"logs:CreateLogGroup\",\"logs:CreateLogStream\",\"logs:PutLogEvents\",\"ec2:*\"],\"Resource\": [\"*\"]} ] }<\/pre>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/141.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3770 \" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/141-1024x461.png\" alt=\"14\" width=\"707\" height=\"310\" \/><\/a><\/p>\n<p>10.\u00a0 In Advanced settings make changes to Timeout.<\/p>\n<ul>\n<li>Increase the <strong>Timeout <\/strong>to 10sec<\/li>\n<li>Click on <strong>Next.<\/strong><\/li>\n<\/ul>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/92.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3750 size-full\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/92.png\" alt=\"9\" width=\"469\" height=\"124\" \/><\/a><\/p>\n<p>11. Click on <strong>Create function.<\/strong><\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/101.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3751 \" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/101.png\" alt=\"10\" width=\"612\" height=\"333\" \/><\/a><\/p>\n<p>12. Test the following Lambda function<\/p>\n<p>. <a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/132.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3775 size-full\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/132.png\" alt=\"13\" width=\"581\" height=\"146\" \/><\/a><\/p>\n<p>13. Lambda function will stop the instances with the tag named <strong>TagName<\/strong>\u00a0we have specified.<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/screenshot-eu-west-1.console.aws_.amazon.com-2015-11-05-13-17-00.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3830\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/screenshot-eu-west-1.console.aws_.amazon.com-2015-11-05-13-17-00.png\" alt=\"screenshot-eu-west-1.console.aws.amazon.com 2015-11-05 13-17-00\" width=\"646\" height=\"122\" \/><\/a><\/p>\n<p>[\/showhide]<\/p>\n<p><strong>Lambda supports Versioning and Aliases:<\/strong><\/p>\n<p style=\"text-align: justify;\">Lambda now supports versioning, which helps to maintain multiple versions of our Lambda function code and helps to achieve the execution in different environments like PROD, DEV, TEST etc. Versioning also allows us to publish one or more versions of our Lambda function code helping in rollback to previous version if there is any error in current version. Each Lambda function version will have there own ARN. After publishing the version of our Lambda function code, the code of the corresponding version will become immutable i.e. the code cannot be changed. AWS Lambda supports aliases for each of our Lambda function versions. Its alias is a pointer, which points to specific Lambda version. Each alias has an ARN, which cannot point to another alias.<\/p>\n<p style=\"text-align: justify;\"><strong>NOTE: <\/strong>Versions after publishing will become immutable, whereas alias are mutable and can be updated accordingly.<\/p>\n<p style=\"text-align: justify;\"><strong>Example of alias in Lambda:<\/strong> Suppose the event source for Lambda is S3 Bucket and whenever we choose S3 bucket as event source, we need to perform few notification changes in S3 bucket:<\/p>\n<ul style=\"text-align: justify;\">\n<li>We need to add the event source in the AWS S3 to know which Lambda function it has to invoke.<\/li>\n<li>In notification configuration of our S3 bucket, we need to specify ARN of our Lambda function that S3 bucket has to invoke whenever new object is created or object is removed.<\/li>\n<\/ul>\n<p style=\"text-align: justify;\">This will invoke the Lambda function whenever the object is created or removed for S3 bucket. But in this case, each time we publish our version we have to update in notification configuration of S3 bucket to invoke correct Lambda function version. Instead of specifying our Lambda function version ARN, we can specify our Lambda function alias ARN in notification configuration. (Example: PROD alias ARN) and we don\u2019t need to update notification configuration in S3 events. If we promote new versions of our Lambda function, we need to add only PROD alias ARN of that corresponding version. Aliases which is pointing to one version can easily point to another updated version and helps us to easily roll back whenever any problems arises. We can refer to our Lambda functions using ARNs.<\/p>\n<p style=\"text-align: justify;\">There will be two ARNs associated with initial version;<\/p>\n<p style=\"text-align: justify;\">Qualified ARN: The function which is having version suffix is called as Qualified ARN<\/p>\n<p style=\"text-align: justify;\">ex: arn:aws:lambda:aws-region:account-id:function:HelloWorld:<strong>$LATEST<\/strong><\/p>\n<p style=\"text-align: justify;\">UnQualified ARN: The function which is not having any version suffix is called UnQualified ARN<\/p>\n<p style=\"text-align: justify;\">ex:\u00a0 arn:aws:lambda:aws-region:account-id:function:HelloWorld<\/p>\n<p style=\"text-align: justify;\">UnQualified ARN can be used in all the relevant operatoins but we will not able to create an alias and they will be having their own resource policies.<\/p>\n<p style=\"text-align: justify;\"><strong>AWS Lambda now also supports Scheduled tasks (It will replace cron jobs):<\/strong><\/p>\n<p style=\"text-align: justify;\">AWS Lambda has come up with amazing feature, which will invoke our Lambda function code on regular and scheduled basis similar to cron jobs. For running cronjobs, we need to have one separate EC2 server running forever, which will cost that can be easily overcome by AWS Lambda scheduling feature . Our AWS Lambda function will be invoked only at particular scheduled time and we don\u2019t need to take care of any EC2 server running, because Lambda will take care of provisioning and managing of servers. It is very\u00a0 cost-effective as the pricing is applicable only for the amount of the time Lambda function code runs. We can specify a fixed data, which includes the number of minutes, hours or days or we may specify a cron expression (minutes: 0-59, hours: 0-23, days: 1-31, month: [1-12]or [JAN-DEC], days of week: [1-7]or[SUN-SAT], year:[1970-2199]).<\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #222222;\">\u00a0<\/span><span id=\":1ry\" dir=\"ltr\" style=\"color: #222222;\">[showhide type=&#8221;we&#8221; more_text=&#8221;Demonstration of Scheduling a Lambda function which stops instances at particular scheduled time&#8230; &#8221; less_text=&#8221;Hide Details&#8221; hidden=&#8221;yes&#8221;]<\/span><\/p>\n<p style=\"text-align: justify;\"><strong>Task 1<\/strong><\/p>\n<ul>\n<li>Launch an EC2 instance and give the key name (i.e, key name of the instance) as <strong>TagName<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/screenshot-eu-west-1.console.aws_.amazon.com-2015-11-05-13-15-08.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3829\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/screenshot-eu-west-1.console.aws_.amazon.com-2015-11-05-13-15-08.png\" alt=\"screenshot-eu-west-1.console.aws.amazon.com 2015-11-05 13-15-08\" width=\"657\" height=\"123\" \/><\/a><\/strong><\/li>\n<li>Download the zipped file from the given link.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/s3-ap-northeast-1.amazonaws.com\/srihari-bucket\/srihari-blog\/ec2listinpython.zip\">https:\/\/s3-ap-northeast-1.amazonaws.com\/srihari-bucket\/srihari-blog\/ec2listinpython.zip<\/a><\/p>\n<p><strong>NOTE : <\/strong>There is no need to hard code by adding your access key and secret key because Lambda works on Role-Based.<\/p>\n<p><strong>Task 2<\/strong><\/p>\n<p><strong>Create a Lambda Function.<\/strong><\/p>\n<p>In this task you are going to create the Lambda function.<\/p>\n<p>1. Click on <strong>Lambda <\/strong>under <strong>Compute<\/strong> section<\/p>\n<p>. <a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/Capture6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3741 size-full\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/Capture6.png\" alt=\"Capture\" width=\"581\" height=\"327\" \/><\/a><\/p>\n<ol start=\"2\">\n<li>Select <strong>Tokyo<\/strong> Region.(Any region of your choice)<\/li>\n<li>Click on <strong>Create a Lambda function<\/strong>.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/25.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3742 size-full\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/25.png\" alt=\"2\" width=\"613\" height=\"186\" \/><\/a><\/p>\n<ol start=\"4\">\n<li>Please select the following BluePrint(lambda-canary).<\/li>\n<li><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/27.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3778\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/27.png\" alt=\"2\" width=\"461\" height=\"257\" \/><\/a><\/li>\n<li>Configure<strong> the event sources<\/strong> as shown below and click on <strong>Next.<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/3new.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3779\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/3new.png\" alt=\"3new\" width=\"677\" height=\"218\" \/><\/a><\/strong><\/li>\n<li>Configure the Lambda function.\n<ul>\n<li>Enter the <strong>Name<\/strong> for Lambda function.<\/li>\n<li>Give the <strong>Description <\/strong>for Lambda function.(Optional)<\/li>\n<li><strong>Runtime<\/strong> should be <strong>Python 2.7 <\/strong>from the Drop Down list<strong>.<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/42.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3780\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/42.png\" alt=\"4\" width=\"687\" height=\"212\" \/><\/a><\/p>\n<ol start=\"7\">\n<li>Perform the following steps as shown<\/li>\n<\/ol>\n<ul>\n<li>Click on <strong>Upload a zip file<\/strong><\/li>\n<li>Click on <strong>upload<\/strong><\/li>\n<\/ul>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/Screenshot-from-2016-08-18-20-34-51.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3746\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/Screenshot-from-2016-08-18-20-34-51.png\" alt=\"5\" width=\"469\" height=\"111\" \/><\/a><\/p>\n<p>8.\u00a0 Update the <strong>Handler<\/strong> as shown below<\/p>\n<p>9. Creating a IAM Role for Lambda.<\/p>\n<ul>\n<li>Click on <strong>Role<\/strong> Drop down List.<\/li>\n<li>Select <strong>Basic execution <\/strong>from the drop down list<\/li>\n<li>.<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/63.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3783\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/63.png\" alt=\"6\" width=\"636\" height=\"145\" \/><\/a><\/li>\n<\/ul>\n<p>10. AWS Lambda uses a role. Create your role from the following steps.<\/p>\n<ul>\n<li>Select \u201c<strong>Create a new IAM Role\u201d<\/strong> from Drop down list of <strong>IAM Role.<\/strong><\/li>\n<li>Give\u00a0 <strong>Role Name<\/strong>.<\/li>\n<li>Click on <strong>Hide Policy Document<\/strong><\/li>\n<\/ul>\n<ul>\n<li>Then Click on <strong>Edit.<\/strong><\/li>\n<\/ul>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/124.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3787\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/124.png\" alt=\"12\" width=\"558\" height=\"351\" \/><\/a> <a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/133.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3788\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/133.png\" alt=\"13\" width=\"582\" height=\"242\" \/><\/a><\/p>\n<ul>\n<li>Add the following Policy to the Role and click on <strong>Allow<\/strong>.<\/li>\n<\/ul>\n<pre class=\"lang:default decode:true \">{\"Version\": \"2012-10-17\",\"Statement\": [{\"Sid\": \"Stmt1445236134000\",\"Effect\": \"Allow\",\"Action\": [\"logs:CreateLogGroup\",\"logs:CreateLogStream\",\"logs:PutLogEvents\",\"ec2:*\"],\"Resource\": [ \"*\" ] } ] }<\/pre>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/142.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3789\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/142.png\" alt=\"14\" width=\"609\" height=\"274\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>11.\u00a0 In Advanced settings make changes to Timeout.<\/p>\n<ul>\n<li>Increase the\u00a0<strong>Timeout\u00a0<\/strong>to 10sec<\/li>\n<li>Click on\u00a0<strong>Next.<\/strong><\/li>\n<\/ul>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/92.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3750\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/92.png\" alt=\"9\" width=\"480\" height=\"127\" \/><\/a><\/p>\n<p>12. Click on <strong>Create function and <\/strong>select <strong>Enable later.<\/strong><\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/94.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3790\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/94.png\" alt=\"9\" width=\"466\" height=\"320\" \/><\/a><\/p>\n<p>13. After creating a Lambda function, go to <strong>Event sources <\/strong>and Click on disabled to Enable the lambda function for performing Scheduled Task. <a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/102.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3772\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/102.png\" alt=\"10\" width=\"725\" height=\"129\" \/><\/a> <a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/114.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3791\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/114.png\" alt=\"11\" width=\"642\" height=\"238\" \/><\/a><\/p>\n<p>14. Test the following Lambda function.<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/132.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3775\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/132.png\" alt=\"13\" width=\"581\" height=\"146\" \/><\/a><\/p>\n<p>15. Lambda function will stop the instances with the tag named TagName we have specified.<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/screenshot-eu-west-1.console.aws_.amazon.com-2015-11-05-13-17-00.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3830\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/screenshot-eu-west-1.console.aws_.amazon.com-2015-11-05-13-17-00.png\" alt=\"screenshot-eu-west-1.console.aws.amazon.com 2015-11-05 13-17-00\" width=\"673\" height=\"127\" \/><\/a><\/p>\n<p><span style=\"color: #222222; font-family: arial, sans-serif; font-size: 12.8px; line-height: normal;\">\u00a0<\/span><span id=\":1lk\" dir=\"ltr\" style=\"color: #222222; font-family: arial, sans-serif; font-size: 12.8px; line-height: normal;\">[\/showhide]<\/span><\/p>\n<p><strong>Execution time for Lambda functions has increased:<\/strong><\/p>\n<p style=\"text-align: justify;\">AWS Lambda function&#8217;s execution time has increased from 1 min(60 sec) to 5 min(300 sec). Lambda functions can scale up to process large volumes of data , in such scenarios\u00a0the execution time can be increased up to 300 sec.We can specify the required timeout while creating our Lambda function as shown.<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/screenshot-eu-west-1.console.aws_.amazon.com-2015-11-05-13-46-43.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3834\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/screenshot-eu-west-1.console.aws_.amazon.com-2015-11-05-13-46-43.png\" alt=\"screenshot-eu-west-1.console.aws.amazon.com 2015-11-05 13-46-43\" width=\"642\" height=\"119\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"author":219,"featured_media":0,"parent":0,"comment_status":"open","ping_status":"open","template":"","blog_category":[3804,3623,3606,3607,3624,3665],"user_email":"prarthitm@cloudthat.com","published_by":"1363","primary-authors":"","secondary-authors":"","acf":[],"_links":{"self":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/3737"}],"collection":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/users\/219"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/comments?post=3737"}],"version-history":[{"count":3,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/3737\/revisions"}],"predecessor-version":[{"id":54964,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/3737\/revisions\/54964"}],"wp:attachment":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/media?parent=3737"}],"wp:term":[{"taxonomy":"blog_category","embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog_category?post=3737"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}