-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRDSInstanceStart.py
More file actions
31 lines (25 loc) · 992 Bytes
/
RDSInstanceStart.py
File metadata and controls
31 lines (25 loc) · 992 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
import botocore
import boto3
from botocore.exceptions import ClientError
def lambda_handler(event, context):
rds = boto3.client('rds')
lambdaFunc = boto3.client('lambda')
print('Trying to get Environment variable')
def rds_start(instance):
try:
response = rds.start_db_instance(DBInstanceIdentifier=instance)
print('Start RDS instance :: ' + instance)
return response
except ClientError as e:
print(e)
try:
funcResponse = lambdaFunc.get_function_configuration(FunctionName='RDSInstanceStop')
rdsInstances = funcResponse['Environment']['Variables']['DBInstanceName']
print('Starting RDS service for DBInstances : ' + rdsInstances)
for instance in rdsInstances.split(","):
rds_start(instance)
except ClientError as e:
print(e)
return {
'message' : "Script execution completed. See Cloudwatch logs for complete output"
}