使用编辑的 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"
以下示例 CLI list-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"
}
]
}