

• 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-variables"></a>

AWS Systems Manager オートメーションランブックでは、以下の変数が使用されます。これらの変数の使用例については、`AWS-UpdateWindowsAmi` Runbook の JSON ソースを参照してください。

**`AWS-UpdateWindowsAmi` ランブックの JSON ソースを表示するには**

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

1. ナビゲーションペインで、[**ドキュメント**] を選択します。

1. ドキュメントリストで、検索バーまたは検索バーの右側にある数字のいずれかを使用して、ランブック `AWS-UpdateWindowsAmi` を選択します。

1. [**Content**] タブを選択します。

**システム変数**  
オートメーションランブックでは、以下のシステム変数がサポートされています。


****  

| 変数 | 詳細 | 
| --- | --- | 
| `global:ACCOUNT_ID` | オートメーションを実行するユーザーまたはロールの AWS アカウント ID です。 | 
| `global:DATE` | yyyy-MM-dd 形式の日付 (実行時)。 | 
| `global:DATE_TIME` | yyyy-MM-dd\_HH.mm.ss 形式の日時 (実行時)。 | 
| `global:AWS_PARTITION` | リソースが置かれているパーティションです。標準 AWS リージョン の場合、パーティションは `aws` です。他のパーティションのリソースについては、パーティションは `aws-{{partitionname}}` です。例えば、AWS GovCloud (米国西部) リージョンのリソースのパーティションは `aws-us-gov` です。 | 
| `global:REGION` | Runbook が実行されるリージョン。たとえば、us-east-2 です。 | 

**オートメーション変数**  
オートメーションランブックでは、以下の Automation 変数がサポートされています。


****  

| 変数 | 詳細 | 
| --- | --- | 
| `automation:EXECUTION_ID` | 現在のオートメーションに割り当てられた一意の識別子 例えば、`1a2b3c-1a2b3c-1a2b3c-1a2b3c1a2b3c1a2b3c` と指定します。 | 

**Topics**
+ [用語](#automation-terms)
+ [サポートされるシナリオ](#automation-variables-support)
+ [サポートされないシナリオ](#automation-variables-unsupported)

## 用語
<a name="automation-terms"></a>

以下の用語では、変数とパラメータの解決方法について説明します。


****  

| 用語 | 定義 | 例 | 
| --- | --- | --- | 
| 定数 ARN | 変数を含まない有効な Amazon リソースネーム (ARN)。 | `arn:aws:iam::123456789012:role/roleName` | 
| Runbook パラメータ | Runbook レベル (`instanceId` など) で定義されたパラメータ。このパラメータは基本的な文字列置換で使用されます。その値は Start Execution 時に渡されます。 |  <pre>{ <br />   "description": "Create Image Demo",<br />   "version": "0.3",<br />   "assumeRole": "{{Your_Automation_Assume_Role_ARN}}",<br />   "parameters":{ <br />      "instanceId": { <br />         "type": "String",<br />         "description": "Instance to create image from"<br />   }<br />}</pre>  | 
| システム変数 | Runbook のいずれかの部分が評価されたときに Runbook に代入される一般的な変数。 |  <pre>"activities": [ <br />   { <br />      "id": "copyImage",<br />      "activityType": "AWS-CopyImage",<br />      "maxAttempts": 1,<br />      "onFailure": "Continue",<br />      "inputs": { <br />         "ImageName": "{{imageName}}",<br />         "SourceImageId": "{{sourceImageId}}",<br />         "SourceRegion": "{{sourceRegion}}",<br />         "Encrypted": true,<br />         "ImageDescription": "Test CopyImage Description created on {{global:DATE}}"<br />      }<br />   }<br />]</pre>  | 
| Automation 変数 | Runbook のいずれかの部分が評価されたときに Runbook に代入される、オートメーションに関連した変数。 |  <pre>{ <br />   "name": "runFixedCmds",<br />   "action": "aws:runCommand",<br />   "maxAttempts": 1,<br />   "onFailure": "Continue",<br />   "inputs": { <br />      "DocumentName": "AWS-RunPowerShellScript",<br />      "InstanceIds": [ <br />         "{{LaunchInstance.InstanceIds}}"<br />      ],<br />      "Parameters": { <br />         "commands": [ <br />            "dir",<br />            "date",<br />            "“{{outputFormat}}” -f “left”,”right”,”{{global:DATE}}”,”{{automation:EXECUTION_ID}}”<br />         ]<br />      }<br />   }<br />}</pre>  | 
| Systems Manager パラメータ | AWS Systems Manager Parameter Store 内で定義された変数。ステップ入力で直接参照することはできません。パラメータにアクセスするにはアクセス許可が必要な場合があります。 |  <pre><br />description: Launch new Windows test instance<br />schemaVersion: '0.3'<br />assumeRole: '{{AutomationAssumeRole}}'<br />parameters:<br />  AutomationAssumeRole:<br />    type: String<br />    default: ''<br />    description: >-<br />      (Required) The ARN of the role that allows Automation to perform the<br />      actions on your behalf. If no role is specified, Systems Manager<br />      Automation uses your IAM permissions to run this runbook.<br />  LatestAmi:<br />    type: String<br />    default: >-<br />      {{ssm:/aws/service/ami-windows-latest/Windows_Server-2016-English-Full-Base}}<br />    description: The latest Windows Server 2016 AMI queried from the public parameter.<br />mainSteps:<br />  - name: launchInstance<br />    action: 'aws:runInstances'<br />    maxAttempts: 3<br />    timeoutSeconds: 1200<br />    onFailure: Abort<br />    inputs:<br />      ImageId: '{{LatestAmi}}'<br />...</pre>  | 

## サポートされるシナリオ
<a name="automation-variables-support"></a>


****  

| シナリオ | コメント | 例 | 
| --- | --- | --- | 
| 作成時の一定 ARN `assumeRole`。 | 権限付与チェックが実行されて、呼び出し元ユーザーが `assumeRole` の委譲を許可されていることが確認されます。 |  <pre>{<br />  "description": "Test all Automation resolvable parameters",<br />  "schemaVersion": "0.3",<br />  "assumeRole": "arn:aws:iam::123456789012:role/roleName",<br />  "parameters": { <br />  ...</pre>  | 
| オートメーションの開始時に、`AssumeRole` に与えられる Runbook のパラメータ。 | Runbook のパラメータリストで定義する必要があります。 |  <pre>{<br />  "description": "Test all Automation resolvable parameters",<br />  "schemaVersion": "0.3",<br />  "assumeRole": "{{dynamicARN}}",<br />  "parameters": {<br /> ...</pre>  | 
| 開始時に Runbook パラメータに渡される値 | お客様がパラメータに使用する値を指定します。開始時に渡される入力は、Runbook のパラメータリストで定義する必要があります。 | <pre>...<br />"parameters": {<br />    "amiId": {<br />      "type": "String",<br />      "default": "{{ami-12345678}}",<br />      "description": "list of commands to run as part of first step"<br />    },<br />...</pre>Start Automation Execution への入力には `{"amiId" : ["{{ami-12345678}}"] }` を含めます。 | 
| ランブックコンテンツ内で参照される Systems Manager パラメータ。 | 変数は、顧客のアカウント内に存在するか、パブリックにアクセス可能なパラメータであり、Runbook の `AssumeRole` に変数へのアクセスがあります。作成時にチェックが実行されて、`AssumeRole` が変数にアクセスできることが確認されます。パラメータは、ステップ入力で直接参照することはできません。 |  <pre><br />...<br />parameters:<br />    LatestAmi:<br />    type: String<br />    default: >-<br />      {{ssm:/aws/service/ami-windows-latest/Windows_Server-2016-English-Full-Base}}<br />    description: The latest Windows Server 2016 AMI queried from the public parameter.<br />mainSteps:<br />  - name: launchInstance<br />    action: 'aws:runInstances'<br />    maxAttempts: 3<br />    timeoutSeconds: 1200<br />    onFailure: Abort<br />    inputs:<br />      ImageId: '{{LatestAmi}}'<br />...</pre>  | 
| ステップ定義内で参照されるシステム変数 | オートメーションが開始されると、システム変数が Runbook に代入されます。Runbook に挿入される値は、代入時の変数の値に対して相対的になります。たとえば、ステップ 1 で挿入される時間変数の値は、ステップの実行にかかる時間のため、ステップ 3 で挿入される時間変数の値とは異なります。システム変数は、ランブックのパラメータリストで設定する必要はありません。 |  <pre>...<br />  "mainSteps": [<br />    {<br />      "name": "RunSomeCommands",<br />      "action": "aws:runCommand",<br />      "maxAttempts": 1,<br />      "onFailure": "Continue",<br />      "inputs": {<br />        "DocumentName": "AWS:RunPowerShell",<br />        "InstanceIds": ["{{LaunchInstance.InstanceIds}}"],<br />        "Parameters": {<br />            "commands" : [<br />                "echo {The time is now {{global:DATE_TIME}}}"<br />            ]<br />        }<br />    }<br />}, ... </pre>  | 
| ステップ定義内で参照される自動化の変数 | Automation 変数は、ランブックのパラメータリストで設定する必要はありません。サポートされる Automation 変数は **automation:EXECUTION\_ID** のみです。 |  <pre>...<br />"mainSteps": [<br />    {<br />      "name": "invokeLambdaFunction",<br />      "action": "aws:invokeLambdaFunction",<br />      "maxAttempts": 1,<br />      "onFailure": "Continue",<br />      "inputs": {<br />        "FunctionName": "Hello-World-LambdaFunction",<br /><br />"Payload" : "{ "executionId" : "{{automation:EXECUTION_ID}}" }"<br />      }<br />    }<br />... </pre>  | 
| 次のステップ定義内からの前のステップの出力の参照 | これはパラメータのリダイレクトです。前のステップの出力は、構文 `{{stepName.OutputName}}` を使用して参照されます。この構文は、お客様がランブックのパラメータに対して使用することはできません。これは、参照ステップの実行時に解決されます。ランブックのパラメータリストでは設定されません。 |  <pre>...<br />"mainSteps": [<br />    {<br />      "name": "LaunchInstance",<br />      "action": "aws:runInstances",<br />      "maxAttempts": 1,<br />      "onFailure": "Continue",<br />      "inputs": {<br />        "ImageId": "{{amiId}}",<br />        "MinInstanceCount": 1,<br />        "MaxInstanceCount": 2<br />      }<br />    },<br />    {<br />      "name":"changeState",<br />      "action": "aws:changeInstanceState",<br />      "maxAttempts": 1,<br />      "onFailure": "Continue",<br />      "inputs": {<br />        "InstanceIds": ["{{LaunchInstance.InstanceIds}}"],<br />        "DesiredState": "terminated"<br />      }<br />    }<br /><br />... </pre>  | 

## サポートされないシナリオ
<a name="automation-variables-unsupported"></a>


****  

| シナリオ | コメント | 例 | 
| --- | --- | --- | 
| 作成時に `assumeRole` に渡される Systems Manager パラメータ | サポート外。 |  <pre>...<br /><br />{<br />  "description": "Test all Automation resolvable parameters",<br />  "schemaVersion": "0.3",<br />  "assumeRole": "{{{{ssm:administratorRoleARN}}}}",<br />  "parameters": {<br /><br />... </pre>  | 
| ステップ入力で直接参照される Systems Manager パラメータ。 | 作成時に `InvalidDocumentContent` 例外を返します。 |  <pre><br />...<br />mainSteps:<br />  - name: launchInstance<br />    action: 'aws:runInstances'<br />    maxAttempts: 3<br />    timeoutSeconds: 1200<br />    onFailure: Abort<br />    inputs:<br />      ImageId: '{{ssm:/aws/service/ami-windows-latest/Windows_Server-2016-English-Full-Base}}'<br />...</pre>  | 
| 変数によるステップの定義 | Runbook 内のステップの定義は変数によって構成されます。 |  <pre>...<br /><br />"mainSteps": [<br />    {<br />      "name": "LaunchInstance",<br />      "action": "aws:runInstances",<br />      "{{attemptModel}}": 1,<br />      "onFailure": "Continue",<br />      "inputs": {<br />        "ImageId": "{{ami-12345678}}",<br />        "MinInstanceCount": 1,<br />        "MaxInstanceCount": 2<br />      }<br /><br />...<br /><br />User supplies input : { "attemptModel" : "minAttempts" } </pre>  | 
| Runbook パラメータの相互参照 | ユーザーは開始時に入力パラメータとして、Runbook 内の別のパラメータへの参照を渡します。 |  <pre>...<br />"parameters": {<br />    "amiId": {<br />      "type": "String",<br />      "default": "{{ami-7f2e6015}}",<br />      "description": "list of commands to run as part of first step"<br />    },<br />    "alternateAmiId": {<br />      "type": "String",<br />      "description": "The alternate AMI to try if this first fails".<br /><br />"default" : "{{amiId}}"<br />    },<br /><br />... </pre>  | 
| 複数レベルの展開 | Runbook で、変数の名前に評価される変数を定義します。これは、変数区切り記号 (*{{ }}*) 内にあり、変数/パラメータの値に展開されます。 |  <pre>...<br />  "parameters": {<br />    "{{firstParameter}}": {<br />      "type": "String",<br />      "default": "param2",<br />      "description": "The parameter to reference"<br />    },<br />    "{{secondParameter}}": {<br />      "type": "String",<br />      "default" : "echo {Hello world}",<br />      "description": "What to run"<br />    }<br />  },<br />  "mainSteps": [{<br />      "name": "runFixedCmds",<br />      "action": "aws:runCommand",<br />      "maxAttempts": 1,<br />      "onFailure": "Continue",<br />      "inputs": {<br />        "DocumentName": "AWS-RunPowerShellScript",<br /><br />"InstanceIds" : "{{LaunchInstance.InstanceIds}}",<br />        "Parameters": {<br />          "commands": [ "{{ {{firstParameter}} }}"]<br /><br />}<br /><br />...<br /><br />Note: The customer intention here would be to run a command of "echo {Hello world}" </pre>  | 
| 別の変数タイプであるRunbook ステップからの出力の参照 | ユーザーは前のRunbook ステップからの出力を後続のステップ内で参照します。出力は、後続のステップのアクションの要件を満たしていない変数タイプです。 |  <pre>...<br />mainSteps:<br />- name: getImageId<br />  action: aws:executeAwsApi<br />  inputs:<br />    Service: ec2<br />    Api: DescribeImages<br />    Filters:  <br />    - Name: "name"<br />      Values: <br />      - "{{ImageName}}"<br />  outputs:<br />  - Name: ImageIdList<br />    Selector: "$.Images"<br />    Type: "StringList"<br />- name: copyMyImages<br />  action: aws:copyImage<br />  maxAttempts: 3<br />  onFailure: Abort<br />  inputs:<br />    SourceImageId: {{getImageId.ImageIdList}}<br />    SourceRegion: ap-northeast-2<br />    ImageName: Encrypted Copies of LAMP base AMI in ap-northeast-2<br />    Encrypted: true <br />... <br />Note: You must provide the type required by the Automation action. <br />In this case, aws:copyImage requires a "String" type variable but the preceding step outputs a "StringList" type variable.<br />                                        </pre>  | 