How to Start/Stop the EC2 Instance by using Lambda Function
To Start/Stop the EC2 Instance by using Lambda Function
Introduction:
AWS Lambda is a serverless compute service that can run the code in response to events and manages the compute resources that can use AWS Lambda to extend other AWS services with custom logic or create the own back-end services that run at AWS scale, performance, and security. Amazon Elastic Compute Cloud (Amazon EC2) is a web service that delivers reliable, resizable compute capacity in the cloud that is designed to make web-scale cloud computing more comfortable for developers.
Login to your AWS account:
In console page select EC2 to create a new instance: Create a new a Instance:
Then create a role for Lambda function with permission: Then open the new role and create a inline policy: Add ARN to restrict the Instances: Create a Lambda Function: This is the Function I had written to stop the instance: Then Increase the execution time in settings: Deploy the changes and run the function:
It will show the status of the instance is stopped: Then start the Instance by changing the code in function: With this method to Start/Stop the EC2 instance by using Lambda Function comes to an end.
Comments ( 0 )
No comments available