# FargateServiceProps

The properties for defining a service using the Fargate launch type.

Extends: FargateServiceProps
Extends: BaseServiceOptions
Used as props by: FargateService

- Source: [`aws-ecs/lib/fargate/fargate-service.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-ecs/lib/fargate/fargate-service.ts#L20)
- Type last changed: v2.215.0 · 15 Sep 2025

## Example

```ts
import * as cw from 'aws-cdk-lib/aws-cloudwatch';

declare const cluster: ecs.Cluster;
declare const taskDefinition: ecs.TaskDefinition;
declare const elbAlarm: cw.Alarm;

const service = new ecs.FargateService(this, 'Service', {
  cluster,
  taskDefinition,
  minHealthyPercent: 100,
  deploymentAlarms: {
    alarmNames: [elbAlarm.alarmName],
    behavior: ecs.AlarmBehavior.ROLLBACK_ON_ALARM,
  },
});

// Defining a deployment alarm after the service has been created
const cpuAlarmName =  'MyCpuMetricAlarm';
new cw.Alarm(this, 'CPUAlarm', {
  alarmName: cpuAlarmName,
  metric: service.metricCpuUtilization(),
  evaluationPeriods: 2,
  threshold: 80,
});
service.enableDeploymentAlarms([cpuAlarmName], {
  behavior: ecs.AlarmBehavior.FAIL_ON_ALARM,
});
```

## Properties

- `assignPublicIp`: boolean = false — Specifies whether the task's elastic network interface receives a public IP address.

  If true, each task will receive a public IP address.

- `availabilityZoneRebalancing`: [AvailabilityZoneRebalancing](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.AvailabilityZoneRebalancing.html) — Whether to use Availability Zone rebalancing for the service.

  **Default:** AvailabilityZoneRebalancing.ENABLED

  If enabled, `maxHealthyPercent` must be greater than 100, and the service must not be a target
  of a Classic Load Balancer.

- `bakeTime`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = none — bake time minutes for service.

- `canaryConfiguration`: [TrafficShiftConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.TrafficShiftConfig.html) — Configuration for canary deployment strategy.

  **Default:** no canary configuration

  Only valid when deploymentStrategy is set to CANARY.

- `capacityProviderStrategies`: [CapacityProviderStrategy](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.CapacityProviderStrategy.html)[] = undefined — A list of Capacity Provider strategies used to place a service.

- `circuitBreaker`: [DeploymentCircuitBreaker](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.DeploymentCircuitBreaker.html) = disabled — Whether to enable the deployment circuit breaker.

  If this property is defined, circuit breaker will be implicitly
  enabled.

- `cloudMapOptions`: [CloudMapOptions](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.CloudMapOptions.html) — The options for configuring an Amazon ECS service to use service discovery.

  **Default:** AWS Cloud Map service discovery is not enabled.

- `cluster`: [ICluster](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.ICluster.html) (required) — The name of the cluster that hosts the service.

- `deploymentAlarms`: [DeploymentAlarmConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.DeploymentAlarmConfig.html) — The alarm(s) to monitor during deployment, and behavior to apply if at least one enters a state of alarm during the deployment or bake time.

  **Default:** No alarms will be monitored during deployment.

- `deploymentController`: [DeploymentController](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.DeploymentController.html) — Specifies which deployment controller to use for the service.

  **Default:** Rolling update (ECS)

  For more information, see
  [Amazon ECS Deployment Types](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-types.html)

- `deploymentStrategy`: [DeploymentStrategy](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.DeploymentStrategy.html) = ROLLING — The deployment strategy to use for the service.

- `desiredCount`: number — The desired number of instantiations of the task definition to keep running on the service.

  **Default:** When creating the service, default is 1; when updating the service, default uses the current task number.

- `enableECSManagedTags`: boolean = false — Specifies whether to enable Amazon ECS managed tags for the tasks within the service.

  For more information, see
  [Tagging Your Amazon ECS Resources](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-using-tags.html)

- `enableExecuteCommand`: boolean = undefined — Whether to enable the ability to execute into a container.

- `forceNewDeployment`: [ForceNewDeployment](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.ForceNewDeployment.html) — Configuration for forcing a new deployment of the service.

  **Default:** no forced deployment

  By default, deployments aren't forced. You can use this option to start
  a new deployment with no service definition changes. For example, you can
  update a service's tasks to use a newer Docker image with the same
  image/tag combination (`my_image:latest`) or to roll Fargate tasks onto
  a newer platform version.

  This is equivalent to calling the `forceNewDeployment()` method, but allows
  you to configure it declaratively at construction time, including the ability
  to explicitly disable it with `enabled: false`.

- `healthCheckGracePeriod`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) — The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing target health checks after a task has first started.

  **Default:** defaults to 60 seconds if at least one load balancer is in-use and it is not already set

- `lifecycleHooks`: [IDeploymentLifecycleHookTarget](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.IDeploymentLifecycleHookTarget.html)[] = none; — The lifecycle hooks to execute during deployment stages.

- `linearConfiguration`: [TrafficShiftConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.TrafficShiftConfig.html) — Configuration for linear deployment strategy.

  **Default:** no linear configuration

  Only valid when deploymentStrategy is set to LINEAR.

- `maxHealthyPercent`: number — The maximum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that can run in a service during a deployment.

  **Default:** 100 if daemon, otherwise 200

- `minHealthyPercent`: number — The minimum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that must continue to run and remain healthy during a deployment.

  **Default:** 0 if daemon, otherwise 50

- `platformVersion`: [FargatePlatformVersion](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.FargatePlatformVersion.html) = Latest — The platform version on which to run your service.

  If one is not specified, the LATEST platform version is used by default. For more information, see
  [AWS Fargate Platform Versions](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/platform_versions.html)
  in the Amazon Elastic Container Service Developer Guide.

- `propagateTags`: [PropagatedTagSource](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.PropagatedTagSource.html) = PropagatedTagSource.NONE — Specifies whether to propagate the tags from the task definition or the service to the tasks in the service.

  Valid values are: PropagatedTagSource.SERVICE, PropagatedTagSource.TASK_DEFINITION or PropagatedTagSource.NONE

- `securityGroups`: [ISecurityGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.ISecurityGroup.html)[] — The security groups to associate with the service.

  **Default:** A new security group is created.

  If you do not specify a security group, a new security group is created.

- `serviceConnectConfiguration`: [ServiceConnectProps](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.ServiceConnectProps.html) — Configuration for Service Connect.

  **Default:** No ports are advertised via Service Connect on this service, and the service cannot make requests to other services via Service Connect.

- `serviceName`: string — The name of the service.

  **Default:** CloudFormation-generated name.

- `taskDefinition`: [TaskDefinition](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.TaskDefinition.html) (required) — The task definition to use for tasks in the service.

  [disable-awslint:ref-via-interface]

- `taskDefinitionRevision`: [TaskDefinitionRevision](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.TaskDefinitionRevision.html) — Revision number for the task definition or `latest` to use the latest active task revision.

  **Default:** Uses the revision of the passed task definition deployed by CloudFormation

- `volumeConfigurations`: [ServiceManagedVolume](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.ServiceManagedVolume.html)[] = undefined — Configuration details for a volume used by the service.

  This allows you to specify
  details about the EBS volume that can be attached to ECS tasks.

- `vpcSubnets`: [SubnetSelection](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SubnetSelection.html) — The subnets to associate with the service.

  **Default:** Public subnets if `assignPublicIp` is set, otherwise the first available one of Private, Isolated, Public, in that order.
