使用已編輯的方式新增和刪除服務執行個體spec
如下列所示AWS CLI範例指令和回應。
當您使用 CLI 時,您的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
新增。
規格格:
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"
您可以使用"${Proton::CURRENT_VAL}"
以指示要保留原始參數值spec
,如果值存在於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-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"
}
]
}