本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
更新服務管道
了解如何更新 AWS Proton 服務管道並取消更新。
服務管道屬於服務。您只能在服務建立和刪除動作的情況下建立或刪除管道。
更新服務管道有四種模式,如下列清單所述。使用 時 AWS CLI, deployment-type
欄位會定義 模式。當您使用 主控台時,這些模式會映射到編輯管道和更新到建議的版本。
-
NONE
在此模式中,不會發生部署。只會更新請求的中繼資料參數。
-
CURRENT_VERSION
在此模式中,會使用您提供的新規格來部署和更新服務管道。只會更新請求的參數。使用此 時,請勿包含次要或主要版本參數
deployment-type
。 -
MINOR_VERSION
在此模式中,服務管道會依預設使用中目前主要版本的已發佈建議 (最新) 次要版本進行部署和更新。您也可以指定目前使用中主要版本的不同次要版本。
-
MAJOR_VERSION
在此模式中,服務管道預設會部署並更新目前範本的已發佈、建議 (最新) 主要和次要版本。您也可以指定高於使用中主要版本的不同主要版本,以及次要版本 (選用)。
如果 deploymentStatus
是 .IN_PROGRESS
AWS Proton attempts 以取消部署,您可以嘗試取消服務管道更新部署。不保證成功取消。
當您取消更新部署時, 會 AWS Proton 嘗試取消部署,如下列步驟所列。
-
將部署狀態設定為
CANCELLING
。 -
停止進行中的部署,並在 時刪除部署建立的任何新資源
IN_PROGRESS
。 -
將部署狀態設定為
CANCELLED
。 -
將資源的狀態還原為部署開始之前的狀態。
如需取消服務管道部署的詳細資訊,請參閱 AWS Proton API 參考中的 CancelServicePipelineDeployment。
使用 主控台或 AWS CLI 進行更新或取消更新部署。
- AWS Management Console
-
使用主控台更新服務管道,如下列步驟所述。
-
在 AWS Proton 主控台
中,選擇 服務。 -
在服務清單中,選擇您要更新管道的服務名稱。
-
服務詳細資訊頁面上有兩個索引標籤:概觀和管道。選擇管道。
-
如果您想要更新規格,請選擇編輯管道並填寫每個表單,然後選擇下一步,直到您完成最終表單,然後選擇更新管道。
如果您想要更新至新版本,且有資訊圖示指出管道範本有新版本可用,請選擇新範本版本的名稱。
-
選擇更新至建議的版本。
-
填寫每個表單,然後選擇下一步,直到您完成最終表單,然後選擇更新。
-
-
- AWS CLI
-
將服務管道更新為新的次要版本,如下列 CLI 範例命令和回應所示。
當您使用修改過的 更新服務管道時
spec
,如果值存在於 中spec
,您可以使用"${Proton::CURRENT_VAL}"
來指出要從原始 保留的參數值spec
。get-service
使用 檢視服務管道spec
的原始 ,如 中所述檢視服務資料。下列範例顯示如何在
"${Proton::CURRENT_VAL}"
中使用spec
。規格:
proton: ServiceSpec pipeline: my_sample_pipeline_optional_input: "${Proton::CURRENT_VAL}" my_sample_pipeline_required_input: "${Proton::CURRENT_VAL}" instances: - name: "my-instance" environment: "simple-env" spec: my_sample_service_instance_optional_input: "${Proton::CURRENT_VAL}" my_sample_service_instance_required_input: "${Proton::CURRENT_VAL}" - name: "my-other-instance" environment: "simple-env" spec: my_sample_service_instance_required_input: "789"
命令:更新
$
aws proton update-service-pipeline \ --service-name "
simple-svc
" \ --spec "file://service-spec.yaml
" \ --template-major-version "1
" \ --template-minor-version "1
" \ --deployment-type "MINOR_VERSION
"回應:
{ "pipeline": { "arn": "arn:aws:proton:region-id:123456789012:service/simple-svc/pipeline/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "createdAt": "2021-04-02T21:29:59.962000+00:00", "deploymentStatus": "IN_PROGRESS", "lastDeploymentAttemptedAt": "2021-04-02T21:39:28.991000+00:00", "lastDeploymentSucceededAt": "2021-04-02T21:29:59.962000+00:00", "spec": "proton: ServiceSpec\n\npipeline:\n my_sample_pipeline_optional_input: \"abc\"\n my_sample_pipeline_required_input: \"123\"\n\ninstances:\n - name: \"my-instance\"\n environment: \"MySimpleEnv\"\n spec:\n my_sample_service_instance_optional_input: \"def\"\n my_sample_service_instance_required_input: \"456\"\n - name: \"my-other-instance\"\n environment: \"MySimpleEnv\"\n spec:\n my_sample_service_instance_required_input: \"789\"\n", "templateMajorVersion": "1", "templateMinorVersion": "0", "templateName": "svc-simple" } }
命令:取得並確認狀態
$
aws proton get-service \ --name "
simple-svc
"回應:
{ "service": { "arn": "arn:aws:proton:region-id:123456789012:service/simple-svc", "branchName": "main", "createdAt": "2021-04-02T21:29:59.962000+00:00", "lastModifiedAt": "2021-04-02T21:30:54.364000+00:00", "name": "simple-svc", "pipeline": { "arn": "arn:aws:proton:region-id:123456789012:service/simple-svc/pipeline", "createdAt": "2021-04-02T21:29:59.962000+00:00", "deploymentStatus": "SUCCEEDED", "lastDeploymentAttemptedAt": "2021-04-02T21:39:28.991000+00:00", "lastDeploymentSucceededAt": "2021-04-02T21:39:28.991000+00:00", "spec": "proton: ServiceSpec\n\npipeline:\n my_sample_pipeline_optional_input: \"abc\"\n my_sample_pipeline_required_input: \"123\"\n\ninstances:\n - name: \"instance-one\"\n environment: \"simple-env\"\n spec:\n my_sample_service_instance_optional_input: \"def\"\n my_sample_service_instance_required_input: \"456\"\n - name: \"my-other-instance\"\n environment: \"simple-env\"\n spec:\n my_sample_service_instance_required_input: \"789\"\n", "templateMajorVersion": "1", "templateMinorVersion": "1", "templateName": "svc-simple" }, "repositoryConnectionArn": "arn:aws:codestar-connections:region-id:123456789012:connection/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "repositoryId": "repo-name/myorg-myapp", "spec": "proton: ServiceSpec\n\npipeline:\n my_sample_pipeline_optional_input: \"abc\"\n my_sample_pipeline_required_input: \"123\"\n\ninstances:\n - name: \"instance-one\"\n environment: \"simple-env\"\n spec:\n my_sample_service_instance_optional_input: \"def\"\n my_sample_service_instance_required_input: \"456\"\n - name: \"my-other-instance\"\n environment: \"simple-env\"\n spec:\n my_sample_service_instance_required_input: \"789\"\n", "status": "ACTIVE", "templateName": "svc-simple" } }
- AWS Management Console
-
使用主控台取消服務管道部署,如下列步驟所示。
-
在 AWS Proton 主控台
的導覽窗格中,選擇服務。 -
在服務清單中,選擇具有您要取消之部署更新管道的服務名稱。
-
在服務詳細資訊頁面中,選擇管道索引標籤。
-
如果您的更新部署狀態為進行中,請在服務管道詳細資訊頁面中選擇取消部署。
-
模態會要求您確認取消。選擇取消部署。
-
您的更新部署狀態設定為取消,然後取消以完成取消。
-
- AWS CLI
-
取消 IN_PROGRESS 服務管道部署更新至次要版本 2,如下列 CLI 範例命令和回應所示。
用於此範例的範本中包含等待條件,因此取消會在更新部署成功之前開始。
命令:取消
$
aws proton cancel-service-pipeline-deployment \ --service-name "
simple-svc
"回應:
{ "pipeline": { "arn": "arn:aws:proton:region-id:123456789012:service/simple-svc/pipeline", "createdAt": "2021-04-02T21:29:59.962000+00:00", "deploymentStatus": "CANCELLING", "lastDeploymentAttemptedAt": "2021-04-02T22:02:45.095000+00:00", "lastDeploymentSucceededAt": "2021-04-02T21:39:28.991000+00:00", "templateMajorVersion": "1", "templateMinorVersion": "1", "templateName": "svc-simple" } }
命令:取得並確認狀態
$
aws proton get-service \ --name "
simple-svc
"回應:
{ "service": { "arn": "arn:aws:proton:region-id:123456789012:service/simple-svc", "branchName": "main", "createdAt": "2021-04-02T21:29:59.962000+00:00", "lastModifiedAt": "2021-04-02T21:30:54.364000+00:00", "name": "simple-svc", "pipeline": { "arn": "arn:aws:proton:region-id:123456789012:service/simple-svc/pipeline", "createdAt": "2021-04-02T21:29:59.962000+00:00", "deploymentStatus": "CANCELLED", "deploymentStatusMessage": "User initiated cancellation.", "lastDeploymentAttemptedAt": "2021-04-02T22:02:45.095000+00:00", "lastDeploymentSucceededAt": "2021-04-02T21:39:28.991000+00:00", "spec": "proton: ServiceSpec\n\npipeline:\n my_sample_pipeline_optional_input: \"abc\"\n my_sample_pipeline_required_input: \"123\"\n\ninstances:\n - name: \"instance-one\"\n environment: \"simple-env\"\n spec:\n my_sample_service_instance_optional_input: \"def\"\n my_sample_service_instance_required_input: \"456\"\n - name: \"my-other-instance\"\n environment: \"simple-env\"\n spec:\n my_sample_service_instance_required_input: \"789\"\n", "templateMajorVersion": "1", "templateMinorVersion": "1", "templateName": "svc-simple" }, "repositoryConnectionArn": "arn:aws:codestar-connections:region-id:123456789012:connection/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "repositoryId": "repo-name/myorg-myapp", "spec": "proton: ServiceSpec\n\npipeline:\n my_sample_pipeline_optional_input: \"abc\"\n my_sample_pipeline_required_input: \"123\"\n\ninstances:\n - name: \"instance-one\"\n environment: \"simple-env\"\n spec:\n my_sample_service_instance_optional_input: \"def\"\n my_sample_service_instance_required_input: \"456\"\n - name: \"my-other-instance\"\n environment: \"simple-env\"\n spec:\n my_sample_service_instance_required_input: \"789\"\n", "status": "ACTIVE", "templateName": "svc-simple" } }