# ForceNewDeployment

Configuration for forcing a new deployment of the service.

- Source: [`aws-ecs/lib/base/base-service.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-ecs/lib/base/base-service.ts#L104)
- Type last changed: v2.259.0 · 12 Jun 2026

## Example

```ts
declare const cluster: ecs.Cluster;
declare const taskDefinition: ecs.TaskDefinition;

// Force a new deployment on every `cdk deploy` by using a time-based nonce
const service = new ecs.FargateService(this, 'Service', {
  cluster,
  taskDefinition,
  forceNewDeployment: {
    enabled: true,
    nonce: Date.now().toString(),
  },
});
```

## Properties

- `enabled`: boolean (required) — Whether to enable the force-new-deployment mechanism for the service.

  Setting this to `true` enables the mechanism, but on its own it does not
  force a new deployment on every `cdk deploy`: CloudFormation only starts a
  new deployment when it detects a change in the template, and the signal for
  that is the `nonce` value changing between deployments. If `nonce` is not
  provided or its value stays the same across deployments, no new deployment
  is forced. When set to `false`, the `ForceNewDeployment` property is rendered
  with `EnableForceNewDeployment: false`.

  To force a new deployment on every `cdk deploy`, provide a `nonce` with a
  unique, time-varying value such as a timestamp, random string, or sequence
  number (e.g. `Date.now().toString()`).

- `nonce`: string — A unique nonce value that signals Amazon ECS to start a new deployment.

  **Default:** no nonce

  When you change this value, it triggers a new deployment even though no
  other service parameters have changed. Use a stable, time-varying value
  like a commit hash, image digest, or version string.

  If not provided and `enabled` is `true`, only `EnableForceNewDeployment`
  is set without a nonce.

  Must be between 1 and 255 characters.
