Skip to content
v2.273.0

CfnService L1 construct ​

The AWS::ECS::Service resource creates an Amazon Elastic Container Service (Amazon ECS) service that runs and maintains the requested number of tasks and associated load balancers.

The stack update fails if you change any properties that require replacement and at least one Amazon ECS Service Connect ServiceConnectConfiguration property is configured. This is because AWS CloudFormation creates the replacement service first, but each ServiceConnectService must have a name that is unique in the namespace. > Starting April 15, 2023, AWS ; will not onboard new customers to Amazon Elastic Inference (EI), and will help current customers migrate their workloads to options that offer better price and performance. After April 15, 2023, new customers will not be able to launch instances with Amazon EI accelerators in Amazon SageMaker, Amazon ECS , or Amazon EC2 . However, customers who have used Amazon EI at least once during the past 30-day period are considered current customers and will be able to continue using the service. > On June 12, 2025, Amazon ECS launched support for updating capacity provider configuration for Amazon ECS services. With this launch, Amazon ECS also aligned the CloudFormation update behavior for CapacityProviderStrategy parameter with the standard practice. For more information, see Amazon ECS adds support for updating capacity provider configuration for ECS services . Previously Amazon ECS ignored the CapacityProviderStrategy property if it was set to an empty list for example, [] in CloudFormation , because updating capacity provider configuration was not supported. Now, with support for capacity provider updates, customers can remove capacity providers from a service by passing an empty list. When you specify an empty list ( [] ) for the CapacityProviderStrategy property in your CloudFormation template, Amazon ECS will remove any capacity providers associated with the service, as follows:

  • For services created with a capacity provider strategy after the launch:

  • If there's a cluster default strategy set, the service will revert to using that default strategy.

  • If no cluster default strategy exists, you will receive the following error:

No launch type to fall back to for empty capacity provider strategy. Your service was not created with a launch type.

  • For services created with a capacity provider strategy prior to the launch:

  • If CapacityProviderStrategy had FARGATE_SPOT or FARGATE capacity providers, the launch type will be updated to FARGATE and the capacity provider will be removed.

  • If the strategy included Auto Scaling group capacity providers, the service will revert to EC2 launch type, and the Auto Scaling group capacity providers will not be used.

Recommended Actions

If you are currently using CapacityProviderStrategy: [] in your CloudFormation templates, you should take one of the following actions:

  • If you do not intend to update the Capacity Provider Strategy:

  • Remove the CapacityProviderStrategy property entirely from your CloudFormation template

  • Alternatively, use !Ref AWS ::NoValue for the CapacityProviderStrategy property in your template

  • If you intend to maintain or update the Capacity Provider Strategy, specify the actual Capacity Provider Strategy for the service in your CloudFormation template.

If your CloudFormation template had an empty list ([]) for CapacityProviderStrategy prior to the aforementioned launch on June 12, and you are using the same template with CapacityProviderStrategy: [] , you might encounter the following error:

Invalid request provided: When switching from launch type to capacity provider strategy on an existing service, or making a change to a capacity provider strategy on a service that is already using one, you must force a new deployment. (Service: Ecs, Status Code: 400, Request ID: xxx) (SDK Attempt Count: 1)" (RequestToken: xxx HandlerErrorCode: InvalidRequest)

Note that CloudFormation automatically initiates a new deployment when it detects a parameter change, but customers cannot choose to force a deployment through CloudFormation . This is an invalid input scenario that requires one of the remediation actions listed above.

If you are experiencing active production issues related to this change, contact AWS Support or your Technical Account Manager.

Example ​

ts
declare const cluster: ecs.Cluster;
declare const taskDefinition: ecs.TaskDefinition;
declare const miCapacityProvider: ecs.ManagedInstancesCapacityProvider;

const service = new ecs.FargateService(this, 'Service', {
  cluster,
  taskDefinition,
  capacityProviderStrategies: [
    {
      capacityProvider: miCapacityProvider.capacityProviderName,
      weight: 1,
    },
  ],
});

// Escape hatch: Force launchType at the CloudFormation level to prevent service replacement
const cfnService = service.node.defaultChild as ecs.CfnService;
cfnService.launchType = 'FARGATE'; // or 'FARGATE_SPOT' depending on your capacity provider
python
# cluster: ecs.Cluster
# task_definition: ecs.TaskDefinition
# mi_capacity_provider: ecs.ManagedInstancesCapacityProvider


service = ecs.FargateService(self, "Service",
    cluster=cluster,
    task_definition=task_definition,
    capacity_provider_strategies=[ecs.CapacityProviderStrategy(
        capacity_provider=mi_capacity_provider.capacity_provider_name,
        weight=1
    )
    ]
)

# Escape hatch: Force launchType at the CloudFormation level to prevent service replacement
cfn_service = service.node.default_child
cfn_service.launch_type = "FARGATE"
java
Cluster cluster;
TaskDefinition taskDefinition;
ManagedInstancesCapacityProvider miCapacityProvider;


FargateService service = FargateService.Builder.create(this, "Service")
        .cluster(cluster)
        .taskDefinition(taskDefinition)
        .capacityProviderStrategies(List.of(CapacityProviderStrategy.builder()
                .capacityProvider(miCapacityProvider.getCapacityProviderName())
                .weight(1)
                .build()))
        .build();

// Escape hatch: Force launchType at the CloudFormation level to prevent service replacement
CfnService cfnService = (CfnService)service.getNode().getDefaultChild();
cfnService.getLaunchType() = "FARGATE";
csharp
// Install: dotnet add package Amazon.CDK.Lib
Cluster cluster;
TaskDefinition taskDefinition;
ManagedInstancesCapacityProvider miCapacityProvider;


var service = new FargateService(this, "Service", new FargateServiceProps {
    Cluster = cluster,
    TaskDefinition = taskDefinition,
    CapacityProviderStrategies = new [] { new CapacityProviderStrategy {
        CapacityProvider = miCapacityProvider.CapacityProviderName,
        Weight = 1
    } }
});

// Escape hatch: Force launchType at the CloudFormation level to prevent service replacement
var cfnService = (CfnService)service.Node.DefaultChild;
cfnService.LaunchType = "FARGATE";
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var cluster Cluster
var taskDefinition TaskDefinition
var miCapacityProvider ManagedInstancesCapacityProvider


service := ecs.NewFargateService(this, jsii.String("Service"), &FargateServiceProps{
	Cluster: Cluster,
	TaskDefinition: TaskDefinition,
	CapacityProviderStrategies: []CapacityProviderStrategy{
		&CapacityProviderStrategy{
			CapacityProvider: miCapacityProvider.CapacityProviderName,
			Weight: jsii.Number(1),
		},
	},
})

// Escape hatch: Force launchType at the CloudFormation level to prevent service replacement
cfnService := service.Node.defaultChild.(CfnService)
cfnService.launchType = "FARGATE"

Initializer ​

ts
new CfnService(scope: Construct, id: string, props?: CfnServiceProps)
python
CfnService(scope: Construct, id: str, props: typing.Optional[CfnServiceProps] = None)
java
new CfnService(Construct scope, String id, CfnServiceProps props)
csharp
new CfnService(Construct scope, string id, CfnServiceProps? props = null)
go
NewCfnService(Scope Construct, Id *string, Props CfnServiceProps)

Construct Props ​

availabilityZoneRebalancingstringavailability_zone_rebalancingstravailabilityZoneRebalancingStringAvailabilityZoneRebalancingstringAvailabilityZoneRebalancing*string= "ENABLED"#
Indicates whether to use Availability Zone rebalancing for the service.
notes

For more information, see Balancing an Amazon ECS service across Availability Zones in the Amazon Elastic Container Service Developer Guide .

The default behavior of AvailabilityZoneRebalancing differs between create and update requests:

  • For create service requests, when no value is specified for AvailabilityZoneRebalancing , Amazon ECS defaults the value to ENABLED .
  • For update service requests, when no value is specified for AvailabilityZoneRebalancing , Amazon ECS defaults to the existing service’s AvailabilityZoneRebalancing value. If the service never had an AvailabilityZoneRebalancing value set, Amazon ECS treats this as DISABLED .
capacityProviderStrategyIResolvable | IResolvable | CfnService.CapacityProviderStrategyItemProperty[]capacity_provider_strategytyping.Union[IResolvable, typing.List[typing.Union[IResolvable, CapacityProviderStrategyItemProperty]]]capacityProviderStrategyIResolvableCapacityProviderStrategyIResolvableCapacityProviderStrategyinterface{}#
The capacity provider strategy to use for the service.
notes

If a capacityProviderStrategy is specified, the launchType parameter must be omitted. If no capacityProviderStrategy or launchType is specified, the defaultCapacityProviderStrategy for the cluster is used.

A capacity provider strategy can contain a maximum of 20 capacity providers.

To remove this property from your service resource, specify an empty CapacityProviderStrategyItem array.

clusterstring | IClusterRefclustertyping.Union[str, IClusterRef]clusterStringClusterstringClusterinterface{}#
The short name or full Amazon Resource Name (ARN) of the cluster that you run your service on.

If you do not specify a cluster, the default cluster is assumed.

deploymentConfigurationIResolvable | CfnService.DeploymentConfigurationPropertydeployment_configurationtyping.Union[IResolvable, DeploymentConfigurationProperty]deploymentConfigurationIResolvableDeploymentConfigurationIResolvableDeploymentConfigurationinterface{}#
Optional deployment parameters that control how many tasks run during the deployment and the ordering of stopping and starting tasks.
deploymentControllerIResolvable | CfnService.DeploymentControllerPropertydeployment_controllertyping.Union[IResolvable, DeploymentControllerProperty]deploymentControllerIResolvableDeploymentControllerIResolvableDeploymentControllerinterface{}#
The deployment controller to use for the service.
desiredCountnumberdesired_countint | floatdesiredCountNumberDesiredCountdoubleDesiredCount*float64#
The number of instantiations of the specified task definition to place and keep running in your service.
notes

For new services, if a desired count is not specified, a default value of 1 is used. When using the DAEMON scheduling strategy, the desired count is not required.

For existing services, if a desired count is not specified, it is omitted from the operation.

enableEcsManagedTagsboolean | IResolvableenable_ecs_managed_tagstyping.Union[bool, IResolvable]enableEcsManagedTagsBooleanEnableEcsManagedTagsboolEnableEcsManagedTagsinterface{}#
Specifies whether to turn on Amazon ECS managed tags for the tasks within the service.
notes

For more information, see Tagging your Amazon ECS resources in the Amazon Elastic Container Service Developer Guide .

When you use Amazon ECS managed tags, you must set the propagateTags request parameter.

enableExecuteCommandboolean | IResolvableenable_execute_commandtyping.Union[bool, IResolvable]enableExecuteCommandBooleanEnableExecuteCommandboolEnableExecuteCommandinterface{}#
Determines whether the execute command functionality is turned on for the service.

If true , the execute command functionality is turned on for all containers in tasks as part of the service.

forceNewDeploymentIResolvable | CfnService.ForceNewDeploymentPropertyforce_new_deploymenttyping.Union[IResolvable, ForceNewDeploymentProperty]forceNewDeploymentIResolvableForceNewDeploymentIResolvableForceNewDeploymentinterface{}#
Determines whether to force a new deployment of the service.
notes

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.

healthCheckGracePeriodSecondsnumberhealth_check_grace_period_secondsint | floathealthCheckGracePeriodSecondsNumberHealthCheckGracePeriodSecondsdoubleHealthCheckGracePeriodSeconds*float64#
The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing, VPC Lattice, and container health checks after a task has first started.
notes

If you do not specify a health check grace period value, the default value of 0 is used. If you do not use any of the health checks, then healthCheckGracePeriodSeconds is unused.

If your service has more running tasks than desired, unhealthy tasks in the grace period might be stopped to reach the desired count.

launchTypestringlaunch_typestrlaunchTypeStringLaunchTypestringLaunchType*string#
The launch type on which to run your service.
notes

For more information, see Amazon ECS Launch Types in the Amazon Elastic Container Service Developer Guide .

If you want to use Managed Instances, you must use the capacityProviderStrategy request parameter

loadBalancersIResolvable | IResolvable | CfnService.LoadBalancerProperty[]load_balancerstyping.Union[IResolvable, typing.List[typing.Union[IResolvable, LoadBalancerProperty]]]loadBalancersIResolvableLoadBalancersIResolvableLoadBalancersinterface{}#
A list of load balancer objects to associate with the service.
notes

If you specify the Role property, LoadBalancers must be specified as well. For information about the number of load balancers that you can specify per service, see Service Load Balancing in the Amazon Elastic Container Service Developer Guide .

To remove this property from your service resource, specify an empty LoadBalancer array.

monitoringIResolvable | CfnService.MonitoringConfigurationPropertymonitoringtyping.Union[IResolvable, MonitoringConfigurationProperty]monitoringIResolvableMonitoringIResolvableMonitoringinterface{}#
The optional monitoring configuration for a service, which defines the resolution for the service-level ``CPUUtilization`` and ``MemoryUtilization`` Amazon CloudWatch metrics.

When not specified, Amazon ECS uses the default resolution of 60 seconds.

networkConfigurationIResolvable | CfnService.NetworkConfigurationPropertynetwork_configurationtyping.Union[IResolvable, NetworkConfigurationProperty]networkConfigurationIResolvableNetworkConfigurationIResolvableNetworkConfigurationinterface{}#
The network configuration for the service.
notes

This parameter is required for task definitions that use the awsvpc network mode to receive their own elastic network interface, and it is not supported for other network modes. For more information, see Task Networking in the Amazon Elastic Container Service Developer Guide .

placementConstraintsIResolvable | IResolvable | CfnService.PlacementConstraintProperty[]placement_constraintstyping.Union[IResolvable, typing.List[typing.Union[IResolvable, PlacementConstraintProperty]]]placementConstraintsIResolvablePlacementConstraintsIResolvablePlacementConstraintsinterface{}#
An array of placement constraint objects to use for tasks in your service.
notes

You can specify a maximum of 10 constraints for each task. This limit includes constraints in the task definition and those specified at runtime.

To remove this property from your service resource, specify an empty PlacementConstraint array.

placementStrategiesIResolvable | IResolvable | CfnService.PlacementStrategyProperty[]placement_strategiestyping.Union[IResolvable, typing.List[typing.Union[IResolvable, PlacementStrategyProperty]]]placementStrategiesIResolvablePlacementStrategiesIResolvablePlacementStrategiesinterface{}#
The placement strategy objects to use for tasks in your service.

You can specify a maximum of 5 strategy rules for each service.

To remove this property from your service resource, specify an empty PlacementStrategy array.

platformVersionstringplatform_versionstrplatformVersionStringPlatformVersionstringPlatformVersion*string= "LATEST"#
The platform version that your tasks in the service are running on.
notes

A platform version is specified only for tasks using the Fargate launch type. If one isn't specified, the LATEST platform version is used. For more information, see AWS Fargate platform versions in the Amazon Elastic Container Service Developer Guide .

propagateTagsstringpropagate_tagsstrpropagateTagsStringPropagateTagsstringPropagateTags*string#
Specifies whether to propagate the tags from the task definition to the task.
notes

If no value is specified, the tags aren't propagated. Tags can only be propagated to the task during task creation. To add tags to a task after task creation, use the TagResource API action.

You must set this to a value other than NONE when you use Cost Explorer. For more information, see Amazon ECS usage reports in the Amazon Elastic Container Service Developer Guide .

The default is NONE .

rolestring | IRoleRefroletyping.Union[str, IRoleRef]roleStringRolestringRoleinterface{}#
The name or full Amazon Resource Name (ARN) of the IAM role that allows Amazon ECS to make calls to your load balancer on your behalf.
notes

This parameter is only permitted if you are using a load balancer with your service and your task definition doesn't use the awsvpc network mode. If you specify the role parameter, you must also specify a load balancer object with the loadBalancers parameter.

If your account has already created the Amazon ECS service-linked role, that role is used for your service unless you specify a role here. The service-linked role is required if your task definition uses the awsvpc network mode or if the service is configured to use service discovery, an external deployment controller, multiple target groups, or Elastic Inference accelerators in which case you don't specify a role here. For more information, see Using service-linked roles for Amazon ECS in the Amazon Elastic Container Service Developer Guide .

If your specified role has a path other than / , then you must either specify the full role ARN (this is recommended) or prefix the role name with the path. For example, if a role with the name bar has a path of /foo/ then you would specify /foo/bar as the role name. For more information, see Friendly names and paths in the IAM User Guide .

schedulingStrategystringscheduling_strategystrschedulingStrategyStringSchedulingStrategystringSchedulingStrategy*string#
The scheduling strategy to use for the service. For more information, see [Services](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs_services.html) .
notes

There are two service scheduler strategies available:

  • REPLICA -The replica scheduling strategy places and maintains the desired number of tasks across your cluster. By default, the service scheduler spreads tasks across Availability Zones. You can use task placement strategies and constraints to customize task placement decisions. This scheduler strategy is required if the service uses the CODE_DEPLOY or EXTERNAL deployment controller types.
  • DAEMON -The daemon scheduling strategy deploys exactly one task on each active container instance that meets all of the task placement constraints that you specify in your cluster. The service scheduler also evaluates the task placement constraints for running tasks and will stop tasks that don't meet the placement constraints. When you're using this strategy, you don't need to specify a desired number of tasks, a task placement strategy, or use Service Auto Scaling policies.

Tasks using the Fargate launch type or the CODE_DEPLOY or EXTERNAL deployment controller types don't support the DAEMON scheduling strategy.

serviceConnectConfigurationIResolvable | CfnService.ServiceConnectConfigurationPropertyservice_connect_configurationtyping.Union[IResolvable, ServiceConnectConfigurationProperty]serviceConnectConfigurationIResolvableServiceConnectConfigurationIResolvableServiceConnectConfigurationinterface{}#
The configuration for this service to discover and connect to services, and be discovered by, and connected from, other services within a namespace.
notes

Tasks that run in a namespace can use short names to connect to services in the namespace. Tasks can connect to services across all of the clusters in the namespace. Tasks connect through a managed proxy container that collects logs and metrics for increased visibility. Only the tasks that Amazon ECS services create are supported with Service Connect. For more information, see Service Connect in the Amazon Elastic Container Service Developer Guide .

serviceNamestringservice_namestrserviceNameStringServiceNamestringServiceName*string#
The name of your service.
notes

Up to 255 letters (uppercase and lowercase), numbers, underscores, and hyphens are allowed. Service names must be unique within a cluster, but you can have similarly named services in multiple clusters within a Region or across multiple Regions.

The stack update fails if you change any properties that require replacement and the ServiceName is configured. This is because AWS CloudFormation creates the replacement service first, but each ServiceName must be unique in the cluster.

serviceRegistriesIResolvable | IResolvable | CfnService.ServiceRegistryProperty[]service_registriestyping.Union[IResolvable, typing.List[typing.Union[IResolvable, ServiceRegistryProperty]]]serviceRegistriesIResolvableServiceRegistriesIResolvableServiceRegistriesinterface{}#
The details of the service discovery registry to associate with this service. For more information, see [Service discovery](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-discovery.html) .

Each service may be associated with one service registry. Multiple service registries for each service isn't supported. > To remove this property from your service resource, specify an empty ServiceRegistry array.

tagsCfnTag[]tagstyping.List[CfnTag]tagsList<CfnTag>TagsCfnTag[]Tags*[]CfnTag#
The metadata that you apply to the service to help you categorize and organize them.
notes

Each tag consists of a key and an optional value, both of which you define. When a service is deleted, the tags are deleted as well.

The following basic restrictions apply to tags:

  • Maximum number of tags per resource - 50
  • For each resource, each tag key must be unique, and each tag key can have only one value.
  • Maximum key length - 128 Unicode characters in UTF-8
  • Maximum value length - 256 Unicode characters in UTF-8
  • If your tagging schema is used across multiple services and resources, remember that other services may have restrictions on allowed characters. Generally allowed characters are: letters, numbers, and spaces representable in UTF-8, and the following characters: + - = . _ : /
taskDefinitionstring | ITaskDefinitionReftask_definitiontyping.Union[str, ITaskDefinitionRef]taskDefinitionStringTaskDefinitionstringTaskDefinitioninterface{}#
The `family` and `revision` ( `family:revision` ) or full ARN of the task definition to run in your service.
notes

If a revision isn't specified, the latest ACTIVE revision is used.

A task definition must be specified if the service uses either the ECS or CODE_DEPLOY deployment controllers.

For more information about deployment types, see Amazon ECS deployment types .

volumeConfigurationsIResolvable | IResolvable | CfnService.ServiceVolumeConfigurationProperty[]volume_configurationstyping.Union[IResolvable, typing.List[typing.Union[IResolvable, ServiceVolumeConfigurationProperty]]]volumeConfigurationsIResolvableVolumeConfigurationsIResolvableVolumeConfigurationsinterface{}#
The configuration for a volume specified in the task definition as a volume that is configured at launch time.

Currently, the only supported volume type is an Amazon EBS volume.

To remove this property from your service resource, specify an empty ServiceVolumeConfiguration array.

vpcLatticeConfigurationsIResolvable | IResolvable | CfnService.VpcLatticeConfigurationProperty[]vpc_lattice_configurationstyping.Union[IResolvable, typing.List[typing.Union[IResolvable, VpcLatticeConfigurationProperty]]]vpcLatticeConfigurationsIResolvableVpcLatticeConfigurationsIResolvableVpcLatticeConfigurationsinterface{}#
The VPC Lattice configuration for the service being created.

Properties ​

attrNamestringattr_namestrattrNameStringAttrNamestringAttrName*stringrequired#
The name of the Amazon ECS service, such as `sample-webapp` .
attrServiceArnstringattr_service_arnstrattrServiceArnStringAttrServiceArnstringAttrServiceArn*stringrequired#
The ARN that identifies the service.

For more information about the ARN format, see Amazon Resource Name (ARN) in the Amazon ECS Developer Guide .

availabilityZoneRebalancingstringavailability_zone_rebalancingstravailabilityZoneRebalancingStringAvailabilityZoneRebalancingstringAvailabilityZoneRebalancing*string#
Indicates whether to use Availability Zone rebalancing for the service.
capacityProviderStrategyIResolvable | IResolvable | CfnService.CapacityProviderStrategyItemProperty[]capacity_provider_strategytyping.Union[IResolvable, typing.List[typing.Union[IResolvable, CapacityProviderStrategyItemProperty]]]capacityProviderStrategyIResolvableCapacityProviderStrategyIResolvableCapacityProviderStrategyinterface{}#
The capacity provider strategy to use for the service.
CFN_RESOURCE_TYPE_NAMEstringcfn_resource_type_namestrCFN_RESOURCE_TYPE_NAMEStringCFN_RESOURCE_TYPE_NAMEstringCFN_RESOURCE_TYPE_NAME*stringrequiredstatic#
The CloudFormation resource type name for this resource class.
Options for this resource, such as condition, update policy etc.
cfnResourceTypestringcfn_resource_typestrcfnResourceTypeStringCfnResourceTypestringCfnResourceType*stringrequired#
AWS resource type.
clusterstringclusterstrclusterStringClusterstringCluster*string#
The short name or full Amazon Resource Name (ARN) of the cluster that you run your service on.
creationStackstring[]creation_stacktyping.List[str]creationStackList<String>CreationStackstring[]CreationStack*[]*stringrequired#
deploymentConfigurationIResolvable | CfnService.DeploymentConfigurationPropertydeployment_configurationtyping.Union[IResolvable, DeploymentConfigurationProperty]deploymentConfigurationIResolvableDeploymentConfigurationIResolvableDeploymentConfigurationinterface{}#
Optional deployment parameters that control how many tasks run during the deployment and the ordering of stopping and starting tasks.
deploymentControllerIResolvable | CfnService.DeploymentControllerPropertydeployment_controllertyping.Union[IResolvable, DeploymentControllerProperty]deploymentControllerIResolvableDeploymentControllerIResolvableDeploymentControllerinterface{}#
The deployment controller to use for the service.
desiredCountnumberdesired_countint | floatdesiredCountNumberDesiredCountdoubleDesiredCount*float64#
The number of instantiations of the specified task definition to place and keep running in your service.
enableEcsManagedTagsboolean | IResolvableenable_ecs_managed_tagstyping.Union[bool, IResolvable]enableEcsManagedTagsBooleanEnableEcsManagedTagsboolEnableEcsManagedTagsinterface{}#
Specifies whether to turn on Amazon ECS managed tags for the tasks within the service.
enableExecuteCommandboolean | IResolvableenable_execute_commandtyping.Union[bool, IResolvable]enableExecuteCommandBooleanEnableExecuteCommandboolEnableExecuteCommandinterface{}#
Determines whether the execute command functionality is turned on for the service.
forceNewDeploymentIResolvable | CfnService.ForceNewDeploymentPropertyforce_new_deploymenttyping.Union[IResolvable, ForceNewDeploymentProperty]forceNewDeploymentIResolvableForceNewDeploymentIResolvableForceNewDeploymentinterface{}#
Determines whether to force a new deployment of the service.
healthCheckGracePeriodSecondsnumberhealth_check_grace_period_secondsint | floathealthCheckGracePeriodSecondsNumberHealthCheckGracePeriodSecondsdoubleHealthCheckGracePeriodSeconds*float64#
The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing, VPC Lattice, and container health checks after a task has first started.
launchTypestringlaunch_typestrlaunchTypeStringLaunchTypestringLaunchType*string#
The launch type on which to run your service.
loadBalancersIResolvable | IResolvable | CfnService.LoadBalancerProperty[]load_balancerstyping.Union[IResolvable, typing.List[typing.Union[IResolvable, LoadBalancerProperty]]]loadBalancersIResolvableLoadBalancersIResolvableLoadBalancersinterface{}#
A list of load balancer objects to associate with the service.
logicalIdstringlogical_idstrlogicalIdStringLogicalIdstringLogicalId*stringrequired#
The logical ID for this CloudFormation stack element.

The logical ID of the element is calculated from the path of the resource node in the construct tree.

To override this value, use overrideLogicalId(newLogicalId).

monitoringIResolvable | CfnService.MonitoringConfigurationPropertymonitoringtyping.Union[IResolvable, MonitoringConfigurationProperty]monitoringIResolvableMonitoringIResolvableMonitoringinterface{}#
The optional monitoring configuration for a service, which defines the resolution for the service-level ``CPUUtilization`` and ``MemoryUtilization`` Amazon CloudWatch metrics.
networkConfigurationIResolvable | CfnService.NetworkConfigurationPropertynetwork_configurationtyping.Union[IResolvable, NetworkConfigurationProperty]networkConfigurationIResolvableNetworkConfigurationIResolvableNetworkConfigurationinterface{}#
The network configuration for the service.
nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
placementConstraintsIResolvable | IResolvable | CfnService.PlacementConstraintProperty[]placement_constraintstyping.Union[IResolvable, typing.List[typing.Union[IResolvable, PlacementConstraintProperty]]]placementConstraintsIResolvablePlacementConstraintsIResolvablePlacementConstraintsinterface{}#
An array of placement constraint objects to use for tasks in your service.
placementStrategiesIResolvable | IResolvable | CfnService.PlacementStrategyProperty[]placement_strategiestyping.Union[IResolvable, typing.List[typing.Union[IResolvable, PlacementStrategyProperty]]]placementStrategiesIResolvablePlacementStrategiesIResolvablePlacementStrategiesinterface{}#
The placement strategy objects to use for tasks in your service.
platformVersionstringplatform_versionstrplatformVersionStringPlatformVersionstringPlatformVersion*string#
The platform version that your tasks in the service are running on.
propagateTagsstringpropagate_tagsstrpropagateTagsStringPropagateTagsstringPropagateTags*string#
Specifies whether to propagate the tags from the task definition to the task.
refstringrefstrrefStringRefstringRef*stringrequired#
Return a string that will be resolved to a CloudFormation `{ Ref }` for this element.

If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through Lazy.any({ produce: resource.ref }).

rolestringrolestrroleStringRolestringRole*string#
The name or full Amazon Resource Name (ARN) of the IAM role that allows Amazon ECS to make calls to your load balancer on your behalf.
schedulingStrategystringscheduling_strategystrschedulingStrategyStringSchedulingStrategystringSchedulingStrategy*string#
The scheduling strategy to use for the service.

For more information, see Services .

serviceConnectConfigurationIResolvable | CfnService.ServiceConnectConfigurationPropertyservice_connect_configurationtyping.Union[IResolvable, ServiceConnectConfigurationProperty]serviceConnectConfigurationIResolvableServiceConnectConfigurationIResolvableServiceConnectConfigurationinterface{}#
The configuration for this service to discover and connect to services, and be discovered by, and connected from, other services within a namespace.
serviceNamestringservice_namestrserviceNameStringServiceNamestringServiceName*string#
The name of your service.
serviceRefServiceReferenceservice_refServiceReferenceserviceRefServiceReferenceServiceRefServiceReferenceServiceRefServiceReferencerequired#
A reference to a Service resource.
serviceRegistriesIResolvable | IResolvable | CfnService.ServiceRegistryProperty[]service_registriestyping.Union[IResolvable, typing.List[typing.Union[IResolvable, ServiceRegistryProperty]]]serviceRegistriesIResolvableServiceRegistriesIResolvableServiceRegistriesinterface{}#
The details of the service discovery registry to associate with this service.

For more information, see Service discovery .

stackStackstackStackstackStackStackStackStackStackrequired#
The stack in which this element is defined.

CfnElements must be defined within a stack scope (directly or indirectly).

Tag Manager which manages the tags for this resource.
tagsRawCfnTag[]tags_rawtyping.List[CfnTag]tagsRawList<CfnTag>TagsRawCfnTag[]TagsRaw*[]CfnTag#
The metadata that you apply to the service to help you categorize and organize them.
taskDefinitionstringtask_definitionstrtaskDefinitionStringTaskDefinitionstringTaskDefinition*string#
The `family` and `revision` ( `family:revision` ) or full ARN of the task definition to run in your service.
volumeConfigurationsIResolvable | IResolvable | CfnService.ServiceVolumeConfigurationProperty[]volume_configurationstyping.Union[IResolvable, typing.List[typing.Union[IResolvable, ServiceVolumeConfigurationProperty]]]volumeConfigurationsIResolvableVolumeConfigurationsIResolvableVolumeConfigurationsinterface{}#
The configuration for a volume specified in the task definition as a volume that is configured at launch time.
vpcLatticeConfigurationsIResolvable | IResolvable | CfnService.VpcLatticeConfigurationProperty[]vpc_lattice_configurationstyping.Union[IResolvable, typing.List[typing.Union[IResolvable, VpcLatticeConfigurationProperty]]]vpcLatticeConfigurationsIResolvableVpcLatticeConfigurationsIResolvableVpcLatticeConfigurationsinterface{}#
The VPC Lattice configuration for the service being created.

Methods ​

addDeletionOverride(path: string): voiddef add_deletion_override(self, path: str) -> Nonepublic void addDeletionOverride(String path)public void AddDeletionOverride(string path)func AddDeletionOverride(Path *string)#
Syntactic sugar for `addOverride(path, undefined)`.
1 parameter

Parameters

  • pathpathpathpathPath — The path of the value to delete.
addDependency(target: CfnResource): voiddef add_dependency(self, target: CfnResource) -> Nonepublic void addDependency(CfnResource target)public void AddDependency(CfnResource target)func AddDependency(Target CfnResource)deprecated#
Use `addResourceDependency` instead.

This method has been renamed to addResourceDependency to more clearly set it apart from construct.node.addDependency. See the documentation of that function for more details.

addDependsOn(target: CfnResource): voiddef add_depends_on(self, target: CfnResource) -> Nonepublic void addDependsOn(CfnResource target)public void AddDependsOn(CfnResource target)func AddDependsOn(Target CfnResource)deprecated#
Use `addResourceDependency` instead.
notes

This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.

This method has been renamed to addResourceDependency, which makes it more clear that this method operates at a different level from the construct-level construct.node.addDependency() mechanism.

addMetadata(key: string, value: any): voiddef add_metadata(self, key: str, value: Any) -> Nonepublic void addMetadata(String key, Object value)public void AddMetadata(string key, object value)func AddMetadata(Key *string, Value interface{})#
Add a value to the CloudFormation Resource Metadata.
addOverride(path: string, value: any): voiddef add_override(self, path: str, value: Any) -> Nonepublic void addOverride(String path, Object value)public void AddOverride(string path, object value)func AddOverride(Path *string, Value interface{})#
Adds an override to the synthesized CloudFormation resource.
notes · 2 parameters

To add a property override, either use addPropertyOverride or prefix path with "Properties." (i.e. Properties.TopicName).

If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.

To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.

For example,

typescript
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes', ['myattribute']);
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.1.ProjectionType', 'INCLUDE');

would add the overrides

json
"Properties": {
  "GlobalSecondaryIndexes": [
    {
      "Projection": {
        "NonKeyAttributes": [ "myattribute" ]
        ...
      }
      ...
    },
    {
      "ProjectionType": "INCLUDE"
      ...
    },
  ]
  ...
}

The value argument to addOverride will not be processed or translated in any way. Pass raw JSON values in here with the correct capitalization for CloudFormation. If you pass CDK classes or structs, they will be rendered with lowercased key names, and CloudFormation will reject the template.

Parameters

  • pathpathpathpathPath — - The path of the property, you can use dot notation to override values in complex types.
  • valuevaluevaluevalueValue — - The value.
addPropertyDeletionOverride(propertyPath: string): voiddef add_property_deletion_override(self, property_path: str) -> Nonepublic void addPropertyDeletionOverride(String propertyPath)public void AddPropertyDeletionOverride(string propertyPath)func AddPropertyDeletionOverride(PropertyPath *string)#
Adds an override that deletes the value of a property from the resource definition.
1 parameter

Parameters

  • propertyPathproperty_pathpropertyPathpropertyPathPropertyPath — The path to the property.
addPropertyOverride(propertyPath: string, value: any): voiddef add_property_override(self, property_path: str, value: Any) -> Nonepublic void addPropertyOverride(String propertyPath, Object value)public void AddPropertyOverride(string propertyPath, object value)func AddPropertyOverride(PropertyPath *string, Value interface{})#
Adds an override to a resource property.

Syntactic sugar for addOverride("Properties.<...>", value).

2 parameters

Parameters

  • propertyPathproperty_pathpropertyPathpropertyPathPropertyPath — The path of the property.
  • valuevaluevaluevalueValue — The value.
addResourceDependency(target: CfnResource, reason?: string): voiddef add_resource_dependency(self, target: CfnResource, reason: typing.Optional[str] = None) -> Nonepublic void addResourceDependency(CfnResource target, String reason)public void AddResourceDependency(CfnResource target, string? reason = null)func AddResourceDependency(Target CfnResource, Reason *string)#
Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
notes

This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.

This method only adds dependencies between L1 resources. If you are looking for a generic construct-to-construct dependency mechanism that works for all constructs including L2s, use construct.node.addDependency instead.

applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#
Sets the cross-stack reference strength for this resource.

When set, any cross-stack reference to this resource will use the specified strength instead of the global default from the consuming stack's context.

1 parameter

Parameters

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy?: RemovalPolicy, options?: RemovalPolicyOptions): voiddef apply_removal_policy(self, policy: typing.Optional[RemovalPolicy] = None, options: typing.Optional[RemovalPolicyOptions] = None) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy, RemovalPolicyOptions options)public void ApplyRemovalPolicy(RemovalPolicy? policy = null, RemovalPolicyOptions? options = null)func ApplyRemovalPolicy(Policy RemovalPolicy, Options RemovalPolicyOptions)#
Sets the deletion policy of the resource based on the removal policy specified.
notes

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN). In some cases, a snapshot can be taken of the resource prior to deletion (RemovalPolicy.SNAPSHOT). A list of resources that support this policy can be found in the following link:

arnForService(resource: IServiceRef): string@staticmethod def arn_for_service(resource: IServiceRef) -> strpublic static String arnForService(IServiceRef resource)public static string ArnForService(IServiceRef resource)func ArnForService(Resource IServiceRef) *stringstatic#
cfnPropertyName(cdkPropertyName: string): stringdef cfn_property_name(self, cdk_property_name: str) -> strpublic String cfnPropertyName(String cdkPropertyName)public string CfnPropertyName(string cdkPropertyName)func CfnPropertyName(CdkPropertyName *string) *string#
getAtt(attributeName: string, typeHint?: ResolutionTypeHint): Referencedef get_att(self, attribute_name: str, type_hint: typing.Optional[ResolutionTypeHint] = None) -> Referencepublic Reference getAtt(String attributeName, ResolutionTypeHint typeHint)public Reference GetAtt(string attributeName, ResolutionTypeHint? typeHint = null)func GetAtt(AttributeName *string, TypeHint ResolutionTypeHint) Reference#
Returns a token for an runtime attribute of this resource.

Ideally, use generated attribute accessors (e.g. resource.arn), but this can be used for future compatibility in case there is no generated attribute.

1 parameter

Parameters

  • attributeNameattribute_nameattributeNameattributeNameAttributeName — The name of the attribute.
getMetadata(key: string): anydef get_metadata(self, key: str) -> Anypublic Object getMetadata(String key)public object GetMetadata(string key)func GetMetadata(Key *string) interface{}#
Retrieve a value value from the CloudFormation Resource Metadata.
inspect(inspector: TreeInspector): voiddef inspect(self, inspector: TreeInspector) -> Nonepublic void inspect(TreeInspector inspector)public void Inspect(TreeInspector inspector)func Inspect(Inspector TreeInspector)#
Examines the CloudFormation resource and discloses attributes.
1 parameter

Parameters

  • inspectorinspectorinspectorinspectorInspector — tree inspector to collect and process attributes.
isCfnElement(x: any): boolean@staticmethod def is_cfn_element(x: Any) -> boolpublic static Boolean isCfnElement(Object x)public static bool IsCfnElement(object x)func IsCfnElement(X interface{}) *boolstatic#
Returns `true` if a construct is a stack element (i.e. part of the synthesized cloudformation template).

Uses duck-typing instead of instanceof to allow stack elements from different versions of this library to be included in the same stack.

returns

Returns: The construct as a stack element or undefined if it is not a stack element.

isCfnResource(x: any): boolean@staticmethod def is_cfn_resource(x: Any) -> boolpublic static Boolean isCfnResource(Object x)public static bool IsCfnResource(object x)func IsCfnResource(X interface{}) *boolstatic#
Check whether the given object is a CfnResource.
isCfnService(x: any): boolean@staticmethod def is_cfn_service(x: Any) -> boolpublic static Boolean isCfnService(Object x)public static bool IsCfnService(object x)func IsCfnService(X interface{}) *boolstatic#
Checks whether the given object is a CfnService.
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

obtainDependencies(): Stack | CfnResource[]def obtain_dependencies(self, ) -> typing.List[typing.Union[Stack, CfnResource]]public List<Stack> obtainDependencies()public Stack[] ObtainDependencies()func ObtainDependencies() *[]interface{}#
Retrieves an array of resources and stacks this resource depends on.

For resources depended on directly, returns the CfnResource object. For dependencies on other stacks, returns the Stack object. The order of the array is not guaranteed.

overrideLogicalId(newLogicalId: string): voiddef override_logical_id(self, new_logical_id: str) -> Nonepublic void overrideLogicalId(String newLogicalId)public void OverrideLogicalId(string newLogicalId)func OverrideLogicalId(NewLogicalId *string)#
Overrides the auto-generated logical ID with a specific ID.
1 parameter

Parameters

  • newLogicalIdnew_logical_idnewLogicalIdnewLogicalIdNewLogicalId — The new logical ID to use for this stack element.
removeDependency(target: CfnResource): voiddef remove_dependency(self, target: CfnResource) -> Nonepublic void removeDependency(CfnResource target)public void RemoveDependency(CfnResource target)func RemoveDependency(Target CfnResource)deprecated#
Use `removeResourceDependency` instead

This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.

removeResourceDependency(target: CfnResource): voiddef remove_resource_dependency(self, target: CfnResource) -> Nonepublic void removeResourceDependency(CfnResource target)public void RemoveResourceDependency(CfnResource target)func RemoveResourceDependency(Target CfnResource)#
Indicates that this resource no longer depends on another resource.

This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.

replaceDependency(target: CfnResource, newTarget: CfnResource): voiddef replace_dependency(self, target: CfnResource, new_target: CfnResource) -> Nonepublic void replaceDependency(CfnResource target, CfnResource newTarget)public void ReplaceDependency(CfnResource target, CfnResource newTarget)func ReplaceDependency(Target CfnResource, NewTarget CfnResource)#
Replaces one dependency with another.
2 parameters

Parameters

  • targettargettargettargetTarget — The dependency to replace.
  • newTargetnew_targetnewTargetnewTargetNewTarget — The new dependency to add.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
returns

Returns: a string representation of this resource

with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.