View a markdown version of this page

註冊和發佈範本 - AWS Proton

終止支援通知:2026 年 10 月 7 日 AWS 將終止 的支援 AWS Proton。2026 年 10 月 7 日之後,您將無法再存取 AWS Proton 主控台或 AWS Proton 資源。您部署的基礎設施將保持不變。如需詳細資訊,請參閱AWS Proton 服務棄用和遷移指南。

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

註冊和發佈範本

您可以使用 註冊和發佈環境和服務範本 AWS Proton,如以下各節所述。

您可以使用 主控台或 建立新的範本版本 AWS CLI。

或者,您可以使用 主控台或 AWS CLI 來建立範本,並為其設定範本同步。此組態可讓您從位於您已定義之已註冊 git 儲存庫中的範本套件進行 AWS Proton 同步。每當遞交推送到變更其中一個範本套件的儲存庫時,如果該版本不存在,就會建立新的範本次要或主要版本。若要進一步了解範本同步組態先決條件和需求,請參閱 範本同步組態。

註冊和發佈環境範本

您可以註冊和發佈下列類型的環境範本。

  • 註冊並發佈 AWS Proton 使用 來部署和管理環境基礎設施的標準環境範本。

  • 註冊並發佈客戶受管環境範本,該範本 AWS Proton 使用 連線到您管理的現有佈建基礎設施。 AWS Proton 不會管理現有的佈建基礎設施。

重要

作為管理員,請確保您的佈建和管理的基礎設施和所有輸出參數與關聯的客戶受管環境範本相容。 AWS Proton 無法代表您考慮變更,因為這些變更不可見 AWS Proton。不一致會導致失敗。

您可以使用 主控台或 AWS CLI 來註冊和發佈環境範本。

AWS 管理主控台
使用 主控台來註冊和發佈新的環境範本。
  1. 在 AWS Proton 主控台中,選擇環境範本。

  2. 選擇建立環境範本。

  3. 在建立環境範本頁面的範本選項區段中,選擇兩個可用範本選項之一。

    • 建立範本以佈建新環境。

    • 建立範本以使用您管理的佈建基礎設施。

  4. 如果您選擇建立範本以佈建新的環境,請在範本套件來源區段中,選擇三個可用範本套件來源選項的其中一個。若要進一步了解同步範本的需求和先決條件,請參閱 範本同步組態。

  5. 提供範本套件的路徑。
    1. 如果您選擇使用其中一個範例範本套件:

      在範本套件區段中,選取範本套件範例。

    2. 如果您從 Git 選擇同步範本,請在來源碼區段中:

      1. 選取範本同步組態的儲存庫。

      2. 輸入要從中同步的儲存庫分支名稱。

      3. (選用) 輸入目錄名稱以限制範本套件的搜尋。

    3. 否則,在 S3 套件位置區段中,提供範本套件的路徑。

  6. 在範本詳細資訊區段中。

    1. 輸入範本名稱。

    2. (選用) 輸入範本顯示名稱。

    3. (選用) 輸入環境範本的範本描述。

  7. (選用) 勾選加密設定區段中自訂加密設定的核取方塊 (進階),以提供您自己的加密金鑰。

  8. (選用) 在標籤區段中,選擇新增標籤,然後輸入索引鍵和值以建立客戶受管標籤。

  9. 選擇建立環境範本。

    您現在位於顯示新環境範本狀態和詳細資訊的新頁面。這些詳細資訊包括 AWS 和客戶受管標籤的清單。當您建立 AWS Proton 資源時, AWS Proton 會自動為您產生 AWS 受管標籤。如需詳細資訊,請參閱AWS Proton 資源和標記。

  10. 新環境範本狀態的狀態會以草稿狀態開始。您和具有proton:CreateEnvironment許可的其他人可以檢視和存取它。依照下一個步驟讓範本可供其他人使用。

  11. 在範本版本區段中,選擇您剛建立之範本次要版本左側的選項按鈕 (1.0)。或者,您可以在資訊提醒中選擇發佈,並略過下一個步驟。

  12. 在範本版本區段中,選擇發佈。

  13. 範本狀態會變更為已發佈。由於它是範本的最新版本,因此它是建議版本。

  14. 在導覽窗格中,選取環境範本以檢視環境範本和詳細資訊的清單。

使用 主控台註冊環境範本的新主要和次要版本。

如需詳細資訊,請參閱版本化範本。

  1. 在 AWS Proton 主控台中,選擇環境範本。

  2. 在環境範本清單中,選擇您要為其建立主要或次要版本的環境範本名稱。

  3. 在環境範本詳細資訊檢視中,選擇範本版本區段中的建立新版本。

  4. 在建立新的環境範本版本頁面的範本套件來源區段中,選擇兩個可用範本套件來源選項之一。

    • 使用其中一個範例範本套件。

    • 使用您自己的範本套件。

  5. 提供所選範本套件的路徑。

    • 如果您選擇使用其中一個範例範本套件,請在範例範本套件區段中,選取範例範本套件。

    • 如果您選擇使用自己的範本套件,請在 S3 套件位置區段中選擇範本套件的路徑。

  6. 在範本詳細資訊區段中。

    1. (選用) 輸入範本顯示名稱。

    2. (選用) 輸入服務範本的範本描述。

  7. 在範本詳細資訊區段中,選擇下列其中一個選項。

    • 若要建立次要版本,請保持核取方塊 核取以建立新的主要版本空白。

    • 若要建立主要版本,請勾選核取方塊 核取以建立新的主要版本。

  8. 繼續執行主控台步驟,以建立新的次要或主要版本,然後選擇建立新版本。

AWS CLI
使用 CLI 註冊和發佈新的環境範本,如下列步驟所示。
  1. 透過指定區域、名稱、顯示名稱 (選用) 和描述 (選用) 來建立標準 OR 客戶受管環境範本。

    1. 建立標準環境範本。

      執行以下命令:

      $ aws proton create-environment-template \ --name "simple-env" \ --display-name "Fargate" \ --description "VPC with public access"

      回應:

      { "environmentTemplate": { "arn": "arn:aws:proton:region-id:123456789012:environment-template/simple-env", "createdAt": "2020-11-11T23:02:45.336000+00:00", "description": "VPC with public access", "displayName": "VPC", "lastModifiedAt": "2020-11-11T23:02:45.336000+00:00", "name": "simple-env" } }
    2. 透過新增值為 的 provisioning 參數來建立客戶受管環境範本CUSTOMER_MANAGED。

      執行以下命令:

      $ aws proton create-environment-template \ --name "simple-env" \ --display-name "Fargate" \ --description "VPC with public access" \ --provisioning "CUSTOMER_MANAGED"

      回應:

      { "environmentTemplate": { "arn": "arn:aws:proton:region-id:123456789012:environment-template/simple-env", "createdAt": "2020-11-11T23:02:45.336000+00:00", "description": "VPC with public access", "displayName": "VPC", "lastModifiedAt": "2020-11-11T23:02:45.336000+00:00", "name": "simple-env", "provisioning": "CUSTOMER_MANAGED" } }
  2. 建立環境範本主要版本 1 的次要版本 0

    對於標準和客戶受管環境範本,此步驟和其餘步驟都相同。

    包含範本名稱、主要版本,以及包含您環境範本套件之儲存貯體的 S3 儲存貯體名稱和金鑰。

    執行以下命令:

    $ aws proton create-environment-template-version \ --template-name "simple-env" \ --description "Version 1" \ --source s3="{bucket=your_s3_bucket, key=your_s3_key}"

    回應:

    { "environmentTemplateVersion": { "arn": "arn:aws:proton:region-id:123456789012:environment-template/simple-env:1.0", "createdAt": "2020-11-11T23:02:47.763000+00:00", "description": "Version 1", "lastModifiedAt": "2020-11-11T23:02:47.763000+00:00", "majorVersion": "1", "minorVersion": "0", "status": "REGISTRATION_IN_PROGRESS", "templateName": "simple-env" } }
  3. 使用 get 命令來檢查註冊狀態。

    執行以下命令:

    $ aws proton get-environment-template-version \ --template-name "simple-env" \ --major-version "1" \ --minor-version "0"

    回應:

    { "environment": { "arn": "arn:aws:proton:region-id:123456789012:environment-template/simple-env:1.0", "createdAt": "2020-11-11T23:02:47.763000+00:00", "description": "Version 1", "lastModifiedAt": "2020-11-11T23:02:47.763000+00:00", "majorVersion": "1", "minorVersion": "0", "recommendedMinorVersion": "0", "schema": "schema:\n format:\n openapi: \"3.0.0\"\n environment_input_type: \"MyEnvironmentInputType\"\n types:\n MyEnvironmentInputType:\n type: object\n description: \"Input properties for my environment\"\n properties:\n my_sample_input:\n type: string\n description: \"This is a sample input\"\n default: \"hello world\"\n my_other_sample_input:\n type: string\n description: \"Another sample input\"\n required:\n - my_other_sample_input\n", "status": "DRAFT", "statusMessage": "", "templateName": "simple-env" } }
  4. 透過提供範本名稱和主要和次要版本,發佈環境範本主要版本 1 的次要版本 0。此版本是 Recommended版本。

    執行以下命令:

    $ aws proton update-environment-template-version \ --template-name "simple-env" \ --major-version "1" \ --minor-version "0" \ --status "PUBLISHED"

    回應:

    { "environmentTemplateVersion": { "arn": "arn:aws:proton:region-id:123456789012:environment-template/simple-env:1.0", "createdAt": "2020-11-11T23:02:47.763000+00:00", "description": "Version 1", "lastModifiedAt": "2020-11-11T23:02:54.610000+00:00", "majorVersion": "1", "minorVersion": "0", "recommendedMinorVersion": "0", "schema": "schema:\n format:\n openapi: \"3.0.0\"\n environment_input_type: \"MyEnvironmentInputType\"\n types:\n MyEnvironmentInputType:\n type: object\n description: \"Input properties for my environment\"\n properties:\n my_sample_input:\n type: string\n description: \"This is a sample input\"\n default: \"hello world\"\n my_other_sample_input:\n type: string\n description: \"Another sample input\"\n required:\n - my_other_sample_input\n", "status": "PUBLISHED", "statusMessage": "", "templateName": "simple-env" } }

使用 建立新範本後 AWS CLI,您可以檢視 AWS 和客戶受管標籤的清單。 AWS Proton 會自動為您產生 AWS 受管標籤。您也可以使用 修改和建立客戶受管標籤 AWS CLI。如需詳細資訊,請參閱AWS Proton 資源和標記。

執行以下命令:

$ aws proton list-tags-for-resource \ --resource-arn "arn:aws:proton:region-id:123456789012:environment-template/simple-env"

註冊和發佈服務範本

當您建立服務範本版本時,您可以指定相容的環境範本清單。如此一來,當開發人員選取服務範本時,他們可以選擇將服務部署到哪個環境。

從服務範本建立服務或發佈服務範本之前,請確認已從列出的相容環境範本部署環境。

如果服務部署到從移除的相容環境範本建置的環境,則無法將服務更新為新的主要版本。

若要新增或移除服務範本版本的相容環境範本,您可以建立新的主要版本。

您可以使用 主控台或 AWS CLI 來註冊和發佈服務範本。

AWS 管理主控台
使用 主控台來註冊和發佈新的服務範本。
  1. 在 AWS Proton 主控台中,選擇服務範本。

  2. 選擇建立服務範本。

  3. 在建立服務範本頁面的範本套件來源區段中,選擇其中一個可用的範本選項。

    • 使用您自己的範本套件。

    • 從 Git 同步範本。

  4. 提供範本套件的路徑。
    1. 如果您從 Git 選擇同步範本,請在來源碼儲存庫區段中:

      1. 選取範本同步組態的儲存庫。

      2. 輸入要從中同步的儲存庫分支名稱。

      3. (選用) 輸入目錄名稱以限制範本套件的搜尋。

    2. 否則,在 S3 套件位置區段中,提供範本套件的路徑。

  5. 在範本詳細資訊區段中。

    1. 輸入範本名稱。

    2. (選用) 輸入範本顯示名稱。

    3. (選用) 輸入服務範本的範本描述。

  6. 在相容環境範本區段中,從相容環境範本清單中選擇。

  7. (選用) 在加密設定區段中,選擇自訂加密設定 (進階) 以提供您自己的加密金鑰。

  8. (選用) 在管道區段中:

    如果您未在服務範本中包含服務管道定義,請取消勾選頁面底部的管道 - 選用核取方塊。建立服務範本後,您無法變更此設定。如需詳細資訊,請參閱範本套件。

  9. (選用) 在支援的元件來源區段中,針對元件來源選擇直接定義,以啟用直接定義的元件連接至您的服務執行個體。

  10. (選用) 在標籤區段中,選擇新增標籤,然後輸入索引鍵和值以建立客戶受管標籤。

  11. 選擇建立服務範本。

    您現在位於顯示新服務範本狀態和詳細資訊的新頁面。這些詳細資訊包括 AWS 和客戶受管標籤的清單。當您建立 AWS Proton 資源時, AWS Proton 會自動為您產生 AWS 受管標籤。如需詳細資訊,請參閱AWS Proton 資源和標記。

  12. 新服務範本狀態的狀態會以草稿狀態開始。您和具有proton:CreateService許可的其他人可以檢視和存取它。依照下一個步驟,讓範本可供其他人使用。

  13. 在範本版本區段中,選擇您剛建立之範本次要版本左側的選項按鈕 (1.0)。或者,您可以在資訊提醒中選擇發佈,並略過下一個步驟。

  14. 在範本版本區段中,選擇發佈。

  15. 範本狀態會變更為已發佈。由於它是範本的最新版本,因此它是建議版本。

  16. 在導覽窗格中,選取服務範本以檢視您的服務範本和詳細資訊清單。

使用 主控台註冊服務範本的新主要和次要版本。

如需詳細資訊,請參閱版本化範本。

  1. 在 AWS Proton 主控台中,選擇服務範本。

  2. 在服務範本清單中,選擇您要為其建立主要或次要版本的服務範本名稱。

  3. 在服務範本詳細資訊檢視中,選擇範本版本區段中的建立新版本。

  4. 在建立新的服務範本版本頁面的套件來源區段中,選取使用您自己的範本套件。

  5. 在 S3 套件位置區段中,選擇範本套件的路徑。

  6. 在範本詳細資訊區段中。

    1. (選用) 輸入範本顯示名稱。

    2. (選用) 輸入服務範本的範本描述。

  7. 在範本詳細資訊區段中,選擇下列其中一個選項。

    • 若要建立次要版本,請保持核取方塊 核取以建立新的主要版本空白。

    • 若要建立主要版本,請勾選核取方塊 核取以建立新的主要版本。

  8. 繼續執行主控台步驟,以建立新的次要或主要版本,然後選擇建立新版本。

AWS CLI

若要建立在沒有服務管道的情況下部署服務的服務範本,請將 參數和值新增至--pipeline-provisioning "CUSTOMER_MANAGED"create-service-template命令。如範本套件建立和中所述設定您的範本套件服務範本套件的結構描述需求。

注意

建立服務範本pipelineProvisioning後,您無法修改 。

  1. 使用 CLI 註冊和發佈有或沒有服務管道的新服務範本,如下列步驟所示。
    1. 使用 CLI 建立具有服務管道的服務範本。

      指定名稱、顯示名稱 (選用) 和描述 (選用)。

      執行以下命令:

      $ aws proton create-service-template \ --name "fargate-service" \ --display-name "Fargate" \ --description "Fargate-based Service"

      回應:

      { "serviceTemplate": { "arn": "arn:aws:proton:region-id:123456789012:service-template/fargate-service", "createdAt": "2020-11-11T23:02:55.551000+00:00", "description": "Fargate-based Service", "displayName": "Fargate", "lastModifiedAt": "2020-11-11T23:02:55.551000+00:00", "name": "fargate-service" } }
    2. 建立不含服務管道的服務範本。

      新增 --pipeline-provisioning。

      執行以下命令:

      $ aws proton create-service-template \ --name "fargate-service" \ --display-name "Fargate" \ --description "Fargate-based Service" \ --pipeline-provisioning "CUSTOMER_MANAGED"

      回應:

      { "serviceTemplate": { "arn": "arn:aws:proton:region-id:123456789012:service-template/fargate-service", "createdAt": "2020-11-11T23:02:55.551000+00:00", "description": "Fargate-based Service", "displayName": "Fargate", "lastModifiedAt": "2020-11-11T23:02:55.551000+00:00", "name": "fargate-service", "pipelineProvisioning": "CUSTOMER_MANAGED" } }
  2. 建立服務範本主要版本 1 的次要版本 0。

    包含範本名稱、相容的環境範本、主要版本,以及包含服務範本套件之儲存貯體的 S3 儲存貯體名稱和金鑰。

    執行以下命令:

    $ aws proton create-service-template-version \ --template-name "fargate-service" \ --description "Version 1" \ --source s3="{bucket=your_s3_bucket, key=your_s3_key}" \ --compatible-environment-templates '[{"templateName":"simple-env","majorVersion":"1"}]'

    回應:

    { "serviceTemplateMinorVersion": { "arn": "arn:aws:proton:region-id:123456789012:service-template/fargate-service:1.0", "compatibleEnvironmentTemplates": [ { "majorVersion": "1", "templateName": "simple-env" } ], "createdAt": "2020-11-11T23:02:57.912000+00:00", "description": "Version 1", "lastModifiedAt": "2020-11-11T23:02:57.912000+00:00", "majorVersion": "1", "minorVersion": "0", "status": "REGISTRATION_IN_PROGRESS", "templateName": "fargate-service" } }

  3. 使用 get 命令來檢查註冊狀態。

    執行以下命令:

    $ aws proton get-service-template-version \ --template-name "fargate-service" \ --major-version "1" \ --minor-version "0"

    回應:

    { "serviceTemplateMinorVersion": { "arn": "arn:aws:proton:us-east-1:123456789012:service-template/fargate-service:1.0", "compatibleEnvironmentTemplates": [ { "majorVersion": "1", "templateName": "simple-env" } ], "createdAt": "2020-11-11T23:02:57.912000+00:00", "description": "Version 1", "lastModifiedAt": "2020-11-11T23:02:57.912000+00:00", "majorVersion": "1", "minorVersion": "0", "schema": "schema:\n format:\n openapi: \"3.0.0\"\n pipeline_input_type: \"MyPipelineInputType\"\n service_input_type: \"MyServiceInstanceInputType\"\n\n types:\n MyPipelineInputType:\n type: object\n description: \"Pipeline input properties\"\n required:\n - my_sample_pipeline_required_input\n properties:\n my_sample_pipeline_optional_input:\n type: string\n description: \"This is a sample input\"\n default: \"hello world\"\n my_sample_pipeline_required_input:\n type: string\n description: \"Another sample input\"\n\n MyServiceInstanceInputType:\n type: object\n description: \"Service instance input properties\"\n required:\n - my_sample_service_instance_required_input\n properties:\n my_sample_service_instance_optional_input:\n type: string\n description: \"This is a sample input\"\n default: \"hello world\"\n my_sample_service_instance_required_input:\n type: string\n description: \"Another sample input\"", "status": "DRAFT", "statusMessage": "", "templateName": "fargate-service" } }
  4. 使用更新命令將狀態變更為 來發佈服務範本"PUBLISHED"。

    執行以下命令:

    $ aws proton update-service-template-version \ --template-name "fargate-service" \ --description "Version 1" \ --major-version "1" \ --minor-version "0" \ --status "PUBLISHED"

    回應:

    { "serviceTemplateVersion": { "arn": "arn:aws:proton:region-id:123456789012:service-template/fargate-service:1.0", "compatibleEnvironmentTemplates": [ { "majorVersion": "1", "templateName": "simple-env" } ], "createdAt": "2020-11-11T23:02:57.912000+00:00", "description": "Version 1", "lastModifiedAt": "2020-11-11T23:02:57.912000+00:00", "majorVersion": "1", "minorVersion": "0", "recommendedMinorVersion": "0", "schema": "schema:\n format:\n openapi: \"3.0.0\"\n pipeline_input_type: \"MyPipelineInputType\"\n service_input_type: \"MyServiceInstanceInputType\"\n\n types:\n MyPipelineInputType:\n type: object\n description: \"Pipeline input properties\"\n required:\n - my_sample_pipeline_required_input\n properties:\n my_sample_pipeline_optional_input:\n type: string\n description: \"This is a sample input\"\n default: \"hello pipeline\"\n my_sample_pipeline_required_input:\n type: string\n description: \"Another sample input\"\n\n MyServiceInstanceInputType:\n type: object\n description: \"Service instance input properties\"\n required:\n - my_sample_service_instance_required_input\n properties:\n my_sample_service_instance_optional_input:\n type: string\n description: \"This is a sample input\"\n default: \"hello world\"\n my_sample_service_instance_required_input:\n type: string\n description: \"Another sample input\"\n", "status": "PUBLISHED", "statusMessage": "", "templateName": "fargate-service" } }
  5. 使用 get 命令擷取服務範本詳細資訊,檢查 AWS Proton 是否已發佈 1.0 版。

    執行以下命令:

    $ aws proton get-service-template-version \ --template-name "fargate-service" \ --major-version "1" \ --minor-version "0"

    回應:

    { "serviceTemplateMinorVersion": { "arn": "arn:aws:proton:us-east-1:123456789012:service-template/fargate-service:1.0", "compatibleEnvironmentTemplates": [ { "majorVersion": "1", "templateName": "simple-env" } ], "createdAt": "2020-11-11T23:02:57.912000+00:00", "description": "Version 1", "lastModifiedAt": "2020-11-11T23:03:04.767000+00:00", "majorVersion": "1", "minorVersion": "0", "schema": "schema:\n format:\n openapi: \"3.0.0\"\n pipeline_input_type: \"MyPipelineInputType\"\n service_input_type: \"MyServiceInstanceInputType\"\n\n types:\n MyPipelineInputType:\n type: object\n description: \"Pipeline input properties\"\n required:\n - my_sample_pipeline_required_input\n properties:\n my_sample_pipeline_optional_input:\n type: string\n description: \"This is a sample input\"\n default: \"hello world\"\n my_sample_pipeline_required_input:\n type: string\n description: \"Another sample input\"\n\n MyServiceInstanceInputType:\n type: object\n description: \"Service instance input properties\"\n required:\n - my_sample_service_instance_required_input\n properties:\n my_sample_service_instance_optional_input:\n type: string\n description: \"This is a sample input\"\n default: \"hello world\"\n my_sample_service_instance_required_input:\n type: string\n description: \"Another sample input\"", "status": "PUBLISHED", "statusMessage": "", "templateName": "fargate-service" } }