

• AWS Systems Manager CloudWatch ダッシュボードは、2026 年 4 月 30 日以降は利用できなくなります。お客様は、これまでと同様に Amazon CloudWatch コンソールを使用して、Amazon CloudWatch ダッシュボードの表示、作成、管理を継続できます。詳細については、「[Amazon CloudWatch ダッシュボードのドキュメント](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Dashboards.html)」を参照してください。

# オートメーションを段階的に実行する
<a name="automation-working-executing-manually"></a>

次の手順では、AWS Systems Manager コンソール、AWS Command Line Interface (AWS CLI) を使用して、手動実行モードでオートメーションを実行する方法を説明します。手動実行モードを使用すると、オートメーションは *Waiting* の状態で開始し、各ステップの間で *Waiting* の状態で一時停止します。これにより、オートメーションをいつ進めるかを制御できます。続行する前にステップの結果を確認する必要がある場合に役立ちます。

このオートメーションは、現在のユーザーのコンテキストで実行します。これは、ランブックおよびこのランブックが呼び出すアクションを使用するアクセス許可がある限り、追加の IAM アクセス許可を設定する必要がないことを意味しています。IAM での管理者権限がある場合、このオートメーションを実行するアクセス許可を既に保持しています。

## オートメーションをステップごとに実行する (コンソール)
<a name="automation-working-executing-manually-console"></a>

次の手順は、Systems Manager コンソールを使用してオートメーションをステップごとに手動で実行する方法を説明します。

**オートメーションをステップごとに実行するには**

1. AWS Systems Manager コンソール ([https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/)) を開きます。

1. ナビゲーションペインで、[**オートメーション**]、[**オートメーションの実行**] の順に選択します。

1. [**Automation document (自動化ドキュメント)**] リストで、ランブックを選択します。[**Document categories (ドキュメントカテゴリ)**] ペインで 1 つ以上のオプションを選択して、目的に応じて SSM ドキュメントをフィルタリングします。自分が所有するランブックを表示するには、[**Owned by me (自分が所有)**] タブを選択します。自分のアカウントと共有されているランブックを表示するには、[**Shared with me (共有ファイル)**] タブを選択します。すべてのランブックを表示するには、[**すべてのドキュメント**] タブを選択します。
**注記**  
ランブックの名前を選択すると、ランブックに関する情報を表示できます。

1. [**Document details (ドキュメントの詳細)**] セクションで、[**Document version (ドキュメントのバージョン)**] が実行するバージョンに設定されていることを確認します。システムには、次のバージョンのオプションが含まれています。
   + **[ランタイムのデフォルトバージョン]**: 自動化ランブックが定期的に更新され、新しいデフォルトバージョンが割り当てられている場合は、このオプションを選択します。
   + **[ランタイムの最新バージョン]**: 自動化ランブックが定期的に更新され、直前に更新されたバージョンを実行する場合は、このオプションを選択します。
   + **[1 (デフォルト)]**: ドキュメントの最初のバージョンを実行するには、このオプションを選択します。これはデフォルト設定です。

1. [**次へ**] を選択します。

1. [**Execution Mode (実行モード)**] セクションで、[**Manual execution (手動実行)**] を選択します。

1. [**Input parameters (入力パラメータ)**] セクションで、必要な入力を指定します。必要に応じて、[**AutomationAssumeRole**] リストから IAM サービスロールを選択できます。

1. [**Execute**] を選択します。

1. オートメーションの最初のステップを開始する準備ができたとき、[**Execute this step (このステップを実行)**] を選択します。オートメーションは1 ステップだけ進み、この手順のステップ 3 で選択したランブックで指定した後続のステップを実行する前に一時停止します。ランブックに複数のステップがある場合は、オートメーションを続行するために各ステップに対して [**Execute this step (このステップを実行)**] を選択する必要があります。[**Execute this step (このステップを実行)**] を選択するたびに、アクションが実行されます。
**注記**  
オートメーションのステータスがコンソールに表示されます。オートメーションでステップの実行に失敗した場合は、「[Systems Manager Automation のトラブルシューティング](automation-troubleshooting.md)」を参照してください。

1. ランブックで指定されているすべてのステップを完了したら、[**Complete and view results (完了して結果を表示)**] を選択してオートメーションを終了し、結果を表示します。

オートメーション実行が完了したら、同じパラメータまたは変更されたパラメータを使用して実行を再実行できます。詳細については、「[オートメーション実行の再実行](automation-rerun-executions.md)」を参照してください。

## オートメーションをステップごとに実行する (コマンドライン)
<a name="automation-working-executing-manually-commandline"></a>

次の手順は、AWS CLI (Linux の場合、Windows の場合は macOS) または AWS Tools for PowerShell 使用して、オートメーションをステップごとに手動で実行する方法を説明しています。

**オートメーションをステップごとに実行するには**

1. まだ AWS CLI または AWS Tools for PowerShell をインストールして設定していない場合は、インストールして設定します。

   詳細については、「[AWS CLI の最新バージョンをインストールまたは更新します。](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)」および「[AWS Tools for PowerShell のインストール](https://docs.aws.amazon.com/powershell/latest/userguide/pstools-getting-set-up.html)」を参照してください。

1. 以下のコマンドを実行して、オートメーションを手動で開始します。各{{リソースプレースホルダーの例}}をユーザー自身の情報に置き換えます。

------
#### [ Linux & macOS ]

   ```
   aws ssm start-automation-execution \
       --document-name {{runbook name}} \
       --mode Interactive \
       --parameters {{runbook parameters}}
   ```

------
#### [ Windows ]

   ```
   aws ssm start-automation-execution ^
       --document-name {{runbook name}} ^
       --mode Interactive ^
       --parameters {{runbook parameters}}
   ```

------
#### [ PowerShell ]

   ```
   Start-SSMAutomationExecution `
       -DocumentName {{runbook name}} `
       -Mode Interactive `
       -Parameter {{runbook parameters}}
   ```

------

   ランブック `AWS-RestartEC2Instance` を使用して指定した EC2 インスタンスを再起動する例を次に示します。

------
#### [ Linux & macOS ]

   ```
   aws ssm start-automation-execution \
       --document-name "AWS-RestartEC2Instance" \
       --mode Interactive \
       --parameters "InstanceId=i-02573cafcfEXAMPLE"
   ```

------
#### [ Windows ]

   ```
   aws ssm start-automation-execution ^
       --document-name "AWS-RestartEC2Instance" ^
       --mode Interactive ^
       --parameters "InstanceId=i-02573cafcfEXAMPLE"
   ```

------
#### [ PowerShell ]

   ```
   Start-SSMAutomationExecution `
       -DocumentName AWS-RestartEC2Instance `
       -Mode Interactive 
       -Parameter @{"InstanceId"="i-02573cafcfEXAMPLE"}
   ```

------

   システムが以下のような情報を返します。

------
#### [ Linux & macOS ]

   ```
   {
       "AutomationExecutionId": "ba9cd881-1b36-4d31-a698-0123456789ab"
   }
   ```

------
#### [ Windows ]

   ```
   {
       "AutomationExecutionId": "ba9cd881-1b36-4d31-a698-0123456789ab"
   }
   ```

------
#### [ PowerShell ]

   ```
   ba9cd881-1b36-4d31-a698-0123456789ab
   ```

------

1. オートメーションの最初のステップを開始する準備が整ったら、次のコマンドを実行します。各{{リソースプレースホルダーの例}}をユーザー自身の情報に置き換えます。オートメーションは1 ステップだけ進み、この手順のステップ 1 で選択したランブックで指定した後続のステップを実行する前に一時停止します。ランブックに複数のステップがある場合は、オートメーションを続行するために各ステップに対して次のコマンドを実行する必要があります。

------
#### [ Linux & macOS ]

   ```
   aws ssm send-automation-signal \
       --automation-execution-id {{ba9cd881-1b36-4d31-a698-0123456789ab}} \
       --signal-type StartStep \
       --payload StepName="{{stopInstances}}"
   ```

------
#### [ Windows ]

   ```
   aws ssm send-automation-signal ^
       --automation-execution-id {{ba9cd881-1b36-4d31-a698-0123456789ab}} ^
       --signal-type StartStep ^
       --payload StepName="{{stopInstances}}"
   ```

------
#### [ PowerShell ]

   ```
   Send-SSMAutomationSignal `
       -AutomationExecutionId {{ba9cd881-1b36-4d31-a698-0123456789ab}} `
       -SignalType StartStep 
       -Payload @{"StepName"="{{stopInstances}}"}
   ```

------

   コマンドが成功した場合、出力はありません。

1. 次のコマンドを実行して、オートメーションにおける各ステップ実行のステータスを取得します。

------
#### [ Linux & macOS ]

   ```
   aws ssm describe-automation-step-executions \
       --automation-execution-id {{ba9cd881-1b36-4d31-a698-0123456789ab}}
   ```

------
#### [ Windows ]

   ```
   aws ssm describe-automation-step-executions ^
       --automation-execution-id {{ba9cd881-1b36-4d31-a698-0123456789ab}}
   ```

------
#### [ PowerShell ]

   ```
   Get-SSMAutomationStepExecution `
       -AutomationExecutionId {{ba9cd881-1b36-4d31-a698-0123456789ab}}
   ```

------

   システムが以下のような情報を返します。

------
#### [ Linux & macOS ]

   ```
   {
       "StepExecutions": [
           {
               "StepName": "stopInstances",
               "Action": "aws:changeInstanceState",
               "ExecutionStartTime": 1557167178.42,
               "ExecutionEndTime": 1557167220.617,
               "StepStatus": "Success",
               "Inputs": {
                   "DesiredState": "\"stopped\"",
                   "InstanceIds": "[\"i-02573cafcfEXAMPLE\"]"
               },
               "Outputs": {
                   "InstanceStates": [
                       "stopped"
                   ]
               },
               "StepExecutionId": "654243ba-71e3-4771-b04f-0123456789ab",
               "OverriddenParameters": {},
               "ValidNextSteps": [
                   "startInstances"
               ]
           },
           {
               "StepName": "startInstances",
               "Action": "aws:changeInstanceState",
               "ExecutionStartTime": 1557167273.754,
               "ExecutionEndTime": 1557167480.73,
               "StepStatus": "Success",
               "Inputs": {
                   "DesiredState": "\"running\"",
                   "InstanceIds": "[\"i-02573cafcfEXAMPLE\"]"
               },
               "Outputs": {
                   "InstanceStates": [
                       "running"
                   ]
               },
               "StepExecutionId": "8a4a1e0d-dc3e-4039-a599-0123456789ab",
               "OverriddenParameters": {}
           }
       ]
   }
   ```

------
#### [ Windows ]

   ```
   {
       "StepExecutions": [
           {
               "StepName": "stopInstances",
               "Action": "aws:changeInstanceState",
               "ExecutionStartTime": 1557167178.42,
               "ExecutionEndTime": 1557167220.617,
               "StepStatus": "Success",
               "Inputs": {
                   "DesiredState": "\"stopped\"",
                   "InstanceIds": "[\"i-02573cafcfEXAMPLE\"]"
               },
               "Outputs": {
                   "InstanceStates": [
                       "stopped"
                   ]
               },
               "StepExecutionId": "654243ba-71e3-4771-b04f-0123456789ab",
               "OverriddenParameters": {},
               "ValidNextSteps": [
                   "startInstances"
               ]
           },
           {
               "StepName": "startInstances",
               "Action": "aws:changeInstanceState",
               "ExecutionStartTime": 1557167273.754,
               "ExecutionEndTime": 1557167480.73,
               "StepStatus": "Success",
               "Inputs": {
                   "DesiredState": "\"running\"",
                   "InstanceIds": "[\"i-02573cafcfEXAMPLE\"]"
               },
               "Outputs": {
                   "InstanceStates": [
                       "running"
                   ]
               },
               "StepExecutionId": "8a4a1e0d-dc3e-4039-a599-0123456789ab",
               "OverriddenParameters": {}
           }
       ]
   }
   ```

------
#### [ PowerShell ]

   ```
   Action: aws:changeInstanceState
   ExecutionEndTime     : 5/6/2019 19:45:46
   ExecutionStartTime   : 5/6/2019 19:45:03
   FailureDetails       : 
   FailureMessage       : 
   Inputs               : {[DesiredState, "stopped"], [InstanceIds, ["i-02573cafcfEXAMPLE"]]}
   IsCritical           : False
   IsEnd                : False
   MaxAttempts          : 0
   NextStep             : 
   OnFailure            : 
   Outputs              : {[InstanceStates, Amazon.Runtime.Internal.Util.AlwaysSendList`1[System.String]]}
   OverriddenParameters : {}
   Response             : 
   ResponseCode         : 
   StepExecutionId      : 8fcc9641-24b7-40b3-a9be-0123456789ab
   StepName             : stopInstances
   StepStatus           : Success
   TimeoutSeconds       : 0
   ValidNextSteps       : {startInstances}
   ```

------

1. 選択したランブック内のすべての指定されているステップが終了したら、次のコマンドを実行してオートメーションを完了します。各{{リソースプレースホルダーの例}}をユーザー自身の情報に置き換えます。

------
#### [ Linux & macOS ]

   ```
   aws ssm stop-automation-execution \
       --automation-execution-id {{ba9cd881-1b36-4d31-a698-0123456789ab}} \
       --type Complete
   ```

------
#### [ Windows ]

   ```
   aws ssm stop-automation-execution ^
       --automation-execution-id {{ba9cd881-1b36-4d31-a698-0123456789ab}} ^
       --type Complete
   ```

------
#### [ PowerShell ]

   ```
   Stop-SSMAutomationExecution `
       -AutomationExecutionId {{ba9cd881-1b36-4d31-a698-0123456789ab}} `
       -Type Complete
   ```

------

   コマンドが成功した場合、出力はありません。