Class Ec2Service
This creates a service using the EC2 launch type on an ECS cluster.
Implements
Inherited Members
Namespace: Amazon.CDK.AWS.ECS
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Ec2Service : BaseService, IBaseService, IApplicationLoadBalancerTarget, INetworkLoadBalancerTarget, ILoadBalancerTarget, IConnectable, IEc2Service, IService, IResource
Syntax (vb)
Public Class Ec2Service
Inherits BaseService
Implements IBaseService, IApplicationLoadBalancerTarget, INetworkLoadBalancerTarget, ILoadBalancerTarget, IConnectable, IEc2Service, IService, IResource
Remarks
Resource: AWS::ECS::Service
ExampleMetadata: infused
Examples
Cluster cluster;
TaskDefinition taskDefinition;
Vpc vpc;
var service = new Ec2Service(this, "Service", new Ec2ServiceProps { Cluster = cluster, TaskDefinition = taskDefinition });
var lb = new LoadBalancer(this, "LB", new LoadBalancerProps { Vpc = vpc });
lb.AddListener(new LoadBalancerListener { ExternalPort = 80 });
lb.AddTarget(service.LoadBalancerTarget(new LoadBalancerTargetOptions {
ContainerName = "MyContainer",
ContainerPort = 80
}));
Synopsis
Constructors
Ec2Service(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
Ec2Service(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Ec2Service(Construct, String, IEc2ServiceProps) | Constructs a new instance of the Ec2Service class. |
Methods
AddPlacementConstraints(PlacementConstraint[]) | Adds one or more placement constraints to use for tasks in the service. |
AddPlacementStrategies(PlacementStrategy[]) | Adds one or more placement strategies to use for tasks in the service. |
FromEc2ServiceArn(Construct, String, String) | Imports from the specified service ARN. |
FromEc2ServiceAttributes(Construct, String, IEc2ServiceAttributes) | Imports from the specified service attributes. |
Constructors
Ec2Service(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected Ec2Service(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
Ec2Service(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected Ec2Service(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Ec2Service(Construct, String, IEc2ServiceProps)
Constructs a new instance of the Ec2Service class.
public Ec2Service(Construct scope, string id, IEc2ServiceProps props)
Parameters
- scope Constructs.Construct
- id System.String
- props IEc2ServiceProps
Methods
AddPlacementConstraints(PlacementConstraint[])
Adds one or more placement constraints to use for tasks in the service.
public virtual void AddPlacementConstraints(params PlacementConstraint[] constraints)
Parameters
- constraints PlacementConstraint[]
Remarks
For more information, see Amazon ECS Task Placement Constraints.
AddPlacementStrategies(PlacementStrategy[])
Adds one or more placement strategies to use for tasks in the service.
public virtual void AddPlacementStrategies(params PlacementStrategy[] strategies)
Parameters
- strategies PlacementStrategy[]
Remarks
For more information, see Amazon ECS Task Placement Strategies.
FromEc2ServiceArn(Construct, String, String)
Imports from the specified service ARN.
public static IEc2Service FromEc2ServiceArn(Construct scope, string id, string ec2ServiceArn)
Parameters
- scope Constructs.Construct
- id System.String
- ec2ServiceArn System.String
Returns
FromEc2ServiceAttributes(Construct, String, IEc2ServiceAttributes)
Imports from the specified service attributes.
public static IBaseService FromEc2ServiceAttributes(Construct scope, string id, IEc2ServiceAttributes attrs)
Parameters
- scope Constructs.Construct
- id System.String
- attrs IEc2ServiceAttributes
Returns