

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

# 应用程序数据包 (aws\$1opsworks\$1app)
<a name="data-bag-json-app"></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 支持 团队联系。

对于 [Deploy 事件](workingcookbook-events.md)或 [Execute Recipes 堆栈命令](workingstacks-commands.md)，表示应用程序的设置。

以下示例显示了如何使用 Chef 搜索来搜索单个数据袋项目，然后搜索多个数据袋项目，将包含应用程序短名称和来源 URLs的消息写入 Chef 日志：

```
app = search("aws_opsworks_app").first
Chef::Log.info("********** The app's short name is '#{app['shortname']}' **********")
Chef::Log.info("********** The app's URL is '#{app['app_source']['url']}' **********")

search("aws_opsworks_app").each do |app|
  Chef::Log.info("********** The app's short name is '#{app['shortname']}' **********")
  Chef::Log.info("********** The app's URL is '#{app['app_source']['url']}' **********")
end
```


****  

|  |  |  | 
| --- |--- |--- |
| [app\$1id](#data-bag-json-app-app-id) | [app\$1source](#data-bag-json-app-app-source) | [data\$1sources](#data-bag-json-app-app-data-source) | 
| [部署](#data-bag-json-app-deploy) | [属性](#data-bag-json-app-attributes) | [域](#data-bag-json-app-app-domains) | 
| [enable\$1ssl](#data-bag-json-app-enable-ssl) | [环境](#data-bag-json-app-app-environment) | [name](#data-bag-json-app-app-name) | 
| [shortname](#data-bag-json-app-app-shortname) | [ssl\$1configuration](#data-bag-json-app-app-ssl-config) | [类型](#data-bag-json-app-app-type) | 

**app\$1id**  <a name="data-bag-json-app-app-id"></a>
应用程序 ID (字符串)。标识应用程序的 GUID。

**app\$1source**  <a name="data-bag-json-app-app-source"></a>
一组内容，指定 OpsWorks Stacks 用于从其源代码控制存储库部署应用程序的信息。该内容因存储库类型而异。    
**password**  
对于私有存储库为密码，对于公共存储库为 `"null"` (字符串)。对于私有 S3 存储桶，此内容设置为私有密钥。  
**revision**  
如果存储库具有多个分支，该内容将指定应用程序的分支或版本，如 `"version1"` (字符串)。否则，其设置为 `"null"`。  
**ssh\$1key**  
访问私有 Git 存储库时为[部署 SSH 密钥](workingapps-deploykeys.md)，对于公共存储库为 `"null"` (字符串)。  
**类型**  
应用程序的源位置 (字符串)。有效值包括：  
+ `"archive"`
+ `"git"`
+ `"other"`
+ `"s3"`  
**url**  
应用程序源代码所在的位置 (字符串)。  
**用户**  
对于私有存储库为用户名称，对于公共存储库为 `"null"` (字符串)。对于私有 S3 存储桶，该内容设置为访问密钥。

**属性**  <a name="data-bag-json-app-attributes"></a>
一组描述目录结构和应用程序内容的内容。    
**document\$1root**  <a name="data-bag-json-app-documentroot"></a>
文档树的根目录。定义文档根目录的路径 (或应用程序主页的位置，如 `home_html`)，该路径相对于您的部署目录。除非指定此属性，否则 document\$1root 默认为 `public`。`document_root` 的值只能以 `a-z`、`A-Z`、`0-9`、`_` (下划线) 或 `-` (连字符) 字符开头。

**data\$1sources**  <a name="data-bag-json-app-app-data-source"></a>
连接应用程序数据库所需的信息。如果应用程序附加了数据库层， OpsWorks Stacks 会自动为此内容分配适当的值。  
data\$1sources 的值为数组，这些数组是通过整型偏移量进行访问，而不是通过密钥进行访问。例如，要访问应用程序的第一个数据源，请使用 `app[:data_sources][0][:type]`。    
**database\$1name**  
数据库名称，这通常是应用程序的短名称 (字符串)。  
**类型**  
数据库实例的类型，通常为 `"RdsDbInstance"` (字符串)。  
**arn**  
数据库实例的 Amazon 资源名称 (ARN) (字符串)。

**部署**  <a name="data-bag-json-app-deploy"></a>
是否应部署应用程序（布尔值）。`true` 表示应在 Deploy 生命周期事件中部署应用程序。在 Setup 生命周期事件中，所有应用程序的此内容均为 `true`。要确定应在实例上部署哪些应用程序，请查看该实例所属的层。

**域**  <a name="data-bag-json-app-app-domains"></a>
应用程序域的列表 (字符串列表)。

**enable\$1ssl**  <a name="data-bag-json-app-enable-ssl"></a>
是否启用 SSL 支持 (布尔值)。

**环境**  <a name="data-bag-json-app-app-environment"></a>
用户指定的已为应用程序定义的环境变量的集合。有关如何定义应用程序的环境变量的更多信息，请参阅[添加应用程序](workingapps-creating.md)。每个内容名称均设置为环境变量名称，且相应的值设置为变量的值。

**name**  <a name="data-bag-json-app-app-name"></a>
应用程序的名称，用于显示目的 (字符串)。

**shortname**  <a name="data-bag-json-app-app-shortname"></a>
应用程序的短名称，由 OpsWorks Stacks 根据名称（字符串）生成。该短名称在内部由配方使用；用作安装应用程序文件的目录的名称。

**ssl\$1configuration**  <a name="data-bag-json-app-app-ssl-config"></a>  
**证书**  
如果您启用了 SSL 支持，即为应用程序的 SSL 证书；否则，为 `"null"` (字符串)。  
**chain**  
如果启用 SSL，则为指定中间证书颁发机构密钥或客户端身份验证的内容 (字符串)。  
**private\$1key**  
如果您启用了 SSL 支持，即为应用程序的 SSL 私有密钥；否则，为 `"null"` (字符串)。

**类型**  <a name="data-bag-json-app-app-type"></a>
应用程序的类型，对于 Chef 12 Linux 和 Chef 12.2 Windows 堆栈，该类型始终设置为 `"other"` (字符串)。