FargateServiceProps

class aws_cdk.aws_ecs.FargateServiceProps(*, cluster, capacity_provider_strategies=None, circuit_breaker=None, cloud_map_options=None, deployment_alarms=None, deployment_controller=None, desired_count=None, enable_ecs_managed_tags=None, enable_execute_command=None, health_check_grace_period=None, max_healthy_percent=None, min_healthy_percent=None, propagate_tags=None, service_connect_configuration=None, service_name=None, task_definition_revision=None, volume_configurations=None, task_definition, assign_public_ip=None, platform_version=None, security_groups=None, vpc_subnets=None)

Bases: BaseServiceOptions

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

Parameters:
  • cluster (ICluster) – The name of the cluster that hosts the service.

  • capacity_provider_strategies (Optional[Sequence[Union[CapacityProviderStrategy, Dict[str, Any]]]]) – A list of Capacity Provider strategies used to place a service. Default: - undefined

  • circuit_breaker (Union[DeploymentCircuitBreaker, Dict[str, Any], None]) – Whether to enable the deployment circuit breaker. If this property is defined, circuit breaker will be implicitly enabled. Default: - disabled

  • cloud_map_options (Union[CloudMapOptions, Dict[str, Any], None]) – The options for configuring an Amazon ECS service to use service discovery. Default: - AWS Cloud Map service discovery is not enabled.

  • deployment_alarms (Union[DeploymentAlarmConfig, Dict[str, Any], None]) – 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.

  • deployment_controller (Union[DeploymentController, Dict[str, Any], None]) – Specifies which deployment controller to use for the service. For more information, see Amazon ECS Deployment Types Default: - Rolling update (ECS)

  • desired_count (Union[int, float, None]) – 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.

  • enable_ecs_managed_tags (Optional[bool]) – Specifies whether to enable Amazon ECS managed tags for the tasks within the service. For more information, see Tagging Your Amazon ECS Resources Default: false

  • enable_execute_command (Optional[bool]) – Whether to enable the ability to execute into a container. Default: - undefined

  • health_check_grace_period (Optional[Duration]) – 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

  • max_healthy_percent (Union[int, float, None]) – 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

  • min_healthy_percent (Union[int, float, None]) – 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

  • propagate_tags (Optional[PropagatedTagSource]) – 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 Default: PropagatedTagSource.NONE

  • service_connect_configuration (Union[ServiceConnectProps, Dict[str, Any], None]) – 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.

  • service_name (Optional[str]) – The name of the service. Default: - CloudFormation-generated name.

  • task_definition_revision (Optional[TaskDefinitionRevision]) – 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

  • volume_configurations (Optional[Sequence[ServiceManagedVolume]]) – Configuration details for a volume used by the service. This allows you to specify details about the EBS volume that can be attched to ECS tasks. Default: - undefined

  • task_definition (TaskDefinition) – The task definition to use for tasks in the service. [disable-awslint:ref-via-interface]

  • assign_public_ip (Optional[bool]) – Specifies whether the task’s elastic network interface receives a public IP address. If true, each task will receive a public IP address. Default: false

  • platform_version (Optional[FargatePlatformVersion]) – 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 in the Amazon Elastic Container Service Developer Guide. Default: Latest

  • security_groups (Optional[Sequence[ISecurityGroup]]) – The security groups to associate with the service. If you do not specify a security group, a new security group is created. Default: - A new security group is created.

  • vpc_subnets (Union[SubnetSelection, Dict[str, Any], None]) – 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.

ExampleMetadata:

infused

Example:

import aws_cdk.aws_cloudwatch as cw

# cluster: ecs.Cluster
# task_definition: ecs.TaskDefinition
# elb_alarm: cw.Alarm


service = ecs.FargateService(self, "Service",
    cluster=cluster,
    task_definition=task_definition,
    deployment_alarms=ecs.DeploymentAlarmConfig(
        alarm_names=[elb_alarm.alarm_name],
        behavior=ecs.AlarmBehavior.ROLLBACK_ON_ALARM
    )
)

# Defining a deployment alarm after the service has been created
cpu_alarm_name = "MyCpuMetricAlarm"
cw.Alarm(self, "CPUAlarm",
    alarm_name=cpu_alarm_name,
    metric=service.metric_cpu_utilization(),
    evaluation_periods=2,
    threshold=80
)
service.enable_deployment_alarms([cpu_alarm_name],
    behavior=ecs.AlarmBehavior.FAIL_ON_ALARM
)

Attributes

assign_public_ip

Specifies whether the task’s elastic network interface receives a public IP address.

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

Default:

false

capacity_provider_strategies

A list of Capacity Provider strategies used to place a service.

Default:
  • undefined

circuit_breaker

Whether to enable the deployment circuit breaker.

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

Default:
  • disabled

cloud_map_options

The options for configuring an Amazon ECS service to use service discovery.

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

cluster

The name of the cluster that hosts the service.

deployment_alarms

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.

deployment_controller

Specifies which deployment controller to use for the service.

For more information, see Amazon ECS Deployment Types

Default:
  • Rolling update (ECS)

desired_count

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.

enable_ecs_managed_tags

Specifies whether to enable Amazon ECS managed tags for the tasks within the service.

For more information, see Tagging Your Amazon ECS Resources

Default:

false

enable_execute_command

Whether to enable the ability to execute into a container.

Default:
  • undefined

health_check_grace_period

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

max_healthy_percent

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

min_healthy_percent

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

platform_version

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 in the Amazon Elastic Container Service Developer Guide.

Default:

Latest

propagate_tags

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

Default:

PropagatedTagSource.NONE

security_groups

The security groups to associate with the service.

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

Default:
  • A new security group is created.

service_connect_configuration

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.

service_name

The name of the service.

Default:
  • CloudFormation-generated name.

task_definition

The task definition to use for tasks in the service.

[disable-awslint:ref-via-interface]

task_definition_revision

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

volume_configurations

Configuration details for a volume used by the service.

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

Default:
  • undefined

vpc_subnets

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.