包裝的範本檔案 AWS Proton - AWS Proton

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

包裝的範本檔案 AWS Proton

準備您的環境和服務基礎結構作為代碼(IaC)文件及其各自的模式文件後,您必須將它們組織在目錄中。您也必須建立資訊清單 YAML 檔案。清單文件列出了目錄中的 IaC 文件,渲染引擎,以及用於在此模板中開發 IaC 的模板語言。

注意

資訊清單檔案也可以獨立於範本包使用,做為直接定義之元件的直接輸入。在這種情況下,它總是為 CloudFormation 和 Terraform 指定單個 IaC 模板文件。如需元件的詳細資訊,請參閱AWS Proton 元件

資訊清單檔案必須遵循下列範例中顯示的格式和內容。

CloudFormation 清單文件格式:

使用 CloudFormation,您可以列出單一檔案。

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

地形清單文件格式:

使用 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 }}"

為環境或服務範本套件組合設定目錄和資訊清單檔案後,您可以將目錄壓縮到 tar ball 中,然後將它們上傳到 Amazon Simple Storage Service (Amazon S3) 儲存貯體, AWS Proton 以便在其中擷取它們,或到範本同步 Git 儲存庫。

當您建立註冊的環境或服務範本的次要版本時 AWS Proton,您會提供位於 S3 儲存貯體中的環境或服務範本 bundle tar ball 的路徑。 AWS Proton 將其與新範本次要版本一起儲存。您可以選取新的範本次要版本來建立或更新環境或服務 AWS Proton。

環境模板包裝包裝

您可以為其建立兩種類型的環境範本套裝軟體 AWS Proton。

  • 若要建立標準環境範本的環境範本套裝軟體,請將結構描述、基礎結構作為程式碼 (IaC) 檔案和資訊清單檔案組合 (如下列環境範本組合包目錄結構所示) 組織在目錄中。

  • 若要為客戶受管理的環境範本建立環境範本套裝軟體,請僅提供結構描述檔案和目錄。請勿包含基礎結構目錄和檔案。 AWS Proton 如果包含基礎結構目錄和檔案,則會擲回錯誤。

如需詳細資訊,請參閱 註冊和發佈範本

CloudFormation 環境模板包目錄結構:

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

地形環境模板捆綁目錄結構:

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

服務模板捆綁包裝

若要建立服務範本套裝軟體,您必須將結構描述、基礎結構即程式碼 (IaC) 檔案以及資訊清單檔案組織到目錄中,如服務範本組合包目錄結構範例所示。

如果您有在範本包中包含服務管線,請不要包含管線目錄和檔案,並在建立要與此範本套件組合關聯的服務範本"pipelineProvisioning": "CUSTOMER_MANAGED"時進行設定。

注意

您無法在建立服務範本pipelineProvisioning之後進行修改。

如需詳細資訊,請參閱 註冊和發佈範本

CloudFormation 服務範本包目錄結構:

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

地形服務模板捆綁目錄結構:

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