

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

# AppSpec 檔案結構
<a name="reference-appspec-file-structure"></a>

以下是 AppSpec 檔案的高階結構，用於部署至 AWS Lambda 和 EC2/現場部署運算平台。

除非另有指定，否則 YAML 格式 AppSpec 檔案中的值若為字串，則不得以引號 ("") 包裝。

## Amazon ECS 部署的 AppSpec 檔案結構
<a name="ecs-appspec-structure"></a>

**注意**  
此 AppSpec 檔案是以 YAML 撰寫，但您可以使用相同的結構在 JSON 中撰寫。JSON 格式 AppSpec 檔案中的字串一律以引號 ("") 包裝。

```
version: {{0.0}}
resources: 
  {{ecs-service-specifications}}
hooks: 
  {{deployment-lifecycle-event-mappings}}
```

在此結構中：

** **version** **  
本節指定 AppSpec 檔案的版本。請不要變更此值。這是必要的。目前，唯一允許的值為 **0.0**。它由 CodeDeploy 保留以供日後使用。  
以字串指定 **version**。

** **resources** **  
本節指定要部署之 Amazon ECS 應用程式的相關資訊。  
如需詳細資訊，請參閱[Amazon ECS 部署的 AppSpec 'resources' 區段](reference-appspec-file-structure-resources.md#reference-appspec-file-structure-resources-ecs)。

** **hooks** **  
本節指定要在特定部署生命週期事件掛鉤上執行的 Lambda 函數，以驗證部署。  
如需詳細資訊，請參閱[Amazon ECS 部署的生命週期事件掛鉤清單](reference-appspec-file-structure-hooks.md#reference-appspec-file-structure-hooks-list-ecs)。

## AWS Lambda 部署的 AppSpec 檔案結構
<a name="lambda-appspec-structure"></a>

**注意**  
此 AppSpec 檔案是以 YAML 撰寫，但您可以使用相同的結構來撰寫 JSON 中 Lambda 部署的 AppSpec 檔案。JSON 格式 AppSpec 檔案中的字串一律以引號 ("") 包裝。

```
version: {{0.0}}
resources: 
  {{lambda-function-specifications}}
hooks: 
  {{deployment-lifecycle-event-mappings}}
```

在此結構中：

** **version** **  
本節指定 AppSpec 檔案的版本。請不要變更此值。這是必要的。目前，唯一允許的值為 **0.0**。它由 CodeDeploy 保留以供日後使用。  
以字串指定 **version**。

** **resources** **  
本節指定要部署之 Lambda 函數的相關資訊。  
如需詳細資訊，請參閱[AppSpec 'resources' 區段 （僅限 Amazon ECS 和 AWS Lambda 部署）](reference-appspec-file-structure-resources.md)。

** **hooks** **  
本節指定要在特定部署生命週期事件上執行的 Lambda 函數，以驗證部署。  
如需詳細資訊，請參閱[AppSpec 'hooks' 區段](reference-appspec-file-structure-hooks.md)。

## EC2/現場部署的 AppSpec 檔案結構
<a name="server-appspec-structure"></a>

```
version: {{0.0}}
os: {{operating-system-name}}
files:
  {{source-destination-files-mappings}}
permissions:
  {{permissions-specifications}}
hooks:
  {{deployment-lifecycle-event-mappings}}
```

在此結構中：

** **version** **  
本節指定 AppSpec 檔案的版本。請不要變更此值。這是必要的。目前，唯一允許的值為 **0.0**。它由 CodeDeploy 保留以供日後使用。  
以字串指定 **version**。

** **os** **  
本區段指定您要部署之執行個體的作業系統值。這是必要的。您可以指定的值如下：  
+ **linux** – 執行個體是 Amazon Linux、Ubuntu Server 或 RHEL 執行個體。
+ **windows** – 執行個體是 Windows Server 執行個體。
以字串指定 **os**。

** **files** **  
本區段指定在部署 **Install** 事件期間應該複製至執行個體的檔案名稱。  
如需詳細資訊，請參閱[AppSpec 'files' 區段 （僅限 EC2/內部部署部署）](reference-appspec-file-structure-files.md)。

** **permissions** **  
本區段指定應該如何將特殊許可 (如果有的話) 套用至 `files` 區段中的檔案，因為它們會複製至執行個體。本節僅適用於 Amazon Linux、Ubuntu Server 和 Red Hat Enterprise Linux (RHEL) 執行個體。  
如需詳細資訊，請參閱 [AppSpec 'permissions' 區段 （僅限 EC2/現場部署）](reference-appspec-file-structure-permissions.md)。

** **hooks** **  
本區段指定要在部署期間於特定部署生命週期事件執行的指令碼。  
如需詳細資訊，請參閱[AppSpec 'hooks' 區段](reference-appspec-file-structure-hooks.md)。

**Topics**
+ [Amazon ECS 部署的 AppSpec 檔案結構](#ecs-appspec-structure)
+ [AWS Lambda 部署的 AppSpec 檔案結構](#lambda-appspec-structure)
+ [EC2/現場部署的 AppSpec 檔案結構](#server-appspec-structure)
+ [AppSpec 'files' 區段 （僅限 EC2/內部部署部署）](reference-appspec-file-structure-files.md)
+ [AppSpec 'resources' 區段 （僅限 Amazon ECS 和 AWS Lambda 部署）](reference-appspec-file-structure-resources.md)
+ [AppSpec 'permissions' 區段 （僅限 EC2/現場部署）](reference-appspec-file-structure-permissions.md)
+ [AppSpec 'hooks' 區段](reference-appspec-file-structure-hooks.md)