Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- 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')
- DBinstance =''
- try:
- funcResponse = lambdaFunc.get_function_configuration(
- FunctionName='StopRDSInstances'
- )
- DBinstance = funcResponse['Environment']['Variables']['DBInstanceName']
- print('Stopping RDS service for DBInstance : ' + DBinstance)
- except ClientError as e:
- print(e)
- DBInstanceIdentifier=''
- try:
- response = rds.stop_db_instance(
- DBInstanceIdentifier=DBinstance
- )
- print('Success :: ')
- return response
- except ClientError as e:
- print(e)
- return
- {
- 'message' : "Script execution completed. See Cloudwatch logs for complete output"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement