Class Service
Note: To prevent a race condition during service deletion, make sure to set
depends_onto the relatedaws.iam.RolePolicy; otherwise, the policy may be destroyed too soon and the ECS service will then get stuck in theDRAININGstate.
Provides an ECS service - effectively a task that is expected to run until an error occurs or a user terminates it (typically a webserver or a database).
See ECS Services section in AWS developer guide.
Example Usage
Daemon Scheduling Strategy
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var bar = new Aws.Ecs.Service("bar", new Aws.Ecs.ServiceArgs
{
Cluster = aws_ecs_cluster.Foo.Id,
SchedulingStrategy = "DAEMON",
TaskDefinition = aws_ecs_task_definition.Bar.Arn,
});
}
}
Inherited Members
Namespace: Pulumi.Aws.Ecs
Assembly: Pulumi.Aws.dll
Syntax
public class Service : CustomResource
Constructors
View SourceService(String, ServiceArgs, CustomResourceOptions)
Create a Service resource with the given unique name, arguments, and options.
Declaration
public Service(string name, ServiceArgs args, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resource |
| ServiceArgs | args | The arguments used to populate this resource's properties |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Properties
View SourceCapacityProviderStrategies
The capacity provider strategy to use for the service. Can be one or more. Defined below.
Declaration
public Output<ImmutableArray<ServiceCapacityProviderStrategy>> CapacityProviderStrategies { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<ServiceCapacityProviderStrategy>> |
Cluster
ARN of an ECS cluster
Declaration
public Output<string> Cluster { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
DeploymentController
Configuration block containing deployment controller configuration. Defined below.
Declaration
public Output<ServiceDeploymentController> DeploymentController { get; }
Property Value
| Type | Description |
|---|---|
| Output<ServiceDeploymentController> |
DeploymentMaximumPercent
The upper limit (as a percentage of the service's desiredCount) of the number of running tasks that can be running in a service during a deployment. Not valid when using the DAEMON scheduling strategy.
Declaration
public Output<int?> DeploymentMaximumPercent { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Int32>> |
DeploymentMinimumHealthyPercent
The lower limit (as a percentage of the service's desiredCount) of the number of running tasks that must remain running and healthy in a service during a deployment.
Declaration
public Output<int?> DeploymentMinimumHealthyPercent { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Int32>> |
DesiredCount
The number of instances of the task definition to place and keep running. Defaults to 0. Do not specify if using the DAEMON scheduling strategy.
Declaration
public Output<int?> DesiredCount { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Int32>> |
EnableEcsManagedTags
Specifies whether to enable Amazon ECS managed tags for the tasks within the service.
Declaration
public Output<bool?> EnableEcsManagedTags { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
ForceNewDeployment
Enable to force a new task deployment of the service. This can be used to update tasks to use a newer Docker image with same image/tag combination (e.g. myimage:latest), roll Fargate tasks onto a newer platform version, or immediately deploy ordered_placement_strategy and placement_constraints updates.
Declaration
public Output<bool?> ForceNewDeployment { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
HealthCheckGracePeriodSeconds
Seconds to ignore failing load balancer health checks on newly instantiated tasks to prevent premature shutdown, up to 2147483647. Only valid for services configured to use load balancers.
Declaration
public Output<int?> HealthCheckGracePeriodSeconds { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Int32>> |
IamRole
ARN of the IAM role that allows Amazon ECS to make calls to your load balancer on your behalf. This parameter is required if you are using a load balancer with your service, but only if your task definition does not use the awsvpc network mode. If using awsvpc network mode, do not specify this role. 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.
Declaration
public Output<string> IamRole { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
LaunchType
The launch type on which to run your service. The valid values are EC2 and FARGATE. Defaults to EC2.
Declaration
public Output<string> LaunchType { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
LoadBalancers
A load balancer block. Load balancers documented below.
Declaration
public Output<ImmutableArray<ServiceLoadBalancer>> LoadBalancers { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<ServiceLoadBalancer>> |
Name
The name of the service (up to 255 letters, numbers, hyphens, and underscores)
Declaration
public Output<string> Name { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
NetworkConfiguration
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.
Declaration
public Output<ServiceNetworkConfiguration> NetworkConfiguration { get; }
Property Value
| Type | Description |
|---|---|
| Output<ServiceNetworkConfiguration> |
OrderedPlacementStrategies
Service level strategy rules that are taken into consideration during task placement. List from top to bottom in order of precedence. Updates to this configuration will take effect next task deployment unless force_new_deployment is enabled. The maximum number of ordered_placement_strategy blocks is 5. Defined below.
Declaration
public Output<ImmutableArray<ServiceOrderedPlacementStrategy>> OrderedPlacementStrategies { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<ServiceOrderedPlacementStrategy>> |
PlacementConstraints
rules that are taken into consideration during task placement. Updates to this configuration will take effect next task deployment unless force_new_deployment is enabled. Maximum number of placement_constraints is 10. Defined below.
Declaration
public Output<ImmutableArray<ServicePlacementConstraint>> PlacementConstraints { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<ServicePlacementConstraint>> |
PlatformVersion
The platform version on which to run your service. Only applicable for launch_type set to FARGATE. Defaults to LATEST. More information about Fargate platform versions can be found in the AWS ECS User Guide.
Declaration
public Output<string> PlatformVersion { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
PropagateTags
Specifies whether to propagate the tags from the task definition or the service to the tasks. The valid values are SERVICE and TASK_DEFINITION.
Declaration
public Output<string> PropagateTags { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
SchedulingStrategy
The scheduling strategy to use for the service. The valid values are REPLICA and DAEMON. Defaults to REPLICA. Note that Fargate tasks do not support the DAEMON scheduling strategy.
Declaration
public Output<string> SchedulingStrategy { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
ServiceRegistries
The service discovery registries for the service. The maximum number of service_registries blocks is 1.
Declaration
public Output<ServiceServiceRegistries> ServiceRegistries { get; }
Property Value
| Type | Description |
|---|---|
| Output<ServiceServiceRegistries> |
Tags
Key-value mapping of resource tags
Declaration
public Output<ImmutableDictionary<string, object>> Tags { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableDictionary<System.String, System.Object>> |
TaskDefinition
The family and revision (family:revision) or full ARN of the task definition that you want to run in your service.
Declaration
public Output<string> TaskDefinition { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
WaitForSteadyState
If true, this provider will wait for the service to reach a steady state (like aws ecs wait services-stable) before continuing. Default false.
Declaration
public Output<bool?> WaitForSteadyState { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
Methods
View SourceGet(String, Input<String>, ServiceState, CustomResourceOptions)
Get an existing Service resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
Declaration
public static Service Get(string name, Input<string> id, ServiceState state = null, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resulting resource. |
| Input<System.String> | id | The unique provider ID of the resource to lookup. |
| ServiceState | state | Any extra arguments used during the lookup. |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Returns
| Type | Description |
|---|---|
| Service |