-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambda.txt
More file actions
38 lines (24 loc) · 818 Bytes
/
Copy pathlambda.txt
File metadata and controls
38 lines (24 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
* StartEC2
import boto3
region = 'ap-south-1'
instances = ['i-097fb3af2f096e0ee']
ec2 = boto3.client('ec2', region_name=region)
def lambda_handler(event, context):
ec2.start_instances(InstanceIds=instances)
print('stopped your instances: ' + str(instances))
* StopEC2
import boto3
region = 'ap-south-1'
instances = ['i-097fb3af2f096e0ee']
ec2 = boto3.client('ec2', region_name=region)
def lambda_handler(event, context):
ec2.stop_instances(InstanceIds=instances)
print('stopped your instances: ' + str(instances))
* TerminateEC2
import boto3
region = 'ap-south-1'
instances = ['i-097fb3af2f096e0ee']
ec2 = boto3.client('ec2', region_name=region)
def lambda_handler(event, context):
ec2.terminate_instances(InstanceIds=instances)
print('stopped your instances: ' + str(instances))