新增和刪除服務執行個體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"
}
]
}