Amazon ECS service definition parameters
A service definition defines how to run your Amazon ECS service. The following parameters can be specified in a service definition.
Launch type
launchType
-
Type: String
Valid values:
EC2
|FARGATE
|EXTERNAL
Required: No
The launch type on which to run your service. If a launch type is not specified, the default
capacityProviderStrategy
is used by default. For more information, see Amazon ECS launch types.If a
launchType
is specified, thecapacityProviderStrategy
parameter must be omitted.
Capacity provider strategy
capacityProviderStrategy
-
Type: Array of objects
Required: No
The capacity provider strategy to use for the service.
A capacity provider strategy consists of one or more capacity providers along with the
base
andweight
to assign to them. A capacity provider must be associated with the cluster to be used in a capacity provider strategy. The PutClusterCapacityProviders API is used to associate a capacity provider with a cluster. Only capacity providers with anACTIVE
orUPDATING
status can be used.If a
capacityProviderStrategy
is specified, thelaunchType
parameter must be omitted. If nocapacityProviderStrategy
orlaunchType
is specified, thedefaultCapacityProviderStrategy
for the cluster is used.If you want to specify a capacity provider that uses an Auto Scaling group, the capacity provider must already be created. New capacity providers can be created with the CreateCapacityProvider API operation.
To use an AWS Fargate capacity provider, specify either the
FARGATE
orFARGATE_SPOT
capacity providers. The AWS Fargate capacity providers are available to all accounts and only need to be associated with a cluster to be used.The PutClusterCapacityProviders API operation is used to update the list of available capacity providers for a cluster after the cluster is created.
capacityProvider
-
Type: String
Required: Yes
The short name or full Amazon Resource Name (ARN) of the capacity provider.
weight
-
Type: Integer
Valid range: Integers between 0 and 1,000.
Required: No
The weight value designates the relative percentage of the total number of tasks launched that use the specified capacity provider.
For example, assume that you have a strategy that contains two capacity providers and both have a weight of one. When the base is satisfied, the tasks split evenly across the two capacity providers. Using that same logic, assume that you specify a weight of 1 for capacityProviderA and a weight of 4 for capacityProviderB. Then, for every one task that is run using capacityProviderA, four tasks use capacityProviderB.
base
-
Type: Integer
Valid range: Integers between 0 and 100,000.
Required: No
The base value designates how many tasks, at a minimum, to run on the specified capacity provider. Only one capacity provider in a capacity provider strategy can have a base defined.
Task definition
taskDefinition
-
Type: String
Required: No
The
family
andrevision
(family:revision
) or full Amazon Resource Name (ARN) of the task definition to run in your service. If arevision
isn't specified, the latestACTIVE
revision of the specified family is used.A task definition must be specified when using the rolling update (
ECS
) deployment controller.
Platform operating system
platformFamily
-
Type: string
Required: Conditional
Default: Linux
This parameter is required for Amazon ECS services hosted on Fargate.
This parameter is ignored for Amazon ECS services hosted on Amazon EC2.
The operating system on the containers that runs the service. The valid values are
LINUX
,WINDOWS_SERVER_2019_FULL
,WINDOWS_SERVER_2019_CORE
,WINDOWS_SERVER_2022_FULL
, andWINDOWS_SERVER_2022_CORE
.The
platformFamily
value for every task that you specify for the service must match the serviceplatformFamily
value. For example, if you set theplatformFamily
toWINDOWS_SERVER_2019_FULL
, theplatformFamily
value for all the tasks must beWINDOWS_SERVER_2019_FULL
.
Platform version
platformVersion
-
Type: String
Required: No
The platform version on which your tasks in the service are running. A platform version is only specified for tasks using the Fargate launch type. If one is not specified, the latest version (
LATEST
) is used by default.AWS Fargate platform versions are used to refer to a specific runtime environment for the Fargate task infrastructure. When specifying the
LATEST
platform version when running a task or creating a service, you get the most current platform version available for your tasks. When you scale up your service, those tasks receive the platform version that was specified on the service's current deployment. For more information, see Fargate platform versions for Amazon ECS.Note
Platform versions are not specified for tasks using the EC2 launch type.
Cluster
cluster
-
Type: String
Required: No
The short name or full Amazon Resource Name (ARN) of the cluster on which to run your service. If you do not specify a cluster, the
default
cluster is assumed.
Service name
serviceName
-
Type: String
Required: Yes
The name of your service. Up to 255 letters (uppercase and lowercase), numbers, hyphens, and underscores 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.
Scheduling strategy
schedulingStrategy
-
Type: String
Valid values:
REPLICA
|DAEMON
Required: No
The scheduling strategy to use. If no scheduling strategy is specified, the
REPLICA
strategy is used. For more information, see Amazon ECS 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. For more information, see Replica strategy. -
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. When using this strategy, there is no need to specify a desired number of tasks, a task placement strategy, or use Service Auto Scaling policies. For more information, see Daemon strategy.Note
Fargate tasks do not support the
DAEMON
scheduling strategy.
-
Desired count
desiredCount
-
Type: Integer
Required: No
The number of instantiations of the specified task definition to place and keep running in your service.
This parameter is required if the
REPLICA
scheduling strategy is used. If the service uses theDAEMON
scheduling strategy, this parameter is optional.
Deployment configuration
deploymentConfiguration
-
Type: Object
Required: No
Optional deployment parameters that control how many tasks run during the deployment and the ordering of stopping and starting tasks.
maximumPercent
-
Type: Integer
Required: No
If a service is using the rolling update (
ECS
) deployment type, themaximumPercent
parameter represents an upper limit on the number of your service's tasks that are allowed in theRUNNING
,STOPPING
, orPENDING
state during a deployment. It is expressed as a percentage of thedesiredCount
that is rounded down to the nearest integer. You can use this parameter to define the deployment batch size. For example, if your service is using theREPLICA
service scheduler and has adesiredCount
of four tasks and amaximumPercent
value of 200%, the scheduler starts four new tasks before stopping the four older tasks. This is provided that the cluster resources required to do this are available. The defaultmaximumPercent
value for a service using theREPLICA
service scheduler is 200%.The Amazon ECS scheduler uses this parameter to replace unhealthy tasks by starting replacement tasks first and then stopping the unhealthy tasks, as long as cluster resources for starting replacement tasks are available. For more information about how the scheduler replaces unhealthy tasks, see Amazon ECS services.
If your service is using the
DAEMON
service scheduler type, themaximumPercent
should remain at 100%. This is the default value.The maximum number of tasks during a deployment is the
desiredCount
multiplied by themaximumPercent
/100, rounded down to the nearest integer value.If a service is using either the blue/green (
CODE_DEPLOY
) orEXTERNAL
deployment types and tasks that use the EC2 launch type, the maximum percent value is set to the default value. The value is used to define the upper limit on the number of the tasks in the service that remain in theRUNNING
state while the container instances are in theDRAINING
state.Note
You can't specify a custom
maximumPercent
value for a service that uses either the blue/green (CODE_DEPLOY
) orEXTERNAL
deployment types and has tasks that use the EC2 launch type.If the service uses either the blue/green (
CODE_DEPLOY
) orEXTERNAL
deployment types, and the tasks in the service use the Fargate launch type, the maximum percent value is not used. The value is still returned when describing your service. minimumHealthyPercent
-
Type: Integer
Required: No
If a service is using the rolling update (
ECS
) deployment type, theminimumHealthyPercent
represents a lower limit on the number of your service's tasks that must remain in theRUNNING
state during a deployment. This is expressed as a percentage of thedesiredCount
that is rounded up to the nearest integer. You can use this parameter to deploy without using additional cluster capacity.For example, if your service has a
desiredCount
of four tasks, aminimumHealthyPercent
of 50%, and amaximumPercent
of 100%, the service scheduler stops two existing tasks to free up cluster capacity before starting two new tasks.If any tasks are unhealthy and if
maximumPercent
doesn't allow the Amazon ECS scheduler to start replacement tasks, the scheduler stops the unhealthy tasks one-by-one — using theminimumHealthyPercent
as a constraint — to clear up capacity to launch replacement tasks. For more information about how the scheduler replaces unhealthy tasks, see Amazon ECS services.For services that do not use a load balancer, consider the following:
-
A service is considered healthy if all essential containers within the tasks in the service pass their health checks.
-
If a task has no essential containers with a health check defined, the service scheduler waits for 40 seconds after a task reaches a
RUNNING
state before the task is counted towards the minimum healthy percent total. -
If a task has one or more essential containers with a health check defined, the service scheduler waits for the task to reach a healthy status before counting it towards the minimum healthy percent total. A task is considered healthy when all essential containers within the task have passed their health checks. The amount of time the service scheduler can wait for is determined by the container health check settings. For more information, see Health check.
For services that do use a load balancer, consider the following:
-
If a task has no essential containers with a health check defined, the service scheduler waits for the load balancer target group health check to return a healthy status before counting the task towards the minimum healthy percent total.
-
If a task has an essential container with a health check defined, the service scheduler waits for both the task to reach a healthy status and the load balancer target group health check to return a healthy status before counting the task towards the minimum healthy percent total.
The default value for a replica service for
minimumHealthyPercent
is 100%. The defaultminimumHealthyPercent
value for a service using theDAEMON
service schedule is 0% for the AWS CLI, the AWS SDKs, and the APIs and 50% for the AWS Management Console.The minimum number of healthy tasks during a deployment is the
desiredCount
multiplied by theminimumHealthyPercent
/100, rounded up to the nearest integer value.If a service is using either the blue/green (
CODE_DEPLOY
) orEXTERNAL
deployment types and is running tasks that use the EC2 launch type, the minimum healthy percent value is set to the default value. The value is used to define the lower limit on the number of the tasks in the service that remain in theRUNNING
state while the container instances are in theDRAINING
state.Note
You can't specify a custom
maximumPercent
value for a service that uses either the blue/green (CODE_DEPLOY
) orEXTERNAL
deployment types and has tasks that use the EC2 launch type.If a service is using either the blue/green (
CODE_DEPLOY
) orEXTERNAL
deployment types and is running tasks that use the Fargate launch type, the minimum healthy percent value is not used, although it is returned when describing your service. -
Deployment controller
deploymentController
-
Type: Object
Required: No
The deployment controller to use for the service. If no deployment controller is specified, the
ECS
controller is used. For more information, see Amazon ECS services.type
-
Type: String
Valid values:
ECS
|CODE_DEPLOY
|EXTERNAL
Required: yes
The deployment controller type to use. There are three deployment controller types available:
ECS
-
The rolling update (
ECS
) deployment type involves replacing the current running version of the container with the latest version. The number of containers Amazon ECS adds or removes from the service during a rolling update is controlled by adjusting the minimum and maximum number of healthy tasks allowed during a service deployment, as specified in the deploymentConfiguration. CODE_DEPLOY
-
The blue/green (
CODE_DEPLOY
) deployment type uses the blue/green deployment model powered by CodeDeploy, which allows you to verify a new deployment of a service before sending production traffic to it. EXTERNAL
-
Use the external deployment type when you want to use any third-party deployment controller for full control over the deployment process for an Amazon ECS service.
Task placement
placementConstraints
-
Type: Array of objects
Required: No
An array of placement constraint objects to use for tasks in your service. You can specify a maximum of 10 constraints per task. This limit includes constraints in the task definition and those specified at run time. If you use the Fargate launch type, task placement constraints aren't supported.
type
-
Type: String
Required: No
The type of constraint. Use
distinctInstance
to ensure that each task in a particular group is running on a different container instance. UsememberOf
to restrict the selection to a group of valid candidates. The valuedistinctInstance
is not supported in task definitions. expression
-
Type: String
Required: No
A cluster query language expression to apply to the constraint. You can't specify an expression if the constraint type is
distinctInstance
. For more information, see Create expressions to define container instances for Amazon ECS tasks.
placementStrategy
-
Type: Array of objects
Required: No
The placement strategy objects to use for tasks in your service. You can specify a maximum of four strategy rules per service.
type
-
Type: String
Valid values:
random
|spread
|binpack
Required: No
The type of placement strategy. The
random
placement strategy randomly places tasks on available candidates. Thespread
placement strategy spreads placement across available candidates evenly based on thefield
parameter. Thebinpack
strategy places tasks on available candidates that have the least available amount of the resource that's specified with thefield
parameter. For example, if you binpack on memory, a task is placed on the instance with the least amount of remaining memory but still enough to run the task. field
-
Type: String
Required: No
The field to apply the placement strategy against. For the
spread
placement strategy, valid values areinstanceId
(orhost
, which has the same effect), or any platform or custom attribute that's applied to a container instance, such asattribute:ecs.availability-zone
. For thebinpack
placement strategy, valid values arecpu
andmemory
. For therandom
placement strategy, this field is not used.
Tags
-
Type: Array of objects
Required: No
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. A maximum of 50 tags can be applied to the service. For more information, see Tagging Amazon ECS resources.
key
-
Type: String
Length Constraints: Minimum length of 1. Maximum length of 128.
Required: No
One part of a key-value pair that make up a tag. A key is a general label that acts like a category for more specific tag values.
value
-
Type: String
Length Constraints: Minimum length of 0. Maximum length of 256.
Required: No
The optional part of a key-value pair that make up a tag. A value acts as a descriptor within a tag category (key).
-
Type: Boolean
Valid values:
true
|false
Required: No
Specifies whether to use Amazon ECS managed tags for the tasks in the service. If no value is specified, the default value is
false
. For more information, see Use tags for billing. propagateTags
-
Type: String
Valid values:
TASK_DEFINITION
|SERVICE
Required: No
Specifies whether to copy the tags from the task definition or the service to the tasks in the service. If no value is specified, the tags are not copied. Tags can only be copied to the tasks within the service during service creation. To add tags to a task after service creation or task creation, use the
TagResource
API action.
Network configuration
networkConfiguration
-
Type: Object
Required: No
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 isn't supported for other network modes. If using the Fargate launch type, theawsvpc
network mode is required. For more information about networking for the Amazon EC2 launch type, see Amazon ECS task networking options for the EC2 launch type. For more information about networking for the Fargate launch type, see Amazon ECS task networking options for the Fargate launch type.awsvpcConfiguration
-
Type: Object
Required: No
An object representing the subnets and security groups for a task or service.
subnets
-
Type: Array of strings
Required: Yes
The subnets that are associated with the task or service. There is a limit of 16 subnets that can be specified according to
awsvpcConfiguration
. securityGroups
-
Type: Array of strings
Required: No
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 five security groups that can be specified based on
awsvpcConfiguration
. assignPublicIP
-
Type: String
Valid values:
ENABLED
|DISABLED
Required: No
Whether the task's elastic network interface receives a public IP address. If no value is specified, the default value of
DISABLED
is used.
healthCheckGracePeriodSeconds
-
Type: Integer
Required: No
The period of time, in seconds, that the Amazon ECS service scheduler should ignore unhealthy Elastic Load Balancing target health checks, container health checks, and Route 53 health checks after a task enters a
RUNNING
state. This is only valid if your service is configured to use a load balancer. If your service has a load balancer defined and you do not specify a health check grace period value, the default value of0
is used.If your service's tasks take a while to start and respond to health checks, you can specify a health check grace period of up to 2,147,483,647 seconds during which the ECS service scheduler ignores the health check status. This grace period can prevent the ECS service scheduler from marking tasks as unhealthy and stopping them before they have time to come up.
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 Determine Amazon ECS task health using container health checks. loadBalancers
-
Type: Array of objects
Required: No
A load balancer object representing the load balancers to use with your service. For services that use an Application Load Balancer or Network Load Balancer, there's a limit of five target groups that you can attach to a service.
After you create a service, the load balancer configuration can't be changed from the AWS Management Console. You can use the AWS Copilot, AWS CloudFormation, AWS CLI or SDK to modify the load balancer configuration for the
ECS
rolling deployment controller only, not AWS CodeDeploy blue/green or external. 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. For information about how to modify the configuration, see UpdateService in the Amazon Elastic Container Service API Reference.For Application Load Balancers and Network Load Balancers, this object must contain the load balancer target group ARN, the container name (as it appears in a container definition), and the container port to access from the load balancer. When a task from this service is placed on a container instance, the container instance and port combination is registered as a target in the target group specified.
targetGroupArn
-
Type: String
Required: No
The full Amazon Resource Name (ARN) of the Elastic Load Balancing target group that's associated with a service.
A target group ARN is only specified when using an Application Load Balancer or Network Load Balancer.
loadBalancerName
-
Type: String
Required: No
The name of the load balancer to associate with the service.
If you're using an Application Load Balancer or a Network Load Balancer, omit the load balancer name parameter.
containerName
-
Type: String
Required: No
The name of the container (as it appears in a container definition) to associate with the load balancer.
containerPort
-
Type: Integer
Required: No
The port on the container to associate with the load balancer. This port must correspond to a
containerPort
in the task definition used by tasks in the service. For tasks that use the EC2 launch type, the container instance must allow inbound traffic on thehostPort
of the port mapping.
role
-
Type: String
Required: No
The short name or full 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 a single target group for your service, and your task definition does not use the
awsvpc
network mode. If you specify therole
parameter, you must also specify a load balancer object with theloadBalancers
parameter.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 namebar
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.Important
If your account has already created the Amazon ECS service-linked role, that role is used by default for your service unless you specify a role here. The service-linked role is required if your task definition uses the awsvpc network mode, in which case you should not specify a role here. For more information, see Using service-linked roles for Amazon ECS.
serviceConnectConfiguration
-
Type: Object
Required: No
The configuration for this service to discover and connect to services, and be discovered by, and connected from, other services within a namespace.
For more information, see Use Service Connect to connect Amazon ECS services with short names.
enabled
-
Type: Boolean
Required: Yes
Specifies whether to use Service Connect with this service.
namespace
-
Type: String
Required: No
The short name or full Amazon Resource Name (ARN) of the AWS Cloud Map namespace for use with Service Connect. The namespace must be in the same AWS Region as the Amazon ECS service and cluster. The type of namespace doesn't affect Service Connect. For more information about AWS Cloud Map, see Working with Services in the AWS Cloud Map Developer Guide.
services
-
Type: Array of objects
Required: No
An array of Service Connect service objects. These are names and aliases (also known as endpoints) that are used by other Amazon ECS services to connect to this service.
This field isn't required for a "client" Amazon ECS service that's a member of a namespace only to connect to other services within the namespace. An example is frontend application that accepts incoming requests from either a load balancer that's attached to the service or by other means.
An object selects a port from the task definition, assigns a name for the AWS Cloud Map service, and an array of aliases (also known as endpoints) and ports for client applications to refer to this service.
portName
-
Type: String
Required: Yes
The
portName
must match thename
of one of theportMappings
from all of the containers in the task definition of this Amazon ECS service. discoveryName
-
Type: String
Required: No
The
discoveryName
is the name of the new AWS Cloud Map service that Amazon ECS creates for this Amazon ECS service. This must be unique within the AWS Cloud Map namespace.If this field isn't specified,
portName
is used. clientAliases
-
Type: Array of objects
Required: No
The list of client aliases for this service connect service. You use these to assign names that can be used by client applications. The maximum number of client aliases that you can have in this list is 1.
Each alias ("endpoint") is a DNS name and port number that other Amazon ECS services ("clients") can use to connect to this service.
Each name and port combination must be unique within the namespace.
These names are configured within each task of the client service, not in AWS Cloud Map. DNS requests to resolve these names don't leave the task, and don't count toward the quota of DNS requests per second per elastic network interface.
port
-
Type: Integer
Required: Yes
The listening port number for the service connect proxy. This port is available inside of all of the tasks within the same namespace.
To avoid changing your applications in client Amazon ECS services, set this to the same port that the client application uses by default.
dnsName
-
Type: String
Required: No
The
dnsName
is the name that you use in the applications of client tasks to connect to this service. The name must be a valid DNS label.The default value is the
discoveryName.namespace
if this field is not specified. If thediscoveryName
isn't specified, theportName
from the task definition is used.To avoid changing your applications in client Amazon ECS services, set this to the same name that the client application uses by default. For example, a few common names are
database
,db
, or the lowercase name of a database, such asmysql
orredis
.
ingressPortOverride
-
Type: Integer
Required: No
(Optional) The port number for the Service Connect proxy to listen on.
Use the value of this field to bypass the proxy for traffic on the port number that's specified in the named
portMapping
in the task definition of this application, and then use it in your Amazon VPC security groups to allow traffic into the proxy for this Amazon ECS service.In
awsvpc
mode, the default value is the container port number that's specified in the namedportMapping
in the task definition of this application. Inbridge
mode, the default value is the dynamic ephemeral port of the Service Connect proxy. logConfiguration
-
Type: LogConfiguration Object
Required: No
This defines where the Service Connect proxy logs are published. Use the logs for debugging during unexpected events. This configuration sets the
logConfiguration
parameter in the Service Connect proxy container in each task in this Amazon ECS service. The proxy container isn't specified in the task definition.We recommend that you use the same log configuration as the application containers of the task definition for this Amazon ECS service. For FireLens, this is the log configuration of the application container. It's not the FireLens log router container that uses the
fluent-bit
orfluentd
container image.
serviceRegistries
-
Type: Array of objects
Required: No
The details of the service discovery configuration for your service. For more information, see Use service discovery to connect Amazon ECS services with DNS names.
registryArn
-
Type: String
Required: No
The Amazon Resource Name (ARN)of the service registry. The currently supported service registry is AWS Cloud Map. For more information, see Working with Services in the AWS Cloud Map Developer Guide.
port
-
Type: Integer
Required: No
The port value that's used if your service discovery service specified an SRV record. This field is required if both the
awsvpc
network mode and SRV records are used. containerName
-
Type: String
Required: No
The container name value to be used for your service discovery service. This value is specified in the task definition. If the task definition that your service task specifies uses the
bridge
orhost
network mode, you must specify acontainerName
andcontainerPort
combination from the task definition. If the task definition that your service task specifies uses theawsvpc
network mode and a type SRV DNS record is used, you must specify either acontainerName
andcontainerPort
combination or aport
value, but not both. containerPort
-
Type: Integer
Required: No
The port value to be used for your service discovery service. This value is specified in the task definition. If the task definition your service task specifies uses the
bridge
orhost
network mode, you must specify acontainerName
andcontainerPort
combination from the task definition. If the task definition your service task specifies uses theawsvpc
network mode and a type SRV DNS record is used, you must specify either acontainerName
andcontainerPort
combination or aport
value, but not both.
Client token
clientToken
-
Type: String
Required: No
The unique, case-sensitive identifier that you provide to ensure the idempotency of the request. It can be up to 32 ASCII characters long.
Volume configurations
volumeConfigurations
-
Type: Object
Required: No
The configuration that will be used to create volumes for tasks that are managed by the service. One volume is created for each task in the service. Only volumes that are marked as
configuredAtLaunch
in the task definition can be configured by using this object. This object is required for attaching Amazon EBS data volumes to tasks that are managed by a service. For more information, see Amazon EBS volumes.name
-
Type: String
Required: Yes
The name of a volume that's configured when creating or updating a service. Up to 255 letters (uppercase and lowercase), numbers, underscores (
_
), and hyphens (-
) are allowed. This value must match the volume name that's specified in the task definition. managedEBSVolume
-
Type: Object
Required: No
The volume configuration for Amazon EBS volumes that are attached to tasks that are managed by a service when a service is created or updated.
encrypted
-
Type: Boolean
Required: No
Valid values:
true
|false
Specifies whether the Amazon EBS volume that's attached to tasks managed by a service will be encrypted. If you've turned on Amazon EBS encryption by default for your account, this setting will be overridden, and the volume will be encrypted. For more information about EBS encryption by default, see Enable Amazon EBS encryption by default in the Amazon EBS User Guide.
kmsKeyId
-
Type: String
Required: No
The identifier of the AWS Key Management Service (AWS KMS) key to use for Amazon EBS encryption. If this parameter is not specified, your AWS KMS key for Amazon EBS is used. If
KmsKeyId
is specified, the encrypted state must betrue
.You can specify the KMS key by using any of the following:
-
Key ID – For example,
1234abcd-12ab-34cd-56ef-1234567890ab
. -
Key alias – For example,
alias/ExampleAlias
. -
Key ARN – For example,
arn:aws:kms:us-east-1:012345678910:key/1234abcd-12ab-34cd-56ef-1234567890ab
. -
Alias ARN – For example,
arn:aws:kms:us-east-1:012345678910:alias/ExampleAlias
.
Important
AWS authenticates the KMS key asynchronously. Therefore, if you specify an ID, alias, or ARN that isn't valid, the action can appear to succeed, but it eventually fails. For more information, see Troubleshooting Amazon EBS volume attachment issues.
-
volumeType
-
Type: String
Required: No
Valid values:
gp2
|gp3
|io1
|io2
|sc1
|st1
|standard
The EBS volume type. For more information about volume types, see Amazon EBS volume types in the Amazon EBS User Guide. The default volume type is
gp3
.Note
The
standard
volume type is not supported for Amazon EBS volumes configured for attachment to Fargate tasks. sizeInGiB
-
Type: Integer
Required: No
Valid range: Integers between 1 and 16,384
The size of the EBS volume in gibibytes (GiB). If you do not provide a snapshot ID to configure a volume for attachment, you must provide a size value. If you configure a volume for attachment by using a snapshot, the default value is the snapshot size. You can then specify a size greater than or equal to the snapshot size.
For
gp2
andgp3
volume types, the valid range is 1-16,384.For
io1
andio2
volume types, the valid range is 4-16,384.For
st1
andsc1
volume types, the valid range is 125-16,384.For the
standard
volume type, the valid range is 1-1,024. snapshotId
-
Type: String
Required: No
The ID of the snapshot of an existing EBS volume that's used to create a new volume that's attached to the ECS task.
iops
-
Type: Integer
Required: No
The number of I/O operations per second (IOPS). For
gp3
,io1
, andio2
volumes, this represents the number of IOPS that are provisioned for the volume. Forgp2
volumes, this value represents the baseline performance of the volume and the rate at which the volume accumulates I/O credits for bursting. This parameter is required forio1
andio2
volumes. This parameter is not supported forgp2
,st1
,sc1
, orstandard
volumes.For
gp3
volumes, the valid range of values is 3,000 to 16,000.For
io1
volumes, the valid range of values is 100 to 64,000.For
io2
volumes, the valid range of values is 100 to 64,000. throughput
-
Type: Integer
Required: No
The throughput to provision for volumes that are attached to tasks that are managed by a service.
Important
This parameter is supported only for
gp3
volumes. roleArn
-
Type: String
Required: Yes
The Amazon Resource ARN (ARN) of the infrastructure AWS Identity and Access Management (IAM) role that provides Amazon ECS permissions to manage Amazon EBS resources for your tasks. For more information, see Amazon ECS infrastructure IAM role.
tagSpecifications
-
Type: Object
Required: No
The specification for tags to be applied to serivce managed Amazon EBS volumes.
resourceType
-
Type: String
Required: Yes
Valid values:
volume
The type of resource to tag on creation.
-
Type: Array of objects
Required: No
The metadata that you apply to volumes to help you categorize and organize them. Each tag consists of a key and an optional value, both of which you define.
AmazonECSCreated
andAmazonECSManaged
are reserved tags that added by Amazon ECS on your behalf, so you can specify a maximum of 48 tags of your own. When a volume is deleted, the tags are deleted as well. For more information, see Tagging Amazon ECS resources.key
-
Type: String
Length Constraints: Minimum length of 1. Maximum length of 128.
Required: No
One part of a key-value pair that makes up a tag. A key is a general label that acts like a category for more specific tag values.
value
-
Type: String
Length Constraints: Minimum length of 0. Maximum length of 256.
Required: No
The optional part of a key-value pair that makes up a tag. A value acts as a descriptor within a tag category (key).
propagateTags
-
Type: String
Valid values:
TASK_DEFINITION
|SERVICE
|NONE
Required: No
Specifies whether to copy the tags from the task definition or the service to a volume. If
NONE
is specified or no value is specified, the tags aren't copied.
fileSystemType
-
Type: String
Required: No
Valid values:
xfs
|ext3
|ext4
|NTFS
The type of file system on a volume. The volume's file system type determines how data is stored and retrieved in the volume. For volumes created from a snapshot, you must specify the same filesystem type that the volume was using when the snapshot was created. If there is a filesystem type mismatch, the task will fail to start.
The valid values for Linux are
xfs
, ext3, and ext4
. The default for volumes that are attached to Linux tasks isXFS
.The valid values for Windows are
NTFS
. The default for volumes that are attached to Windows tasks isNTFS
.
Service definition template
The following shows the JSON representation of an Amazon ECS service definition.
Amazon EC2 launch type
{ "cluster": "", "serviceName": "", "taskDefinition": "", "loadBalancers": [ { "targetGroupArn": "", "loadBalancerName": "", "containerName": "", "containerPort": 0 } ], "serviceRegistries": [ { "registryArn": "", "port": 0, "containerName": "", "containerPort": 0 } ], "desiredCount": 0, "clientToken": "", "launchType": "EC2", "capacityProviderStrategy": [ { "capacityProvider": "", "weight": 0, "base": 0 } ], "platformVersion": "", "role": "", "deploymentConfiguration": { "deploymentCircuitBreaker": { "enable": true, "rollback": true }, "maximumPercent": 0, "minimumHealthyPercent": 0, "alarms": { "alarmNames": [ "" ], "enable": true, "rollback": true } }, "placementConstraints": [ { "type": "distinctInstance", "expression": "" } ], "placementStrategy": [ { "type": "binpack", "field": "" } ], "networkConfiguration": { "awsvpcConfiguration": { "subnets": [ "" ], "securityGroups": [ "" ], "assignPublicIp": "DISABLED" } }, "healthCheckGracePeriodSeconds": 0, "schedulingStrategy": "REPLICA", "deploymentController": { "type": "EXTERNAL" }, "tags": [ { "key": "", "value": "" } ], "enableECSManagedTags": true, "propagateTags": "TASK_DEFINITION", "enableExecuteCommand": true, "serviceConnectConfiguration": { "enabled": true, "namespace": "", "services": [ { "portName": "", "discoveryName": "", "clientAliases": [ { "port": 0, "dnsName": "" } ], "ingressPortOverride": 0 } ], "logConfiguration": { "logDriver": "journald", "options": { "KeyName": "" }, "secretOptions": [ { "name": "", "valueFrom": "" } ] } }, "volumeConfigurations": [ { "name": "", "managedEBSVolume": { "encrypted": true, "kmsKeyId": "", "volumeType": "", "sizeInGiB": 0, "snapshotId": "", "iops": 0, "throughput": 0, "tagSpecifications": [ { "resourceType": "volume", "tags": [ { "key": "", "value": "" } ], "propagateTags": "NONE" } ], "roleArn": "", "filesystemType": "" } } ] }
Fargate launch type
{ "cluster": "", "serviceName": "", "taskDefinition": "", "loadBalancers": [ { "targetGroupArn": "", "loadBalancerName": "", "containerName": "", "containerPort": 0 } ], "serviceRegistries": [ { "registryArn": "", "port": 0, "containerName": "", "containerPort": 0 } ], "desiredCount": 0, "clientToken": "", "launchType": "FARGATE", "capacityProviderStrategy": [ { "capacityProvider": "", "weight": 0, "base": 0 } ], "platformVersion": "", "platformFamily": "", "role": "", "deploymentConfiguration": { "deploymentCircuitBreaker": { "enable": true, "rollback": true }, "maximumPercent": 0, "minimumHealthyPercent": 0, "alarms": { "alarmNames": [ "" ], "enable": true, "rollback": true } }, "placementStrategy": [ { "type": "binpack", "field": "" } ], "networkConfiguration": { "awsvpcConfiguration": { "subnets": [ "" ], "securityGroups": [ "" ], "assignPublicIp": "DISABLED" } }, "healthCheckGracePeriodSeconds": 0, "schedulingStrategy": "REPLICA", "deploymentController": { "type": "EXTERNAL" }, "tags": [ { "key": "", "value": "" } ], "enableECSManagedTags": true, "propagateTags": "TASK_DEFINITION", "enableExecuteCommand": true, "serviceConnectConfiguration": { "enabled": true, "namespace": "", "services": [ { "portName": "", "discoveryName": "", "clientAliases": [ { "port": 0, "dnsName": "" } ], "ingressPortOverride": 0 } ], "logConfiguration": { "logDriver": "journald", "options": { "KeyName": "" }, "secretOptions": [ { "name": "", "valueFrom": "" } ] } }, "volumeConfigurations": [ { "name": "", "managedEBSVolume": { "encrypted": true, "kmsKeyId": "", "volumeType": "", "sizeInGiB": 0, "snapshotId": "", "iops": 0, "throughput": 0, "tagSpecifications": [ { "resourceType": "volume", "tags": [ { "key": "", "value": "" } ], "propagateTags": "NONE" } ], "roleArn": "", "filesystemType": "" } } ] }
You can create this service definition template using the following AWS CLI command.
aws ecs create-service --generate-cli-skeleton