

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 命令数据包 (aws\$1opsworks\$1command)
<a name="data-bag-json-command"></a>

**重要**  
该 AWS OpsWorks Stacks 服务于 2024 年 5 月 26 日终止，新客户和现有客户均已禁用。我们强烈建议客户尽快将其工作负载迁移到其他解决方案。如果您对迁移有疑问，请通过 re [AWS : Post 或通过 Pre](https://repost.aws/) mium Su [AWS pp](https://aws.amazon.com/support) ort 与 AWS 支持 团队联系。

表示 OpsWorks Stacks 在一个或多个实例上运行的命令的设置。

以下示例演示了如何使用 Chef 搜索来先后搜索单个数据包项目和多个数据包项目，以将包含命令类型和发送时间的消息写入 Chef 日志：

```
command = search("aws_opsworks_command").first
Chef::Log.info("********** The command's type is '#{command['type']}' **********")
Chef::Log.info("********** The command was sent at '#{command['sent_at']}' **********")

search("aws_opsworks_command").each do |command|
  Chef::Log.info("********** The command's type is '#{command['type']}' **********")
  Chef::Log.info("********** The command was sent at '#{command['sent_at']}' **********")
end
```


****  

|  |  |  | 
| --- |--- |--- |
| [args](#data-bag-json-command-args) | [command\$1id](#data-bag-json-command-command-id) | [iam\$1user\$1arn](#data-bag-json-command-iam-user-arn) | 
| [instance\$1id](#data-bag-json-command-instance-id) | [sent\$1at](#data-bag-json-command-sent-at) | [类型](#data-bag-json-command-type) | 

**args**  <a name="data-bag-json-command-args"></a>
命令的参数 (字符串)。

**command\$1id**  <a name="data-bag-json-command-command-id"></a>
命令的随机唯一标识符，由 OpsWorks Stacks（字符串）分配。

**iam\$1user\$1arn**  <a name="data-bag-json-command-iam-user-arn"></a>
如果命令是由客户创建的，即为创建命令的用户的 Amazon 资源名称 (ARN) (字符串)。

**instance\$1id**  <a name="data-bag-json-command-instance-id"></a>
运行命令的实例的标识符 (字符串)。

**sent\$1at**  <a name="data-bag-json-command-sent-at"></a>
 OpsWorks Stacks 运行命令的时间戳（字符串）。

**类型**  <a name="data-bag-json-command-type"></a>
命令的类型 (字符串)。有效值包括：  
+ `"configure"`
+ `"deploy"`
+ `"deregister"`
+ `"execute_recipes"`
+ `"grant_remote_access"`
+ `"install_dependencies"`
+ `"restart"`
+ `"revoke_remote_access"`
+ `"rollback"`
+ `"setup"`
+ `"shutdown"`
+ `"start"`
+ `"stop"`
+ `"sync_remote_users"`
+ `"undeploy"`
+ `"update_agent"`
+ `"update_custom_cookbooks"`
+ `"update_dependencies"`