Skip to content

Commit b970bdd

Browse files
author
awstools
committed
feat(client-ecs): Add support to roll back an In_Progress ECS Service Deployment
1 parent 66fdd56 commit b970bdd

File tree

13 files changed

+563
-99
lines changed

13 files changed

+563
-99
lines changed

clients/client-ecs/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,14 @@ StartTask
567567

568568
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/ecs/command/StartTaskCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ecs/Interface/StartTaskCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ecs/Interface/StartTaskCommandOutput/)
569569

570+
</details>
571+
<details>
572+
<summary>
573+
StopServiceDeployment
574+
</summary>
575+
576+
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/ecs/command/StopServiceDeploymentCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ecs/Interface/StopServiceDeploymentCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ecs/Interface/StopServiceDeploymentCommandOutput/)
577+
570578
</details>
571579
<details>
572580
<summary>

clients/client-ecs/src/ECS.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ import {
210210
} from "./commands/RegisterTaskDefinitionCommand";
211211
import { RunTaskCommand, RunTaskCommandInput, RunTaskCommandOutput } from "./commands/RunTaskCommand";
212212
import { StartTaskCommand, StartTaskCommandInput, StartTaskCommandOutput } from "./commands/StartTaskCommand";
213+
import {
214+
StopServiceDeploymentCommand,
215+
StopServiceDeploymentCommandInput,
216+
StopServiceDeploymentCommandOutput,
217+
} from "./commands/StopServiceDeploymentCommand";
213218
import { StopTaskCommand, StopTaskCommandInput, StopTaskCommandOutput } from "./commands/StopTaskCommand";
214219
import {
215220
SubmitAttachmentStateChangesCommand,
@@ -324,6 +329,7 @@ const commands = {
324329
RegisterTaskDefinitionCommand,
325330
RunTaskCommand,
326331
StartTaskCommand,
332+
StopServiceDeploymentCommand,
327333
StopTaskCommand,
328334
SubmitAttachmentStateChangesCommand,
329335
SubmitContainerStateChangeCommand,
@@ -1018,6 +1024,23 @@ export interface ECS {
10181024
cb: (err: any, data?: StartTaskCommandOutput) => void
10191025
): void;
10201026

1027+
/**
1028+
* @see {@link StopServiceDeploymentCommand}
1029+
*/
1030+
stopServiceDeployment(
1031+
args: StopServiceDeploymentCommandInput,
1032+
options?: __HttpHandlerOptions
1033+
): Promise<StopServiceDeploymentCommandOutput>;
1034+
stopServiceDeployment(
1035+
args: StopServiceDeploymentCommandInput,
1036+
cb: (err: any, data?: StopServiceDeploymentCommandOutput) => void
1037+
): void;
1038+
stopServiceDeployment(
1039+
args: StopServiceDeploymentCommandInput,
1040+
options: __HttpHandlerOptions,
1041+
cb: (err: any, data?: StopServiceDeploymentCommandOutput) => void
1042+
): void;
1043+
10211044
/**
10221045
* @see {@link StopTaskCommand}
10231046
*/

clients/client-ecs/src/ECSClient.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ import {
166166
} from "./commands/RegisterTaskDefinitionCommand";
167167
import { RunTaskCommandInput, RunTaskCommandOutput } from "./commands/RunTaskCommand";
168168
import { StartTaskCommandInput, StartTaskCommandOutput } from "./commands/StartTaskCommand";
169+
import {
170+
StopServiceDeploymentCommandInput,
171+
StopServiceDeploymentCommandOutput,
172+
} from "./commands/StopServiceDeploymentCommand";
169173
import { StopTaskCommandInput, StopTaskCommandOutput } from "./commands/StopTaskCommand";
170174
import {
171175
SubmitAttachmentStateChangesCommandInput,
@@ -267,6 +271,7 @@ export type ServiceInputTypes =
267271
| RegisterTaskDefinitionCommandInput
268272
| RunTaskCommandInput
269273
| StartTaskCommandInput
274+
| StopServiceDeploymentCommandInput
270275
| StopTaskCommandInput
271276
| SubmitAttachmentStateChangesCommandInput
272277
| SubmitContainerStateChangeCommandInput
@@ -331,6 +336,7 @@ export type ServiceOutputTypes =
331336
| RegisterTaskDefinitionCommandOutput
332337
| RunTaskCommandOutput
333338
| StartTaskCommandOutput
339+
| StopServiceDeploymentCommandOutput
334340
| StopTaskCommandOutput
335341
| SubmitAttachmentStateChangesCommandOutput
336342
| SubmitContainerStateChangeCommandOutput

clients/client-ecs/src/commands/DescribeServiceDeploymentsCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export interface DescribeServiceDeploymentsCommandOutput extends DescribeService
6969
* // runningTaskCount: Number("int"),
7070
* // pendingTaskCount: Number("int"),
7171
* // },
72-
* // status: "PENDING" || "SUCCESSFUL" || "STOPPED" || "STOP_REQUESTED" || "IN_PROGRESS" || "ROLLBACK_IN_PROGRESS" || "ROLLBACK_SUCCESSFUL" || "ROLLBACK_FAILED",
72+
* // status: "PENDING" || "SUCCESSFUL" || "STOPPED" || "STOP_REQUESTED" || "IN_PROGRESS" || "ROLLBACK_REQUESTED" || "ROLLBACK_IN_PROGRESS" || "ROLLBACK_SUCCESSFUL" || "ROLLBACK_FAILED",
7373
* // statusReason: "STRING_VALUE",
7474
* // deploymentConfiguration: { // DeploymentConfiguration
7575
* // deploymentCircuitBreaker: { // DeploymentCircuitBreaker

clients/client-ecs/src/commands/ListServiceDeploymentsCommand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export interface ListServiceDeploymentsCommandOutput extends ListServiceDeployme
4444
* service: "STRING_VALUE", // required
4545
* cluster: "STRING_VALUE",
4646
* status: [ // ServiceDeploymentStatusList
47-
* "PENDING" || "SUCCESSFUL" || "STOPPED" || "STOP_REQUESTED" || "IN_PROGRESS" || "ROLLBACK_IN_PROGRESS" || "ROLLBACK_SUCCESSFUL" || "ROLLBACK_FAILED",
47+
* "PENDING" || "SUCCESSFUL" || "STOPPED" || "STOP_REQUESTED" || "IN_PROGRESS" || "ROLLBACK_REQUESTED" || "ROLLBACK_IN_PROGRESS" || "ROLLBACK_SUCCESSFUL" || "ROLLBACK_FAILED",
4848
* ],
4949
* createdAt: { // CreatedAt
5050
* before: new Date("TIMESTAMP"),
@@ -65,7 +65,7 @@ export interface ListServiceDeploymentsCommandOutput extends ListServiceDeployme
6565
* // createdAt: new Date("TIMESTAMP"),
6666
* // finishedAt: new Date("TIMESTAMP"),
6767
* // targetServiceRevisionArn: "STRING_VALUE",
68-
* // status: "PENDING" || "SUCCESSFUL" || "STOPPED" || "STOP_REQUESTED" || "IN_PROGRESS" || "ROLLBACK_IN_PROGRESS" || "ROLLBACK_SUCCESSFUL" || "ROLLBACK_FAILED",
68+
* // status: "PENDING" || "SUCCESSFUL" || "STOPPED" || "STOP_REQUESTED" || "IN_PROGRESS" || "ROLLBACK_REQUESTED" || "ROLLBACK_IN_PROGRESS" || "ROLLBACK_SUCCESSFUL" || "ROLLBACK_FAILED",
6969
* // statusReason: "STRING_VALUE",
7070
* // },
7171
* // ],
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
// smithy-typescript generated code
2+
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
3+
import { getSerdePlugin } from "@smithy/middleware-serde";
4+
import { Command as $Command } from "@smithy/smithy-client";
5+
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
6+
7+
import { ECSClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../ECSClient";
8+
import { commonParams } from "../endpoint/EndpointParameters";
9+
import { StopServiceDeploymentRequest, StopServiceDeploymentResponse } from "../models/models_0";
10+
import { de_StopServiceDeploymentCommand, se_StopServiceDeploymentCommand } from "../protocols/Aws_json1_1";
11+
12+
/**
13+
* @public
14+
*/
15+
export type { __MetadataBearer };
16+
export { $Command };
17+
/**
18+
* @public
19+
*
20+
* The input for {@link StopServiceDeploymentCommand}.
21+
*/
22+
export interface StopServiceDeploymentCommandInput extends StopServiceDeploymentRequest {}
23+
/**
24+
* @public
25+
*
26+
* The output of {@link StopServiceDeploymentCommand}.
27+
*/
28+
export interface StopServiceDeploymentCommandOutput extends StopServiceDeploymentResponse, __MetadataBearer {}
29+
30+
/**
31+
* <p>Stops an ongoing service deployment.</p>
32+
* <p>The following stop types are avaiable:</p>
33+
* <ul>
34+
* <li>
35+
* <p>ROLLBACK - This option rolls back the service deployment to the previous
36+
* service revision. </p>
37+
* <p>You can use this option even if you didn't configure the service deployment
38+
* for the rollback option. </p>
39+
* </li>
40+
* </ul>
41+
* <p>For more information, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/stop-service-deployment.html">Stopping Amazon ECS
42+
* service deployments</a> in the <i>Amazon Elastic Container Service Developer
43+
* Guide</i>.</p>
44+
* @example
45+
* Use a bare-bones client and the command you need to make an API call.
46+
* ```javascript
47+
* import { ECSClient, StopServiceDeploymentCommand } from "@aws-sdk/client-ecs"; // ES Modules import
48+
* // const { ECSClient, StopServiceDeploymentCommand } = require("@aws-sdk/client-ecs"); // CommonJS import
49+
* const client = new ECSClient(config);
50+
* const input = { // StopServiceDeploymentRequest
51+
* serviceDeploymentArn: "STRING_VALUE", // required
52+
* stopType: "ABORT" || "ROLLBACK",
53+
* };
54+
* const command = new StopServiceDeploymentCommand(input);
55+
* const response = await client.send(command);
56+
* // { // StopServiceDeploymentResponse
57+
* // serviceDeploymentArn: "STRING_VALUE",
58+
* // };
59+
*
60+
* ```
61+
*
62+
* @param StopServiceDeploymentCommandInput - {@link StopServiceDeploymentCommandInput}
63+
* @returns {@link StopServiceDeploymentCommandOutput}
64+
* @see {@link StopServiceDeploymentCommandInput} for command's `input` shape.
65+
* @see {@link StopServiceDeploymentCommandOutput} for command's `response` shape.
66+
* @see {@link ECSClientResolvedConfig | config} for ECSClient's `config` shape.
67+
*
68+
* @throws {@link AccessDeniedException} (client fault)
69+
* <p>You don't have authorization to perform the requested action.</p>
70+
*
71+
* @throws {@link ClientException} (client fault)
72+
* <p>These errors are usually caused by a client action. This client action might be using
73+
* an action or resource on behalf of a user that doesn't have permissions to use the
74+
* action or resource. Or, it might be specifying an identifier that isn't valid.</p>
75+
* <p>The following list includes additional causes for the error:</p>
76+
* <ul>
77+
* <li>
78+
* <p>The <code>RunTask</code> could not be processed because you use managed
79+
* scaling and there is a capacity error because the quota of tasks in the
80+
* <code>PROVISIONING</code> per cluster has been reached. For information
81+
* about the service quotas, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-quotas.html">Amazon ECS
82+
* service quotas</a>.</p>
83+
* </li>
84+
* </ul>
85+
*
86+
* @throws {@link ConflictException} (client fault)
87+
* <p>The <code>RunTask</code> request could not be processed due to conflicts. The provided
88+
* <code>clientToken</code> is already in use with a different <code>RunTask</code>
89+
* request. The <code>resourceIds</code> are the existing task ARNs which are already
90+
* associated with the <code>clientToken</code>. </p>
91+
* <p>To fix this issue:</p>
92+
* <ul>
93+
* <li>
94+
* <p>Run <code>RunTask</code> with a unique <code>clientToken</code>.</p>
95+
* </li>
96+
* <li>
97+
* <p>Run <code>RunTask</code> with the <code>clientToken</code> and the original
98+
* set of parameters</p>
99+
* </li>
100+
* </ul>
101+
*
102+
* @throws {@link InvalidParameterException} (client fault)
103+
* <p>The specified parameter isn't valid. Review the available parameters for the API
104+
* request.</p>
105+
* <p>For more information about service event errors, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-event-messages-list.html">Amazon ECS service event messages</a>. </p>
106+
*
107+
* @throws {@link ServerException} (server fault)
108+
* <p>These errors are usually caused by a server issue.</p>
109+
*
110+
* @throws {@link ServiceDeploymentNotFoundException} (client fault)
111+
* <p>The service deploy ARN that you specified in the <code>StopServiceDeployment</code> doesn't exist. You can use <code>ListServiceDeployments</code> to retrieve the service deployment ARNs.</p>
112+
*
113+
* @throws {@link UnsupportedFeatureException} (client fault)
114+
* <p>The specified task isn't supported in this Region.</p>
115+
*
116+
* @throws {@link ECSServiceException}
117+
* <p>Base exception class for all service exceptions from ECS service.</p>
118+
*
119+
*
120+
* @example To stop a service deployment
121+
* ```javascript
122+
* // This example stops the service deployment using the ROLLBACK option.
123+
* const input = {
124+
* serviceDeploymentArn: "arn:aws:ecs:us-east-1:123456789012:service-deployment/MyCluster/MyService/r9i43YFjvgF_xlg7m2eJ1r",
125+
* stopType: "ROLLBACK"
126+
* };
127+
* const command = new StopServiceDeploymentCommand(input);
128+
* const response = await client.send(command);
129+
* /* response is
130+
* {
131+
* serviceDeploymentArn: "arn:aws:ecs:us-east-1:123456789012:service-deployment/MyCluster/MyService/r9i43YFjvgF_xlg7m2eJ1r"
132+
* }
133+
* *\/
134+
* ```
135+
*
136+
* @public
137+
*/
138+
export class StopServiceDeploymentCommand extends $Command
139+
.classBuilder<
140+
StopServiceDeploymentCommandInput,
141+
StopServiceDeploymentCommandOutput,
142+
ECSClientResolvedConfig,
143+
ServiceInputTypes,
144+
ServiceOutputTypes
145+
>()
146+
.ep(commonParams)
147+
.m(function (this: any, Command: any, cs: any, config: ECSClientResolvedConfig, o: any) {
148+
return [
149+
getSerdePlugin(config, this.serialize, this.deserialize),
150+
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
151+
];
152+
})
153+
.s("AmazonEC2ContainerServiceV20141113", "StopServiceDeployment", {})
154+
.n("ECSClient", "StopServiceDeploymentCommand")
155+
.f(void 0, void 0)
156+
.ser(se_StopServiceDeploymentCommand)
157+
.de(de_StopServiceDeploymentCommand)
158+
.build() {
159+
/** @internal type navigation helper, not in runtime. */
160+
protected declare static __types: {
161+
api: {
162+
input: StopServiceDeploymentRequest;
163+
output: StopServiceDeploymentResponse;
164+
};
165+
sdk: {
166+
input: StopServiceDeploymentCommandInput;
167+
output: StopServiceDeploymentCommandOutput;
168+
};
169+
};
170+
}

clients/client-ecs/src/commands/TagResourceCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { MetadataBearer as __MetadataBearer } from "@smithy/types";
66

77
import { ECSClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../ECSClient";
88
import { commonParams } from "../endpoint/EndpointParameters";
9-
import { TagResourceRequest, TagResourceResponse } from "../models/models_0";
9+
import { TagResourceRequest, TagResourceResponse } from "../models/models_1";
1010
import { de_TagResourceCommand, se_TagResourceCommand } from "../protocols/Aws_json1_1";
1111

1212
/**

clients/client-ecs/src/commands/UntagResourceCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { MetadataBearer as __MetadataBearer } from "@smithy/types";
66

77
import { ECSClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../ECSClient";
88
import { commonParams } from "../endpoint/EndpointParameters";
9-
import { UntagResourceRequest, UntagResourceResponse } from "../models/models_0";
9+
import { UntagResourceRequest, UntagResourceResponse } from "../models/models_1";
1010
import { de_UntagResourceCommand, se_UntagResourceCommand } from "../protocols/Aws_json1_1";
1111

1212
/**

clients/client-ecs/src/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export * from "./RegisterContainerInstanceCommand";
4343
export * from "./RegisterTaskDefinitionCommand";
4444
export * from "./RunTaskCommand";
4545
export * from "./StartTaskCommand";
46+
export * from "./StopServiceDeploymentCommand";
4647
export * from "./StopTaskCommand";
4748
export * from "./SubmitAttachmentStateChangesCommand";
4849
export * from "./SubmitContainerStateChangeCommand";

0 commit comments

Comments
 (0)