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
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var mongo = new Aws.Ecs.Service("mongo", new Aws.Ecs.ServiceArgs
{
Cluster = aws_ecs_cluster.Foo.Id,
TaskDefinition = aws_ecs_task_definition.Mongo.Arn,
DesiredCount = 3,
IamRole = aws_iam_role.Foo.Arn,
OrderedPlacementStrategies =
{
new Aws.Ecs.Inputs.ServiceOrderedPlacementStrategyArgs
{
Type = "binpack",
Field = "cpu",
},
},
LoadBalancers =
{
new Aws.Ecs.Inputs.ServiceLoadBalancerArgs
{
TargetGroupArn = aws_lb_target_group.Foo.Arn,
ContainerName = "mongo",
ContainerPort = 8080,
},
},
PlacementConstraints =
{
new Aws.Ecs.Inputs.ServicePlacementConstraintArgs
{
Type = "memberOf",
Expression = "attribute:ecs.availability-zone in [us-west-2a, us-west-2b]",
},
},
}, new CustomResourceOptions
{
DependsOn =
{
"aws_iam_role_policy.foo",
},
});
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/ecs"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := ecs.NewService(ctx, "mongo", &ecs.ServiceArgs{
Cluster: pulumi.String(aws_ecs_cluster.Foo.Id),
TaskDefinition: pulumi.String(aws_ecs_task_definition.Mongo.Arn),
DesiredCount: pulumi.Int(3),
IamRole: pulumi.String(aws_iam_role.Foo.Arn),
OrderedPlacementStrategies: ecs.ServiceOrderedPlacementStrategyArray{
&ecs.ServiceOrderedPlacementStrategyArgs{
Type: pulumi.String("binpack"),
Field: pulumi.String("cpu"),
},
},
LoadBalancers: ecs.ServiceLoadBalancerArray{
&ecs.ServiceLoadBalancerArgs{
TargetGroupArn: pulumi.String(aws_lb_target_group.Foo.Arn),
ContainerName: pulumi.String("mongo"),
ContainerPort: pulumi.Int(8080),
},
},
PlacementConstraints: ecs.ServicePlacementConstraintArray{
&ecs.ServicePlacementConstraintArgs{
Type: pulumi.String("memberOf"),
Expression: pulumi.String("attribute:ecs.availability-zone in [us-west-2a, us-west-2b]"),
},
},
}, pulumi.DependsOn([]pulumi.Resource{
"aws_iam_role_policy.foo",
}))
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
mongo = aws.ecs.Service("mongo",
cluster=aws_ecs_cluster["foo"]["id"],
task_definition=aws_ecs_task_definition["mongo"]["arn"],
desired_count=3,
iam_role=aws_iam_role["foo"]["arn"],
ordered_placement_strategies=[{
"type": "binpack",
"field": "cpu",
}],
load_balancers=[{
"target_group_arn": aws_lb_target_group["foo"]["arn"],
"container_name": "mongo",
"containerPort": 8080,
}],
placement_constraints=[{
"type": "memberOf",
"expression": "attribute:ecs.availability-zone in [us-west-2a, us-west-2b]",
}],
opts=ResourceOptions(depends_on=["aws_iam_role_policy.foo"]))import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const mongo = new aws.ecs.Service("mongo", {
cluster: aws_ecs_cluster.foo.id,
taskDefinition: aws_ecs_task_definition.mongo.arn,
desiredCount: 3,
iamRole: aws_iam_role.foo.arn,
orderedPlacementStrategies: [{
type: "binpack",
field: "cpu",
}],
loadBalancers: [{
targetGroupArn: aws_lb_target_group.foo.arn,
containerName: "mongo",
containerPort: 8080,
}],
placementConstraints: [{
type: "memberOf",
expression: "attribute:ecs.availability-zone in [us-west-2a, us-west-2b]",
}],
}, {
dependsOn: ["aws_iam_role_policy.foo"],
});Ignoring Changes to Desired Count
Coming soon!
Coming soon!
import pulumi
import pulumi_aws as aws
example = aws.ecs.Service("example",
desired_count=2,
lifecycle={
"ignoreChanges": ["desiredCount"],
})import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.ecs.Service("example", {
// Example: Create service with 2 instances to start
desiredCount: 2,
}, { ignoreChanges: ["desiredCount"] });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,
});
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/ecs"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := ecs.NewService(ctx, "bar", &ecs.ServiceArgs{
Cluster: pulumi.String(aws_ecs_cluster.Foo.Id),
SchedulingStrategy: pulumi.String("DAEMON"),
TaskDefinition: pulumi.String(aws_ecs_task_definition.Bar.Arn),
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
bar = aws.ecs.Service("bar",
cluster=aws_ecs_cluster["foo"]["id"],
scheduling_strategy="DAEMON",
task_definition=aws_ecs_task_definition["bar"]["arn"])import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const bar = new aws.ecs.Service("bar", {
cluster: aws_ecs_cluster_foo.id,
schedulingStrategy: "DAEMON",
taskDefinition: aws_ecs_task_definition_bar.arn,
});External Deployment Controller
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var example = new Aws.Ecs.Service("example", new Aws.Ecs.ServiceArgs
{
Cluster = aws_ecs_cluster.Example.Id,
DeploymentController = new Aws.Ecs.Inputs.ServiceDeploymentControllerArgs
{
Type = "EXTERNAL",
},
});
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/ecs"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := ecs.NewService(ctx, "example", &ecs.ServiceArgs{
Cluster: pulumi.String(aws_ecs_cluster.Example.Id),
DeploymentController: &ecs.ServiceDeploymentControllerArgs{
Type: pulumi.String("EXTERNAL"),
},
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
example = aws.ecs.Service("example",
cluster=aws_ecs_cluster["example"]["id"],
deployment_controller={
"type": "EXTERNAL",
})import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.ecs.Service("example", {
cluster: aws_ecs_cluster_example.id,
deploymentController: {
type: "EXTERNAL",
},
});Create a Service Resource
new Service(name: string, args?: ServiceArgs, opts?: CustomResourceOptions);def Service(resource_name, opts=None, capacity_provider_strategies=None, cluster=None, deployment_controller=None, deployment_maximum_percent=None, deployment_minimum_healthy_percent=None, desired_count=None, enable_ecs_managed_tags=None, force_new_deployment=None, health_check_grace_period_seconds=None, iam_role=None, launch_type=None, load_balancers=None, name=None, network_configuration=None, ordered_placement_strategies=None, placement_constraints=None, platform_version=None, propagate_tags=None, scheduling_strategy=None, service_registries=None, tags=None, task_definition=None, wait_for_steady_state=None, __props__=None);func NewService(ctx *Context, name string, args *ServiceArgs, opts ...ResourceOption) (*Service, error)public Service(string name, ServiceArgs? args = null, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args ServiceArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- opts ResourceOptions
- A bag of options that control this resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args ServiceArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ServiceArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
Service Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The Service resource accepts the following input properties:
- Capacity
Provider List<ServiceStrategies Capacity Provider Strategy Args> The capacity provider strategy to use for the service. Can be one or more. Defined below.
- Cluster string
ARN of an ECS cluster
- Deployment
Controller ServiceDeployment Controller Args Configuration block containing deployment controller configuration. Defined below.
- Deployment
Maximum intPercent 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
DAEMONscheduling strategy.- Deployment
Minimum intHealthy Percent 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.
- Desired
Count int The number of instances of the task definition to place and keep running. Defaults to 0. Do not specify if using the
DAEMONscheduling strategy.- bool
Specifies whether to enable Amazon ECS managed tags for the tasks within the service.
- Force
New boolDeployment 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 deployordered_placement_strategyandplacement_constraintsupdates.- Health
Check intGrace Period Seconds 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.
- Iam
Role string 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
awsvpcnetwork mode. If usingawsvpcnetwork 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.- Launch
Type string The launch type on which to run your service. The valid values are
EC2andFARGATE. Defaults toEC2.- Load
Balancers List<ServiceLoad Balancer Args> A load balancer block. Load balancers documented below.
- Name string
The name of the service (up to 255 letters, numbers, hyphens, and underscores)
- Network
Configuration ServiceNetwork Configuration Args The network configuration for the service. This parameter is required for task definitions that use the
awsvpcnetwork mode to receive their own Elastic Network Interface, and it is not supported for other network modes.- Ordered
Placement List<ServiceStrategies Ordered Placement Strategy Args> 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_deploymentis enabled. The maximum number ofordered_placement_strategyblocks is5. Defined below.- Placement
Constraints List<ServicePlacement Constraint Args> rules that are taken into consideration during task placement. Updates to this configuration will take effect next task deployment unless
force_new_deploymentis enabled. Maximum number ofplacement_constraintsis10. Defined below.- Platform
Version string The platform version on which to run your service. Only applicable for
launch_typeset toFARGATE. Defaults toLATEST. More information about Fargate platform versions can be found in the AWS ECS User Guide.- string
Specifies whether to propagate the tags from the task definition or the service to the tasks. The valid values are
SERVICEandTASK_DEFINITION.- Scheduling
Strategy string The scheduling strategy to use for the service. The valid values are
REPLICAandDAEMON. Defaults toREPLICA. Note that Tasks using the Fargate launch type or theCODE_DEPLOYorEXTERNALdeployment controller types don’t support theDAEMONscheduling strategy.- Service
Registries ServiceService Registries Args The service discovery registries for the service. The maximum number of
service_registriesblocks is1.- Dictionary<string, string>
Key-value map of resource tags
- Task
Definition string The family and revision (
family:revision) or full ARN of the task definition that you want to run in your service. Required unless using theEXTERNALdeployment controller. If a revision is not specified, the latestACTIVErevision is used.- Wait
For boolSteady State
- Capacity
Provider []ServiceStrategies Capacity Provider Strategy The capacity provider strategy to use for the service. Can be one or more. Defined below.
- Cluster string
ARN of an ECS cluster
- Deployment
Controller ServiceDeployment Controller Configuration block containing deployment controller configuration. Defined below.
- Deployment
Maximum intPercent 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
DAEMONscheduling strategy.- Deployment
Minimum intHealthy Percent 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.
- Desired
Count int The number of instances of the task definition to place and keep running. Defaults to 0. Do not specify if using the
DAEMONscheduling strategy.- bool
Specifies whether to enable Amazon ECS managed tags for the tasks within the service.
- Force
New boolDeployment 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 deployordered_placement_strategyandplacement_constraintsupdates.- Health
Check intGrace Period Seconds 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.
- Iam
Role string 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
awsvpcnetwork mode. If usingawsvpcnetwork 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.- Launch
Type string The launch type on which to run your service. The valid values are
EC2andFARGATE. Defaults toEC2.- Load
Balancers []ServiceLoad Balancer A load balancer block. Load balancers documented below.
- Name string
The name of the service (up to 255 letters, numbers, hyphens, and underscores)
- Network
Configuration ServiceNetwork Configuration The network configuration for the service. This parameter is required for task definitions that use the
awsvpcnetwork mode to receive their own Elastic Network Interface, and it is not supported for other network modes.- Ordered
Placement []ServiceStrategies Ordered Placement Strategy 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_deploymentis enabled. The maximum number ofordered_placement_strategyblocks is5. Defined below.- Placement
Constraints []ServicePlacement Constraint rules that are taken into consideration during task placement. Updates to this configuration will take effect next task deployment unless
force_new_deploymentis enabled. Maximum number ofplacement_constraintsis10. Defined below.- Platform
Version string The platform version on which to run your service. Only applicable for
launch_typeset toFARGATE. Defaults toLATEST. More information about Fargate platform versions can be found in the AWS ECS User Guide.- string
Specifies whether to propagate the tags from the task definition or the service to the tasks. The valid values are
SERVICEandTASK_DEFINITION.- Scheduling
Strategy string The scheduling strategy to use for the service. The valid values are
REPLICAandDAEMON. Defaults toREPLICA. Note that Tasks using the Fargate launch type or theCODE_DEPLOYorEXTERNALdeployment controller types don’t support theDAEMONscheduling strategy.- Service
Registries ServiceService Registries The service discovery registries for the service. The maximum number of
service_registriesblocks is1.- map[string]string
Key-value map of resource tags
- Task
Definition string The family and revision (
family:revision) or full ARN of the task definition that you want to run in your service. Required unless using theEXTERNALdeployment controller. If a revision is not specified, the latestACTIVErevision is used.- Wait
For boolSteady State
- capacity
Provider ServiceStrategies Capacity Provider Strategy[] The capacity provider strategy to use for the service. Can be one or more. Defined below.
- cluster string
ARN of an ECS cluster
- deployment
Controller ServiceDeployment Controller Configuration block containing deployment controller configuration. Defined below.
- deployment
Maximum numberPercent 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
DAEMONscheduling strategy.- deployment
Minimum numberHealthy Percent 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.
- desired
Count number The number of instances of the task definition to place and keep running. Defaults to 0. Do not specify if using the
DAEMONscheduling strategy.- boolean
Specifies whether to enable Amazon ECS managed tags for the tasks within the service.
- force
New booleanDeployment 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 deployordered_placement_strategyandplacement_constraintsupdates.- health
Check numberGrace Period Seconds 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.
- iam
Role string 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
awsvpcnetwork mode. If usingawsvpcnetwork 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.- launch
Type string The launch type on which to run your service. The valid values are
EC2andFARGATE. Defaults toEC2.- load
Balancers ServiceLoad Balancer[] A load balancer block. Load balancers documented below.
- name string
The name of the service (up to 255 letters, numbers, hyphens, and underscores)
- network
Configuration ServiceNetwork Configuration The network configuration for the service. This parameter is required for task definitions that use the
awsvpcnetwork mode to receive their own Elastic Network Interface, and it is not supported for other network modes.- ordered
Placement ServiceStrategies Ordered Placement Strategy[] 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_deploymentis enabled. The maximum number ofordered_placement_strategyblocks is5. Defined below.- placement
Constraints ServicePlacement Constraint[] rules that are taken into consideration during task placement. Updates to this configuration will take effect next task deployment unless
force_new_deploymentis enabled. Maximum number ofplacement_constraintsis10. Defined below.- platform
Version string The platform version on which to run your service. Only applicable for
launch_typeset toFARGATE. Defaults toLATEST. More information about Fargate platform versions can be found in the AWS ECS User Guide.- string
Specifies whether to propagate the tags from the task definition or the service to the tasks. The valid values are
SERVICEandTASK_DEFINITION.- scheduling
Strategy string The scheduling strategy to use for the service. The valid values are
REPLICAandDAEMON. Defaults toREPLICA. Note that Tasks using the Fargate launch type or theCODE_DEPLOYorEXTERNALdeployment controller types don’t support theDAEMONscheduling strategy.- service
Registries ServiceService Registries The service discovery registries for the service. The maximum number of
service_registriesblocks is1.- {[key: string]: string}
Key-value map of resource tags
- task
Definition string The family and revision (
family:revision) or full ARN of the task definition that you want to run in your service. Required unless using theEXTERNALdeployment controller. If a revision is not specified, the latestACTIVErevision is used.- wait
For booleanSteady State
- capacity_
provider_ List[Servicestrategies Capacity Provider Strategy] The capacity provider strategy to use for the service. Can be one or more. Defined below.
- cluster str
ARN of an ECS cluster
- deployment_
controller Dict[ServiceDeployment Controller] Configuration block containing deployment controller configuration. Defined below.
- deployment_
maximum_ floatpercent 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
DAEMONscheduling strategy.- deployment_
minimum_ floathealthy_ percent 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.
- desired_
count float The number of instances of the task definition to place and keep running. Defaults to 0. Do not specify if using the
DAEMONscheduling strategy.- bool
Specifies whether to enable Amazon ECS managed tags for the tasks within the service.
- force_
new_ booldeployment 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 deployordered_placement_strategyandplacement_constraintsupdates.- health_
check_ floatgrace_ period_ seconds 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.
- iam_
role str 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
awsvpcnetwork mode. If usingawsvpcnetwork 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.- launch_
type str The launch type on which to run your service. The valid values are
EC2andFARGATE. Defaults toEC2.- load_
balancers List[ServiceLoad Balancer] A load balancer block. Load balancers documented below.
- name str
The name of the service (up to 255 letters, numbers, hyphens, and underscores)
- network_
configuration Dict[ServiceNetwork Configuration] The network configuration for the service. This parameter is required for task definitions that use the
awsvpcnetwork mode to receive their own Elastic Network Interface, and it is not supported for other network modes.- ordered_
placement_ List[Servicestrategies Ordered Placement Strategy] 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_deploymentis enabled. The maximum number ofordered_placement_strategyblocks is5. Defined below.- placement_
constraints List[ServicePlacement Constraint] rules that are taken into consideration during task placement. Updates to this configuration will take effect next task deployment unless
force_new_deploymentis enabled. Maximum number ofplacement_constraintsis10. Defined below.- platform_
version str The platform version on which to run your service. Only applicable for
launch_typeset toFARGATE. Defaults toLATEST. More information about Fargate platform versions can be found in the AWS ECS User Guide.- str
Specifies whether to propagate the tags from the task definition or the service to the tasks. The valid values are
SERVICEandTASK_DEFINITION.- scheduling_
strategy str The scheduling strategy to use for the service. The valid values are
REPLICAandDAEMON. Defaults toREPLICA. Note that Tasks using the Fargate launch type or theCODE_DEPLOYorEXTERNALdeployment controller types don’t support theDAEMONscheduling strategy.- service_
registries Dict[ServiceService Registries] The service discovery registries for the service. The maximum number of
service_registriesblocks is1.- Dict[str, str]
Key-value map of resource tags
- task_
definition str The family and revision (
family:revision) or full ARN of the task definition that you want to run in your service. Required unless using theEXTERNALdeployment controller. If a revision is not specified, the latestACTIVErevision is used.- wait_
for_ boolsteady_ state
Outputs
All input properties are implicitly available as output properties. Additionally, the Service resource produces the following output properties:
Look up an Existing Service Resource
Get an existing Service resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: ServiceState, opts?: CustomResourceOptions): Servicestatic get(resource_name, id, opts=None, capacity_provider_strategies=None, cluster=None, deployment_controller=None, deployment_maximum_percent=None, deployment_minimum_healthy_percent=None, desired_count=None, enable_ecs_managed_tags=None, force_new_deployment=None, health_check_grace_period_seconds=None, iam_role=None, launch_type=None, load_balancers=None, name=None, network_configuration=None, ordered_placement_strategies=None, placement_constraints=None, platform_version=None, propagate_tags=None, scheduling_strategy=None, service_registries=None, tags=None, task_definition=None, wait_for_steady_state=None, __props__=None);func GetService(ctx *Context, name string, id IDInput, state *ServiceState, opts ...ResourceOption) (*Service, error)public static Service Get(string name, Input<string> id, ServiceState? state, CustomResourceOptions? opts = null)- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
The following state arguments are supported:
- Capacity
Provider List<ServiceStrategies Capacity Provider Strategy Args> The capacity provider strategy to use for the service. Can be one or more. Defined below.
- Cluster string
ARN of an ECS cluster
- Deployment
Controller ServiceDeployment Controller Args Configuration block containing deployment controller configuration. Defined below.
- Deployment
Maximum intPercent 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
DAEMONscheduling strategy.- Deployment
Minimum intHealthy Percent 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.
- Desired
Count int The number of instances of the task definition to place and keep running. Defaults to 0. Do not specify if using the
DAEMONscheduling strategy.- bool
Specifies whether to enable Amazon ECS managed tags for the tasks within the service.
- Force
New boolDeployment 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 deployordered_placement_strategyandplacement_constraintsupdates.- Health
Check intGrace Period Seconds 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.
- Iam
Role string 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
awsvpcnetwork mode. If usingawsvpcnetwork 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.- Launch
Type string The launch type on which to run your service. The valid values are
EC2andFARGATE. Defaults toEC2.- Load
Balancers List<ServiceLoad Balancer Args> A load balancer block. Load balancers documented below.
- Name string
The name of the service (up to 255 letters, numbers, hyphens, and underscores)
- Network
Configuration ServiceNetwork Configuration Args The network configuration for the service. This parameter is required for task definitions that use the
awsvpcnetwork mode to receive their own Elastic Network Interface, and it is not supported for other network modes.- Ordered
Placement List<ServiceStrategies Ordered Placement Strategy Args> 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_deploymentis enabled. The maximum number ofordered_placement_strategyblocks is5. Defined below.- Placement
Constraints List<ServicePlacement Constraint Args> rules that are taken into consideration during task placement. Updates to this configuration will take effect next task deployment unless
force_new_deploymentis enabled. Maximum number ofplacement_constraintsis10. Defined below.- Platform
Version string The platform version on which to run your service. Only applicable for
launch_typeset toFARGATE. Defaults toLATEST. More information about Fargate platform versions can be found in the AWS ECS User Guide.- string
Specifies whether to propagate the tags from the task definition or the service to the tasks. The valid values are
SERVICEandTASK_DEFINITION.- Scheduling
Strategy string The scheduling strategy to use for the service. The valid values are
REPLICAandDAEMON. Defaults toREPLICA. Note that Tasks using the Fargate launch type or theCODE_DEPLOYorEXTERNALdeployment controller types don’t support theDAEMONscheduling strategy.- Service
Registries ServiceService Registries Args The service discovery registries for the service. The maximum number of
service_registriesblocks is1.- Dictionary<string, string>
Key-value map of resource tags
- Task
Definition string The family and revision (
family:revision) or full ARN of the task definition that you want to run in your service. Required unless using theEXTERNALdeployment controller. If a revision is not specified, the latestACTIVErevision is used.- Wait
For boolSteady State
- Capacity
Provider []ServiceStrategies Capacity Provider Strategy The capacity provider strategy to use for the service. Can be one or more. Defined below.
- Cluster string
ARN of an ECS cluster
- Deployment
Controller ServiceDeployment Controller Configuration block containing deployment controller configuration. Defined below.
- Deployment
Maximum intPercent 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
DAEMONscheduling strategy.- Deployment
Minimum intHealthy Percent 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.
- Desired
Count int The number of instances of the task definition to place and keep running. Defaults to 0. Do not specify if using the
DAEMONscheduling strategy.- bool
Specifies whether to enable Amazon ECS managed tags for the tasks within the service.
- Force
New boolDeployment 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 deployordered_placement_strategyandplacement_constraintsupdates.- Health
Check intGrace Period Seconds 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.
- Iam
Role string 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
awsvpcnetwork mode. If usingawsvpcnetwork 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.- Launch
Type string The launch type on which to run your service. The valid values are
EC2andFARGATE. Defaults toEC2.- Load
Balancers []ServiceLoad Balancer A load balancer block. Load balancers documented below.
- Name string
The name of the service (up to 255 letters, numbers, hyphens, and underscores)
- Network
Configuration ServiceNetwork Configuration The network configuration for the service. This parameter is required for task definitions that use the
awsvpcnetwork mode to receive their own Elastic Network Interface, and it is not supported for other network modes.- Ordered
Placement []ServiceStrategies Ordered Placement Strategy 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_deploymentis enabled. The maximum number ofordered_placement_strategyblocks is5. Defined below.- Placement
Constraints []ServicePlacement Constraint rules that are taken into consideration during task placement. Updates to this configuration will take effect next task deployment unless
force_new_deploymentis enabled. Maximum number ofplacement_constraintsis10. Defined below.- Platform
Version string The platform version on which to run your service. Only applicable for
launch_typeset toFARGATE. Defaults toLATEST. More information about Fargate platform versions can be found in the AWS ECS User Guide.- string
Specifies whether to propagate the tags from the task definition or the service to the tasks. The valid values are
SERVICEandTASK_DEFINITION.- Scheduling
Strategy string The scheduling strategy to use for the service. The valid values are
REPLICAandDAEMON. Defaults toREPLICA. Note that Tasks using the Fargate launch type or theCODE_DEPLOYorEXTERNALdeployment controller types don’t support theDAEMONscheduling strategy.- Service
Registries ServiceService Registries The service discovery registries for the service. The maximum number of
service_registriesblocks is1.- map[string]string
Key-value map of resource tags
- Task
Definition string The family and revision (
family:revision) or full ARN of the task definition that you want to run in your service. Required unless using theEXTERNALdeployment controller. If a revision is not specified, the latestACTIVErevision is used.- Wait
For boolSteady State
- capacity
Provider ServiceStrategies Capacity Provider Strategy[] The capacity provider strategy to use for the service. Can be one or more. Defined below.
- cluster string
ARN of an ECS cluster
- deployment
Controller ServiceDeployment Controller Configuration block containing deployment controller configuration. Defined below.
- deployment
Maximum numberPercent 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
DAEMONscheduling strategy.- deployment
Minimum numberHealthy Percent 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.
- desired
Count number The number of instances of the task definition to place and keep running. Defaults to 0. Do not specify if using the
DAEMONscheduling strategy.- boolean
Specifies whether to enable Amazon ECS managed tags for the tasks within the service.
- force
New booleanDeployment 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 deployordered_placement_strategyandplacement_constraintsupdates.- health
Check numberGrace Period Seconds 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.
- iam
Role string 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
awsvpcnetwork mode. If usingawsvpcnetwork 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.- launch
Type string The launch type on which to run your service. The valid values are
EC2andFARGATE. Defaults toEC2.- load
Balancers ServiceLoad Balancer[] A load balancer block. Load balancers documented below.
- name string
The name of the service (up to 255 letters, numbers, hyphens, and underscores)
- network
Configuration ServiceNetwork Configuration The network configuration for the service. This parameter is required for task definitions that use the
awsvpcnetwork mode to receive their own Elastic Network Interface, and it is not supported for other network modes.- ordered
Placement ServiceStrategies Ordered Placement Strategy[] 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_deploymentis enabled. The maximum number ofordered_placement_strategyblocks is5. Defined below.- placement
Constraints ServicePlacement Constraint[] rules that are taken into consideration during task placement. Updates to this configuration will take effect next task deployment unless
force_new_deploymentis enabled. Maximum number ofplacement_constraintsis10. Defined below.- platform
Version string The platform version on which to run your service. Only applicable for
launch_typeset toFARGATE. Defaults toLATEST. More information about Fargate platform versions can be found in the AWS ECS User Guide.- string
Specifies whether to propagate the tags from the task definition or the service to the tasks. The valid values are
SERVICEandTASK_DEFINITION.- scheduling
Strategy string The scheduling strategy to use for the service. The valid values are
REPLICAandDAEMON. Defaults toREPLICA. Note that Tasks using the Fargate launch type or theCODE_DEPLOYorEXTERNALdeployment controller types don’t support theDAEMONscheduling strategy.- service
Registries ServiceService Registries The service discovery registries for the service. The maximum number of
service_registriesblocks is1.- {[key: string]: string}
Key-value map of resource tags
- task
Definition string The family and revision (
family:revision) or full ARN of the task definition that you want to run in your service. Required unless using theEXTERNALdeployment controller. If a revision is not specified, the latestACTIVErevision is used.- wait
For booleanSteady State
- capacity_
provider_ List[Servicestrategies Capacity Provider Strategy] The capacity provider strategy to use for the service. Can be one or more. Defined below.
- cluster str
ARN of an ECS cluster
- deployment_
controller Dict[ServiceDeployment Controller] Configuration block containing deployment controller configuration. Defined below.
- deployment_
maximum_ floatpercent 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
DAEMONscheduling strategy.- deployment_
minimum_ floathealthy_ percent 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.
- desired_
count float The number of instances of the task definition to place and keep running. Defaults to 0. Do not specify if using the
DAEMONscheduling strategy.- bool
Specifies whether to enable Amazon ECS managed tags for the tasks within the service.
- force_
new_ booldeployment 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 deployordered_placement_strategyandplacement_constraintsupdates.- health_
check_ floatgrace_ period_ seconds 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.
- iam_
role str 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
awsvpcnetwork mode. If usingawsvpcnetwork 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.- launch_
type str The launch type on which to run your service. The valid values are
EC2andFARGATE. Defaults toEC2.- load_
balancers List[ServiceLoad Balancer] A load balancer block. Load balancers documented below.
- name str
The name of the service (up to 255 letters, numbers, hyphens, and underscores)
- network_
configuration Dict[ServiceNetwork Configuration] The network configuration for the service. This parameter is required for task definitions that use the
awsvpcnetwork mode to receive their own Elastic Network Interface, and it is not supported for other network modes.- ordered_
placement_ List[Servicestrategies Ordered Placement Strategy] 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_deploymentis enabled. The maximum number ofordered_placement_strategyblocks is5. Defined below.- placement_
constraints List[ServicePlacement Constraint] rules that are taken into consideration during task placement. Updates to this configuration will take effect next task deployment unless
force_new_deploymentis enabled. Maximum number ofplacement_constraintsis10. Defined below.- platform_
version str The platform version on which to run your service. Only applicable for
launch_typeset toFARGATE. Defaults toLATEST. More information about Fargate platform versions can be found in the AWS ECS User Guide.- str
Specifies whether to propagate the tags from the task definition or the service to the tasks. The valid values are
SERVICEandTASK_DEFINITION.- scheduling_
strategy str The scheduling strategy to use for the service. The valid values are
REPLICAandDAEMON. Defaults toREPLICA. Note that Tasks using the Fargate launch type or theCODE_DEPLOYorEXTERNALdeployment controller types don’t support theDAEMONscheduling strategy.- service_
registries Dict[ServiceService Registries] The service discovery registries for the service. The maximum number of
service_registriesblocks is1.- Dict[str, str]
Key-value map of resource tags
- task_
definition str The family and revision (
family:revision) or full ARN of the task definition that you want to run in your service. Required unless using theEXTERNALdeployment controller. If a revision is not specified, the latestACTIVErevision is used.- wait_
for_ boolsteady_ state
Supporting Types
ServiceCapacityProviderStrategy
- Capacity
Provider string The short name of the capacity provider.
- Base int
The number of 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.
- Weight int
The relative percentage of the total number of launched tasks that should use the specified capacity provider.
- Capacity
Provider string The short name of the capacity provider.
- Base int
The number of 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.
- Weight int
The relative percentage of the total number of launched tasks that should use the specified capacity provider.
- capacity
Provider string The short name of the capacity provider.
- base number
The number of 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.
- weight number
The relative percentage of the total number of launched tasks that should use the specified capacity provider.
- capacity
Provider str The short name of the capacity provider.
- base float
The number of 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.
- weight float
The relative percentage of the total number of launched tasks that should use the specified capacity provider.
ServiceDeploymentController
ServiceLoadBalancer
- Container
Name string The name of the container to associate with the load balancer (as it appears in a container definition).
- Container
Port int The port on the container to associate with the load balancer.
- Elb
Name string The name of the ELB (Classic) to associate with the service.
- Target
Group stringArn The ARN of the Load Balancer target group to associate with the service.
- Container
Name string The name of the container to associate with the load balancer (as it appears in a container definition).
- Container
Port int The port on the container to associate with the load balancer.
- Elb
Name string The name of the ELB (Classic) to associate with the service.
- Target
Group stringArn The ARN of the Load Balancer target group to associate with the service.
- container
Name string The name of the container to associate with the load balancer (as it appears in a container definition).
- container
Port number The port on the container to associate with the load balancer.
- elb
Name string The name of the ELB (Classic) to associate with the service.
- target
Group stringArn The ARN of the Load Balancer target group to associate with the service.
- container
Port float The port on the container to associate with the load balancer.
- container_
name str The name of the container to associate with the load balancer (as it appears in a container definition).
- elb
Name str The name of the ELB (Classic) to associate with the service.
- target_
group_ strarn The ARN of the Load Balancer target group to associate with the service.
ServiceNetworkConfiguration
- Subnets List<string>
The subnets associated with the task or service.
- Assign
Public boolIp Assign a public IP address to the ENI (Fargate launch type only). Valid values are
trueorfalse. Defaultfalse.- Security
Groups List<string> The security groups associated with the task or service. If you do not specify a security group, the default security group for the VPC is used.
- Subnets []string
The subnets associated with the task or service.
- Assign
Public boolIp Assign a public IP address to the ENI (Fargate launch type only). Valid values are
trueorfalse. Defaultfalse.- Security
Groups []string The security groups associated with the task or service. If you do not specify a security group, the default security group for the VPC is used.
- subnets string[]
The subnets associated with the task or service.
- assign
Public booleanIp Assign a public IP address to the ENI (Fargate launch type only). Valid values are
trueorfalse. Defaultfalse.- security
Groups string[] The security groups associated with the task or service. If you do not specify a security group, the default security group for the VPC is used.
- subnets List[str]
The subnets associated with the task or service.
- assign
Public boolIp Assign a public IP address to the ENI (Fargate launch type only). Valid values are
trueorfalse. Defaultfalse.- security_
groups List[str] The security groups associated with the task or service. If you do not specify a security group, the default security group for the VPC is used.
ServiceOrderedPlacementStrategy
- Type string
The type of placement strategy. Must be one of:
binpack,random, orspread- Field string
For the
spreadplacement strategy, valid values areinstanceId(orhost, which has the same effect), or any platform or custom attribute that is applied to a container instance. For thebinpacktype, valid values arememoryandcpu. For therandomtype, this attribute is not needed. For more information, see Placement Strategy.
- Type string
The type of placement strategy. Must be one of:
binpack,random, orspread- Field string
For the
spreadplacement strategy, valid values areinstanceId(orhost, which has the same effect), or any platform or custom attribute that is applied to a container instance. For thebinpacktype, valid values arememoryandcpu. For therandomtype, this attribute is not needed. For more information, see Placement Strategy.
- type string
The type of placement strategy. Must be one of:
binpack,random, orspread- field string
For the
spreadplacement strategy, valid values areinstanceId(orhost, which has the same effect), or any platform or custom attribute that is applied to a container instance. For thebinpacktype, valid values arememoryandcpu. For therandomtype, this attribute is not needed. For more information, see Placement Strategy.
- type str
The type of placement strategy. Must be one of:
binpack,random, orspread- field str
For the
spreadplacement strategy, valid values areinstanceId(orhost, which has the same effect), or any platform or custom attribute that is applied to a container instance. For thebinpacktype, valid values arememoryandcpu. For therandomtype, this attribute is not needed. For more information, see Placement Strategy.
ServicePlacementConstraint
- Type string
The type of constraint. The only valid values at this time are
memberOfanddistinctInstance.- Expression string
Cluster Query Language expression to apply to the constraint. Does not need to be specified for the
distinctInstancetype. For more information, see Cluster Query Language in the Amazon EC2 Container Service Developer Guide.
- Type string
The type of constraint. The only valid values at this time are
memberOfanddistinctInstance.- Expression string
Cluster Query Language expression to apply to the constraint. Does not need to be specified for the
distinctInstancetype. For more information, see Cluster Query Language in the Amazon EC2 Container Service Developer Guide.
- type string
The type of constraint. The only valid values at this time are
memberOfanddistinctInstance.- expression string
Cluster Query Language expression to apply to the constraint. Does not need to be specified for the
distinctInstancetype. For more information, see Cluster Query Language in the Amazon EC2 Container Service Developer Guide.
- type str
The type of constraint. The only valid values at this time are
memberOfanddistinctInstance.- expression str
Cluster Query Language expression to apply to the constraint. Does not need to be specified for the
distinctInstancetype. For more information, see Cluster Query Language in the Amazon EC2 Container Service Developer Guide.
ServiceServiceRegistries
- Registry
Arn string The ARN of the Service Registry. The currently supported service registry is Amazon Route 53 Auto Naming Service(
aws.servicediscovery.Service). For more information, see Service- Container
Name string The container name value, already specified in the task definition, to be used for your service discovery service.
- Container
Port int The port value, already specified in the task definition, to be used for your service discovery service.
- Port int
The port value used if your Service Discovery service specified an SRV record.
- Registry
Arn string The ARN of the Service Registry. The currently supported service registry is Amazon Route 53 Auto Naming Service(
aws.servicediscovery.Service). For more information, see Service- Container
Name string The container name value, already specified in the task definition, to be used for your service discovery service.
- Container
Port int The port value, already specified in the task definition, to be used for your service discovery service.
- Port int
The port value used if your Service Discovery service specified an SRV record.
- registry
Arn string The ARN of the Service Registry. The currently supported service registry is Amazon Route 53 Auto Naming Service(
aws.servicediscovery.Service). For more information, see Service- container
Name string The container name value, already specified in the task definition, to be used for your service discovery service.
- container
Port number The port value, already specified in the task definition, to be used for your service discovery service.
- port number
The port value used if your Service Discovery service specified an SRV record.
- registry
Arn str The ARN of the Service Registry. The currently supported service registry is Amazon Route 53 Auto Naming Service(
aws.servicediscovery.Service). For more information, see Service- container
Port float The port value, already specified in the task definition, to be used for your service discovery service.
- container_
name str The container name value, already specified in the task definition, to be used for your service discovery service.
- port float
The port value used if your Service Discovery service specified an SRV record.
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.