編輯服務 - AWS Proton

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

編輯服務

您可以對AWS Proton服務進行以下編輯。

  • 編輯服務描述。

  • 透過新增和移除服務執行個體來編輯服務。

編輯服務說明

您可以使用主控台或AWS CLI來編輯服務描述。

AWS Management Console

使用主控台編輯服務,如下列步驟所述。

在服務列表中。
  1. AWS Proton主控台中,選擇 [服務]。

  2. 在服務清單中,請選擇您要更新的服務左側的選項按鈕。

  3. 選擇 Edit (編輯)。

  4. 在 [設定服務] 頁面中,填寫表單,然後選擇 [下一步]。

  5. 在 [設定自訂設定] 頁面中,選擇 [下一步]。

  6. 檢閱您的編輯並選擇 [儲存變更]。

在服務詳細資訊頁面中。
  1. AWS Proton主控台中,選擇 [服務]。

  2. 在服務清單中,請選擇您要編輯的服務名稱。

  3. 在服務詳細資訊頁面中,選擇編輯

  4. 在 [設定服務] 頁面中,填寫表單,然後選擇 [下一步]。

  5. 在 [設定自訂設定] 頁面中,填寫表單,然後選擇 [下一步]。

  6. 檢閱您的編輯並選擇 [儲存變更]。

AWS CLI

編輯描述,如下列 CLI 範例命令和回應所示。

命令:

$ aws proton update-service \ --name "MySimpleService" \ --description "Edit by updating description"

回應:

{ "service": { "arn": "arn:aws:proton:region-id:123456789012:service/MySimpleService", "branchName": "main", "createdAt": "2021-03-12T22:39:42.318000+00:00", "description": "Edit by updating description", "lastModifiedAt": "2021-03-12T22:44:21.975000+00:00", "name": "MySimpleService", "repositoryConnectionArn": "arn:aws:codestar-connections:region-id:123456789012:connection/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "repositoryId": "my-repository/myorg-myapp", "status": "ACTIVE", "templateName": "fargate-service" } }

編輯服務以新增或移除服務執行個體

對於AWS Proton服務,您可以提交已編輯的規格,以新增或刪除服務執行個體。若要成功請求必須滿足下列條件:

  • 當您提交編輯請求時,您的服務和管道尚未被編輯或刪除。

  • 您編輯的規格不包括修改服務管道或對要刪除的現有服務實例進行編輯的編輯。

  • 您編輯的規格不會移除任何具有附加元件的現有服務執行個體。若要刪除這類服務執行個體,您應該先更新元件,以將其與其服務執行個體中斷連結。如需元件的詳細資訊,請參閱AWS Proton 元件

刪除失敗的執行個體是DELETE_FAILED狀態中的服務執行個體。當您要求編輯服務時,會AWS Proton嘗試移除刪除失敗的執行個體,做為編輯程序的一部分。如果您的任何服務執行個體無法刪除,則可能仍有與執行個體相關聯的資源,即使在主控台或中看不到這些資源AWS CLI。檢查刪除失敗的執行個體基礎結構資源並清理它們,AWS Proton以便為您移除它們。

如需服務的服務執行個體配額,請參閱AWS Proton 配額。建立服務之後,您也必須維護至少 1 個服務執行個體。在更新程序期間,AWS Proton會計算現有服務執行個體以及要新增或移除的執行個體。刪除失敗的執行個體包含在此計數中,您必須在編輯時考慮這些執行個體spec

使用主控台或新AWS CLI增或移除服務執行個體

AWS Management Console

使用主控台編輯服務以新增或移除服務執行個體。

AWS Proton主控台

  1. 在導覽窗格中,選擇 Services (服務)。

  2. 選取您要編輯的服務。

  3. 選擇 Edit (編輯)。

  4. (選擇性) 在 [設定服務] 頁面上,編輯服務名稱或說明,然後選擇 [下一步]。

  5. 在 [設定自訂設定] 頁面上,選擇 [刪除] 以刪除服務執行個體,然後選擇 [新增執行個體] 以新增服務執行個體並填寫表單。

  6. 選擇 Next (下一步)。

  7. 檢閱更新,然後選擇 [儲存變更]。

  8. 強制回應會要求您驗證服務執行個體的刪除。按照說明進行操作,然後選擇是,刪除

  9. 在服務詳細資訊頁面上,檢視服務的狀態詳細資料。

AWS CLI

新增和刪除服務執行個體spec,AWS CLI如下列範例指令和回應所示。

使用 CLI 時,spec必須除要刪除的服務執行個體,並包含要新增的服務執行個體和尚未標示為要刪除的現有服務執行個體。

下列清單顯示編輯spec前的範例,以及規格所部署的服務執行個體清單。此規格在前面的範例中用於編輯服務描述。

Spec (格)

proton: ServiceSpec pipeline: my_sample_pipeline_optional_input: "abc" my_sample_pipeline_required_input: "123" instances: - name: "my-instance" environment: "simple-env" spec: my_sample_service_instance_optional_input: "def" my_sample_service_instance_required_input: "456" - name: "my-other-instance" environment: "simple-env" spec: my_sample_service_instance_required_input: "789"

下列範例 CLIlist-service-instances 命令和回應會顯示新增或刪除服務執行個體之前的作用中執行個體。

命令:

$ aws proton list-service-instances \ --service-name "MySimpleService"

回應:

{ "serviceInstances": [ { "arn": "arn:aws:proton:region-id:123456789012:service/MySimpleService/service-instance/my-other-instance", "createdAt": "2021-03-12T22:39:42.318000+00:00", "deploymentStatus": "SUCCEEDED", "environmentName": "simple-env", "lastDeploymentAttemptedAt": "2021-03-12T22:39:43.109000+00:00", "lastDeploymentSucceededAt": "2021-03-12T22:39:43.109000+00:00", "name": "my-other-instance", "serviceName": "example-svc", "templateMajorVersion": "1", "templateMinorVersion": "0", "templateName": "fargate-service" }, { "arn": "arn:aws:proton:region-id:123456789012:service/MySimpleService/service-instance/my-instance", "createdAt": "2021-03-12T22:39:42.318000+00:00", "deploymentStatus": "SUCCEEDED", "environmentName": "simple-env", "lastDeploymentAttemptedAt": "2021-03-12T22:39:43.160000+00:00", "lastDeploymentSucceededAt": "2021-03-12T22:39:43.160000+00:00", "name": "my-instance", "serviceName": "example-svc", "serviceTemplateArn": "arn:aws:proton:region-id:123456789012:service-template/fargate-service", "templateMajorVersion": "1", "templateMinorVersion": "0", "templateName": "fargate-service" } ] }

下列清單顯示spec用於刪除和新增執行個體的已編輯範例。已移除名為my-instance的現有執行個體,並新增名為的新執行yet-another-instance個體。

Spec (格)

proton: ServiceSpec pipeline: my_sample_pipeline_optional_input: "abc" my_sample_pipeline_required_input: "123" instances: - name: "my-other-instance" environment: "simple-env" spec: my_sample_service_instance_required_input: "789" - name: "yet-another-instance" environment: "simple-env" spec: my_sample_service_instance_required_input: "789"

如果值存在於中spec,您可以使用"${Proton::CURRENT_VAL}"指示要保留原始參數值的參數值spec。用get-service於檢視服務spec的原始檔案,如中所述檢視服務資料

下列清單顯示如何用"${Proton::CURRENT_VAL}"來確保您spec包含要保留現有服務執行個體的參數值變更。

Spec (格)

proton: ServiceSpec pipeline: my_sample_pipeline_optional_input: "${Proton::CURRENT_VAL}" my_sample_pipeline_required_input: "${Proton::CURRENT_VAL}" instances: - name: "my-other-instance" environment: "simple-env" spec: my_sample_service_instance_required_input: "${Proton::CURRENT_VAL}" - name: "yet-another-instance" environment: "simple-env" spec: my_sample_service_instance_required_input: "789"

下一個清單顯示 CLI 命令和編輯服務的回應。

命令:

$ aws proton update-service --name "MySimpleService" \ --description "Edit by adding and deleting a service instance" \ --spec "file://spec.yaml"

回應:

{ "service": { "arn": "arn:aws:proton:region-id:123456789012:service/MySimpleService", "branchName": "main", "createdAt": "2021-03-12T22:39:42.318000+00:00", "description": "Edit by adding and deleting a service instance", "lastModifiedAt": "2021-03-12T22:55:48.169000+00:00", "name": "MySimpleService", "repositoryConnectionArn": "arn:aws:codestar-connections:region-id:123456789012:connection/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "repositoryId": "my-repository/myorg-myapp", "status": "UPDATE_IN_PROGRESS", "templateName": "fargate-service" } }

下列list-service-instances指令和回應會確認已移除名為my-instance的現有執行個體,並新增名為的新執行yet-another-instance個體。

命令:

$ aws proton list-service-instances \ --service-name "MySimpleService"

回應:

{ "serviceInstances": [ { "arn": "arn:aws:proton:region-id:123456789012:service/MySimpleService/service-instance/yet-another-instance", "createdAt": "2021-03-12T22:39:42.318000+00:00", "deploymentStatus": "SUCCEEDED", "environmentName": "simple-env", "lastDeploymentAttemptedAt": "2021-03-12T22:56:01.565000+00:00", "lastDeploymentSucceededAt": "2021-03-12T22:56:01.565000+00:00", "name": "yet-another-instance", "serviceName": "MySimpleService", "templateMajorVersion": "1", "templateMinorVersion": "0", "templateName": "fargate-service" }, { "arn": "arn:aws:proton:region-id:123456789012:service/MySimpleService/service-instance/my-other-instance", "createdAt": "2021-03-12T22:39:42.318000+00:00", "deploymentStatus": "SUCCEEDED", "environmentName": "simple-env", "lastDeploymentAttemptedAt": "2021-03-12T22:39:43.109000+00:00", "lastDeploymentSucceededAt": "2021-03-12T22:39:43.109000+00:00", "name": "my-other-instance", "serviceName": "MySimpleService", "templateMajorVersion": "1", "templateMinorVersion": "0", "templateName": "fargate-service" } ] }

新增或移除服務執行個體時會如何

在您提交服務編輯以刪除及新增服務執行個體之後,請執AWS Proton行下列動作。

  • 將服務設定為UPDATE_IN_PROGRESS

  • 如果服務具有管線,請將其狀態設定為IN_PROGRESS並封鎖管線動作。

  • 設定要刪除的任何服務執行個體DELETE_IN_PROGRESS

  • 封鎖服務動作。

  • 封鎖標示為要刪除的服務執行個體上的動作。

  • 建立新的服務執行個體。

  • 刪除您列出要刪除的例證。

  • 嘗試移除刪除失敗的執行個體。

  • 新增和刪除完成後,重新佈建服務管線 (如果有的話)、將您的服務設定為,ACTIVE並啟用服務和管線動作。

AWS Proton嘗試重新調解失敗模式,如下所示。

  • 如果一或多個服務執行個體無法建立,請AWS Proton嘗試取消佈建所有新建立的服務執行個體,並將其還原spec為先前的狀態。它不會刪除任何服務實例,也不會以任何方式修改管道。

  • 如果一或多個服務執行個體無法刪除,請AWS Proton重新佈建管線而不刪除的執行個體。會spec更新以包含新增的執行個體,並排除標記為要刪除的執行個體。

  • 如果管線佈建失敗,則嘗試復原,且服務和管線都會反映失敗的更新狀態。

標記和服務編輯

當您將服務執行個體新增為服務編輯的一部分時,AWS受管理的標籤會傳播到新執行個體和佈建的資源,並自動建立。如果您建立新標籤,這些標籤只會套用至新的例項。現有服務客戶受管標籤也會傳播至新的執行個體。如需詳細資訊,請參閱 AWS Proton資源和標記