

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

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

**重要**  
 AWS OpsWorks Stacks 此服務已於 2024 年 5 月 26 日終止，並已針對新客戶和現有客戶停用。我們強烈建議客戶盡快將其工作負載遷移至其他解決方案。如果您對遷移有任何疑問，請透過 [AWS re：Post](https://repost.aws/) 或透過 [AWS Premium Support](https://aws.amazon.com/support) 聯絡 AWS 支援 團隊。

代表 Stacks OpsWorks 在一或多個執行個體上執行之命令的設定。

下列範例示範如何使用 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) | [type](#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>
命令的隨機唯一識別符，由 Stacks OpsWorks （字串） 指派。

**iam\$1user\$1arn**  <a name="data-bag-json-command-iam-user-arn"></a>
若命令是由客戶建立，則為建立命令之使用者的 Amazon Resource Name (ARN) (字串)。

**instance\$1id**  <a name="data-bag-json-command-instance-id"></a>
執行命令之執行個體的識別符 (字串)。

**sent\$1at**  <a name="data-bag-json-command-sent-at"></a>
Stacks 執行命令 （字串） OpsWorks 時的時間戳記。

**type**  <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"`