LAMBDA மூலம் EC2 INSTANCE START-STOP செய்வது எப்படி?

Опубликовано: 01 Июнь 2025
на канале: Tamil Cloud
3,818
96

EC2 - Start and Stop from Lambda Function
*****************************************

1) Create Ec2 instance

2) Create Role with inline policy for that Instance Start and Stop Permission

3) Create Lambda Function for Start and stop

4) Create Cloudwatch Event for Lambda Trigger

import json
import boto3

region='regionname'

instances = ['instance-id']

def lambda_handler(event, context):
TODO implement
ec2 = boto3.client('ec2', region_name=region)
ec2.stop_instances(InstanceIds=instances)
print 'stopped your instances: ' + str(instances)