![](http://aws-guide.work/wp-content/themes/cocoon-master/images/b-woman.png)
この記事では
・RDSを開始するLamdba関数を作成
します!
![](http://aws-guide.work/wp-content/themes/cocoon-master/images/b-woman.png)
今回は
・Pythonのコードを作成
します!
前提
Lamdba関数用のIAMロールが作成されていること。
IAMロールの作成の詳細は、以下の記事をご確認ください。
Lamdba関数の作成
Lambda関数の作成の詳細は、以下の記事をご確認ください。
ソースコード
import boto3
region = "ap-northeast-1"
DBInstanceIdentifier = "sample-rds-postgres"
rds = boto3.client("rds", region_name=region)
def lambda_handler(event, context):
rds.start_db_instance(DBInstanceIdentifier=DBInstanceIdentifier)
print("Starting instance: " + str(DBInstanceIdentifier))
実行結果
RDSを開始できました。
※CloudWatch Logsで確認し。
![実行結果](https://aws-guide.work/wp-content/uploads/2024/03/aws_lambda_rds_start_001.png)