

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

# Systems Manager Automation アクションのリファレンス
<a name="automation-actions"></a>

このリファレンスでは、オートメーションランブックで指定できるAutomation アクションについて説明します。Automation は AWS Systems Manager のツールです。これらのアクションは他のタイプの Systems Manager (SSM) ドキュメントでは使用できません。SSM の他のドキュメントタイプのプラグインについては、「[コマンドドキュメントプラグインリファレンス](documents-command-ssm-plugin-reference.md)」を参照してください。

Systems Manager Automation は、オートエアコンランブックで定義されたステップを実行します。各ステップは、特定のオペレーションに関連付けられます。このアクションは、ステップの入力、動作、出力を決定します。ステップは、ランブックの `mainSteps` セクションで定義されます。

アクションまたはステップの出力を指定する必要はありません。出力は、ステップに関係付けられるアクションで事前判断されます。Runbook でステップ入力を指定すると、前のステップの 1 つあるいは複数の出力を参照できます。たとえば、`aws:runInstances` の出力は後続の `aws:runCommand` アクションで利用できます。Runbook の `Output` セクションで前のステップの出力を参照することもできます。

**重要**  
AWS Identity and Access Management (IAM) サービスロールを使用して他のサービスを呼び出す自動化ワークフローを実行する場合は、それらのサービスを呼び出すためのアクセス許可をサービスロールに設定する必要がある点に注意してください。この要件は、`AWS-ConfigureS3BucketLogging`、`AWS-CreateDynamoDBBackup`、`AWS-RestartEC2Instance` ランブックなど、すべての AWS オートメーションランブック (`AWS-*` ランブック) に適用されます。この要件は、他のサービスを呼び出すアクションを使用して他の AWS のサービスを呼び出すように作成したカスタムオートメーションランブックにも適用されます。例えば、`aws:executeAwsApi`、`aws:createStack`、または `aws:copyImage` のアクションを使用する場合は、それらのサービスを呼び出すためのアクセス許可を持つサービスロールを設定します。ロールに IAM インラインポリシーを追加することで、他の AWS のサービスへのアクセス許可を有効にできます。詳細については、「[(オプション) 他の AWS のサービス を呼び出すためのオートメーションインラインポリシーまたはカスタマー管理ポリシーを追加する](automation-setup-iam.md#add-inline-policy)」を参照してください。

**Topics**
+ [すべてのアクションで共有されるプロパティ](#automation-common)
+ [`aws:approve` - 手動承認のためにオートメーションを一時停止する](automation-action-approve.md)
+ [`aws:assertAwsResourceProperty` – AWS リソースの状態またはイベントの状態をアサートする](automation-action-assertAwsResourceProperty.md)
+ [`aws:branch` – 条件付きオートメーションステップを実行する](automation-action-branch.md)
+ [`aws:changeInstanceState` – インスタンスの状態を変更またはアサートする](automation-action-changestate.md)
+ [`aws:copyImage` — Amazon Machine Image のコピーまたは暗号化](automation-action-copyimage.md)
+ [`aws:createImage` – Amazon マシンイメージ (AMI) を作成する](automation-action-create.md)
+ [`aws:createStack` – CloudFormation スタックを作成する](automation-action-createstack.md)
+ [`aws:createTags` – AWS リソースのタグを作成する](automation-action-createtag.md)
+ [`aws:deleteImage` – Amazon Machine Image を削除する](automation-action-delete.md)
+ [`aws:deleteStack` – CloudFormation スタックを削除する](automation-action-deletestack.md)
+ [`aws:executeAutomation` – 別のオートメーションを実行する](automation-action-executeAutomation.md)
+ [`aws:executeAwsApi` — AWS API オペレーションの呼び出しと実行](automation-action-executeAwsApi.md)
+ [`aws:executeScript` – スクリプトを実行する](automation-action-executeScript.md)
+ [`aws:executeStateMachine` – AWS Step Functions ステートマシンを実行する](automation-action-executeStateMachine.md)
+ [`aws:invokeWebhook` – オートメーションのウェブフック統合を呼び出す](invoke-webhook.md)
+ [`aws:invokeLambdaFunction` – AWS Lambda 関数を呼び出す](automation-action-lamb.md)
+ [`aws:loop` — オートメーション内のステップを反復処理します。](automation-action-loop.md)
+ [`aws:pause` – オートメーションを一時停止する](automation-action-pause.md)
+ [`aws:runCommand` – マネージドインスタンスでコマンドを実行する](automation-action-runcommand.md)
+ [`aws:runInstances` – Amazon EC2 インスタンスの起動](automation-action-runinstance.md)
+ [`aws:sleep` – オートメーションを遅らせる](automation-action-sleep.md)
+ [`aws:updateVariable` — ランブック変数の値を更新します。](automation-action-update-variable.md)
+ [`aws:waitForAwsResourceProperty` – AWS リソースプロパティを待つ](automation-action-waitForAwsResourceProperty.md)
+ [オートメーションシステム変数](automation-variables.md)

## すべてのアクションで共有されるプロパティ
<a name="automation-common"></a>

共通プロパティは、すべてのアクションで見つかるパラメータまたはオプションです。一部のオプションは、ステップの動作を定義します。たとえば、ステップが完了するまで待機する時間や、ステップが失敗した場合の対処方法などです。以下のプロパティは、すべてのアクションに共通です。

[description](#descriptProp)  
ランブックまたはステップの目的を説明するために提供する情報。  
タイプ: 文字列  
必須: いいえ

[name](#nameProp)  
Runbook のすべてのステップ名にわたって一意でなければならない識別子。  
タイプ: 文字列  
使用できるパターン: [a-zA-Z0-9\_]\+$  
必須: はい

[action](#actProp)  
ステップが実行するアクションの名前です。[`aws:runCommand` – マネージドインスタンスでコマンドを実行する](automation-action-runcommand.md) はここで指定できるアクションの例です。このドキュメントは、使用可能なすべてのアクションの詳細情報を提供します。  
型: 文字列  
必須: はい

[maxAttempts](#maxProp)  
ステップが失敗した場合は再試行する回数。指定した値が 1 より大きい場合、すべての再試行が失敗するまでステップは失敗したと見なされません。デフォルト値は 1 です。  
タイプ: 整数  
必須: いいえ

[timeoutSeconds](#timeProp)  
ステップのタイムアウト値。タイムアウトが達したときに `maxAttempts` の値が 1 以上の場合、すべての再試行が実行されるまでこのステップはタイムアウトとは見なされません。  
タイプ: 整数  
必須: いいえ

[onFailure](#failProp)  
失敗時にオートメーションを中止するか、続行するか、別のステップに移行するかを示します。このオプションのデフォルト値は中止です。  
型: 文字列  
有効な値: Abort \| Continue \| step:{{step\_name}}  
必須: いいえ

[onCancel](#canProp)  
ユーザーがオートメーションをキャンセルした場合に、オートメーションがどのステップに進むべきかを示します。Automation は、最大で 2 分間、キャンセルワークフローを実行します。  
型: 文字列  
有効な値: Abort \| step:{{step\_name}}  
必須: いいえ  
`onCancel` プロパティでは、次のアクションへの移動はサポートされていません。  
+ `aws:approve`
+ `aws:copyImage`
+ `aws:createImage`
+ `aws:createStack`
+ `aws:createTags`
+ `aws:loop`
+ `aws:pause`
+ `aws:runInstances`
+ `aws:sleep`

[isEnd](#endProp)  
このオプションでは、特定のステップの最後にオートメーションを停止します。ステップが失敗または成功した場合に、オートメーションが停止します。デフォルト値は false です。  
タイプ: ブール値  
有効な値: true \| false  
必須: いいえ

[nextStep](#nextProp)  
ステップを正常に完了した後に、次に処理するオートメーションのステップを指定します。  
型: 文字列  
必須: いいえ

[isCritical](#critProp)  
自動化の正常な完了のために、ステップを critical として指定します。この指定のステップが失敗した場合、自動化は自動化の失敗の最終的なステータスをレポートします。このプロパティは、ステップで明示的に定義した場合のみ評価されます。ステップで `onFailure` プロパティが `Continue` に設定されている場合、値はデフォルトで false になります。それ以外の場合、このオプションのデフォルト値は true です。  
タイプ: ブール値  
有効な値: true \| false  
必須: いいえ

[inputs](#inProp)  
アクション固有のプロパティ。  
型: マップ  
必須: はい

### 例
<a name="automation-demo"></a>

```
---
description: "Custom Automation Example"
schemaVersion: '0.3'
assumeRole: "{{ AutomationAssumeRole }}"
parameters:
  AutomationAssumeRole:
    type: String
    description: "(Required) The ARN of the role that allows Automation to perform
      the actions on your behalf. If no role is specified, Systems Manager Automation
      uses your IAM permissions to run this runbook."
    default: ''
  InstanceId:
      type: String
      description: "(Required) The Instance Id whose root EBS volume you want to restore the latest Snapshot."
      default: ''
mainSteps:
- name: getInstanceDetails
  action: aws:executeAwsApi
  onFailure: Abort
  inputs:
    Service: ec2
    Api: DescribeInstances
    InstanceIds:
    - "{{ InstanceId }}"
  outputs:
    - Name: availabilityZone
      Selector: "$.Reservations[0].Instances[0].Placement.AvailabilityZone"
      Type: String
    - Name: rootDeviceName
      Selector: "$.Reservations[0].Instances[0].RootDeviceName"
      Type: String
  nextStep: getRootVolumeId
- name: getRootVolumeId
  action: aws:executeAwsApi
  maxAttempts: 3
  onFailure: Abort
  inputs:
    Service: ec2
    Api: DescribeVolumes
    Filters:
    -  Name: attachment.device
       Values: ["{{ getInstanceDetails.rootDeviceName }}"]
    -  Name: attachment.instance-id
       Values: ["{{ InstanceId }}"]
  outputs:
    - Name: rootVolumeId
      Selector: "$.Volumes[0].VolumeId"
      Type: String
  nextStep: getSnapshotsByStartTime
- name: getSnapshotsByStartTime
  action: aws:executeScript
  timeoutSeconds: 45
  onFailure: Abort
  inputs:
    Runtime: python3.8
    Handler: getSnapshotsByStartTime
    InputPayload:
      rootVolumeId : "{{ getRootVolumeId.rootVolumeId }}"
    Script: |-
      def getSnapshotsByStartTime(events,context):
        import boto3

        #Initialize client
        ec2 = boto3.client('ec2')
        rootVolumeId = events['rootVolumeId']
        snapshotsQuery = ec2.describe_snapshots(
          Filters=[
            {
              "Name": "volume-id",
              "Values": [rootVolumeId]
            }
          ]
        )
        if not snapshotsQuery['Snapshots']:
          noSnapshotFoundString = "NoSnapshotFound"
          return { 'noSnapshotFound' : noSnapshotFoundString }
        else:
          jsonSnapshots = snapshotsQuery['Snapshots']
          sortedSnapshots = sorted(jsonSnapshots, key=lambda k: k['StartTime'], reverse=True)
          latestSortedSnapshotId = sortedSnapshots[0]['SnapshotId']
          return { 'latestSnapshotId' : latestSortedSnapshotId }
  outputs:
  - Name: Payload
    Selector: $.Payload
    Type: StringMap
  - Name: latestSnapshotId
    Selector: $.Payload.latestSnapshotId
    Type: String
  - Name: noSnapshotFound
    Selector: $.Payload.noSnapshotFound
    Type: String 
  nextStep: branchFromResults
- name: branchFromResults
  action: aws:branch
  onFailure: Abort
  onCancel: step:startInstance
  inputs:
    Choices:
    - NextStep: createNewRootVolumeFromSnapshot
      Not:
        Variable: "{{ getSnapshotsByStartTime.noSnapshotFound }}"
        StringEquals: "NoSnapshotFound"
  isEnd: true
- name: createNewRootVolumeFromSnapshot
  action: aws:executeAwsApi
  onFailure: Abort
  inputs:
    Service: ec2
    Api: CreateVolume
    AvailabilityZone: "{{ getInstanceDetails.availabilityZone }}"
    SnapshotId: "{{ getSnapshotsByStartTime.latestSnapshotId }}"
  outputs:
    - Name: newRootVolumeId
      Selector: "$.VolumeId"
      Type: String
  nextStep: stopInstance
- name: stopInstance
  action: aws:executeAwsApi
  onFailure: Abort
  inputs:
    Service: ec2
    Api: StopInstances
    InstanceIds:
    - "{{ InstanceId }}"
  nextStep: verifyVolumeAvailability
- name: verifyVolumeAvailability
  action: aws:waitForAwsResourceProperty
  timeoutSeconds: 120
  inputs:
    Service: ec2
    Api: DescribeVolumes
    VolumeIds:
    - "{{ createNewRootVolumeFromSnapshot.newRootVolumeId }}"
    PropertySelector: "$.Volumes[0].State"
    DesiredValues:
    - "available"
  nextStep: verifyInstanceStopped
- name: verifyInstanceStopped
  action: aws:waitForAwsResourceProperty
  timeoutSeconds: 120
  inputs:
    Service: ec2
    Api: DescribeInstances
    InstanceIds:
    - "{{ InstanceId }}"
    PropertySelector: "$.Reservations[0].Instances[0].State.Name"
    DesiredValues:
    - "stopped"
  nextStep: detachRootVolume
- name: detachRootVolume
  action: aws:executeAwsApi
  onFailure: Abort
  isCritical: true
  inputs:
    Service: ec2
    Api: DetachVolume
    VolumeId: "{{ getRootVolumeId.rootVolumeId }}"
  nextStep: verifyRootVolumeDetached
- name: verifyRootVolumeDetached
  action: aws:waitForAwsResourceProperty
  timeoutSeconds: 30
  inputs:
    Service: ec2
    Api: DescribeVolumes
    VolumeIds:
    - "{{ getRootVolumeId.rootVolumeId }}"
    PropertySelector: "$.Volumes[0].State"
    DesiredValues:
    - "available"
  nextStep: attachNewRootVolume
- name: attachNewRootVolume
  action: aws:executeAwsApi
  onFailure: Abort
  inputs:
    Service: ec2
    Api: AttachVolume
    Device: "{{ getInstanceDetails.rootDeviceName }}"
    InstanceId: "{{ InstanceId }}"
    VolumeId: "{{ createNewRootVolumeFromSnapshot.newRootVolumeId }}"
  nextStep: verifyNewRootVolumeAttached
- name: verifyNewRootVolumeAttached
  action: aws:waitForAwsResourceProperty
  timeoutSeconds: 30
  inputs:
    Service: ec2
    Api: DescribeVolumes
    VolumeIds:
    - "{{ createNewRootVolumeFromSnapshot.newRootVolumeId }}"
    PropertySelector: "$.Volumes[0].Attachments[0].State"
    DesiredValues:
    - "attached"
  nextStep: startInstance
- name: startInstance
  action: aws:executeAwsApi
  onFailure: Abort
  inputs:
    Service: ec2
    Api: StartInstances
    InstanceIds:
    - "{{ InstanceId }}"
```