You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/aws-cdk-lib/aws-ecs/README.md
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2234,3 +2234,31 @@ new ecs.ExternalService(this, 'ExternalService', {
2234
2234
daemon: true,
2235
2235
});
2236
2236
```
2237
+
2238
+
### Force New Deployment
2239
+
2240
+
You can force a new deployment of a service without changing the task definition or desired count. This can be useful to trigger a deployment when you want to deploy new tasks even if there are no changes to the service configuration.
2241
+
2242
+
When enabled, ECS will start a new deployment even if there are no changes to the service configuration. This is accomplished by setting a unique timestamp nonce that forces CloudFormation to recognize the service as changed.
2243
+
2244
+
```ts
2245
+
declareconst cluster:ecs.Cluster;
2246
+
declareconst taskDefinition:ecs.TaskDefinition;
2247
+
2248
+
const service =newecs.FargateService(this, 'Service', {
2249
+
cluster,
2250
+
taskDefinition,
2251
+
});
2252
+
2253
+
// Force a new deployment
2254
+
service.forceNewDeployment(true);
2255
+
```
2256
+
2257
+
You can also disable force new deployment by calling the method with `false`:
2258
+
2259
+
```ts
2260
+
// Disable force new deployment
2261
+
service.forceNewDeployment(false);
2262
+
```
2263
+
2264
+
The `forceNewDeployment` method works with all service types including `FargateService`, `Ec2Service`, and `ExternalService`. Each call to this method generates a unique timestamp nonce, ensuring that multiple services or multiple calls to the same service will have different nonces.
0 commit comments