AWS Lambda is a serverless, event-driven compute service that lets you run code for virtually any type of application or backend service without provisioning or managing servers.
Lambda functions are efficient whenever you want to create a function that will only contain simple expressions
Each Lambda function runs in its own container. When a function is created, Lambda packages it into a new container and then executes that container on a multi-tenant cluster of machines managed by AWS.
Step-1.Create the EC2 Instance.
Step-2. Create IAM Roles and policies.
- Create a policy > Select EC2 type >Access level -Write (Stop Instance).
- Add Specific ARN (Details of the EC2 Instance which we need to start/stop)
- We have created separate policy for start/stop the EC2 Instance.
- Create a Role > select entity (AWS Service)>select the use case as "Lambda".
- We have created separate Roles for start/stop the EC2 Instance.
Step-3. Create Lambda function.
- We can add the trigger rule "Event Bridge"
The similar we create another lambda function for start the EC2 instance and schedule corn job using add trigger"Event bridge"
It will start/stop EC2 instance using Lambda function.
Top comments (0)