class CfnService (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.ECS.CfnService |
![]() | software.amazon.awscdk.services.ecs.CfnService |
![]() | aws_cdk.aws_ecs.CfnService |
![]() | @aws-cdk/aws-ecs » CfnService |
Implements
IConstruct
, IConstruct
, IDependable
, IInspectable
A CloudFormation AWS::ECS::Service
.
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
ServiceConnectService
is configured. This is because AWS CloudFormation creates the replacement service first, but eachServiceConnectService
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.
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as ecs from '@aws-cdk/aws-ecs';
const cfnService = new ecs.CfnService(this, 'MyCfnService', /* all optional props */ {
capacityProviderStrategy: [{
base: 123,
capacityProvider: 'capacityProvider',
weight: 123,
}],
cluster: 'cluster',
deploymentConfiguration: {
alarms: {
alarmNames: ['alarmNames'],
enable: false,
rollback: false,
},
deploymentCircuitBreaker: {
enable: false,
rollback: false,
},
maximumPercent: 123,
minimumHealthyPercent: 123,
},
deploymentController: {
type: 'type',
},
desiredCount: 123,
enableEcsManagedTags: false,
enableExecuteCommand: false,
healthCheckGracePeriodSeconds: 123,
launchType: 'launchType',
loadBalancers: [{
containerPort: 123,
// the properties below are optional
containerName: 'containerName',
loadBalancerName: 'loadBalancerName',
targetGroupArn: 'targetGroupArn',
}],
networkConfiguration: {
awsvpcConfiguration: {
subnets: ['subnets'],
// the properties below are optional
assignPublicIp: 'assignPublicIp',
securityGroups: ['securityGroups'],
},
},
placementConstraints: [{
type: 'type',
// the properties below are optional
expression: 'expression',
}],
placementStrategies: [{
type: 'type',
// the properties below are optional
field: 'field',
}],
platformVersion: 'platformVersion',
propagateTags: 'propagateTags',
role: 'role',
schedulingStrategy: 'schedulingStrategy',
serviceConnectConfiguration: {
enabled: false,
// the properties below are optional
logConfiguration: {
logDriver: 'logDriver',
options: {
optionsKey: 'options',
},
secretOptions: [{
name: 'name',
valueFrom: 'valueFrom',
}],
},
namespace: 'namespace',
services: [{
portName: 'portName',
// the properties below are optional
clientAliases: [{
port: 123,
// the properties below are optional
dnsName: 'dnsName',
}],
discoveryName: 'discoveryName',
ingressPortOverride: 123,
}],
},
serviceName: 'serviceName',
serviceRegistries: [{
containerName: 'containerName',
containerPort: 123,
port: 123,
registryArn: 'registryArn',
}],
tags: [{
key: 'key',
value: 'value',
}],
taskDefinition: 'taskDefinition',
});
Initializer
new CfnService(scope: Construct, id: string, props?: CfnServiceProps)
Parameters
- scope
Construct
— - scope in which this resource is defined. - id
string
— - scoped id of the resource. - props
Cfn
— - resource properties.Service Props
Create a new AWS::ECS::Service
.
Construct Props
Name | Type | Description |
---|---|---|
capacity | IResolvable | IResolvable | Capacity [] | The capacity provider strategy to use for the service. |
cluster? | string | The short name or full Amazon Resource Name (ARN) of the cluster that you run your service on. |
deployment | IResolvable | Deployment | Optional deployment parameters that control how many tasks run during the deployment and the ordering of stopping and starting tasks. |
deployment | IResolvable | Deployment | The deployment controller to use for the service. |
desired | number | The number of instantiations of the specified task definition to place and keep running in your service. |
enable | boolean | IResolvable | Specifies whether to turn on Amazon ECS managed tags for the tasks within the service. |
enable | boolean | IResolvable | Determines whether the execute command functionality is turned on for the service. |
health | number | 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. |
launch | string | The launch type on which to run your service. |
load | IResolvable | Load | IResolvable [] | A list of load balancer objects to associate with the service. |
network | Network | IResolvable | The network configuration for the service. |
placement | IResolvable | Placement | IResolvable [] | An array of placement constraint objects to use for tasks in your service. |
placement | IResolvable | Placement | IResolvable [] | The placement strategy objects to use for tasks in your service. |
platform | string | The platform version that your tasks in the service are running on. |
propagate | string | Specifies whether to propagate the tags from the task definition to the task. |
role? | 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. |
scheduling | string | The scheduling strategy to use for the service. For more information, see Services . |
service | IResolvable | Service | The configuration for this service to discover and connect to services, and be discovered by, and connected from, other services within a namespace. |
service | string | The name of your service. |
service | IResolvable | Service | IResolvable [] | The details of the service discovery registry to associate with this service. For more information, see Service discovery . |
tags? | Cfn [] | The metadata that you apply to the service to help you categorize and organize them. |
task | string | The family and revision ( family:revision ) or full ARN of the task definition to run in your service. |
capacityProviderStrategy?
Type:
IResolvable
|
IResolvable
|
Capacity
[]
(optional)
The capacity provider strategy to use for the service.
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 may contain a maximum of 6 capacity providers.
cluster?
Type:
string
(optional)
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.
deploymentConfiguration?
Type:
IResolvable
|
Deployment
(optional)
Optional deployment parameters that control how many tasks run during the deployment and the ordering of stopping and starting tasks.
deploymentController?
Type:
IResolvable
|
Deployment
(optional)
The deployment controller to use for the service.
If no deployment controller is specified, the default value of ECS
is used.
desiredCount?
Type:
number
(optional)
The number of instantiations of the specified task definition to place and keep running in your service.
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.
enableEcsManagedTags?
Type:
boolean |
IResolvable
(optional)
Specifies whether to turn on Amazon ECS managed tags for the tasks within the service.
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 need to set the propagateTags
request parameter.
enableExecuteCommand?
Type:
boolean |
IResolvable
(optional)
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.
healthCheckGracePeriodSeconds?
Type:
number
(optional)
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.
This is only used when your service is configured to use a load balancer. If your service has a load balancer defined and you don't specify a health check grace period value, the default value of 0
is used.
If you do not use an Elastic Load Balancing, we recommend that you use the startPeriod
in the task definition health check parameters. For more information, see Health check .
If your service's tasks take a while to start and respond to Elastic Load Balancing health checks, you can specify a health check grace period of up to 2,147,483,647 seconds (about 69 years). During that time, the Amazon ECS service scheduler ignores health check status. This grace period can prevent the service scheduler from marking tasks as unhealthy and stopping them before they have time to come up.
launchType?
Type:
string
(optional)
The launch type on which to run your service.
For more information, see Amazon ECS Launch Types in the Amazon Elastic Container Service Developer Guide .
loadBalancers?
Type:
IResolvable
|
Load
|
IResolvable
[]
(optional)
A list of load balancer objects to associate with the service.
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 .
networkConfiguration?
Type:
Network
|
IResolvable
(optional)
The network configuration for the service.
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 .
placementConstraints?
Type:
IResolvable
|
Placement
|
IResolvable
[]
(optional)
An array of placement constraint objects to use for tasks in your service.
You can specify a maximum of 10 constraints for each task. This limit includes constraints in the task definition and those specified at runtime.
placementStrategies?
Type:
IResolvable
|
Placement
|
IResolvable
[]
(optional)
The placement strategy objects to use for tasks in your service.
You can specify a maximum of 5 strategy rules for each service.
platformVersion?
Type:
string
(optional)
The platform version that your tasks in the service are running on.
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 .
propagateTags?
Type:
string
(optional)
Specifies whether to propagate the tags from the task definition to the task.
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.
The default is NONE
.
role?
Type:
string
(optional)
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.
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 .
schedulingStrategy?
Type:
string
(optional)
The scheduling strategy to use for the service. For more information, see Services .
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 theCODE_DEPLOY
orEXTERNAL
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
orEXTERNAL
deployment controller types don't support theDAEMON
scheduling strategy.
serviceConnectConfiguration?
Type:
IResolvable
|
Service
(optional)
The configuration for this service to discover and connect to services, and be discovered by, and connected from, other services within a namespace.
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 .
serviceName?
Type:
string
(optional)
The name of your service.
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 eachServiceName
must be unique in the cluster.
serviceRegistries?
Type:
IResolvable
|
Service
|
IResolvable
[]
(optional)
The details of the service discovery registry to associate with this service. For more information, see Service discovery .
Each service may be associated with one service registry. Multiple service registries for each service isn't supported.
tags?
Type:
Cfn
[]
(optional)
The metadata that you apply to the service to help you categorize and organize them.
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: + - = . _ : / @.
- Tag keys and values are case-sensitive.
- Do not use
aws:
,AWS:
, or any upper or lowercase combination of such as a prefix for either keys or values as it is reserved for AWS use. You cannot edit or delete tag keys or values with this prefix. Tags with this prefix do not count against your tags per resource limit.
taskDefinition?
Type:
string
(optional)
The family
and revision
( family:revision
) or full ARN of the task definition to run in your service.
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 .
Properties
Name | Type | Description |
---|---|---|
attr | string | The name of the Amazon ECS service, such as sample-webapp . |
attr | string | Not currently supported in AWS CloudFormation . |
cfn | ICfn | Options for this resource, such as condition, update policy etc. |
cfn | { [string]: any } | |
cfn | string | AWS resource type. |
creation | string[] | |
logical | string | The logical ID for this CloudFormation stack element. |
node | Construct | The construct tree node associated with this construct. |
ref | string | Return a string that will be resolved to a CloudFormation { Ref } for this element. |
stack | Stack | The stack in which this element is defined. |
tags | Tag | The metadata that you apply to the service to help you categorize and organize them. |
capacity | IResolvable | IResolvable | Capacity [] | The capacity provider strategy to use for the service. |
cluster? | string | The short name or full Amazon Resource Name (ARN) of the cluster that you run your service on. |
deployment | IResolvable | Deployment | Optional deployment parameters that control how many tasks run during the deployment and the ordering of stopping and starting tasks. |
deployment | IResolvable | Deployment | The deployment controller to use for the service. |
desired | number | The number of instantiations of the specified task definition to place and keep running in your service. |
enable | boolean | IResolvable | Specifies whether to turn on Amazon ECS managed tags for the tasks within the service. |
enable | boolean | IResolvable | Determines whether the execute command functionality is turned on for the service. |
health | number | 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. |
launch | string | The launch type on which to run your service. |
load | IResolvable | Load | IResolvable [] | A list of load balancer objects to associate with the service. |
network | Network | IResolvable | The network configuration for the service. |
placement | IResolvable | Placement | IResolvable [] | An array of placement constraint objects to use for tasks in your service. |
placement | IResolvable | Placement | IResolvable [] | The placement strategy objects to use for tasks in your service. |
platform | string | The platform version that your tasks in the service are running on. |
propagate | string | Specifies whether to propagate the tags from the task definition to the task. |
role? | 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. |
scheduling | string | The scheduling strategy to use for the service. For more information, see Services . |
service | IResolvable | Service | The configuration for this service to discover and connect to services, and be discovered by, and connected from, other services within a namespace. |
service | string | The name of your service. |
service | IResolvable | Service | IResolvable [] | The details of the service discovery registry to associate with this service. For more information, see Service discovery . |
task | string | The family and revision ( family:revision ) or full ARN of the task definition to run in your service. |
static CFN_RESOURCE_TYPE_NAME | string | The CloudFormation resource type name for this resource class. |
attrName
Type:
string
The name of the Amazon ECS service, such as sample-webapp
.
attrServiceArn
Type:
string
Not currently supported in AWS CloudFormation .
cfnOptions
Type:
ICfn
Options for this resource, such as condition, update policy etc.
cfnProperties
Type:
{ [string]: any }
cfnResourceType
Type:
string
AWS resource type.
creationStack
Type:
string[]
logicalId
Type:
string
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)
.
node
Type:
Construct
The construct tree node associated with this construct.
ref
Type:
string
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 })
.
stack
Type:
Stack
The stack in which this element is defined.
CfnElements must be defined within a stack scope (directly or indirectly).
tags
Type:
Tag
The metadata that you apply to the service to help you categorize and organize them.
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: + - = . _ : / @.
- Tag keys and values are case-sensitive.
- Do not use
aws:
,AWS:
, or any upper or lowercase combination of such as a prefix for either keys or values as it is reserved for AWS use. You cannot edit or delete tag keys or values with this prefix. Tags with this prefix do not count against your tags per resource limit.
capacityProviderStrategy?
Type:
IResolvable
|
IResolvable
|
Capacity
[]
(optional)
The capacity provider strategy to use for the service.
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 may contain a maximum of 6 capacity providers.
cluster?
Type:
string
(optional)
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.
deploymentConfiguration?
Type:
IResolvable
|
Deployment
(optional)
Optional deployment parameters that control how many tasks run during the deployment and the ordering of stopping and starting tasks.
deploymentController?
Type:
IResolvable
|
Deployment
(optional)
The deployment controller to use for the service.
If no deployment controller is specified, the default value of ECS
is used.
desiredCount?
Type:
number
(optional)
The number of instantiations of the specified task definition to place and keep running in your service.
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.
enableEcsManagedTags?
Type:
boolean |
IResolvable
(optional)
Specifies whether to turn on Amazon ECS managed tags for the tasks within the service.
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 need to set the propagateTags
request parameter.
enableExecuteCommand?
Type:
boolean |
IResolvable
(optional)
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.
healthCheckGracePeriodSeconds?
Type:
number
(optional)
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.
This is only used when your service is configured to use a load balancer. If your service has a load balancer defined and you don't specify a health check grace period value, the default value of 0
is used.
If you do not use an Elastic Load Balancing, we recommend that you use the startPeriod
in the task definition health check parameters. For more information, see Health check .
If your service's tasks take a while to start and respond to Elastic Load Balancing health checks, you can specify a health check grace period of up to 2,147,483,647 seconds (about 69 years). During that time, the Amazon ECS service scheduler ignores health check status. This grace period can prevent the service scheduler from marking tasks as unhealthy and stopping them before they have time to come up.
launchType?
Type:
string
(optional)
The launch type on which to run your service.
For more information, see Amazon ECS Launch Types in the Amazon Elastic Container Service Developer Guide .
loadBalancers?
Type:
IResolvable
|
Load
|
IResolvable
[]
(optional)
A list of load balancer objects to associate with the service.
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 .
networkConfiguration?
Type:
Network
|
IResolvable
(optional)
The network configuration for the service.
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 .
placementConstraints?
Type:
IResolvable
|
Placement
|
IResolvable
[]
(optional)
An array of placement constraint objects to use for tasks in your service.
You can specify a maximum of 10 constraints for each task. This limit includes constraints in the task definition and those specified at runtime.
placementStrategies?
Type:
IResolvable
|
Placement
|
IResolvable
[]
(optional)
The placement strategy objects to use for tasks in your service.
You can specify a maximum of 5 strategy rules for each service.
platformVersion?
Type:
string
(optional)
The platform version that your tasks in the service are running on.
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 .
propagateTags?
Type:
string
(optional)
Specifies whether to propagate the tags from the task definition to the task.
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.
The default is NONE
.
role?
Type:
string
(optional)
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.
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 .
schedulingStrategy?
Type:
string
(optional)
The scheduling strategy to use for the service. For more information, see Services .
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 theCODE_DEPLOY
orEXTERNAL
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
orEXTERNAL
deployment controller types don't support theDAEMON
scheduling strategy.
serviceConnectConfiguration?
Type:
IResolvable
|
Service
(optional)
The configuration for this service to discover and connect to services, and be discovered by, and connected from, other services within a namespace.
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 .
serviceName?
Type:
string
(optional)
The name of your service.
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 eachServiceName
must be unique in the cluster.
serviceRegistries?
Type:
IResolvable
|
Service
|
IResolvable
[]
(optional)
The details of the service discovery registry to associate with this service. For more information, see Service discovery .
Each service may be associated with one service registry. Multiple service registries for each service isn't supported.
taskDefinition?
Type:
string
(optional)
The family
and revision
( family:revision
) or full ARN of the task definition to run in your service.
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 .
static CFN_RESOURCE_TYPE_NAME
Type:
string
The CloudFormation resource type name for this resource class.
Methods
Name | Description |
---|---|
add | Syntactic sugar for addOverride(path, undefined) . |
add | Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned. |
add | Add a value to the CloudFormation Resource Metadata. |
add | Adds an override to the synthesized CloudFormation resource. |
add | Adds an override that deletes the value of a property from the resource definition. |
add | Adds an override to a resource property. |
apply | Sets the deletion policy of the resource based on the removal policy specified. |
get | Returns a token for an runtime attribute of this resource. |
get | Retrieve a value value from the CloudFormation Resource Metadata. |
inspect(inspector) | Examines the CloudFormation resource and discloses attributes. |
override | Overrides the auto-generated logical ID with a specific ID. |
to | Returns a string representation of this construct. |
protected render |
addDeletionOverride(path)
public addDeletionOverride(path: string): void
Parameters
- path
string
— The path of the value to delete.
Syntactic sugar for addOverride(path, undefined)
.
addDependsOn(target)
public addDependsOn(target: CfnResource): void
Parameters
- target
Cfn
Resource
Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
addMetadata(key, value)
public addMetadata(key: string, value: any): void
Parameters
- key
string
- value
any
Add a value to the CloudFormation Resource Metadata.
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.)
addOverride(path, value)
public addOverride(path: string, value: any): void
Parameters
- path
string
— - The path of the property, you can use dot notation to override values in complex types. - value
any
— - The value.
Adds an override to the synthesized CloudFormation resource.
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,
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes', ['myattribute']);
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.1.ProjectionType', 'INCLUDE');
would add the overrides
"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.
addPropertyDeletionOverride(propertyPath)
public addPropertyDeletionOverride(propertyPath: string): void
Parameters
- propertyPath
string
— The path to the property.
Adds an override that deletes the value of a property from the resource definition.
addPropertyOverride(propertyPath, value)
public addPropertyOverride(propertyPath: string, value: any): void
Parameters
- propertyPath
string
— The path of the property. - value
any
— The value.
Adds an override to a resource property.
Syntactic sugar for addOverride("Properties.<...>", value)
.
applyRemovalPolicy(policy?, options?)
public applyRemovalPolicy(policy?: RemovalPolicy, options?: RemovalPolicyOptions): void
Parameters
- policy
Removal
Policy - options
Removal
Policy Options
Sets the deletion policy of the resource based on the removal policy specified.
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
).
getAtt(attributeName)
public getAtt(attributeName: string): Reference
Parameters
- attributeName
string
— The name of the attribute.
Returns
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.
getMetadata(key)
public getMetadata(key: string): any
Parameters
- key
string
Returns
any
Retrieve a value value from the CloudFormation Resource Metadata.
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.)
inspect(inspector)
public inspect(inspector: TreeInspector): void
Parameters
- inspector
Tree
— - tree inspector to collect and process attributes.Inspector
Examines the CloudFormation resource and discloses attributes.
overrideLogicalId(newLogicalId)
public overrideLogicalId(newLogicalId: string): void
Parameters
- newLogicalId
string
— The new logical ID to use for this stack element.
Overrides the auto-generated logical ID with a specific ID.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
protected renderProperties(props)
protected renderProperties(props: { [string]: any }): { [string]: any }
Parameters
- props
{ [string]: any }
Returns
{ [string]: any }