

终止支持通知：2026 年 10 月 7 日， AWS 将终止对的支持。 AWS Proton 2026 年 10 月 7 日之后，您将无法再访问 AWS Proton 控制台或 AWS Proton 资源。您部署的基础架构将保持不变。有关更多信息，请参阅《[AWS Proton 服务弃用和迁移指南》](https://docs.aws.amazon.com/proton/latest/userguide/proton-end-of-support.html)。

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

# 总结模板文件 AWS Proton
<a name="ag-wrap-up"></a>

在准备环境和服务基础设施即代码 (IaC) 文件及其相应的架构文件后，您必须将它们放置到不同的目录中。您还必须创建一个清单 YAML 文件。清单文件列出了目录中的 IaC 文件、渲染引擎以及用于开发该模板中的 IaC 的模板语言。

**注意**  
也可以独立于模板捆绑包使用清单文件，以作为*直接定义的组件* 的直接输入。在这种情况下，它总是为两者 CloudFormation 和 Terraform 指定一个 IaC 模板文件。有关组件的更多信息，请参阅[AWS Proton 组件](ag-components.md)。

清单文件需要符合以下示例中所示的格式和内容。

**CloudFormation 清单文件格式：**

使用 CloudFormation，您可以列出单个文件。

```
infrastructure:
  templates:
    - file: "cloudformation.yaml"
      rendering_engine: jinja
      template_language: cloudformation
```

**Terraform 清单文件格式：**

通过使用 Terraform，您可以明确列出单个文件，或使用 `*` 通配符列出目录中的每个文件。

**注意**  
通配符仅包含名称以 `.tf` 结尾的文件。将忽略其他文件。

```
infrastructure:
  templates:
    - file: "*"
      rendering_engine: hcl
      template_language: terraform
```

**CodeBuild基于配置的清单文件格式：**

使用 CodeBuild基于基础的配置，您可以指定配置和取消置备 shell 命令。

**注意**  
除了清单以外，您的捆绑包还应包含您的命令依赖的任何文件。

以下示例清单使用 CodeBuild基于配置的资源调配，使用 () 来配置（*部署*）和取消配置 AWS Cloud Development Kit (AWS CDK) （*销毁*AWS CDK）资源。模板捆绑包还应包含 CDK 代码。

在预置期间，AWS Proton 创建一个输入文件，其中包含您在名为 `proton-input.json` 的模板架构中定义的输入参数的值。

```
infrastructure:
  templates:
    - rendering_engine: codebuild
      settings:
        image: aws/codebuild/amazonlinux2-x86_64-standard:4.0
        runtimes:
          nodejs: 16
        provision:
          - npm install
          - npm run build
          - npm run cdk bootstrap
          - npm run cdk deploy -- --require-approval never --outputs-file proton-outputs.json
          - jq 'to_entries | map_values(.value) | add | to_entries | map({key:.key, valueString:.value})' < proton-outputs.json > outputs.json
          - aws proton notify-resource-deployment-status-change --resource-arn $RESOURCE_ARN --status IN_PROGRESS --outputs file://./outputs.json
        deprovision:
          - npm install
          - npm run build
          - npm run cdk destroy
        project_properties:
          VpcConfig:
            VpcId: "{{ environment.inputs.codebuild_vpc_id }}"
            Subnets: "{{ environment.inputs.codebuild_subnets }}"
            SecurityGroupIds: "{{ environment.inputs.codebuild_security_groups }}"
```

为环境或服务模板包设置目录和清单文件后，您可以将这些目录压缩成焦油球，然后将其上传到可以检索它们的亚马逊简单存储服务 (Amazon S3) 存储桶 AWS Proton ，或者上传到[模板同步](ag-template-sync-configs.md) Git 存储库。

当您创建注册的环境或服务模板的次要版本时 AWS Proton，您需要提供指向位于 S3 存储桶中的环境或服务模板包 tar ball 的路径。 AWS Proton 将其与新的模板次要版本一起保存。您可以选择新的模板次要版本来创建或更新环境或服务 AWS Proton。

## 打包环境模板捆绑包
<a name="environment-wrap-up"></a>

您创建的环境模板包有两种类型。 AWS Proton
+ 要为*标准* 环境模板创建环境模板捆绑包，请在目录中放置架构、基础设施即代码 (IaC) 文件和清单文件，如以下环境模板捆绑包目录结构中所示。
+ 要为*客户托管* 环境模板创建环境模板捆绑包，请仅提供架构文件和目录。*不要*包含基础架构目录和文件。 AWS Proton 如果包含基础架构目录和文件，则会引发错误。

有关更多信息，请参阅 [注册并发布模板](template-create.md)。

CloudFormation 环境模板包目录结构：

```
 /schema
   schema.yaml
 /infrastructure
   manifest.yaml
   cloudformation.yaml
```

Terraform 环境模板捆绑包目录结构：

```
 /schema
   schema.yaml
 /infrastructure
   manifest.yaml
   environment.tf
```

## 打包服务模板捆绑包
<a name="service-wrap-up"></a>

要创建服务模板捆绑包，您必须将架构、基础设施即代码 (IaC) 文件和清单文件放置在目录中，如服务模板捆绑包目录结构示例中所示。

如果在您的模板捆绑包中*不* 包含服务管道，则*不要* 包含管道目录和文件，并在创建与该模板捆绑包关联的服务模板时设置 `"pipelineProvisioning": "CUSTOMER_MANAGED"`。

**注意**  
在创建服务模板后，您无法修改 `pipelineProvisioning`。

有关更多信息，请参阅 [注册并发布模板](template-create.md)。

CloudFormation 服务模板包目录结构：

```
 /schema
   schema.yaml
 /instance_infrastructure
   manifest.yaml
   cloudformation.yaml
 /pipeline_infrastructure
   manifest.yaml
   cloudformation.yaml
```

Terraform 服务模板捆绑包目录结构：

```
 /schema
   schema.yaml
 /instance_infrastructure
   manifest.yaml
   instance.tf
 /pipeline_infrastructure
   manifest.yaml
   pipeline.tf
```