CfnTaskSetPropsMixin
- class aws_cdk.mixins_preview.aws_ecs.mixins.CfnTaskSetPropsMixin(props, *, strategy=None)
Bases:
MixinCreate a task set in the specified cluster and service.
This is used when a service uses the
EXTERNALdeployment controller type. For more information, see Amazon ECS deployment types in the Amazon Elastic Container Service Developer Guide . .. epigraph:On March 21, 2024, a change was made to resolve the task definition revision before authorization. When a task definition revision is not specified, authorization will occur using the latest revision of a task definition.
For information about the maximum number of task sets and other quotas, see Amazon ECS service quotas in the Amazon Elastic Container Service Developer Guide .
- See:
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecs-taskset.html
- CloudformationResource:
AWS::ECS::TaskSet
- Mixin:
true
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview import mixins from aws_cdk.mixins_preview.aws_ecs import mixins as ecs_mixins cfn_task_set_props_mixin = ecs_mixins.CfnTaskSetPropsMixin(ecs_mixins.CfnTaskSetMixinProps( capacity_provider_strategy=[ecs_mixins.CfnTaskSetPropsMixin.CapacityProviderStrategyItemProperty( base=123, capacity_provider="capacityProvider", weight=123 )], cluster="cluster", external_id="externalId", launch_type="launchType", load_balancers=[ecs_mixins.CfnTaskSetPropsMixin.LoadBalancerProperty( container_name="containerName", container_port=123, target_group_arn="targetGroupArn" )], network_configuration=ecs_mixins.CfnTaskSetPropsMixin.NetworkConfigurationProperty( aws_vpc_configuration=ecs_mixins.CfnTaskSetPropsMixin.AwsVpcConfigurationProperty( assign_public_ip="assignPublicIp", security_groups=["securityGroups"], subnets=["subnets"] ) ), platform_version="platformVersion", scale=ecs_mixins.CfnTaskSetPropsMixin.ScaleProperty( unit="unit", value=123 ), service="service", service_registries=[ecs_mixins.CfnTaskSetPropsMixin.ServiceRegistryProperty( container_name="containerName", container_port=123, port=123, registry_arn="registryArn" )], tags=[CfnTag( key="key", value="value" )], task_definition="taskDefinition" ), strategy=mixins.PropertyMergeStrategy.OVERRIDE )
Create a mixin to apply properties to
AWS::ECS::TaskSet.- Parameters:
props (
Union[CfnTaskSetMixinProps,Dict[str,Any]]) – L1 properties to apply.strategy (
Optional[PropertyMergeStrategy]) – (experimental) Strategy for merging nested properties. Default: - PropertyMergeStrategy.MERGE
Methods
- apply_to(construct)
Apply the mixin properties to the construct.
- Parameters:
construct (
IConstruct)- Return type:
- supports(construct)
Check if this mixin supports the given construct.
- Parameters:
construct (
IConstruct)- Return type:
bool
Attributes
- CFN_PROPERTY_KEYS = ['capacityProviderStrategy', 'cluster', 'externalId', 'launchType', 'loadBalancers', 'networkConfiguration', 'platformVersion', 'scale', 'service', 'serviceRegistries', 'tags', 'taskDefinition']
Static Methods
- classmethod is_mixin(x)
(experimental) Checks if
xis a Mixin.- Parameters:
x (
Any) – Any object.- Return type:
bool- Returns:
true if
xis an object created from a class which extendsMixin.- Stability:
experimental
AwsVpcConfigurationProperty
- class CfnTaskSetPropsMixin.AwsVpcConfigurationProperty(*, assign_public_ip=None, security_groups=None, subnets=None)
Bases:
objectAn object representing the networking details for a task or service.
For example
awsVpcConfiguration={subnets=["subnet-12344321"],securityGroups=["sg-12344321"]}.- Parameters:
assign_public_ip (
Optional[str]) – Whether the task’s elastic network interface receives a public IP address. Consider the following when you set this value: - When you usecreate-serviceorupdate-service, the default isDISABLED. - When the servicedeploymentControllerisECS, the value must beDISABLED.security_groups (
Optional[Sequence[str]]) – The IDs of the security groups associated with the task or service. If you don’t specify a security group, the default security group for the VPC is used. There’s a limit of 5 security groups that can be specified. .. epigraph:: All specified security groups must be from the same VPC.subnets (
Optional[Sequence[str]]) – The IDs of the subnets associated with the task or service. There’s a limit of 16 subnets that can be specified. .. epigraph:: All specified subnets must be from the same VPC.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_ecs import mixins as ecs_mixins aws_vpc_configuration_property = ecs_mixins.CfnTaskSetPropsMixin.AwsVpcConfigurationProperty( assign_public_ip="assignPublicIp", security_groups=["securityGroups"], subnets=["subnets"] )
Attributes
- assign_public_ip
Whether the task’s elastic network interface receives a public IP address.
Consider the following when you set this value:
When you use
create-serviceorupdate-service, the default isDISABLED.When the service
deploymentControllerisECS, the value must beDISABLED.
- security_groups
The IDs of the security groups associated with the task or service.
If you don’t specify a security group, the default security group for the VPC is used. There’s a limit of 5 security groups that can be specified. .. epigraph:
All specified security groups must be from the same VPC.
- subnets
The IDs of the subnets associated with the task or service.
There’s a limit of 16 subnets that can be specified. .. epigraph:
All specified subnets must be from the same VPC.
CapacityProviderStrategyItemProperty
- class CfnTaskSetPropsMixin.CapacityProviderStrategyItemProperty(*, base=None, capacity_provider=None, weight=None)
Bases:
objectThe details of a capacity provider strategy.
A capacity provider strategy can be set when using the RunTask or CreateCluster APIs or as the default capacity provider strategy for a cluster with the
CreateClusterAPI.Only capacity providers that are already associated with a cluster and have an
ACTIVEorUPDATINGstatus can be used in a capacity provider strategy. The PutClusterCapacityProviders API is used to associate a capacity provider with a cluster.If specifying a capacity provider that uses an Auto Scaling group, the capacity provider must already be created. New Auto Scaling group capacity providers can be created with the CreateClusterCapacityProvider API operation.
To use a AWS Fargate capacity provider, specify either the
FARGATEorFARGATE_SPOTcapacity providers. The AWS Fargate capacity providers are available to all accounts and only need to be associated with a cluster to be used in a capacity provider strategy.With
FARGATE_SPOT, you can run interruption tolerant tasks at a rate that’s discounted compared to theFARGATEprice.FARGATE_SPOTruns tasks on spare compute capacity. When AWS needs the capacity back, your tasks are interrupted with a two-minute warning.FARGATE_SPOTsupports Linux tasks with the X86_64 architecture on platform version 1.3.0 or later.FARGATE_SPOTsupports Linux tasks with the ARM64 architecture on platform version 1.4.0 or later.A capacity provider strategy can contain a maximum of 20 capacity providers.
- Parameters:
base (
Union[int,float,None]) – The base value designates how many tasks, at a minimum, to run on the specified capacity provider for each service. Only one capacity provider in a capacity provider strategy can have a base defined. If no value is specified, the default value of0is used. Base value characteristics: - Only one capacity provider in a strategy can have a base defined - The default value is0if not specified - The valid range is 0 to 100,000 - Base requirements are satisfied first before weight distributioncapacity_provider (
Optional[str]) – The short name of the capacity provider. This can be either an AWS managed capacity provider (FARGATEorFARGATE_SPOT) or the name of a custom capacity provider that you created.weight (
Union[int,float,None]) – The weight value designates the relative percentage of the total number of tasks launched that should use the specified capacity provider. Theweightvalue is taken into consideration after thebasevalue, if defined, is satisfied. If noweightvalue is specified, the default value of0is used. When multiple capacity providers are specified within a capacity provider strategy, at least one of the capacity providers must have a weight value greater than zero and any capacity providers with a weight of0can’t be used to place tasks. If you specify multiple capacity providers in a strategy that all have a weight of0, anyRunTaskorCreateServiceactions using the capacity provider strategy will fail. Weight value characteristics: - Weight is considered after the base value is satisfied - The default value is0if not specified - The valid range is 0 to 1,000 - At least one capacity provider must have a weight greater than zero - Capacity providers with weight of0cannot place tasks Task distribution logic: - Base satisfaction: The minimum number of tasks specified by the base value are placed on that capacity provider - Weight distribution: After base requirements are met, additional tasks are distributed according to weight ratios Examples: Equal Distribution: Two capacity providers both with weight1will split tasks evenly after base requirements are met. Weighted Distribution: If capacityProviderA has weight1and capacityProviderB has weight4, then for every 1 task on A, 4 tasks will run on B.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_ecs import mixins as ecs_mixins capacity_provider_strategy_item_property = ecs_mixins.CfnTaskSetPropsMixin.CapacityProviderStrategyItemProperty( base=123, capacity_provider="capacityProvider", weight=123 )
Attributes
- base
The base value designates how many tasks, at a minimum, to run on the specified capacity provider for each service.
Only one capacity provider in a capacity provider strategy can have a base defined. If no value is specified, the default value of
0is used.Base value characteristics:
Only one capacity provider in a strategy can have a base defined
The default value is
0if not specifiedThe valid range is 0 to 100,000
Base requirements are satisfied first before weight distribution
- capacity_provider
The short name of the capacity provider.
This can be either an AWS managed capacity provider (
FARGATEorFARGATE_SPOT) or the name of a custom capacity provider that you created.
- weight
The weight value designates the relative percentage of the total number of tasks launched that should use the specified capacity provider.
The
weightvalue is taken into consideration after thebasevalue, if defined, is satisfied.If no
weightvalue is specified, the default value of0is used. When multiple capacity providers are specified within a capacity provider strategy, at least one of the capacity providers must have a weight value greater than zero and any capacity providers with a weight of0can’t be used to place tasks. If you specify multiple capacity providers in a strategy that all have a weight of0, anyRunTaskorCreateServiceactions using the capacity provider strategy will fail.Weight value characteristics:
Weight is considered after the base value is satisfied
The default value is
0if not specifiedThe valid range is 0 to 1,000
At least one capacity provider must have a weight greater than zero
Capacity providers with weight of
0cannot place tasks
Task distribution logic:
Base satisfaction: The minimum number of tasks specified by the base value are placed on that capacity provider
Weight distribution: After base requirements are met, additional tasks are distributed according to weight ratios
Examples:
Equal Distribution: Two capacity providers both with weight
1will split tasks evenly after base requirements are met.Weighted Distribution: If capacityProviderA has weight
1and capacityProviderB has weight4, then for every 1 task on A, 4 tasks will run on B.
LoadBalancerProperty
- class CfnTaskSetPropsMixin.LoadBalancerProperty(*, container_name=None, container_port=None, target_group_arn=None)
Bases:
objectThe load balancer configuration to use with a service or task set.
When you add, update, or remove a load balancer configuration, Amazon ECS starts a new deployment with the updated Elastic Load Balancing configuration. This causes tasks to register to and deregister from load balancers.
We recommend that you verify this on a test environment before you update the Elastic Load Balancing configuration.
A service-linked role is required for services that use multiple target groups. For more information, see Using service-linked roles in the Amazon Elastic Container Service Developer Guide .
- Parameters:
container_name (
Optional[str]) – The name of the container (as it appears in a container definition) to associate with the load balancer. You need to specify the container name when configuring the target group for an Amazon ECS load balancer.container_port (
Union[int,float,None]) – The port on the container to associate with the load balancer. This port must correspond to acontainerPortin the task definition the tasks in the service are using. For tasks that use the EC2 launch type, the container instance they’re launched on must allow ingress traffic on thehostPortof the port mapping.target_group_arn (
Optional[str]) – The full Amazon Resource Name (ARN) of the Elastic Load Balancing target group or groups associated with a service or task set. A target group ARN is only specified when using an Application Load Balancer or Network Load Balancer. For services using theECSdeployment controller, you can specify one or multiple target groups. For more information, see Registering multiple target groups with a service in the Amazon Elastic Container Service Developer Guide . For services using theCODE_DEPLOYdeployment controller, you’re required to define two target groups for the load balancer. For more information, see Blue/green deployment with CodeDeploy in the Amazon Elastic Container Service Developer Guide . .. epigraph:: If your service’s task definition uses theawsvpcnetwork mode, you must chooseipas the target type, notinstance. Do this when creating your target groups because tasks that use theawsvpcnetwork mode are associated with an elastic network interface, not an Amazon EC2 instance. This network mode is required for the Fargate launch type.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_ecs import mixins as ecs_mixins load_balancer_property = ecs_mixins.CfnTaskSetPropsMixin.LoadBalancerProperty( container_name="containerName", container_port=123, target_group_arn="targetGroupArn" )
Attributes
- container_name
The name of the container (as it appears in a container definition) to associate with the load balancer.
You need to specify the container name when configuring the target group for an Amazon ECS load balancer.
- container_port
The port on the container to associate with the load balancer.
This port must correspond to a
containerPortin the task definition the tasks in the service are using. For tasks that use the EC2 launch type, the container instance they’re launched on must allow ingress traffic on thehostPortof the port mapping.
- target_group_arn
The full Amazon Resource Name (ARN) of the Elastic Load Balancing target group or groups associated with a service or task set.
A target group ARN is only specified when using an Application Load Balancer or Network Load Balancer.
For services using the
ECSdeployment controller, you can specify one or multiple target groups. For more information, see Registering multiple target groups with a service in the Amazon Elastic Container Service Developer Guide .For services using the
CODE_DEPLOYdeployment controller, you’re required to define two target groups for the load balancer. For more information, see Blue/green deployment with CodeDeploy in the Amazon Elastic Container Service Developer Guide . .. epigraph:If your service's task definition uses the ``awsvpc`` network mode, you must choose ``ip`` as the target type, not ``instance`` . Do this when creating your target groups because tasks that use the ``awsvpc`` network mode are associated with an elastic network interface, not an Amazon EC2 instance. This network mode is required for the Fargate launch type.
NetworkConfigurationProperty
- class CfnTaskSetPropsMixin.NetworkConfigurationProperty(*, aws_vpc_configuration=None)
Bases:
objectThe network configuration for a task or service.
- Parameters:
aws_vpc_configuration (
Union[IResolvable,AwsVpcConfigurationProperty,Dict[str,Any],None]) – The VPC subnets and security groups that are associated with a task. .. epigraph:: All specified subnets and security groups must be from the same VPC.- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_ecs import mixins as ecs_mixins network_configuration_property = ecs_mixins.CfnTaskSetPropsMixin.NetworkConfigurationProperty( aws_vpc_configuration=ecs_mixins.CfnTaskSetPropsMixin.AwsVpcConfigurationProperty( assign_public_ip="assignPublicIp", security_groups=["securityGroups"], subnets=["subnets"] ) )
Attributes
- aws_vpc_configuration
The VPC subnets and security groups that are associated with a task.
All specified subnets and security groups must be from the same VPC.
ScaleProperty
- class CfnTaskSetPropsMixin.ScaleProperty(*, unit=None, value=None)
Bases:
objectA floating-point percentage of the desired number of tasks to place and keep running in the task set.
- Parameters:
unit (
Optional[str]) – The unit of measure for the scale value.value (
Union[int,float,None]) – The value, specified as a percent total of a service’sdesiredCount, to scale the task set. Accepted values are numbers between 0 and 100.
- See:
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecs-taskset-scale.html
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_ecs import mixins as ecs_mixins scale_property = ecs_mixins.CfnTaskSetPropsMixin.ScaleProperty( unit="unit", value=123 )
Attributes
- unit
The unit of measure for the scale value.
- value
The value, specified as a percent total of a service’s
desiredCount, to scale the task set.Accepted values are numbers between 0 and 100.
ServiceRegistryProperty
- class CfnTaskSetPropsMixin.ServiceRegistryProperty(*, container_name=None, container_port=None, port=None, registry_arn=None)
Bases:
objectThe details for the service registry.
Each service may be associated with one service registry. Multiple service registries for each service are not supported.
When you add, update, or remove the service registries configuration, Amazon ECS starts a new deployment. New tasks are registered and deregistered to the updated service registry configuration.
- Parameters:
container_name (
Optional[str]) – The container name value to be used for your service discovery service. It’s already specified in the task definition. If the task definition that your service task specifies uses thebridgeorhostnetwork mode, you must specify acontainerNameandcontainerPortcombination from the task definition. If the task definition that your service task specifies uses theawsvpcnetwork mode and a type SRV DNS record is used, you must specify either acontainerNameandcontainerPortcombination or aportvalue. However, you can’t specify both.container_port (
Union[int,float,None]) – The port value to be used for your service discovery service. It’s already specified in the task definition. If the task definition your service task specifies uses thebridgeorhostnetwork mode, you must specify acontainerNameandcontainerPortcombination from the task definition. If the task definition your service task specifies uses theawsvpcnetwork mode and a type SRV DNS record is used, you must specify either acontainerNameandcontainerPortcombination or aportvalue. However, you can’t specify both.port (
Union[int,float,None]) – The port value used if your service discovery service specified an SRV record. This field might be used if both theawsvpcnetwork mode and SRV records are used.registry_arn (
Optional[str]) – The Amazon Resource Name (ARN) of the service registry. The currently supported service registry is AWS Cloud Map . For more information, see CreateService .
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_ecs import mixins as ecs_mixins service_registry_property = ecs_mixins.CfnTaskSetPropsMixin.ServiceRegistryProperty( container_name="containerName", container_port=123, port=123, registry_arn="registryArn" )
Attributes
- container_name
The container name value to be used for your service discovery service.
It’s already specified in the task definition. If the task definition that your service task specifies uses the
bridgeorhostnetwork mode, you must specify acontainerNameandcontainerPortcombination from the task definition. If the task definition that your service task specifies uses theawsvpcnetwork mode and a type SRV DNS record is used, you must specify either acontainerNameandcontainerPortcombination or aportvalue. However, you can’t specify both.
- container_port
The port value to be used for your service discovery service.
It’s already specified in the task definition. If the task definition your service task specifies uses the
bridgeorhostnetwork mode, you must specify acontainerNameandcontainerPortcombination from the task definition. If the task definition your service task specifies uses theawsvpcnetwork mode and a type SRV DNS record is used, you must specify either acontainerNameandcontainerPortcombination or aportvalue. However, you can’t specify both.
- port
The port value used if your service discovery service specified an SRV record.
This field might be used if both the
awsvpcnetwork mode and SRV records are used.
- registry_arn
The Amazon Resource Name (ARN) of the service registry.
The currently supported service registry is AWS Cloud Map . For more information, see CreateService .