

• 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="documents-components"></a>

本部分包含有关构成 SSM 文档的组件的信息。

**Topics**
+ [架构、功能和示例](documents-schemas-features.md)
+ [数据元素和参数](documents-syntax-data-elements-parameters.md)
+ [命令文档插件参考](documents-command-ssm-plugin-reference.md)

# 架构、功能和示例
<a name="documents-schemas-features"></a>

AWS Systems Manager (SSM) 文档当前使用以下架构版本。
+ `Command` 型文档可以使用 1.2、2.0 和 2.2 版架构。如果您使用架构 1.2 文档，我们建议您创建使用架构版本 2.2 的文件。
+ `Policy` 型文档必须使用 2.0 版或更高版本的架构。
+ `Automation` 型文档必须使用 0.3 版架构。
+ `Session` 型文档必须使用 1.0 版架构。
+ 您可以创建 JSON 或 YAML 格式的文档。

有关 `Session` 文档架构的更多信息，请参阅 [会话文档架构](session-manager-schema.md)。

通过为 `Command` 和 `Policy` 文档使用最新架构版本，您可以利用以下功能。


**2.2 版架构文档功能**  

| 功能 | Details | 
| --- | --- | 
|  编辑文档  |  文档现在可以更新。如果版本为 1.2，对文档的任何更新都需要另存为其他名称。  | 
|  自动版本控制  |  对文档的任何更新都会创建一个新版本。这不是架构版本，而是文档版本。  | 
|  默认版本  |  如果您拥有某个文档的多个版本，可以指定哪个版本是默认文档。  | 
|  顺序  |  文档中的插件或*步骤*按指定的顺序运行。  | 
|  跨平台支持  |  跨平台支持可让您为同一个 SSM 文档中的不同插件指定不同操作系统。跨平台支持在某个步骤中使用 `precondition` 参数。  | 
| 参数插值 | 插值是指将变量值插入或替换到字符串中。可以将其想象为在使用字符串之前用实际值填充空白。在 SSM 文档上下文中，参数插值允许在执行命令之前将字符串参数插值到环境变量中，从而更好地防范命令注入攻击。设置为 `ENV_VAR` 时，代理会创建一个包含参数值的环境变量 `SSM_parameter-name`。 | 

**注意**  
您必须将实例上的 AWS Systems Manager SSM Agent 更新到最新版本才能使用新的 Systems Manager 功能和 SSM 文档功能。有关更多信息，请参阅 [使用 Run Command 更新 SSM Agent](run-command-tutorial-update-software.md#rc-console-agentexample)。

下表列出了主要架构版本之间的区别。


****  

| 版本 1.2 | 版本 2.2（最新版本） | Details | 
| --- | --- | --- | 
|  runtimeConfig  |  mainSteps  |  在版本 2.2 中，`mainSteps` 部分替换了 `runtimeConfig` 部分。这些区域有：`mainSteps` 部分允许 Systems Manager 按顺序运行步骤。  | 
|  属性  |  输入  |  在版本 2.2 中，`inputs` 部分替换了 `properties` 部分。`inputs` 部分接受步骤参数。  | 
|   命令  |  runCommand  |  在版本 2.2 中，`inputs` 部分接收 `runCommand` 参数，而不是 `commands` 参数。  | 
|  id  |  action  |  在版本 2.2 中，`Action` 替换了 `ID`。这只是更改了名称。  | 
|  不适用  |  名称  |  在版本 2.2 中，`name` 是用户定义的任意步骤名称。  | 

**使用前提条件参数**  
在 2.2 版或更高版本架构中，您可以使用 `precondition` 参数为每个插件指定目标操作系统验证您在 SSM 文档中定义的输入参数。`precondition` 参数支持引用 SSM 文档的输入参数，`platformType` 使用`Linux` 的值、`MacOS`,和 `Windows`。仅支持 `StringEquals` 运算符。

对于使用 2.2 版或更高版本架构的文档，如果未指定 `precondition`，每个插件将被运行或跳过，具体取决于插件与操作系统的兼容性。插件与操作系统的兼容性在 `precondition` 之前被评估。对于使用 2.0 版或更低版本架构的文档，不兼容的插件将会引发错误。

例如，在 2.2 版架构文档中，如果未指定 `precondition`，将会列出 `aws:runShellScript` 插件，该步骤在 Linux 实例上运行，但系统会在 Windows Server 实例上跳过该步骤，因为 `aws:runShellScript` 与 Windows Server 实例不兼容。但是，对于 2.0 版架构文档，如果您指定 `aws:runShellScript` 插件，然后在 Windows Server 实例上运行文档，执行将会失败。本节稍后将介绍在 SSM 文档中使用前提条件参数的示例。

## 架构版本 2.2
<a name="documents-schema-twox"></a>

**顶级元素**  
以下示例使用 2.2 版架构显示 SSM 文档的顶级元素。

------
#### [ YAML ]

```
---
schemaVersion: "2.2"
description: A description of the document.
parameters:
  parameter 1:
    property 1: "value"
    property 2: "value"
  parameter 2:
    property 1: "value"
    property 2: "value"
mainSteps:
  - action: Plugin name
    name: A name for the step.
    inputs:
      input 1: "value"
      input 2: "value"
      input 3: "{{ parameter 1 }}"
```

------
#### [ JSON ]

```
{
   "schemaVersion": "2.2",
   "description": "A description of the document.",
   "parameters": {
       "parameter 1": {
           "property 1": "value",
           "property 2": "value"
        },
        "parameter 2":{
           "property 1": "value",
           "property 2": "value"
        } 
    },
   "mainSteps": [
      {
         "action": "Plugin name",
         "name": "A name for the step.",
         "inputs": {
            "input 1": "value",
            "input 2": "value",
            "input 3": "{{ parameter 1 }}"
         }
      }
   ]
}
```

------

**2.2 版架构示例**  
以下示例使用 `aws:runPowerShellScript` 插件在目标实例上运行 PowerShell 命令。

------
#### [ YAML ]

```
---
schemaVersion: "2.2"
description: "Example document"
parameters:
  Message:
    type: "String"
    description: "Example parameter"
    default: "Hello World"
    allowedValues: 
    - "Hello World"
mainSteps:
  - action: "aws:runPowerShellScript"
    name: "example"
    inputs:
      timeoutSeconds: '60'
      runCommand:
      - "Write-Output {{Message}}"
```

------
#### [ JSON ]

```
{
   "schemaVersion": "2.2",
   "description": "Example document",
   "parameters": {
      "Message": {
         "type": "String",
         "description": "Example parameter",
         "default": "Hello World",
         "allowedValues": ["Hello World"]
      }
   },
   "mainSteps": [
      {
         "action": "aws:runPowerShellScript",
         "name": "example",
         "inputs": {
            "timeoutSeconds": "60",
            "runCommand": [
               "Write-Output {{Message}}"
            ]
         }
      }
   ]
}
```

------

**架构版本 2.2 前提条件参数示例**  
2.2 版架构提供跨平台支持。这意味着在一个 SSM 文档内，您可以为不同的插件指定不同的操作系统。跨平台支持在某个步骤中使用 `precondition` 参数，如下例所示。您也可以使用 `precondition` 参数来验证您在 SSM 文档中定义的输入参数。您可以在以下第二个示例中看到此内容。

------
#### [ YAML ]

```
---
schemaVersion: '2.2'
description: cross-platform sample
mainSteps:
- action: aws:runPowerShellScript
  name: PatchWindows
  precondition:
    StringEquals:
    - platformType
    - Windows
  inputs:
    runCommand:
    - cmds
- action: aws:runShellScript
  name: PatchLinux
  precondition:
    StringEquals:
    - platformType
    - Linux
  inputs:
    runCommand:
    - cmds
```

------
#### [ JSON ]

```
{
   "schemaVersion": "2.2",
   "description": "cross-platform sample",
   "mainSteps": [
      {
         "action": "aws:runPowerShellScript",
         "name": "PatchWindows",
         "precondition": {
            "StringEquals": [
               "platformType",
               "Windows"
            ]
         },
         "inputs": {
            "runCommand": [
               "cmds"
            ]
         }
      },
      {
         "action": "aws:runShellScript",
         "name": "PatchLinux",
         "precondition": {
            "StringEquals": [
               "platformType",
               "Linux"
            ]
         },
         "inputs": {
            "runCommand": [
               "cmds"
            ]
         }
      }
   ]
}
```

------

------
#### [ YAML ]

```
---
schemaVersion: '2.2'
parameters:
  action:
    type: String
    allowedValues:
    - Install
    - Uninstall
  confirmed:
    type: String
    allowedValues:
    - True
    - False
mainSteps:
- action: aws:runShellScript
  name: InstallAwsCLI
  precondition:
    StringEquals:
    - "{{ action }}"
    - "Install"
  inputs:
    runCommand:
    - sudo apt install aws-cli
- action: aws:runShellScript
  name: UninstallAwsCLI
  precondition:
    StringEquals:
    - "{{ action }} {{ confirmed }}"
    - "Uninstall True"
  inputs:
    runCommand:
    - sudo apt remove aws-cli
```

------
#### [ JSON ]

```
{
   "schemaVersion": "2.2",
   "parameters": {
      "action": {
         "type": "String",
         "allowedValues": [
            "Install",
            "Uninstall"
         ]
      },
      "confirmed": {
         "type": "String",
         "allowedValues": [
            true,
            false
         ]
      }
   },
   "mainSteps": [
      {
         "action": "aws:runShellScript",
         "name": "InstallAwsCLI",
         "precondition": {
            "StringEquals": [
               "{{ action }}",
               "Install"
            ]
         },
         "inputs": {
            "runCommand": [
               "sudo apt install aws-cli"
            ]
         }
      },
      {
         "action": "aws:runShellScript",
         "name": "UninstallAwsCLI",
         "precondition": {
            "StringEquals": [
               "{{ action }} {{ confirmed }}",
               "Uninstall True"
            ]
         },
         "inputs": {
            "runCommand": [
               "sudo apt remove aws-cli"
            ]
         }
      }
   ]
}
```

------

**2.2 版架构插值示例（3.3.2746.0 之前的 SSM Agent 版本）**  
在 3.3.2746.0 之前的 SSM Agent 版本中，代理会忽略 `interpolationType` 参数，转而执行原始字符串的替换。若要显式引用 `SSM_parameter-name`，则必须明确设置此项。以下 Linux 示例显式引用了环境变量 `SSM_Message`。

```
{
    "schemaVersion": "2.2",
    "description": "An example document",
    "parameters": {
        "Message": {
            "type": "String",
            "description": "Message to be printed",
            "default": "Hello",
            "interpolationType" : "ENV_VAR",
	     "allowedPattern: "^[^"]*$"

        }
    },
    "mainSteps": [{
        "action": "aws:runShellScript",
        "name": "printMessage",
        "inputs": {
            "runCommand": [
              "if [ -z "${SSM_Message+x}" ]; then",
              "    export SSM_Message=\"{{Message}}\"",
              "fi",
              "",
              "echo $SSM_Message"
            ]
        }
    }
}
```

**注意**  
如果 SSM 文档未使用以下双大括号，则 `allowedPattern` 在技术上是不必要的：`{{ }}`

**2.2 版架构 State Manager 示例**  
您可以将以下 SSM 文档用于State Manager（Systems Manager 中的一项工具）来下载并安装 ClamAV 防病毒软件。State Manager会强制实施特定配置，这意味着每次运行State Manager关联时，系统都会检查是否安装了 ClamAV 软件。如果未安装，State Manager 会重新运行本文档。

------
#### [ YAML ]

```
---
schemaVersion: '2.2'
description: State Manager Bootstrap Example
parameters: {}
mainSteps:
- action: aws:runShellScript
  name: configureServer
  inputs:
    runCommand:
    - sudo yum install -y httpd24
    - sudo yum --enablerepo=epel install -y clamav
```

------
#### [ JSON ]

```
{
   "schemaVersion": "2.2",
   "description": "State Manager Bootstrap Example",
   "parameters": {},
   "mainSteps": [
      {
         "action": "aws:runShellScript",
         "name": "configureServer",
         "inputs": {
            "runCommand": [
               "sudo yum install -y httpd24",
               "sudo yum --enablerepo=epel install -y clamav"
            ]
         }
      }
   ]
}
```

------

**2.2 版架构清单示例**  
您可以将以下 SSM 文档用于 State Manager,以收集关于实例的清单元数据。

------
#### [ YAML ]

```
---
schemaVersion: '2.2'
description: Software Inventory Policy Document.
parameters:
  applications:
    type: String
    default: Enabled
    description: "(Optional) Collect data for installed applications."
    allowedValues:
    - Enabled
    - Disabled
  awsComponents:
    type: String
    default: Enabled
    description: "(Optional) Collect data for AWS Components like amazon-ssm-agent."
    allowedValues:
    - Enabled
    - Disabled
  networkConfig:
    type: String
    default: Enabled
    description: "(Optional) Collect data for Network configurations."
    allowedValues:
    - Enabled
    - Disabled
  windowsUpdates:
    type: String
    default: Enabled
    description: "(Optional) Collect data for all Windows Updates."
    allowedValues:
    - Enabled
    - Disabled
  instanceDetailedInformation:
    type: String
    default: Enabled
    description: "(Optional) Collect additional information about the instance, including
      the CPU model, speed, and the number of cores, to name a few."
    allowedValues:
    - Enabled
    - Disabled
  customInventory:
    type: String
    default: Enabled
    description: "(Optional) Collect data for custom inventory."
    allowedValues:
    - Enabled
    - Disabled
mainSteps:
- action: aws:softwareInventory
  name: collectSoftwareInventoryItems
  inputs:
    applications: "{{ applications }}"
    awsComponents: "{{ awsComponents }}"
    networkConfig: "{{ networkConfig }}"
    windowsUpdates: "{{ windowsUpdates }}"
    instanceDetailedInformation: "{{ instanceDetailedInformation }}"
    customInventory: "{{ customInventory }}"
```

------
#### [ JSON ]

```
{
   "schemaVersion": "2.2",
   "description": "Software Inventory Policy Document.",
   "parameters": {
      "applications": {
         "type": "String",
         "default": "Enabled",
         "description": "(Optional) Collect data for installed applications.",
         "allowedValues": [
            "Enabled",
            "Disabled"
         ]
      },
      "awsComponents": {
         "type": "String",
         "default": "Enabled",
         "description": "(Optional) Collect data for AWS Components like amazon-ssm-agent.",
         "allowedValues": [
            "Enabled",
            "Disabled"
         ]
      },
      "networkConfig": {
         "type": "String",
         "default": "Enabled",
         "description": "(Optional) Collect data for Network configurations.",
         "allowedValues": [
            "Enabled",
            "Disabled"
         ]
      },
      "windowsUpdates": {
         "type": "String",
         "default": "Enabled",
         "description": "(Optional) Collect data for all Windows Updates.",
         "allowedValues": [
            "Enabled",
            "Disabled"
         ]
      },
      "instanceDetailedInformation": {
         "type": "String",
         "default": "Enabled",
         "description": "(Optional) Collect additional information about the instance, including\nthe CPU model, speed, and the number of cores, to name a few.",
         "allowedValues": [
            "Enabled",
            "Disabled"
         ]
      },
      "customInventory": {
         "type": "String",
         "default": "Enabled",
         "description": "(Optional) Collect data for custom inventory.",
         "allowedValues": [
            "Enabled",
            "Disabled"
         ]
      }
   },
   "mainSteps": [
      {
         "action": "aws:softwareInventory",
         "name": "collectSoftwareInventoryItems",
         "inputs": {
            "applications": "{{ applications }}",
            "awsComponents": "{{ awsComponents }}",
            "networkConfig": "{{ networkConfig }}",
            "windowsUpdates": "{{ windowsUpdates }}",
            "instanceDetailedInformation": "{{ instanceDetailedInformation }}",
            "customInventory": "{{ customInventory }}"
         }
      }
   ]
}
```

------

**2.2 版架构 `AWS-ConfigureAWSPackage` 示例**  
以下示例显示 `AWS-ConfigureAWSPackage` 文档。这些区域有：`mainSteps`部分包括`aws:configurePackage`插件`action`步骤。

**注意**  
在 Linux 操作系统上，仅支持 `AmazonCloudWatchAgent` 和 `AWSSupport-EC2Rescue` 软件包。

------
#### [ YAML ]

```
---
schemaVersion: '2.2'
description: 'Install or uninstall the latest version or specified version of an AWS
  package. Available packages include the following: AWSPVDriver, AwsEnaNetworkDriver,
  AwsVssComponents, and AmazonCloudWatchAgent, and AWSSupport-EC2Rescue.'
parameters:
  action:
    description: "(Required) Specify whether or not to install or uninstall the package."
    type: String
    allowedValues:
    - Install
    - Uninstall
  name:
    description: "(Required) The package to install/uninstall."
    type: String
    allowedPattern: "^arn:[a-z0-9][-.a-z0-9]{0,62}:[a-z0-9][-.a-z0-9]{0,62}:([a-z0-9][-.a-z0-9]{0,62})?:([a-z0-9][-.a-z0-9]{0,62})?:package\\/[a-zA-Z][a-zA-Z0-9\\-_]{0,39}$|^[a-zA-Z][a-zA-Z0-9\\-_]{0,39}$"
  version:
    type: String
    description: "(Optional) A specific version of the package to install or uninstall."
mainSteps:
- action: aws:configurePackage
  name: configurePackage
  inputs:
    name: "{{ name }}"
    action: "{{ action }}"
    version: "{{ version }}"
```

------
#### [ JSON ]

```
{
   "schemaVersion": "2.2",
   "description": "Install or uninstall the latest version or specified version of an AWS package. Available packages include the following: AWSPVDriver, AwsEnaNetworkDriver, AwsVssComponents, and AmazonCloudWatchAgent, and AWSSupport-EC2Rescue.",
   "parameters": {
      "action": {
         "description":"(Required) Specify whether or not to install or uninstall the package.",
         "type":"String",
         "allowedValues":[
            "Install",
            "Uninstall"
         ]
      },
      "name": {
         "description": "(Required) The package to install/uninstall.",
         "type": "String",
         "allowedPattern": "^arn:[a-z0-9][-.a-z0-9]{0,62}:[a-z0-9][-.a-z0-9]{0,62}:([a-z0-9][-.a-z0-9]{0,62})?:([a-z0-9][-.a-z0-9]{0,62})?:package\\/[a-zA-Z][a-zA-Z0-9\\-_]{0,39}$|^[a-zA-Z][a-zA-Z0-9\\-_]{0,39}$"
      },
      "version": {
         "type": "String",
         "description": "(Optional) A specific version of the package to install or uninstall."
      }
   },
   "mainSteps":[
      {
         "action": "aws:configurePackage",
         "name": "configurePackage",
         "inputs": {
            "name": "{{ name }}",
            "action": "{{ action }}",
            "version": "{{ version }}"
         }
      }
   ]
}
```

------

## 架构版本 1.2
<a name="documents-schema-onex"></a>

以下示例显示 1.2 版架构文档的顶级元素。

```
{
   "schemaVersion":"1.2",
   "description":"A description of the SSM document.",
   "parameters":{
      "parameter 1":{
         "one or more parameter properties"
      },
      "parameter 2":{
         "one or more parameter properties"
      },
      "parameter 3":{
         "one or more parameter properties"
      }
   },
   "runtimeConfig":{
      "plugin 1":{
         "properties":[
            {
               "one or more plugin properties"
            }
         ]
      }
   }
}
```

**1.2 版架构 `aws:runShellScript` 示例**  
以下示例显示 `AWS-RunShellScript` SSM 文档。**runtimeConfig** 部分包含 `aws:runShellScript` 插件。

```
{
    "schemaVersion":"1.2",
    "description":"Run a shell script or specify the commands to run.",
    "parameters":{
        "commands":{
            "type":"StringList",
            "description":"(Required) Specify a shell script or a command to run.",
            "minItems":1,
            "displayType":"textarea"
        },
        "workingDirectory":{
            "type":"String",
            "default":"",
            "description":"(Optional) The path to the working directory on your instance.",
            "maxChars":4096
        },
        "executionTimeout":{
            "type":"String",
            "default":"3600",
            "description":"(Optional) The time in seconds for a command to complete before it is considered to have failed. Default is 3600 (1 hour). Maximum is 172800 (48 hours).",
            "allowedPattern":"([1-9][0-9]{0,3})|(1[0-9]{1,4})|(2[0-7][0-9]{1,3})|(28[0-7][0-9]{1,2})|(28800)"
        }
    },
    "runtimeConfig":{
        "aws:runShellScript":{
            "properties":[
                {
                    "id":"0.aws:runShellScript",
                    "runCommand":"{{ commands }}",
                    "workingDirectory":"{{ workingDirectory }}",
                    "timeoutSeconds":"{{ executionTimeout }}"
                }
            ]
        }
    }
}
```

## 架构版本 0.3
<a name="automation-doc-syntax-examples"></a>

**顶级元素**  
以下示例显示 JSON 格式的架构 0.3 版自动化运行手册的顶级元素。

```
{
    "description": "document-description",
    "schemaVersion": "0.3",
    "assumeRole": "{{assumeRole}}",
    "parameters": {
        "parameter1": {
            "type": "String",
            "description": "parameter-1-description",
            "default": ""
        },
        "parameter2": {
            "type": "String",
            "description": "parameter-2-description",
            "default": ""
        }
    },
    "variables": {
        "variable1": {
            "type": "StringMap",
            "description": "variable-1-description",
            "default": {}
        },
        "variable2": {
            "type": "String",
            "description": "variable-2-description",
            "default": "default-value"
        }
    },
    "mainSteps": [
        {
            "name": "myStepName",
            "action": "action-name",
            "maxAttempts": 1,
            "inputs": {
                "Handler": "python-only-handler-name",
                "Runtime": "runtime-name",
                "Attachment": "script-or-zip-name"
            },
            "outputs": {
                "Name": "output-name",
                "Selector": "selector.value",
                "Type": "data-type"
            }
        }
    ],
    "files": {
        "script-or-zip-name": {
            "checksums": {
                "sha256": "checksum"
            },
            "size": 1234
        }
    }
}
```

**YAML 自动化运行手册示例**  
以下示例显示了 YAML 格式的自动化运行手册的内容。0.3 版文档架构的此工作示例还演示了如何使用 Markdown 格式化文档描述。

```
description: >-
  ##Title: LaunchInstanceAndCheckState

  -----

  **Purpose**: This Automation runbook first launches an EC2 instance
  using the AMI ID provided in the parameter ```imageId```. The second step of
  this document continuously checks the instance status check value for the
  launched instance until the status ```ok``` is returned.


  ##Parameters:

  -----

  Name | Type | Description | Default Value

  ------------- | ------------- | ------------- | -------------

  assumeRole | String | (Optional) The ARN of the role that allows Automation to
  perform the actions on your behalf. | -

  imageId  | String | (Optional) The AMI ID to use for launching the instance.
  The default value uses the latest Amazon Linux AMI ID available. | {{
  ssm:/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64 }}
schemaVersion: '0.3'
assumeRole: 'arn:aws:iam::111122223333::role/AutomationServiceRole'
parameters:
  imageId:
    type: String
    default: '{{ ssm:/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64 }}'
    description: >-
      (Optional) The AMI ID to use for launching the instance. The default value
      uses the latest released Amazon Linux AMI ID.
  tagValue:
    type: String
    default: ' LaunchedBySsmAutomation'
    description: >-
      (Optional) The tag value to add to the instance. The default value is
      LaunchedBySsmAutomation.
  instanceType:
    type: String
    default: t2.micro
    description: >-
      (Optional) The instance type to use for the instance. The default value is
      t2.micro.
mainSteps:
  - name: LaunchEc2Instance
    action: 'aws:executeScript'
    outputs:
      - Name: payload
        Selector: $.Payload
        Type: StringMap
    inputs:
      Runtime: python3.11
      Handler: launch_instance
      Script: ''
      InputPayload:
        image_id: '{{ imageId }}'
        tag_value: '{{ tagValue }}'
        instance_type: '{{ instanceType }}'
      Attachment: launch.py
    description: >-
      **About This Step**


      This step first launches an EC2 instance using the ```aws:executeScript```
      action and the provided python script.
  - name: WaitForInstanceStatusOk
    action: 'aws:executeScript'
    inputs:
      Runtime: python3.11
      Handler: poll_instance
      Script: |-
        def poll_instance(events, context):
          import boto3
          import time

          ec2 = boto3.client('ec2')

          instance_id = events['InstanceId']

          print('[INFO] Waiting for instance status check to report ok', instance_id)

          instance_status = "null"

          while True:
            res = ec2.describe_instance_status(InstanceIds=[instance_id])

            if len(res['InstanceStatuses']) == 0:
              print("Instance status information is not available yet")
              time.sleep(5)
              continue

            instance_status = res['InstanceStatuses'][0]['InstanceStatus']['Status']

            print('[INFO] Polling to get status of the instance', instance_status)

            if instance_status == 'ok':
              break

            time.sleep(10)

          return {'Status': instance_status, 'InstanceId': instance_id}
      InputPayload: '{{ LaunchEc2Instance.payload }}'
    description: >-
      **About This Step**


      The python script continuously polls the instance status check value for
      the instance launched in Step 1 until the ```ok``` status is returned.
files:
  launch.py:
    checksums:
      sha256: 18871b1311b295c43d0f...[truncated]...772da97b67e99d84d342ef4aEXAMPLE
```

## 安全处理参数示例
<a name="secure-parameter-examples"></a>

以下示例演示使用环境变量 `interpolationType` 安全处理参数。

### 基本安全命令执行
<a name="basic-secure-command"></a>

本示例说明如何安全处理命令参数：

**注意**  
在不使用以下双大括号的 SSM 文档中，`allowedPattern` 在技术上是不必要的：`{{ }}`

------
#### [ YAML ]

```
---

schemaVersion: '2.2'
description: An example document.
parameters:
  Message:
    type: String
    description: "Message to be printed"
    default: Hello
    interpolationType: ENV_VAR
    allowedPattern: "^[^"]*$"
mainSteps:
  - action: aws:runShellScript
    name: printMessage
    precondition:
      StringEquals:
        - platformType
        - Linux
    inputs:
      runCommand:
        - echo {{Message}}
```

------
#### [ JSON ]

```
{
    "schemaVersion": "2.2",
    "description": "An example document.",
    "parameters": {
        "Message": {
            "type": "String",
            "description": "Message to be printed",
            "default": "Hello",
            "interpolationType": "ENV_VAR",
            "allowedPattern": "^[^"]*$"
        }
    },
    "mainSteps": [{
        "action": "aws:runShellScript",
        "name": "printMessage",
        "precondition": {
           "StringEquals": ["platformType", "Linux"]
        },
        "inputs": {
            "runCommand": [
              "echo {{Message}}"
            ]
        }
    }]
}
```

------

### 在解释性语言中使用参数
<a name="interpreted-language-example"></a>

本示例演示在 Python 中安全处理参数：

------
#### [ YAML ]

```
---
schemaVersion: '2.2'
description: 'Secure Python script execution'
parameters:
  inputData:
    type: String
    description: 'Input data for processing'
    interpolationType: 'ENV_VAR'
mainSteps:
  - action: aws:runPowerShellScript
    name: runPython
    inputs:
      runCommand:
        - |
          python3 -c '
          import os
          import json
          
          # Safely access parameter through environment variable
          input_data = os.environ.get("SSM_inputData", "")
          
          # Process the data
          try:
              processed_data = json.loads(input_data)
              print(f"Successfully processed: {processed_data}")
          except json.JSONDecodeError:
              print("Invalid JSON input")
          '
```

------

### 向后兼容性示例
<a name="backwards-compatibility-example"></a>

本示例展示如何安全处理参数，同时保持向后兼容性：

------
#### [ YAML ]

```
---
schemaVersion: '2.2'
description: 'Backwards compatible secure parameter handling'
parameters:
  userInput:
    type: String
    description: 'User input to process'
    interpolationType: 'ENV_VAR'
    allowedPattern: '^[^"]*$'

mainSteps:
  - action: aws:runShellScript
    name: processInput
    inputs:
      runCommand:
        - |
          # Handle both modern and legacy agent versions
          if [ -z "${SSM_userInput+x}" ]; then
              # Legacy agent - fall back to direct parameter reference
              export SSM_userInput="{{userInput}}"
          fi
          
          # Process the input securely
          echo "Processing input: $SSM_userInput"
```

------

**注意**  
在不使用以下双大括号的 SSM 文档中，`allowedPattern` 在技术上是不必要的：`{{ }}`

## 参数安全的最佳实践
<a name="parameter-security-best-practices"></a>

在处理 SSM 文档中的参数时，请遵循以下最佳实践：
+ **使用环境变量插值**：即将用于命令执行的字符串参数始终使用 `interpolationType: "ENV_VAR"`。
+ **实现输入验证**：使用 `allowedPattern` 将参数值限制为安全模式。
+ **处理遗留系统**：为不支持环境变量插值的旧版 SSM Agent 添加回退逻辑。
+ **转义特殊字符**：在命令中使用参数值时，请对特殊字符进行恰当转义以防止被 shell 解释。
+ **限制参数范围**：为用例使用尽可能严格的参数模式。

# 数据元素和参数
<a name="documents-syntax-data-elements-parameters"></a>

本主题介绍 SSM 文档中使用的数据元素。用于创建文档的架构版本定义了文档接受的语法和数据元素。我们建议您对命令文档使用架构版本 2.2 或更高版本。自动化运行手册使用架构版本 0.3。此外，自动化运行手册还支持使用 Markdown（一种标记语言），它允许您为文档和文档中的各个步骤添加 Wiki 样式的描述。有关使用 Markdown 的详细信息，请参阅*《AWS 管理控制台 入门指南》*中的[在控制台中使用 Markdown](https://docs.aws.amazon.com/general/latest/gr/aws-markdown.html)。

以下部分介绍了 SSM 文档中可以包含的数据元素。

## 顶级数据元素
<a name="top-level"></a>

**schemaVersion**  
要使用的架构版本。  
类型：版本  
是否必需：是

**描述**  
您提供的描述文档目的的信息。您还可以使用此字段来指定参数是否需要一个值才能运行文档，或者为参数提供值是否为可选项。可在本主题的所有示例中查看必需参数和可选参数。  
类型：字符串  
必需：否

**参数**  
定义文档接受的参数的结构。  
为增强处理字符串参数的安全性，可通过指定 `interpolationType` 属性来使用环境变量插值。设置为 `ENV_VAR` 时，系统会创建一个包含参数值的环境变量 `SSM_parameter-name`。  
下面是一个使用环境变量 `interpolationType` 的参数的示例：  

```
{
    "schemaVersion": "2.2",
    "description": "An example document.",
    "parameters": {
        "Message": {
            "type": "String",
            "description": "Message to be printed",
            "default": "Hello",
            "interpolationType" : "ENV_VAR",
            "allowedPattern": "^[^"]*$"

        }
    },
    "mainSteps": [{
        "action": "aws:runShellScript",
        "name": "printMessage",
        "precondition" : {
           "StringEquals" : ["platformType", "Linux"]
        },
        "inputs": {
            "runCommand": [
              "echo {{Message}}"
            ]
        }
    }
}
```
在不使用以下双大括号的 SSM 文档中，`allowedPattern` 在技术上是不必要的：`{{ }}`
对于经常使用的参数，建议将这些参数存储在 Parameter Store（AWS Systems Manager 中的一项工具）中。然后，可以在文档中定义参数，并引用 Parameter Store 参数作为默认值。要引用 Parameter Store 参数，请使用以下语法。  

```
{{ssm:parameter-name}}
```
可以使用参数通过与任何其他文档参数相同的方式引用 Parameter Store 参数。在以下示例中，`commands` 参数的默认值是 Parameter Store 参数 `myShellCommands`。如果将 `commands` 参数指定为 `runCommand` 字符串，文档将运行存储在 `myShellCommands` 参数中的命令。  

```
---
schemaVersion: '2.2'
description: runShellScript with command strings stored as Parameter Store parameter
parameters:
  commands:
    type: StringList
    description: "(Required) The commands to run on the instance."
    default: ["{{ ssm:myShellCommands }}"],
            interpolationType : 'ENV_VAR'
            allowedPattern: '^[^"]*$'

mainSteps:
- action: aws:runShellScript
  name: runShellScriptDefaultParams
  inputs:
    runCommand:"{{ commands }}"
```

```
{
    "schemaVersion": "2.2",
    "description": "runShellScript with command strings stored as Parameter Store parameter",
    "parameters": {
      "commands": {
        "type": "StringList",
        "description": "(Required) The commands to run on the instance.",
        "default": ["{{ ssm:myShellCommands }}"],
        "interpolationType" : "ENV_VAR"
      }
    },
    "mainSteps": [
      {
        "action": "aws:runShellScript",
        "name": "runShellScriptDefaultParams",
        "inputs": {
            "runCommand": [
              "{{ commands }}"
          ]
        }
      }
    ]
  }
```
您可以在文档的 `parameters` 部分引用 `String` 和 `StringList` Parameter Store 参数。您不能引用 `SecureString` Parameter Store 参数。
有关 Parameter Store 的更多信息，请参阅 [AWS Systems Manager Parameter Store](systems-manager-parameter-store.md)。  
类型：结构  
`parameters` 结构接受以下字段和值：  
+ `type`：(必需) 允许的值包括：`String`、`StringList`、`Integer`、`Boolean`、`MapList` 和 `StringMap`。要查看每种类型的示例，请参阅下一节中的 [文档参数 `type` 示例](#top-level-properties-type)。
**注意**  
命令类型文档仅支持 `String` 和 `StringList` 参数类型。
+ `description`：(可选) 关于参数的描述。
+ `default`：（可选）参数的默认值或对 Parameter Store 中参数的引用。
+ `allowedValues`：（可选）参数允许的值数组。定义参数的允许值将验证用户输入。如果用户输入了不允许的值，则执行将无法启动。

------
#### [ YAML ]

  ```
  DirectoryType:
    type: String
    description: "(Required) The directory type to launch."
    default: AwsMad
    allowedValues:
    - AdConnector
    - AwsMad
    - SimpleAd
  ```

------
#### [ JSON ]

  ```
  "DirectoryType": {
    "type": "String",
    "description": "(Required) The directory type to launch.",
    "default": "AwsMad",
    "allowedValues": [
      "AdConnector",
      "AwsMad",
      "SimpleAd"
    ]
  }
  ```

------
+ `allowedPattern`：（可选）验证用户输入是否与参数的定义模式匹配的正则表达式。如果用户输入与允许的模式不匹配，则执行无法启动。
**注意**  
Systems Manager 会执行两次 `allowedPattern` 验证。第一次验证是在您使用文档时利用 [Java 正则表达式库](https://docs.oracle.com/javase/8/docs/api/java/util/regex/package-summary.html)在 API 级别进行。第二次验证是在处理文档之前通过使用 [GO 正则表达式库](https://pkg.go.dev/regexp)在 SSM Agent 上进行。

------
#### [ YAML ]

  ```
  InstanceId:
    type: String
    description: "(Required) The instance ID to target."
    allowedPattern: "^i-(?:[a-f0-9]{8}|[a-f0-9]{17})$"
    default: ''
  ```

------
#### [ JSON ]

  ```
  "InstanceId": {
    "type": "String",
    "description": "(Required) The instance ID to target.",
    "allowedPattern": "^i-(?:[a-f0-9]{8}|[a-f0-9]{17})$",
    "default": ""
  }
  ```

------
+ `displayType`：（可选）用于在 AWS 管理控制台 中显示 `textfield` 或 `textarea`。`textfield` 是单行文本框。`textarea` 是多行文本区域。
+ `minItems`：(可选) 允许的最小项目数。
+ `maxItems`：(可选) 允许的最大项目数。
+ `minChars`：(可选) 允许的最小参数字符数。
+ `maxChars`：(可选) 允许的最大参数字符数。
+ `interpolationType`：（可选）定义在执行命令之前如何处理参数值。如果设置为 `ENV_VAR`，则可以将参数值用作名为 `SSM_parameter-name` 的环境变量。此功能通过将参数值视为文字字符串，从而帮助防范命令注入攻击。

  类型：字符串

  有效值：`ENV_VAR`
必需：否

**变量**  
（仅限架构版本 0.3）您可以在自动化运行手册的整个步骤中引用或更新的值。变量与参数类似，但在重要方面有所区别。参数值在运行手册的上下文中是静态的，但是变量的值可以在运行手册的上下文中更改。更新变量的值时，数据类型必须与定义的数据类型相匹配。有关更新自动化中的变量值的信息，请参阅 [`aws:updateVariable` – 更新运行手册变量的值](automation-action-update-variable.md)  
类型：Boolean \$1 Integer \$1 MapList \$1 String \$1 StringList \$1 StringMap  
必需：否  

```
variables:
    payload:
        type: StringMap
        default: "{}"
```

```
{
    "variables": [
        "payload": {
            "type": "StringMap",
            "default": "{}"
        }
    ]
}
```

**runtimeConfig**  
(仅限 1.2 版架构) 由一个或多个 Systems Manager 插件应用的实例的配置。不保证插件按顺序运行。  
类型：Dictionary<string,PluginConfiguration>  
必需：否

**mainSteps**  
（仅架构版本 0.3、2.0 和 2.2）可以包含多个步骤（插件）的对象。插件在步骤内定义。步骤按文档中列出的先后顺序运行。  
类型：Dictionary<string,PluginConfiguration>  
是否必需：是

**输出**  
（仅架构版本 0.3）通过执行本文档而生成的可用于其他进程的数据。例如，如果文档创建新的 AMI，您可以指定 “CreateImage.ImageId” 作为输出值，然后使用该输出以在后续自动化执行中创建新的实例。有关输出的更多信息，请参阅 [使用操作输出作为输入](automation-action-outputs-inputs.md)。  
类型：Dictionary<string,OutputConfiguration>  
必需：否

**文件**  
（仅架构版本 0.3）附加到文档并在自动化执行期间运行的脚本文件（及其校验和）。仅适用于包含 `aws:executeScript` 操作且已在一个或多个步骤中指定附件的文档。  
要了解自动化运行手册支持的运行时，请参阅 [`aws:executeScript` - 运行脚本](automation-action-executeScript.md)。有关在自动化运行手册中包含脚本的更多信息，请参阅 [在运行手册中使用脚本](automation-document-script-considerations.md) 和 [自动化运行手册的视觉对象设计体验](automation-visual-designer.md)。  
使用附件创建自动化运行手册时，可以使用 `--attachments` 选项（对于 AWS CLI）或 `Attachments`（对于 API 和开发工具包）指定附件文件。您可以为存储在 Amazon Simple Storage Service（Amazon S3）存储桶中的 SSM 文档和文件指定文件位置。有关更多信息，请参阅 AWS Systems Manager API 参考中的[附件](https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_CreateDocument.html#systemsmanager-CreateDocument-request-Attachments)。  

```
---
files:
  launch.py:
    checksums:
      sha256: 18871b1311b295c43d0f...[truncated]...772da97b67e99d84d342ef4aEXAMPLE
```

```
"files": {
    "launch.py": {
        "checksums": {
            "sha256": "18871b1311b295c43d0f...[truncated]...772da97b67e99d84d342ef4aEXAMPLE"
        }
    }
}
```
类型：Dictionary<string,FilesConfiguration>  
必需：否

## 文档参数 `type` 示例
<a name="top-level-properties-type"></a>

SSM 文档中的参数类型是静态的。这意味着参数类型在定义后无法更改。将参数用于 SSM 文档插件时，不能在插件的输入中动态更改参数的类型。例如，您不能在 `aws:runShellScript` 插件的 `runCommand` 输入中引用 `Integer` 参数，因为此输入接受字符串或字符串列表。要将参数用于插件输入，参数类型必须与接受的类型匹配。例如，您必须为`aws:updateSsmAgent` 插件的 `allowDowngrade` 输入指定 `Boolean` 类型参数。如果参数类型与插件的输入类型不匹配，则 SSM 文档无法验证，并且系统不会创建文档。在其他插件或 AWS Systems Manager 自动化操作的输入中使用下游参数时也是如此。例如，您不能引用 `aws:runDocument` 插件的 `documentParameters` 输入内的 `StringList` 参数。`documentParameters` 输入接受字符串映射，即使下游 SSM 文档参数类型是 `StringList` 参数并与您要引用的参数匹配。

将参数用于自动化操作时，大多数情况下创建 SSM 文档时不会验证参数类型。只有在使用 `aws:runCommand` 操作的情况下，才会在创建 SSM 文档时验证参数类型。在所有其他情况下，在运行操作之前验证该操作的输入时，会在自动化执行期间进行参数验证。例如，如果输入参数为 `String` 并将其引用为 `aws:runInstances` 操作 `MaxInstanceCount` 输入的值，则会创建 SSM 文档。但是，在运行该文档期间，验证 `aws:runInstances` 操作时自动化将失败，因为 `MaxInstanceCount` 输入需要 `Integer`。

下面是每个参数的示例 `type`。

字符串  
使用引号括起来的零个或多个 Unicode 字符序列。例如，"i-1234567890abcdef0"。使用反斜杠转义。  
字符串参数可包括一个值为 `ENV_VAR` 的可选 `interpolationType` 字段，以启用环境变量插值增强安全性。  

```
---
InstanceId:
  type: String
  description: "(Optional) The target EC2 instance ID."
  interpolationType: ENV_VAR
```

```
"InstanceId":{
  "type":"String",
  "description":"(Optional) The target EC2 instance ID.",
  "interpolationType": "ENV_VAR"
}
```

StringList  
以逗号分隔的字符串项目列表。例如，["cd \$1", "pwd"]。  

```
---
commands:
  type: StringList
  description: "(Required) Specify a shell script or a command to run."
  default: ""
  minItems: 1
  displayType: textarea
```

```
"commands":{
  "type":"StringList",
  "description":"(Required) Specify a shell script or a command to run.",
  "minItems":1,
  "displayType":"textarea"
}
```

布尔值  
仅接受 `true` 或 `false`。不接受 "true" 或 0。  

```
---
canRun:
  type: Boolean
  description: ''
  default: true
```

```
"canRun": {
  "type": "Boolean",
  "description": "",
  "default": true
}
```

整数  
整数。不接受小数（例如 3.14159）或使用引号的数字（例如 "3"）。  

```
---
timeout:
  type: Integer
  description: The type of action to perform.
  default: 100
```

```
"timeout": {
  "type": "Integer",
  "description": "The type of action to perform.",
  "default": 100    
}
```

StringMap  
键到值的映射。密钥和值必须是字符串。例如，\$1"Env": "Prod"\$1。  

```
---
notificationConfig:
  type: StringMap
  description: The configuration for events to be notified about
  default:
    NotificationType: 'Command'
    NotificationEvents:
    - 'Failed'
    NotificationArn: "$dependency.topicArn"
  maxChars: 150
```

```
"notificationConfig" : {
  "type" : "StringMap",
  "description" : "The configuration for events to be notified about",
  "default" : {
    "NotificationType" : "Command",
    "NotificationEvents" : ["Failed"],
    "NotificationArn" : "$dependency.topicArn"
  },
  "maxChars" : 150
}
```

MapList  
StringMap 对象的列表。  

```
blockDeviceMappings:
  type: MapList
  description: The mappings for the create image inputs
  default:
  - DeviceName: "/dev/sda1"
    Ebs:
      VolumeSize: "50"
  - DeviceName: "/dev/sdm"
    Ebs:
      VolumeSize: "100"
  maxItems: 2
```

```
"blockDeviceMappings":{
  "type":"MapList",
  "description":"The mappings for the create image inputs",
  "default":[
    {
      "DeviceName":"/dev/sda1",
      "Ebs":{
        "VolumeSize":"50"
      }
    },
    {
      "DeviceName":"/dev/sdm",
      "Ebs":{
        "VolumeSize":"100"
      }
    }
  ],
  "maxItems":2
}
```

## 查看 SSM 命令文档内容
<a name="viewing-ssm-document-content"></a>

要预览需要的和可选参数 AWS Systems Manager(SSM) 命令文档，除了文档运行的操作外，您还可以在 Systems Manager 控制台中查看此文档的内容。

**查看 SSM 命令文档内容**

1. 访问 [https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/)，打开 AWS Systems Manager 控制台。

1. 在导航窗格中，选择**文档**。

1. 在搜索框中，选择**文档类型**，然后选择**命令**。

1. 选择文档的名称，然后选择**内容**选项卡。

1. 在内容字段中，查看文档的可用参数和操作步骤。

   例如，下图显示 (1) `version` 和 (2) `allowDowngrade` 是 `AWS-UpdateSSMAgent` 文档的可选参数，并且文档运行的第一个操作是 (3) `aws:updateSsmAgent`。  
![\[在 Systems Manager 控制台中查看 SSM 文档内容\]](http://docs.aws.amazon.com/zh_cn/systems-manager/latest/userguide/images/view-document-content.png)

# 命令文档插件参考
<a name="documents-command-ssm-plugin-reference"></a>

此参考介绍可在 AWS Systems Manager (SSM) 命令类型文档中指定的插件。这些插件不能在使自动化操作的 SSM 自动化运行手册中使用。有关 AWS Systems Manager 自动化操作的信息，请参阅 [Systems Manager 自动化操作参考](automation-actions.md)。

Systems Manager 通过读取 SSM 文档的内容确定在托管实例上执行的操作。每个文档都包含代码执行部分。根据文档的架构版本，此代码执行部分可能包含一个或多个插件或步骤。为了便于理解本帮助主题，我们将这些插件和步骤都称为*插件*。本部分包含有关每个 Systems Manager 插件的信息。有关文档的详细信息（包括有关创建文档和架构版本之间的差异的信息），请参阅 [AWS Systems Manager 文档](documents.md)。

对于接受字符串参数（例如 `aws:runShellScript` 和 `aws:runPowerShellScript`）的插件，可以使用 `interpolationType` 参数增强安全性，方法是将参数输入视为字符串文本值，而非可能的可执行命令。例如：

```
{
    "schemaVersion": "2.2",
    "description": "runShellScript with command strings stored as Parameter Store parameter",
    "parameters": {
      "commands": {
        "type": "StringList",
        "description": "(Required) The commands to run on the instance.",
        "default": ["{{ ssm:myShellCommands }}"],
        "interpolationType" : "ENV_VAR"
      }
    },
    //truncated
 }
```

**注意**  
此处介绍的部分插件仅在 Windows Server 实例或 Linux 实例上运行。每个插件都记录了平台依赖关系。  
macOS 的 Amazon Elastic Compute Cloud (Amazon EC2) 实例支持以下文档插件：  
`aws:refreshAssociation`
`aws:runShellScript`
`aws:runPowerShellScript`
`aws:softwareInventory`
`aws:updateSsmAgent`

**Topics**
+ [共享输入](#shared-inputs)
+ [`aws:applications`](#aws-applications)
+ [`aws:cloudWatch`](#aws-cloudWatch)
+ [`aws:configureDocker`](#aws-configuredocker)
+ [`aws:configurePackage`](#aws-configurepackage)
+ [`aws:domainJoin`](#aws-domainJoin)
+ [`aws:downloadContent`](#aws-downloadContent)
+ [`aws:psModule`](#aws-psModule)
+ [`aws:refreshAssociation`](#aws-refreshassociation)
+ [`aws:runDockerAction`](#aws-rundockeraction)
+ [`aws:runDocument`](#aws-rundocument)
+ [`aws:runPowerShellScript`](#aws-runPowerShellScript)
+ [`aws:runShellScript`](#aws-runShellScript)
+ [`aws:softwareInventory`](#aws-softwareinventory)
+ [`aws:updateAgent`](#aws-updateagent)
+ [`aws:updateSsmAgent`](#aws-updatessmagent)

## 共享输入
<a name="shared-inputs"></a>

仅在版本 3.0.502 和更高版本的 SSM Agent 中，所有插件都可以使用以下输入：

**最终步骤**  
您希望文档运行的最后一步。如果此输入是为某个步骤定义的，则它优先于 `onFailure` 或 `onSuccess` 输入中指定的 `exit` 值。为了使具有此输入的步骤按预期运行，该步骤必须是文档 `mainSteps` 中定义的最后一个步骤。  
类型：布尔值  
有效值：`true` \$1 `false`  
必需：否

**onFailure**  
如果您为插件指定此输入的 `exit` 值并且步骤失败，则步骤状态会显示失败，并且文档不会运行任何剩余步骤，除非 `finallyStep` 已定义。如果您为插件指定此输入的 `successAndExit` 值并且步骤失败，则步骤状态会显示成功，并且文档不会运行任何剩余的步骤，除非 `finallyStep` 已定义。  
类型：字符串  
有效值：`exit` \$1 `successAndExit`  
必需：否

**onSuccess**  
如果您为插件指定此输入并且步骤成功运行，则文档不会运行任何剩余的步骤，除非 `finallyStep` 已定义。  
类型：字符串  
有效值：`exit`  
必需：否

------
#### [ YAML ]

```
---
schemaVersion: '2.2'
description: Shared inputs example
parameters:
  customDocumentParameter:
    type: String
    description: Example parameter for a custom Command-type document.
mainSteps:
- action: aws:runDocument
  name: runCustomConfiguration
  inputs:
    documentType: SSMDocument
    documentPath: "yourCustomDocument"
    documentParameters: '"documentParameter":{{customDocumentParameter}}'
    onSuccess: exit
- action: aws:runDocument
  name: ifConfigurationFailure
  inputs:
    documentType: SSMDocument
    documentPath: "yourCustomRepairDocument"
    onFailure: exit
- action: aws:runDocument
  name: finalConfiguration
  inputs:
    documentType: SSMDocument
    documentPath: "yourCustomFinalDocument"
    finallyStep: true
```

------
#### [ JSON ]

```
{
   "schemaVersion": "2.2",
   "description": "Shared inputs example",
   "parameters": {
      "customDocumentParameter": {
         "type": "String",
         "description": "Example parameter for a custom Command-type document."
      }
   },
   "mainSteps":[
      {
         "action": "aws:runDocument",
         "name": "runCustomConfiguration",
         "inputs": {
            "documentType": "SSMDocument",
            "documentPath": "yourCustomDocument",
            "documentParameters": "\"documentParameter\":{{customDocumentParameter}}",
            "onSuccess": "exit"
         }
      },
      {
         "action": "aws:runDocument",
         "name": "ifConfigurationFailure",
         "inputs": {
            "documentType": "SSMDocument",
            "documentPath": "yourCustomRepairDocument",
            "onFailure": "exit"
         }
      },
      {
         "action": "aws:runDocument",
         "name":"finalConfiguration",
         "inputs": {
            "documentType": "SSMDocument",
            "documentPath": "yourCustomFinalDocument",
            "finallyStep": true
         }
      }
   ]
}
```

------

## `aws:applications`
<a name="aws-applications"></a>

在 EC2 实例上安装、修复或卸载应用程序。此插件仅在 Windows Server 操作系统中运行。

### 语法
<a name="applications-syntax"></a>

#### Schema 2.2
<a name="applications-syntax-2.2"></a>

------
#### [ YAML ]

```
---
schemaVersion: '2.2'
description: aws:applications plugin
parameters:
  source:
    description: "(Required) Source of msi."
    type: String
mainSteps:
- action: aws:applications
  name: example
  inputs:
    action: Install
    source: "{{ source }}"
```

------
#### [ JSON ]

```
{
  "schemaVersion":"2.2",
  "description":"aws:applications",
  "parameters":{
    "source":{
    "description":"(Required) Source of msi.",
    "type":"String"
    }
  },
  "mainSteps":[
    {
      "action":"aws:applications",
      "name":"example",
      "inputs":{
        "action":"Install",
        "source":"{{ source }}"
      }
    }
  ]
}
```

------

#### Schema 1.2
<a name="applications-syntax-1.2"></a>

------
#### [ YAML ]

```
---
runtimeConfig:
  aws:applications:
    properties:
    - id: 0.aws:applications
      action: "{{ action }}"
      parameters: "{{ parameters }}"
      source: "{{ source }}"
      sourceHash: "{{ sourceHash }}"
```

------
#### [ JSON ]

```
{
   "runtimeConfig":{
      "aws:applications":{
         "properties":[
            {
               "id":"0.aws:applications",
               "action":"{{ action }}",
               "parameters":"{{ parameters }}",
               "source":"{{ source }}",
               "sourceHash":"{{ sourceHash }}"
            }
         ]
      }
   }
}
```

------

### 属性
<a name="applications-properties"></a>

**action**  
要执行的操作。  
类型：Enum  
有效值：`Install` \$1`Repair` \$1`Uninstall`  
是否必需：是

**参数**  
安装程序的参数。  
类型：字符串  
必需：否

**source**  
应用程序的 `.msi` 文件的 URL。  
类型：字符串  
是否必需：是

**sourceHash**  
`.msi` 文件的 SHA256 哈希值。  
类型：字符串  
必需：否

## `aws:cloudWatch`
<a name="aws-cloudWatch"></a>

从中导出数据 Windows Server 添加到 Amazon CloudWatch 视台或 Amazon CloudWatch Logs 中，并使用云监控指标监控数据。此插件仅在 Windows Server 操作系统中运行。要详细了解如何配置 CloudWatch 与 Amazon Elastic Compute Cloud（Amazon EC2）的集成，请参阅《Amazon CloudWatch 用户指南》**中的[使用 CloudWatch 代理收集指标、日志和跟踪信息](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent.html)。

**重要**  
统一的 CloudWatch 代理已取代 SSM Agent，作为将日志数据发送到 Amazon CloudWatch Logs 的工具。不支持 SSM Agent aws:cloudWatch 插件。我们建议仅将统一的 CloudWatch 代理用于您的日志收集过程。有关更多信息，请参阅以下主题：  
[将节点日志发送到统一的 CloudWatch Logs（CloudWatch 代理）](monitoring-cloudwatch-agent.md)
[将 Windows Server 节点日志收集迁移到 CloudWatch 代理](monitoring-cloudwatch-agent.md#monitoring-cloudwatch-agent-migrate)
《Amazon CloudWatch 用户指南》**中的[使用 CloudWatch 代理收集指标、日志和跟踪信息](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent.html)。

您可以导出和监视以下数据类型：

**ApplicationEventLog**  
将应用程序事件日志数据发送到 CloudWatch Logs。

**CustomLogs**  
将任何基于文本的日志文件发送到 Amazon CloudWatch Logs。CloudWatch 插件会为日志文件创建指纹。系统随后将数据偏移与每个指纹进行关联。该插件会在出现更改时上传文件，记录偏移，然后将该偏移与指纹关联。此方法用于避免出现这种情况：用户启用插件后，将服务与包含大量文件的目录关联，然后系统会上传所有文件。  
请注意，如果应用程序在轮询期间截断或尝试清除日志，为 `LogDirectoryPath` 指定的任何日志都可能丢失条目。例如，如果您要限制日志文件大小，请在达到此限制时创建新的日志文件，然后继续将数据写入新文件。

**ETW**  
将 Windows (ETW) 事件跟踪数据发送到 CloudWatch Logs。

**IIS**  
将 IIS 日志数据发送到 CloudWatch Logs

**PerformanceCounter**  
将 Windows 性能计数器发送到 CloudWatch。您可以选择不同类别作为指标上传到 CloudWatch。对于要上传的每个性能计数器，创建具有唯一 ID 的 **PerformanceCounter** 部分 (例如“PerformanceCounter2”、“PerformanceCounter3”等)，然后配置其属性。  
如果 AWS Systems Manager SSM Agent 或 CloudWatch 插件已停止，则性能计数器数据不再记录到 CloudWatch 中。此行为不同于自定义日志或 Windows 事件日志。自定义日志和 Windows 事件日志会保留性能计数器数据，并在 SSM Agent 后或 CloudWatch 插件可用时将其上传到 CloudWatch。

**SecurityEventLog**  
将安全日志数据发送到 CloudWatch Logs。

**SystemEventLog**  
将系统事件日志数据发送到 CloudWatch Logs。

可为数据定义以下目标：

**CloudWatch**  
发送性能计数器指标数据时所在的目标。可添加具有唯一 ID 的更多部分 (例如，“CloudWatch2”和“CloudWatch3”等)，并为每个新 ID 指定一个不同的区域，将相同数据发送到不同位置。

**CloudWatchLogs**  
发送日志数据时所在的目标。可添加具有唯一 ID 的更多部分 (例如，“CloudWatchLogs2”和“CloudWatchLogs3”等)，并为每个新 ID 指定一个不同的区域，将相同数据发送到不同位置。

### 语法
<a name="cloudWatch-syntax"></a>

```
"runtimeConfig":{
        "aws:cloudWatch":{
            "settings":{
                "startType":"{{ status }}"
            },
            "properties":"{{ properties }}"
        }
    }
```

### 设置和属性
<a name="cloudWatch-properties"></a>

**AccessKey**  
您的访问密钥 ID。如果未使用 IAM 角色启动实例，则必须指定此属性。此属性不能与 SSM 一起使用。  
类型：字符串  
必需：否

**CategoryName**  
性能监视器提供的性能计数器类别。  
类型：字符串  
是否必需：是

**CounterName**  
性能监视器提供的性能计数器名称。  
类型：字符串  
是否必需：是

**CultureName**  
记录时间戳的区域设置。如果 **CultureName** 为空，则它默认为您的 Windows Server 实例所使用的相同区域位置。  
类型：字符串  
有效值：有关支持的值的列表，请参阅 Microsoft 网站上的[国家语言支持 (NLS)](https://msdn.microsoft.com/en-us/library/cc233982.aspx)。不支持 **div**、**div-MV**、**hu** 和 **hu-HU** 值。  
必需：否

**DimensionName**  
Amazon CloudWatch 指标的维度。如果您要指定 `DimensionName`，则必须指定 `DimensionValue`。这些参数在列出指标时提供另一个视图。您可以对多个指标使用同一个维度，以便查看属于特定维度的所有指标。  
类型：字符串  
必需：否

**DimensionValue**  
Amazon CloudWatch 指标的维度值。  
类型：字符串  
必需：否

**编码**  
要使用的文件编码 (例如 UTF-8)。使用编码名称，而不是显示名称。  
类型：字符串  
有效值：有关支持的值的列表，请参阅 Microsoft Learn 库中的 [Encoding Class](https://learn.microsoft.com/en-us/dotnet/api/system.text.encoding?view=net-7.0)。  
是否必需：是

**筛选条件**  
日志名称的前缀。将此参数保留空白以监控所有文件。  
类型：字符串  
有效值：有关支持的值的列表，请参阅 MSDN 库中的 [FileSystemWatcherFilter 属性](http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.filter.aspx)主题。  
必需：否

**流**  
要上传的每个数据类型以及数据的目标（CloudWatch 或 CloudWatch Logs ）。例如，要将在 `"Id": "PerformanceCounter"` 下定义的性能计数器发送到在 `"Id": "CloudWatch"` 下定义的 CloudWatch 目标，请输入 **“PerformanceCounter,CloudWatch”**。同样，要将自定义日志、ETW 日志和系统日志发送到 `"Id": "ETW"` 下定义的 CloudWatch Logs 目标，请输入 **“(ETW),CloudWatchLogs”**。此外，还可以将相同性能计数器或日志文件发送到多个目标。例如，要将应用程序日志发送到在 `"Id": "CloudWatchLogs"` 和 `"Id": "CloudWatchLogs2"` 下定义的两个不同目标，请输入 **"ApplicationEventLog,(CloudWatchLogs, CloudWatchLogs2)"**。  
类型：字符串  
有效值 (源)：`ApplicationEventLog` \$1 `CustomLogs` \$1 `ETW` \$1 `PerformanceCounter` \$1 `SystemEventLog` \$1 `SecurityEventLog`   
有效值 (目标)：`CloudWatch` \$1 `CloudWatchLogs` \$1 `CloudWatch`*n* \$1 `CloudWatchLogs`*n*   
是否必需：是

**FullName**  
组件的完整名称。  
类型：字符串  
是否必需：是

**Id**  
标识数据源或目标。此标识符在配置文件中必须是唯一的。  
类型：字符串  
是否必需：是

**InstanceName**  
性能计数器实例的名称。请勿使用星号 (\$1) 标识所有实例，因为每个性能计数器组件仅支持一个指标。不过可以使用 **\$1Total**。  
类型：字符串  
是否必需：是

**级别**  
发送到 Amazon CloudWatch 的消息类型。  
类型：字符串  
有效值：  
+ **1** – 仅上传错误消息。
+ **2** – 仅上传警告消息。
+ **4** – 仅上传信息消息。
您可以将这些值加在一起以包含多种类型的消息。例如，**3** 表示将包含错误消息 (**1**) 和警告消息 (**2**)。值 **7** 表示将包含错误消息 (**1**)、警告消息 (**2**) 和说明性消息 (**4**)。  
是否必需：是  
应将 Windows 安全日志的级别设置为 7。

**LineCount**  
标识日志文件的标头中的行数。例如，IIS 日志文件拥有几乎相同的标头。您可以输入 **3**，系统会读取日志文件标头的前三行以进行识别。在 IIS 日志文件中，第三行是日期和时间戳，各日志文件的日期和时间戳互不相同。  
类型：整数  
必需：否

**LogDirectoryPath**  
对于 CustomLogs，这是日志在 EC2 实例上的存储路径。对于 IIS 日志，这是为单个站点存储 IIS 日志的文件夹 (例如 **C:\$1\$1inetpub\$1\$1logs\$1\$1LogFiles\$1\$1W3SVC*n***)。对于 IIS 日志，仅支持 W3C 日志格式。不支持 IIS、NCSA 和自定义格式。  
类型：字符串  
是否必需：是

**LogGroup**  
日志组的名称。此名称显示在 CloudWatch 控制台的 **Log Groups（日志组）**屏幕上。  
类型：字符串  
是否必需：是

**LogName**  
日志文件的名称。  

1. 要查找日志的名称，请在事件查看器的导航窗格中，选择 **Applications and Services Logs (应用程序和服务日志)**。

1. 在日志列表中，右键单击要上传的日志（例如 `Microsoft` > `Windows` > `Backup` > `Operational`），然后选择**创建自定义视图**。

1. 在 **Create Custom View (创建自定义视图)** 对话框中，选择 **XML** 选项卡。**LogName** 位于 <Select Path=> 标签中（例如 `Microsoft-Windows-Backup`）。将此文本复制到 **LogName** 参数。
类型：字符串  
有效值：`Application` \$1 `Security` \$1 `System` \$1 `Microsoft-Windows-WinINet/Analytic`  
是否必需：是

**LogStream**  
目标日志流。如果使用默认值 **\$1instance\$1id\$1**，则将该实例的实例 ID 用作日志流名称。  
类型：字符串  
有效值：`{instance_id}` \$1 `{hostname}` \$1 `{ip_address}` *<log\$1stream\$1name>*  
如果输入的日志流名称不存在，则 CloudWatch Logs 会自动创建该名称。可以使用文字字符串或预定义的变量（**\$1instance\$1id\$1**、**\$1hostname\$1**、**\$1ip\$1address\$1**），或所有这三个变量的组合来定义日志流名称。  
此参数中指定的日志流名称将在 CloudWatch 控制台中的 **Log Groups > Streams for *<YourLogStream>***（日志组 > <YourLogStream> 的流）屏幕上显示。  
是否必需：是

**MetricName**  
您希望性能数据包含在其下的 CloudWatch 指标。  
不要在名称中使用特殊字符。如果您这样做，指标和相关警报可能无法正常工作。
类型：字符串  
是否必需：是

**NameSpace**  
您希望将写入性能计数器数据的指标命名空间。  
类型：字符串  
是否必需：是

**PollInterval**  
必须在多少秒之后才能上传新性能计数器和日志数据。  
类型：整数  
有效值：将其设置为 5 秒或 5 秒以上。建议设置为十五秒 (00:00:15)。  
是否必需：是

**区域**  
要发送日志数据的 AWS 区域。虽然可以将性能计数器发送到与日志数据发送目标不同的区域，但是我们建议您将此参数设置为运行实例的区域。  
类型：字符串  
有效值：Systems Manager 和 CloudWatch Logs 都支持的 AWS 区域 区域ID，例如 `us-east-2`、`eu-west-1`, 和 `ap-southeast-1`。对于每个服务支持的 AWS 区域 的列表，请参阅**《Amazon Web Services 一般参考》中的 [Amazon CloudWatch Logs Service Endpoints](https://docs.aws.amazon.com/general/latest/gr/cwl_region.html#cwl_region) 和 [Systems Manager service endpoints](https://docs.aws.amazon.com/general/latest/gr/ssm.html#ssm_region)。  
是否必需：是

**SecretKey**  
您的秘密访问密钥。如果未使用 IAM 角色启动实例，则必须指定此属性。  
类型：字符串  
必需：否

**startType**  
打开或关闭实例上的 CloudWatch 功能。  
类型：字符串  
有效值：`Enabled` \$1 `Disabled`  
是否必需：是

**TimestampFormat**  
要使用的时间戳格式。有关支持的值的列表，请参阅 MSDN 库中的[自定义日期和时间格式字符串](http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx)。  
类型：字符串  
是否必需：是

**TimeZoneKind**  
在日志时间戳中不包含时区信息时提供时区信息。如果此参数留空且时间戳不包括时区信息，则 CloudWatch Logs 默认为本地时区。如果时间戳已包含时区信息，则忽略此参数。  
类型：字符串  
有效值：`Local` \$1 `UTC`  
必需：否

**单位**  
适当的指标计量单位。  
类型：字符串  
有效值：秒 \$1 微秒 \$1 毫秒 \$1 字节 \$1 千字节 \$1 兆字节 \$1 千兆字节 \$1 太兆字节 \$1 位 \$1 千位 \$1 兆位 \$1 千兆位 \$1 太兆位 \$1 百分比 \$1 计数 \$1 字节/秒 \$1 千字节/秒 \$1 兆字节/秒 \$1 千兆字节/秒 \$1 太兆字节/秒 \$1 位/秒 \$1 千位/秒 \$1 兆位/秒 \$1 千兆位/秒 \$1 太兆位/秒 \$1 计数/秒 \$1 无  
是否必需：是

## `aws:configureDocker`
<a name="aws-configuredocker"></a>

(2.0 版或更高版本架构) 将实例配置为使用容器和 Docker。此插件在大多数 Linux 变体和 Windows Server 操作系统中受支持。

### 语法
<a name="configuredocker-syntax"></a>

#### Schema 2.2
<a name="configuredocker-syntax-2.2"></a>

------
#### [ YAML ]

```
---
schemaVersion: '2.2'
description: aws:configureDocker
parameters:
  action:
    description: "(Required) The type of action to perform."
    type: String
    default: Install
    allowedValues:
    - Install
    - Uninstall
mainSteps:
- action: aws:configureDocker
  name: configureDocker
  inputs:
    action: "{{ action }}"
```

------
#### [ JSON ]

```
{
  "schemaVersion": "2.2",
  "description": "aws:configureDocker plugin",
  "parameters": {
    "action": {
      "description": "(Required) The type of action to perform.",
      "type": "String",
      "default": "Install",
      "allowedValues": [
        "Install",
        "Uninstall"
      ]
    }
  },
  "mainSteps": [
    {
      "action": "aws:configureDocker",
      "name": "configureDocker",
      "inputs": {
        "action": "{{ action }}"
      }
    }
  ]
}
```

------

### 输入
<a name="configuredocker-properties"></a>

**action**  
要执行的操作类型。  
类型：Enum  
有效值：`Install` \$1 `Uninstall`  
是否必需：是

## `aws:configurePackage`
<a name="aws-configurepackage"></a>

（2.0 版或更高版本架构）安装或卸载 AWS Systems Manager Distributor 程序包。您可以安装所指定软件包的最新版本、默认版本或其中一个版本。AWS 提供的软件包也受支持。此插件可在 Windows Server 和 Linux 操作系统上运行，但 Linux 操作系统不支持所有可用的软件包。

Windows Server 的可用 AWS 程序包包括：`AWSPVDriver`、`AWSNVMe`、`AwsEnaNetworkDriver`、`AwsVssComponents`、`AmazonCloudWatchAgent`、`CodeDeployAgent`，和 `AWSSupport-EC2Rescue.`

适用于 Linux 操作系统的可用 AWS 软件包包括：`AmazonCloudWatchAgent`、`CodeDeployAgent`,和 `AWSSupport-EC2Rescue`。

### 语法
<a name="configurepackage-syntax"></a>

#### Schema 2.2
<a name="configurepackage-syntax-2.2"></a>

------
#### [ YAML ]

```
---
schemaVersion: '2.2'
description: aws:configurePackage
parameters:
  name:
    description: "(Required) The name of the AWS package to install or uninstall."
    type: String
  action:
    description: "(Required) The type of action to perform."
    type: String
    default: Install
    allowedValues:
    - Install
    - Uninstall
  ssmParameter:
    description: "(Required) Argument stored in Parameter Store."
    type: String
    default: "{{ ssm:parameter_store_arg }}"
mainSteps:
- action: aws:configurePackage
  name: configurePackage
  inputs:
    name: "{{ name }}"
    action: "{{ action }}"
    additionalArguments: 
      "{\"SSM_parameter_store_arg\": \"{{ ssmParameter }}\", \"SSM_custom_arg\": \"myValue\"}"
```

------
#### [ JSON ]

```
{
   "schemaVersion": "2.2",
   "description": "aws:configurePackage",
   "parameters": {
      "name": {
         "description": "(Required) The name of the AWS package to install or uninstall.",
         "type": "String"
      },
      "action": {
         "description": "(Required) The type of action to perform.",
         "type": "String",
         "default": "Install",
         "allowedValues": [
            "Install",
            "Uninstall"
         ]
      },
      "ssmParameter": {
         "description": "(Required) Argument stored in Parameter Store.",
         "type": "String",
         "default": "{{ ssm:parameter_store_arg }}"
      }
   },
   "mainSteps": [
      {
         "action": "aws:configurePackage",
         "name": "configurePackage",
         "inputs": {
            "name": "{{ name }}",
            "action": "{{ action }}",
            "additionalArguments": "{\"SSM_parameter_store_arg\": \"{{ ssmParameter }}\", \"SSM_custom_arg\": \"myValue\"}"
         }
      }
   ]
}
```

------

### 输入
<a name="configurepackage-properties"></a>

**name**  
要安装或卸载的 AWS 软件包名称。可用的软件包如下所述：`AWSPVDriver`、`AwsEnaNetworkDriver`、`AwsVssComponents`，和 `AmazonCloudWatchAgent`。  
类型：字符串  
是否必需：是

**action**  
安装或卸载软件包。  
类型：Enum  
有效值：`Install` \$1 `Uninstall`  
是否必需：是

**安装类型**  
要执行的安装类型。如果指定 `Uninstall and reinstall`，该软件包将完全卸载，然后重新安装。在重新安装完成之前，应用程序不可用。如果指定 `In-place update`，将根据您在更新脚本中提供的指令，仅将新文件或更改的文件添加到现有的安装中。应用程序在整个更新过程中保持可用。这些区域有:已发布的软件包 AWS 不支持 `In-place update` 选项。`Uninstall and reinstall` 为默认值。  
类型：Enum  
有效值：`Uninstall and reinstall` \$1 `In-place update`  
必需：否

**附加参数**  
为安装、卸载或更新脚本提供的其他参数的 JSON 字符串。每个参数的前缀必须为 `SSM_`。可以使用约定 `{{ssm:parameter-name}}` 在附加参数中引用 Parameter Store 参数。要在安装、卸载或更新脚本过程中使用附加参数，必须使用适合操作系统的语法将参数作为环境变量引用。例如，在 PowerShell 中，您引用 `SSM_arg` 参数为 `$Env:SSM_arg`。您定义的参数数量没有限制，但附加参数输入有 4096 个字符限制。此限制包括您定义的所有秘钥和值。  
类型：StringMap  
必需：否

**版本**  
要卸载或安装的特定版本的软件包。如果要安装，系统默认安装最新发布的版本。如果要卸载，系统默认卸载当前安装的版本。如果没有找到已安装的版本，则会下载最新发布的版本，然后运行卸载操作。  
类型：字符串  
必需：否

## `aws:domainJoin`
<a name="aws-domainJoin"></a>

将 EC2 实例加入域。此插件在 Linux 和 Windows Server 操作系统上运行。该插件会将 Linux 实例的主机名更改为 EC2AMAZ-*XXXXXXX* 格式。有关加入 EC2 实例的更多信息，请参阅* AWS Directory Service 管理指南*中的[将 EC2 实例加入到 AWS 托管 Microsoft AD 目录](https://docs.aws.amazon.com/directoryservice/latest/admin-guide/ms_ad_join_instance.html)。

### 语法
<a name="domainJoin-syntax"></a>

#### Schema 2.2
<a name="domainJoin-syntax-2.2"></a>

------
#### [ YAML ]

```
---
schemaVersion: '2.2'
description: aws:domainJoin
parameters:
  directoryId:
    description: "(Required) The ID of the directory."
    type: String
  directoryName:
    description: "(Required) The name of the domain."
    type: String
  directoryOU:
    description: "(Optional) The organizational unit to assign the computer object to."
    type: String
  dnsIpAddresses:
    description: "(Required) The IP addresses of the DNS servers for your directory."
    type: StringList
  hostname:
    description: "(Optional) The hostname you want to assign to the node."
    type: String
mainSteps:
- action: aws:domainJoin
  name: domainJoin
  inputs:
    directoryId: "{{ directoryId }}"
    directoryName: "{{ directoryName }}"
    directoryOU: "{{ directoryOU }}"
    dnsIpAddresses: "{{ dnsIpAddresses }}"
    hostname: "{{ hostname }}"
```

------
#### [ JSON ]

```
{
  "schemaVersion": "2.2",
  "description": "aws:domainJoin",
  "parameters": {
    "directoryId": {
      "description": "(Required) The ID of the directory.",
      "type": "String"
    },
    "directoryName": {
      "description": "(Required) The name of the domain.",
      "type": "String"
    },
    "directoryOU": {
        "description": "(Optional) The organizational unit to assign the computer object to.",
        "type": "String"
      },
    "dnsIpAddresses": {
      "description": "(Required) The IP addresses of the DNS servers for your directory.",
      "type": "StringList"
    },
    "hostname": {
        "description": "(Optional) The hostname you want to assign to the node.",
        "type": "String"
      }
  },
  "mainSteps": [
    {
      "action": "aws:domainJoin",
      "name": "domainJoin",
      "inputs": {
        "directoryId": "{{ directoryId }}",
        "directoryName": "{{ directoryName }}",
        "directoryOU":"{{ directoryOU }}",
        "dnsIpAddresses":"{{ dnsIpAddresses }}",
        "hostname":"{{ hostname }}"
      }
    }
  ]
}
```

------

#### Schema 1.2
<a name="domainJoin-syntax-1.2"></a>

------
#### [ YAML ]

```
---
runtimeConfig:
  aws:domainJoin:
    properties:
      directoryId: "{{ directoryId }}"
      directoryName: "{{ directoryName }}"
      directoryOU: "{{ directoryOU }}"
      dnsIpAddresses: "{{ dnsIpAddresses }}"
```

------
#### [ JSON ]

```
{
   "runtimeConfig":{
      "aws:domainJoin":{
         "properties":{
            "directoryId":"{{ directoryId }}",
            "directoryName":"{{ directoryName }}",
            "directoryOU":"{{ directoryOU }}",
            "dnsIpAddresses":"{{ dnsIpAddresses }}"
         }
      }
   }
}
```

------

### 属性
<a name="domainJoin-properties"></a>

**directoryId**  
目录的 ID。  
类型：字符串  
是否必需：是  
示例："directoryId": "d-1234567890"

**directoryName**  
域的名称。  
类型：字符串  
是否必需：是  
示例："directoryName": "example.com"

**directoryOU**  
组织部门 (OU)。  
类型：字符串  
必需：否  
示例："directoryOU": "OU=test,DC=example,DC=com"

**dnsIpAddresses**  
DNS 服务器的 IP 地址。  
类型：StringList  
是否必需：是  
示例："dnsIpAddresses": ["198.51.100.1","198.51.100.2"]

**hostname**  
要分配给节点的主机名。如果未提供，则 Windows Server 实例的名称不会更改，而 Linux 实例将使用默认的命名模式。如果提供，Windows Server 实例将使用所提供的确切值，而 Linux 实例将以此为前缀（除非将 `keepHostName` 设置为“true”）。  
类型：字符串  
必需：否

**keepHostName**  
确定 Linux 实例在加入域时是否更改主机名。此参数仅适用于 Linux。默认情况下（`hostname`、`hostnameNumAppendDigits` 无输入，且 `keepHostName` 设置为“false”），Linux 主机将重命名为 EC2AMAZ-XXXXXX 模式。设置为“true”时，将会保留原始主机名并忽略 `hostname` 和 `hostnameNumAppendDigits` 的输入。  
类型：布尔值  
必需：否

**hostnameNumAppendDigits**  
定义要在主机名值之后附加的随机数值位数。此参数仅适用于 Linux，并且应与 `hostname` 参数结合使用。如果未提供 `hostname`，则会忽略此参数。  
类型：字符串  
允许的值：1 至 5  
必需：否

### 示例
<a name="domainJoin-examples"></a>

有关示例，请参阅《AWS Directory Service 管理指南》**中的[将 Amazon EC2 实例加入您的 AWS Managed Microsoft AD](https://docs.aws.amazon.com/directoryservice/latest/admin-guide/ec2-join-aws-domain.html)。

## `aws:downloadContent`
<a name="aws-downloadContent"></a>

（2.0 版或更高版本架构）从远程位置下载 SSM 文档和脚本。不支持 GitHub Enterprise 存储库。此插件在 Linux 和 Windows Server 操作系统中受支持。

### 语法
<a name="downloadContent-syntax"></a>

#### Schema 2.2
<a name="downloadContent-syntax-2.2"></a>

------
#### [ YAML ]

```
---
schemaVersion: '2.2'
description: aws:downloadContent
parameters:
  sourceType:
    description: "(Required) The download source."
    type: String
  sourceInfo:
    description: "(Required) The information required to retrieve the content from
      the required source."
    type: StringMap
mainSteps:
- action: aws:downloadContent
  name: downloadContent
  inputs:
    sourceType: "{{ sourceType }}"
    sourceInfo: "{{ sourceInfo }}"
```

------
#### [ JSON ]

```
{
  "schemaVersion": "2.2",
  "description": "aws:downloadContent",
  "parameters": {
    "sourceType": {
    "description": "(Required) The download source.",
    "type": "String"
  },
  "sourceInfo": {
    "description": "(Required) The information required to retrieve the content from the required source.",
    "type": "StringMap"
    }
  },
  "mainSteps": [
    {
      "action": "aws:downloadContent",
      "name": "downloadContent",
      "inputs": {
        "sourceType":"{{ sourceType }}",
        "sourceInfo":"{{ sourceInfo }}"
      }
    }
  ]
}
```

------

### 输入
<a name="downloadContent-inputs"></a>

**sourceType**  
下载源 Systems Manager 支持以下下载脚本和 SSM 文档的源类型：`GitHub`、`Git`、`HTTP`、`S3`，和`SSMDocument`。  
类型：字符串  
是否必需：是

**sourceInfo**  
从所需源检索内容所需的信息。  
类型：StringMap  
是否必需：是  
 **对于 sourceType `GitHub,`，请指定以下内容：**  
+ owner：存储库所有者。
+ repository：存储库的名称。
+ path：您要下载的文件或目录所在的路径。
+ getOptions：用于从分支（而非主分支）或存储库中的特定提交中检索内容的额外选项。如果您在主分支中使用最新提交，则可以省略 getOptions。如果您的存储库是在 2020 年 10 月 1 日之后创建的，则默认分支可能被命名为 main 而不是 master。在这种情况下，需要为 getOptions 参数指定值。

  此参数采用以下格式：
  + branch:refs/heads/*branch\$1name*

    默认值为 `master`。

    要指定非默认分支，请使用以下格式：

    branch:refs/heads/*branch\$1name*
  + commitID：*commitID*

    默认值为 `head`。

    要在最新提交以外的提交中使用 SSM 文档的版本，请指定完整的提交 ID。例如：

    ```
    "getOptions": "commitID:bbc1ddb94...b76d3bEXAMPLE",
    ```
+ tokenInfo：以 `{{ssm-secure:secure-string-token-name}}` 格式存储 GitHub 访问令牌信息的 Systems Manager 参数（SecureString 参数）。
**注意**  
该 `tokenInfo` 字段是唯一支持 SecureString 参数的 SSM 文档插件字段。任何其他字段和任何其他 SSM 文档插件都不支持 SecureString 参数。

```
{
    "owner":"TestUser",
    "repository":"GitHubTest",
    "path":"scripts/python/test-script",
    "getOptions":"branch:master",
    "tokenInfo":"{{ssm-secure:secure-string-token}}"
}
```
 **对于 sourceType `Git`，必须指定以下内容：**  
+ repository

  path：要下载的文件或目录的 Git repository URL。

  类型：字符串
此外，您可以指定以下任何可选参数：  
+ getOptions

  用于从分支（而非主分支）或存储库中的特定提交中检索内容的额外选项。如果您在主分支中使用最新提交，则可以省略 getOptions。

  类型：字符串

  此参数采用以下格式：
  + branch:refs/heads/*branch\$1name*

    默认值为 `master`。

    仅当您的 SSM 文档存储在 `master` 以外的分支中时， `"branch"` 才是必需的。例如：

    ```
    "getOptions": "branch:refs/heads/main"
    ```
  + commitID：*commitID*

    默认值为 `head`。

    要在最新提交以外的提交中使用 SSM 文档的版本，请指定完整的提交 ID。例如：

    ```
    "getOptions": "commitID:bbc1ddb94...b76d3bEXAMPLE",
    ```
+ privateSSHKey

  连接指定的`repository` 时要使用的 SSH 秘钥。可以使用以下格式为引用 SSH 密钥值 `SecureString` 参数：`{{ssm-secure:your-secure-string-parameter}}`。

  类型：字符串
+ 跳过主机键检查

  确定连接到您指定的 `repository` 时 StrictHostKeyChecking 选项的值。默认值为 `false`。

  类型：布尔值
+ username

  连接到使用 HTTP 指定的 `repository` 时使用的用户名。可以使用以下格式引用用户名值的 `SecureString` 参数：`{{ssm-secure:your-secure-string-parameter}}`。

  类型：字符串
+ password

  连接到使用 HTTP 指定的 `repository` 时使用的密码。可以使用以下格式为引用密码值 `SecureString` 参数：`{{ssm-secure:your-secure-string-parameter}}`。

  类型：字符串
 对于 **sourceType`HTTP`，必须指定以下内容：**  
+ url

  要下载的文件或目录的 URL。

  类型：字符串
此外，您可以指定以下任何可选参数：  
+ allowInsecureDownload

  确定是否可以通过未使用安全套接字层 (SSL) 或传输层安全 (TLS) 加密的连接执行下载。默认值为 `false`。我们建议您不要在未加密的情况下执行下载。如果您选择这样做，您将承担所有相关风险。安全性是 AWS 和您的共同责任。这被描述为责任共担共担模式。要了解更多信息，请参阅[责任共担模式](https://aws.amazon.com/compliance/shared-responsibility-model/)。

  类型：布尔值
+ authMethod

  确定在连接到指定的 `url` 时是否要使用用户名和密码。如果指定 `Basic` 或者 `Digest` 时，您必须为 `username` 和 `password` 参数提供值。使用 `Digest` 方法，3.0.1181.0 版本或更高版本的 SSM Agent 必须安装在实例上。`Digest` 方法支持 MD5 和 SHA256 加密。

  类型：字符串

  有效值：`None` \$1`Basic` \$1`Digest`
+ username

  连接到 `url` 您指定使用 `Basic` 身份验证。可以使用以下格式引用用户名值的 `SecureString` 参数：`{{ssm-secure:your-secure-string-parameter}}`。

  类型：字符串
+ password

  连接到您使用 `Basic` 身份验证指定的 `url` 时使用的密码。可以使用以下格式为引用密码值 `SecureString` 参数：`{{ssm-secure:your-secure-string-parameter}}`。

  类型：字符串
 **对于 sourceType `S3`，请指定以下内容：**  
+ 路径：要从 Amazon S3 下载的文件或目录的 URL。
从 S3 存储桶下载文件时，会在下载目录中生成 .etag 文件。

```
{
    "path": "https://s3.amazonaws.com/amzn-s3-demo-bucket/powershell/helloPowershell.ps1" 
}
```
 **对于 SourceType `SSMDocument`，请指定以下其中*一* 项：**  
+ 名称：采用以下格式的文档的名称和版本：`name:version`。版本为可选项。

  ```
  {
      "name": "Example-RunPowerShellScript:3" 
  }
  ```
+ name：采用以下格式的文档 ARN：`arn:aws:ssm:region:account_id:document/document_name`

  ```
  {
     "name":"arn:aws:ssm:us-east-2:3344556677:document/MySharedDoc"
  }
  ```

**destinationPath**  
实例上的可选本地路径，用于下载文件。如果不指定路径，内容将下载到命令 ID 的相对路径。  
类型：字符串  
必需：否

## `aws:psModule`
<a name="aws-psModule"></a>

在 Amazon EC2 实例上安装 PowerShell 模块。此插件仅在 Windows Server 操作系统中运行。

### 语法
<a name="psModule-syntax"></a>

#### Schema 2.2
<a name="psModule-syntax-2.2"></a>

------
#### [ YAML ]

```
---
schemaVersion: '2.2'
description: aws:psModule
parameters:
  source:
    description: "(Required) The URL or local path on the instance to the application
      .zip file."
    type: String
mainSteps:
- action: aws:psModule
  name: psModule
  inputs:
    source: "{{ source }}"
```

------
#### [ JSON ]

```
{
  "schemaVersion": "2.2",
  "description": "aws:psModule",
  "parameters": {
    "source": {
      "description": "(Required) The URL or local path on the instance to the application .zip file.",
      "type": "String"
    }
  },
  "mainSteps": [
    {
      "action": "aws:psModule",
      "name": "psModule",
      "inputs": {
        "source": "{{ source }}"
      }
    }
  ]
}
```

------

#### Schema 1.2
<a name="domainJoin-syntax-1.2"></a>

------
#### [ YAML ]

```
---
runtimeConfig:
  aws:psModule:
    properties:
    - runCommand: "{{ commands }}"
      source: "{{ source }}"
      sourceHash: "{{ sourceHash }}"
      workingDirectory: "{{ workingDirectory }}"
      timeoutSeconds: "{{ executionTimeout }}"
```

------
#### [ JSON ]

```
{
   "runtimeConfig":{
      "aws:psModule":{
         "properties":[
            {
               "runCommand":"{{ commands }}",
               "source":"{{ source }}",
               "sourceHash":"{{ sourceHash }}",
               "workingDirectory":"{{ workingDirectory }}",
               "timeoutSeconds":"{{ executionTimeout }}"
            }
         ]
      }
   }
}
```

------

### 属性
<a name="psModule-properties"></a>

**runCommand**  
安装模块后要运行的 PowerShell 命令。  
类型：StringList  
必需：否

**source**  
访问实例上应用程序 `.zip` 文件的 URL 或本地路径。  
类型：字符串  
是否必需：是

**sourceHash**  
`.zip` 文件的 SHA256 哈希值。  
类型：字符串  
必需：否

**timeoutSeconds**  
在被视为已失败前命令将运行的时间 (以秒为单位)。  
类型：字符串  
必需：否

**workingDirectory**  
实例上工作目录的路径。  
类型：字符串  
必需：否

## `aws:refreshAssociation`
<a name="aws-refreshassociation"></a>

(2.0 版或更高版本架构) 按需刷新 (强制应用) 关联。此操作将根据所选关联或绑定到目标的所有关联中定义的内容来更改系统状态。此插件仅在 Linux 和 Windows Server 操作系统上运行。

### 语法
<a name="refreshassociation-syntax"></a>

#### Schema 2.2
<a name="refreshassociation-syntax-2.2"></a>

------
#### [ YAML ]

```
---
schemaVersion: '2.2'
description: aws:refreshAssociation
parameters:
  associationIds:
    description: "(Optional) List of association IDs. If empty, all associations bound
      to the specified target are applied."
    type: StringList
mainSteps:
- action: aws:refreshAssociation
  name: refreshAssociation
  inputs:
    associationIds:
    - "{{ associationIds }}"
```

------
#### [ JSON ]

```
{
  "schemaVersion": "2.2",
  "description": "aws:refreshAssociation",
  "parameters": {
    "associationIds": {
      "description": "(Optional) List of association IDs. If empty, all associations bound to the specified target are applied.",
      "type": "StringList"
    }
  },
  "mainSteps": [
    {
      "action": "aws:refreshAssociation",
      "name": "refreshAssociation",
      "inputs": {
        "associationIds": [
          "{{ associationIds }}"
        ]
      }
    }
  ]
}
```

------

### 输入
<a name="refreshassociation-properties"></a>

**associationIds**  
关联 ID 的列表。如果为空，则应用与指定目标绑定的所有关联。  
类型：StringList  
必需：否

## `aws:runDockerAction`
<a name="aws-rundockeraction"></a>

（2.0 版或更高版本架构）在容器上运行 Docker 操作。此插件仅在 Linux 和 Windows Server 操作系统上运行。

### 语法
<a name="rundockeraction-syntax"></a>

#### Schema 2.2
<a name="rundockeraction-syntax-2.2"></a>

------
#### [ YAML ]

```
---
mainSteps:
- action: aws:runDockerAction
  name: RunDockerAction
  inputs:
    action: "{{ action }}"
    container: "{{ container }}"
    image: "{{ image }}"
    memory: "{{ memory }}"
    cpuShares: "{{ cpuShares }}"
    volume: "{{ volume }}"
    cmd: "{{ cmd }}"
    env: "{{ env }}"
    user: "{{ user }}"
    publish: "{{ publish }}"
    workingDirectory: "{{ workingDirectory }}"
    timeoutSeconds: "{{ timeoutSeconds }}"
```

------
#### [ JSON ]

```
{
   "mainSteps":[
      {
         "action":"aws:runDockerAction",
         "name":"RunDockerAction",
         "inputs":{
            "action":"{{ action }}",
            "container":"{{ container }}",
            "image":"{{ image }}",
            "memory":"{{ memory }}",
            "cpuShares":"{{ cpuShares }}",
            "volume":"{{ volume }}",
            "cmd":"{{ cmd }}",
            "env":"{{ env }}",
            "user":"{{ user }}",
            "publish":"{{ publish }}",
            "workingDirectory": "{{ workingDirectory }}",
            "timeoutSeconds": "{{ timeoutSeconds }}"
         }
      }
   ]
}
```

------

### 输入
<a name="rundockeraction-properties"></a>

**action**  
要执行的操作类型。  
类型：字符串  
是否必需：是

**容器**  
Docker 容器 ID。  
类型：字符串  
必需：否

**image**  
Docker 映像名称。  
类型：字符串  
必需：否

**cmd**  
容器命令。  
类型：字符串  
必需：否

**memory**  
容器内存限制。  
类型：字符串  
必需：否

**cpuShares**  
容器 CPU 份额 (相对权重)。  
类型：字符串  
必需：否

**volume**  
容器卷挂载。  
类型：StringList  
必需：否

**env**  
容器的环境变量。  
类型：字符串  
必需：否

**用户**  
容器的用户名。  
类型：字符串  
必需：否

**发布**  
容器已发布端口。  
类型：字符串  
必需：否

**workingDirectory**  
您的托管节点上的工作目录的路径。  
类型：字符串  
必需：否

**timeoutSeconds**  
在被视为已失败前命令将运行的时间 (以秒为单位)。  
类型：字符串  
必需：否

## `aws:runDocument`
<a name="aws-rundocument"></a>

（2.0 版或更高版本架构）运行存储在 Systems Manager 或本地共享存储中的 SSM 文档。您可以将此插件与 [`aws:downloadContent`](#aws-downloadContent) 插件配合使用，以将远程位置的 SSM 文档下载到本地共享存储，然后运行该文档。此插件在 Linux 和 Windows Server 操作系统中受支持。此插件不支持运行 `AWS-UpdateSSMAgent` 文档或使用 `aws:updateSsmAgent` 插件的任何文档。

### 语法
<a name="rundocument-syntax"></a>

#### Schema 2.2
<a name="aws-rundocument-syntax-2.2"></a>

------
#### [ YAML ]

```
---
schemaVersion: '2.2'
description: aws:runDocument
parameters:
  documentType:
    description: "(Required) The document type to run."
    type: String
    allowedValues:
    - LocalPath
    - SSMDocument
mainSteps:
- action: aws:runDocument
  name: runDocument
  inputs:
    documentType: "{{ documentType }}"
```

------
#### [ JSON ]

```
{
  "schemaVersion": "2.2",
  "description": "aws:runDocument",
  "parameters": {
    "documentType": {
      "description": "(Required) The document type to run.",
      "type": "String",
      "allowedValues": [
        "LocalPath",
        "SSMDocument"
      ]
    }
  },
  "mainSteps": [
    {
      "action": "aws:runDocument",
      "name": "runDocument",
      "inputs": {
        "documentType": "{{ documentType }}"
      }
    }
  ]
}
```

------

### 输入
<a name="rundocument-properties"></a>

**documentType**  
要运行的文档类型。您可以运行本地文档 (`LocalPath`) 或存储在 Systems Manager (`SSMDocument`) 中的文档。  
类型：字符串  
是否必需：是

**documentPath**  
文档的路径。如果 `documentType` 是 `LocalPath`，则指定本地共享存储上文档的路径。如果 `documentType` 是 `SSMDocument`，则指定文档的名称。  
类型：字符串  
必需：否

**documentParameters**  
文档的参数。  
类型：StringMap  
必需：否

## `aws:runPowerShellScript`
<a name="aws-runPowerShellScript"></a>

运行 PowerShell 脚本或者指定要运行的脚本的路径。此插件在 Microsoft Windows Server 和 Linux 操作系统上运行。

### 语法
<a name="runPowerShellScript-syntax"></a>

#### Schema 2.2
<a name="runPowerShellScript-syntax-2.2"></a>

------
#### [ YAML ]

```
---
schemaVersion: '2.2'
description: aws:runPowerShellScript
parameters:
  commands:
    type: String
    description: "(Required) The commands to run or the path to an existing script
      on the instance."
    default: Write-Host "Hello World"
mainSteps:
- action: aws:runPowerShellScript
  name: runPowerShellScript
  inputs:
    timeoutSeconds: '60'
    runCommand:
    - "{{ commands }}"
```

------
#### [ JSON ]

```
{
  "schemaVersion": "2.2",
  "description": "aws:runPowerShellScript",
  "parameters": {
    "commands": {
      "type": "String",
      "description": "(Required) The commands to run or the path to an existing script on the instance.",
      "default": "Write-Host \"Hello World\""
    }
  },
  "mainSteps": [
    {
      "action": "aws:runPowerShellScript",
      "name": "runPowerShellScript",
      "inputs": {
        "timeoutSeconds": "60",
        "runCommand": [
          "{{ commands }}"
        ]
      }
    }
  ]
}
```

------

#### Schema 1.2
<a name="runPowerShellScript-syntax-1.2"></a>

------
#### [ YAML ]

```
---
runtimeConfig:
  aws:runPowerShellScript:
    properties:
    - id: 0.aws:runPowerShellScript
      runCommand: "{{ commands }}"
      workingDirectory: "{{ workingDirectory }}"
      timeoutSeconds: "{{ executionTimeout }}"
```

------
#### [ JSON ]

```
{
   "runtimeConfig":{
      "aws:runPowerShellScript":{
         "properties":[
            {
               "id":"0.aws:runPowerShellScript",
               "runCommand":"{{ commands }}",
               "workingDirectory":"{{ workingDirectory }}",
               "timeoutSeconds":"{{ executionTimeout }}"
            }
         ]
      }
   }
}
```

------

### 属性
<a name="runPowerShellScript-properties"></a>

**runCommand**  
指定要运行的命令或实例上现有脚本的路径。  
类型：StringList  
是否必需：是

**timeoutSeconds**  
在被视为已失败前命令将运行的时间（以秒为单位）。如果达到超时，Systems Manager 停止命令执行。  
类型：字符串  
必需：否

**workingDirectory**  
实例上工作目录的路径。  
类型：字符串  
必需：否

## `aws:runShellScript`
<a name="aws-runShellScript"></a>

运行 Linux shell 脚本或者指定要运行的脚本的路径。此插件仅在 Linux 操作系统中运行。

### 语法
<a name="runShellScript-syntax"></a>

#### Schema 2.2
<a name="runShellScript-syntax-2.2"></a>

------
#### [ YAML ]

```
---
schemaVersion: '2.2'
description: aws:runShellScript
parameters:
  commands:
    type: String
    description: "(Required) The commands to run or the path to an existing script
      on the instance."
    default: echo Hello World
mainSteps:
- action: aws:runShellScript
  name: runShellScript
  inputs:
    timeoutSeconds: '60'
    runCommand:
    - "{{ commands }}"
```

------
#### [ JSON ]

```
{
  "schemaVersion": "2.2",
  "description": "aws:runShellScript",
  "parameters": {
    "commands": {
      "type": "String",
      "description": "(Required) The commands to run or the path to an existing script on the instance.",
      "default": "echo Hello World"
    }
  },
  "mainSteps": [
    {
      "action": "aws:runShellScript",
      "name": "runShellScript",
      "inputs": {
        "timeoutSeconds": "60",
        "runCommand": [
          "{{ commands }}"
        ]
      }
    }
  ]
}
```

------

#### Schema 1.2
<a name="runShellScript-syntax-1.2"></a>

------
#### [ YAML ]

```
---
runtimeConfig:
  aws:runShellScript:
    properties:
    - runCommand: "{{ commands }}"
      workingDirectory: "{{ workingDirectory }}"
      timeoutSeconds: "{{ executionTimeout }}"
```

------
#### [ JSON ]

```
{
   "runtimeConfig":{
      "aws:runShellScript":{
         "properties":[
            {
               "runCommand":"{{ commands }}",
               "workingDirectory":"{{ workingDirectory }}",
               "timeoutSeconds":"{{ executionTimeout }}"
            }
         ]
      }
   }
}
```

------

### 属性
<a name="runShellScript-properties"></a>

**runCommand**  
指定要运行的命令或实例上现有脚本的路径。  
类型：StringList  
是否必需：是

**timeoutSeconds**  
在被视为已失败前命令将运行的时间（以秒为单位）。如果达到超时，Systems Manager 停止命令执行。  
类型：字符串  
必需：否

**workingDirectory**  
实例上工作目录的路径。  
类型：字符串  
必需：否

## `aws:softwareInventory`
<a name="aws-softwareinventory"></a>

（2.0 版或更高版本架构）收集有关托管实例上应用程序、文件和配置的元数据。此插件仅在 Linux 和 Windows Server 操作系统上运行。在配置清单收集时，应该首先创建 AWS Systems Manager State Manager 关联。Systems Manager 会在关联运行时收集清单数据。如果您不先创建关联，并试图调用 `aws:softwareInventory` 插件，则系统会返回以下错误：

```
The aws:softwareInventory plugin can only be invoked via ssm-associate.
```

一个实例一次只能配置一个清单关联。如果您为一个实例配置了两个或更多关联，则清单关联不会运行，而且系统不会收集清单数据。有关收集文件清单的更多信息，请参阅 [AWS Systems Manager 清单](systems-manager-inventory.md)。

### 语法
<a name="softwareinventory-syntax"></a>

#### Schema 2.2
<a name="softwareinventory-syntax-2.2"></a>

------
#### [ YAML ]

```
---
mainSteps:
- action: aws:softwareInventory
  name: collectSoftwareInventoryItems
  inputs:
    applications: "{{ applications }}"
    awsComponents: "{{ awsComponents }}"
    networkConfig: "{{ networkConfig }}"
    files: "{{ files }}"
    services: "{{ services }}"
    windowsRoles: "{{ windowsRoles }}"
    windowsRegistry: "{{ windowsRegistry}}"
    windowsUpdates: "{{ windowsUpdates }}"
    instanceDetailedInformation: "{{ instanceDetailedInformation }}"
    customInventory: "{{ customInventory }}"
```

------
#### [ JSON ]

```
{
   "mainSteps":[
      {
         "action":"aws:softwareInventory",
         "name":"collectSoftwareInventoryItems",
         "inputs":{
            "applications":"{{ applications }}",
            "awsComponents":"{{ awsComponents }}",
            "networkConfig":"{{ networkConfig }}",
            "files":"{{ files }}",
            "services":"{{ services }}",
            "windowsRoles":"{{ windowsRoles }}",
            "windowsRegistry":"{{ windowsRegistry}}",
            "windowsUpdates":"{{ windowsUpdates }}",
            "instanceDetailedInformation":"{{ instanceDetailedInformation }}",
            "customInventory":"{{ customInventory }}"
         }
      }
   ]
}
```

------

### 输入
<a name="softwareinventory-properties"></a>

**应用程序**  
（可选）收集已安装应用程序的元数据。  
类型：字符串  
必需：否

**awsComponents**  
（可选）收集AWS 组件（例如 amazon-ssm-agent）的元数据。  
类型：字符串  
必需：否

**文件**  
（可选，需要 2.2.64.0 版本或更高版本的 SSM Agent ）收集文件的元数据，包括文件名称、文件创建时间、文件上次修改和访问时间以及文件大小等等。有关收集文件清单的更多信息，请参阅 [使用文件和 Windows 注册表清单](inventory-file-and-registry.md)。  
类型：字符串  
必需：否

**networkConfig**  
（可选）收集网络配置的元数据。  
类型：字符串  
必需：否

**billingInfo**  
（可选）收集与 AMI 账单代码关联的平台详细信息的元数据。  
类型：字符串  
必需：否

**windowsUpdates**  
（可选）收集所有 Windows 更新的元数据。  
类型：字符串  
必需：否

**instanceDetailedInformation**  
（可选）收集多于默认清单插件 （`aws:instanceInformation`）提供的信息的实例信息，包括 CPU 型号、速度和核心数量，等等。  
类型：字符串  
必需：否

**务**  
（可选，仅限 Windows 操作系统，需要 2.2.64.0 版本或更高版本的SSM Agent ）收集服务配置的元数据。  
类型：字符串  
必需：否

**windowsRegistry**  
（可选，仅限 Windows 操作系统，需要 2.2.64.0 版本或更高版本的SSM Agent）收集 Windows 注册表项和值。您可以选择一个键路径并以递归方式收集所有键和值。您还可以收集特定路径的特定注册表项及其值。清单会收集键路径、名称、类型和值。有关收集 Windows 注册表清单的更多信息，请参阅 [使用文件和 Windows 注册表清单](inventory-file-and-registry.md)。  
类型：字符串  
必需：否

**windowsRoles**  
（可选，仅限 Windows 操作系统，需要 2.2.64.0 版本或更高版本的 SSM Agent ）收集 Microsoft Windows 角色配置的元数据。  
类型：字符串  
必需：否

**customInventory**  
（可选）收集自定义清单数据。有关自定义清单的更多信息，请参阅 [使用自定义清单](inventory-custom.md)  
类型：字符串  
必需：否

**customInventoryDirectory**  
（可选）从指定目录收集自定义清单数据。有关自定义清单的更多信息，请参阅 [使用自定义清单](inventory-custom.md)  
类型：字符串  
必需：否

## `aws:updateAgent`
<a name="aws-updateagent"></a>

此命令可将 EC2Config 服务更新为最新版本或指定较旧版本。此插件仅在 Microsoft Windows Server 操作系统上运行。有关 EC2Config 服务的更多信息，请参阅《Amazon EC2 用户指南》**中的[使用 EC2Config 服务配置 Windows 实例（旧版）](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2config-service.html)。

### 语法
<a name="updateagent-syntax"></a>

#### Schema 2.2
<a name="updateagent-syntax-2.2"></a>

------
#### [ YAML ]

```
---
schemaVersion: '2.2'
description: aws:updateAgent
mainSteps:
- action: aws:updateAgent
  name: updateAgent
  inputs:
    agentName: Ec2Config
    source: https://s3.{Region}.amazonaws.com/aws-ssm-{Region}/manifest.json
```

------
#### [ JSON ]

```
{
  "schemaVersion": "2.2",
  "description": "aws:updateAgent",
  "mainSteps": [
    {
      "action": "aws:updateAgent",
      "name": "updateAgent",
      "inputs": {
        "agentName": "Ec2Config",
        "source": "https://s3.{Region}.amazonaws.com/aws-ssm-{Region}/manifest.json"
      }
    }
  ]
}
```

------

#### Schema 1.2
<a name="updateagent-syntax-1.2"></a>

------
#### [ YAML ]

```
---
runtimeConfig:
  aws:updateAgent:
    properties:
      agentName: Ec2Config
      source: https://s3.{Region}.amazonaws.com/aws-ssm-{Region}/manifest.json
      allowDowngrade: "{{ allowDowngrade }}"
      targetVersion: "{{ version }}"
```

------
#### [ JSON ]

```
{
   "runtimeConfig":{
      "aws:updateAgent":{
         "properties":{
            "agentName":"Ec2Config",
            "source":"https://s3.{Region}.amazonaws.com/aws-ssm-{Region}/manifest.json",
            "allowDowngrade":"{{ allowDowngrade }}",
            "targetVersion":"{{ version }}"
         }
      }
   }
}
```

------

### 属性
<a name="updateagent-properties"></a>

**agentName**  
EC2Config。这是运行 EC2Config 服务的代理的名称。  
类型：字符串  
是否必需：是

**allowDowngrade**  
允许将 EC2Config 服务降级为早期版本。如果设置为 False，则只能将该服务升级为更新的版本 (默认)。如果设置为 True，则指定早期版本。  
类型：布尔值  
必需：否

**source**  
Systems Manager 复制要安装的 EC2Config 版本的位置。您无法更改此位置。  
类型：字符串  
是否必需：是

**targetVersion**  
要安装的特定版本的 EC2Config 服务。如果未指定，服务将更新到最新版本。  
类型：字符串  
必需：否

## `aws:updateSsmAgent`
<a name="aws-updatessmagent"></a>

将 SSM Agent 更新到最新版本或指定较旧版本。此插件在 Linux 和 Windows Server 操作系统上运行。有关更多信息，请参阅 [使用 SSM Agent](ssm-agent.md)。

### 语法
<a name="updateSSMagent-syntax"></a>

#### Schema 2.2
<a name="updateaSSMgent-syntax-2.2"></a>

------
#### [ YAML ]

```
---
schemaVersion: '2.2'
description: aws:updateSsmAgent
parameters:
  allowDowngrade:
    default: 'false'
    description: "(Optional) Allow the Amazon SSM Agent service to be downgraded to
      an earlier version. If set to false, the service can be upgraded to newer versions
      only (default). If set to true, specify the earlier version."
    type: String
    allowedValues:
    - 'true'
    - 'false'
mainSteps:
- action: aws:updateSsmAgent
  name: updateSSMAgent
  inputs:
    agentName: amazon-ssm-agent
    source: https://s3.{Region}.amazonaws.com/amazon-ssm-{Region}/ssm-agent-manifest.json
    allowDowngrade: "{{ allowDowngrade }}"
```

------
#### [ JSON ]

```
{
  "schemaVersion": "2.2",
  "description": "aws:updateSsmAgent",
  "parameters": {
    "allowDowngrade": {
      "default": "false",
      "description": "(Required) Allow the Amazon SSM Agent service to be downgraded to an earlier version. If set to false, the service can be upgraded to newer versions only (default). If set to true, specify the earlier version.",
      "type": "String",
      "allowedValues": [
        "true",
        "false"
      ]
    }
  },
  "mainSteps": [
    {
      "action": "aws:updateSsmAgent",
      "name": "awsupdateSsmAgent",
      "inputs": {
        "agentName": "amazon-ssm-agent",
        "source": "https://s3.{Region}.amazonaws.com/amazon-ssm-{Region}/ssm-agent-manifest.json",
        "allowDowngrade": "{{ allowDowngrade }}"
      }
    }
  ]
}
```

------

#### Schema 1.2
<a name="updateaSSMgent-syntax-1.2"></a>

------
#### [ YAML ]

```
---
runtimeConfig:
  aws:updateSsmAgent:
    properties:
    - agentName: amazon-ssm-agent
      source: https://s3.{Region}.amazonaws.com/aws-ssm-{Region}/manifest.json
      allowDowngrade: "{{ allowDowngrade }}"
```

------
#### [ JSON ]

```
{
   "runtimeConfig":{
      "aws:updateSsmAgent":{
         "properties":[
            {
               "agentName":"amazon-ssm-agent",
               "source":"https://s3.{Region}.amazonaws.com/aws-ssm-{Region}/manifest.json",
               "allowDowngrade":"{{ allowDowngrade }}"
            }
         ]
      }
   }
}
```

------

### 属性
<a name="updateSSMagent-properties"></a>

**agentName**  
amazon-ssm-agent。这是在实例上处理请求并运行命令的 Systems Manager agent 的名称。  
类型：字符串  
是否必需：是

**allowDowngrade**  
允许将 SSM Agent 降级为早期版本。如果设置为 False，则只能将该代理升级为更新的版本 (默认)。如果设置为 True，则指定早期版本。  
类型：布尔值  
是否必需：是

**source**  
复制 Systems Manager 要安装的 SSM Agent 版本的位置。您无法更改此位置。  
类型：字符串  
是否必需：是

**targetVersion**  
要安装的特定版本的 SSM Agent。如果未指定，代理将更新到最新版本。  
类型：字符串  
必需：否