![](https://batch-file.net/wp-content/themes/cocoon-master/images/b-woman.png)
バッチファイルから
・RDSを停止
できます!
前提
AWS CLIがインストールされていること。
コード
ここでは例として
・DB識別子「sample-rds-postgres」を停止
します。
![DB識別子「sample-rds-postgres」](https://batch-file.net/wp-content/uploads/2024/03/bat_aws_rds_stop_cli_001.png)
@echo off
rem DB識別子
set dbIdentifier=sample-rds-postgres
rem プロファイル名
set profile=develop
rem RDSを停止
aws rds stop-db-instance --db-instance-identifier %dbIdentifier% --profile %profile% > nul
rem 実行結果を確認
if %errorlevel% == 0 (
echo 正常終了しました。戻り値:%errorlevel%
) else (
echo 異常終了しました。戻り値:%errorlevel%
)
echo.
pause
実行結果
RDSを停止できました。
![実行結果①](https://batch-file.net/wp-content/uploads/2024/03/bat_aws_rds_stop_cli_002.png)
![実行結果②(停止中)](https://batch-file.net/wp-content/uploads/2024/03/bat_aws_rds_stop_cli_003.png)
![実行結果③(一時的に停止済み)](https://batch-file.net/wp-content/uploads/2024/03/bat_aws_rds_stop_cli_004.png)
参考①
上記は以下の記事を参考にして作成しました。
参考②
上記で使用した以下の詳細は、公式サイトをご確認ください。
●aws rds stop-db-instance