Help us understand the problem. What is going on with this article?

AWS CLIでRDSメンテナンス実施

More than 3 years have passed since last update.

公式ドキュメント

http://docs.aws.amazon.com/cli/latest/reference/rds/index.html

前提条件

AWS CLIバージョン

以下のバージョンで動作確認済
* AWS CLI 1.7.29

コマンド
aws --version
結果
aws-cli/1.7.29

マネジメントコンソール(日本語)

対象RDSインスタンスの「メンテナンスの詳細」に通知がある事

RDSメンテナンスの詳細.png

aws rdsコマンドによるメンテナンス実行

エンドポイントの設定

コマンド
RDS_ENDPOINT='dbinstance.xxxxxxxxxx.ap-northeast-1.rds.amazonaws.com' && echo ${RDS_ENDPOINT_TARGET}
結果
dbinstance.xxxxxxxxxx.ap-northeast-1.rds.amazonaws.com

DBインスタンスの設定

コマンド
RDS_DBINSTANCE='dbinstance' && echo ${RDS_DBINSTANCE}
結果
dbinstance

DBインスタンス確認

コマンド
aws rds describe-pending-maintenance-actions --filter Name=db-instance-id,Values=${RDS_DBINSTANCE}
結果
{
    "PendingMaintenanceActions": [
        {
            "PendingMaintenanceActionDetails": [
                {
                    "Action": "os-upgrade",
                    "Description": "Security and stability updates"
                }
            ],
            "ResourceIdentifier": "arn:aws:rds:ap-northeast-1:012345678910:db:dbinstance"
        }
    ]
}

Actionの設定

aws rds describe-pending-maintenance-actionsにて確認済みのActionを設定

コマンド
RDS_ACTION=`aws rds  describe-pending-maintenance-actions \ 
--filter Name=db-instance-id,Values=${RDS_INSTANCEID_TARGET} \ 
| jq -r '.PendingMaintenanceActions[].PendingMaintenanceActionDetails[].Action '` \ 
&& echo ${RDS_ACTION}
結果
os-upgrade

ResourceIdentifierの設定

aws rds describe-pending-maintenance-actionsにて確認済みのResourceIdentifierを設定

コマンド
RDS_RESOURCEIDENTIFIER=`aws rds  describe-pending-maintenance-actions \
 --filter Name=db-instance-id,Values=${RDS_DBINSTANCE} \
| jq -r '.PendingMaintenanceActions[].ResourceIdentifier'` \
&& echo ${RDS_RESOURCEIDENTIFIER}
結果
arn:aws:rds:ap-northeast-1:012345678910:db:dbinstance

opt-in-type の設定

即時にメンテナンスを実行する為、immediate を設定

コマンド
RDS_OPTINTYPE='immediate' && echo ${RDS_OPTINTYPE}
結果
immediate

aws rds apply-pending-maintenance-actionの実行

メンテナンス対象のDBインスタンスへメンテナンスアクションを実施

コマンド
aws rds apply-pending-maintenance-action --apply-action ${RDS_ACTION} \
--opt-in-type ${RDS_OPTINTYPE}  \
--resource-identifier ${RDS_RESOURCEIDENTIFIER}
結果
{
    "ResourcePendingMaintenanceActions": {
        "PendingMaintenanceActionDetails": [
            {
                "Action": "os-upgrade",
                "Description": "Security and stability updates",
                "OptInStatus": "immediate"
            }
        ],
        "ResourceIdentifier": "arn:aws:rds:ap-northeast-1:012345678910:db:dbinstance"
    }
}

※アップデート中はDBインスタンスがオフラインとなるので注意

aws rds describe-pending-maintenance-actionsの確認

コマンド
aws rds describe-pending-maintenance-actions --filter Name=db-instance-id,Values=${RDS_DBINSTANCE}
結果
{
    "PendingMaintenanceActions": []
}

aws describe-eventsの確認

aws describe-eventsコマンドにてイベント確認

コマンド
aws --output text rds describe-events
結果
EVENTS  YYYY-MM-DDThh:mm:ss.635Z        Applying off-line patches to DB instance        dbinstance    db-instance
EVENTCATEGORIES maintenance
EVENTS  YYYY-MM-DDThh:mm:ss.258Z        DB instance shutdown    dbinstance    db-instance
EVENTCATEGORIES availability
EVENTS  YYYY-MM-DDThh:mm:ss.845Z        DB instance restarted   dbinstance    db-instance
EVENTCATEGORIES availability
EVENTS  YYYY-MM-DDThh:mm:ss.148Z        DB instance shutdown    dbinstance    db-instance
EVENTCATEGORIES availability
EVENTS  YYYY-MM-DDThh:mm:ss.835Z        DB instance restarted   dbinstance    db-instance
EVENTCATEGORIES availability
EVENTS  YYYY-MM-DDThh:mm:ss.322Z        Finished applying off-line patches to DB instance       dbinstance    db-instance
EVENTCATEGORIES maintenance
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした