Тёмный

Automatically change the rds database instance type using the lambda function 

Devops TerraByte
Подписаться 939
Просмотров 196
50% 1

In this video we will change the RDS database type using the python lambda function
Code used in this video :-
import sys
import botocore
import boto3
import json
from botocore.exceptions import ClientError
def lambda_handler(event, context):
rds = boto3.client('rds')
lambdaFunc = boto3.client('lambda')
print('Trying to get Environment variable')
try:
funcResponse = lambdaFunc.get_function_configuration(
FunctionName='RDS_Instance_Modification_Function'
)
DBinstance = funcResponse['Environment']['Variables']['DBInstanceName']
DBinstanceClass = funcResponse['Environment']['Variables']['DBinstanceClass']
print(f'Starting RDS service for DBInstance: {DBinstance}')
print(f'RDS instance class: {DBinstanceClass}')
response = rds.modify_db_instance(DBInstanceIdentifier=DBinstance, DBInstanceClass=DBinstanceClass, ApplyImmediately=True)
print(f'Success :: {response}')
return json.dumps(dict(abc=123))
except ClientError as e:
return json.dumps(dict(error=str(e)))
return json.dumps(dict(abc=12345))
****************************************************************************
Additional Policy added in the IAM cosole :-
{
"Effect": "Allow",
"Action": "lambda:GetFunctionConfiguration",
"Resource": "Your lambda function ARN"
}

Опубликовано:

 

5 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии    
Далее
Top REST API Design Pitfalls
1:21:26
Просмотров 2,7 тыс.