Interface IEc2ServiceProps
The properties for defining a service using the EC2 launch type.
Inherited Members
Namespace: Amazon.CDK.AWS.ECS
Assembly: Amazon.CDK.AWS.ECS.dll
Syntax (csharp)
public interface IEc2ServiceProps : IBaseServiceOptions
Syntax (vb)
Public Interface IEc2ServiceProps
Inherits IBaseServiceOptions
Remarks
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
Properties
AssignPublicIp | Specifies whether the task's elastic network interface receives a public IP address. |
Daemon | Specifies whether the service will use the daemon scheduling strategy. |
PlacementConstraints | The placement constraints to use for tasks in the service. |
PlacementStrategies | The placement strategies to use for tasks in the service. |
SecurityGroup | (deprecated) The security groups to associate with the service. |
SecurityGroups | The security groups to associate with the service. |
TaskDefinition | The task definition to use for tasks in the service. |
VpcSubnets | The subnets to associate with the service. |
Properties
AssignPublicIp
Specifies whether the task's elastic network interface receives a public IP address.
virtual Nullable<bool> AssignPublicIp { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
If true, each task will receive a public IP address.
This property is only used for tasks that use the awsvpc network mode.
Default: false
Daemon
Specifies whether the service will use the daemon scheduling strategy.
virtual Nullable<bool> Daemon { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
If true, the service scheduler deploys exactly one task on each container instance in your cluster.
When you are using this strategy, do not specify a desired number of tasks orany task placement strategies.
Default: false
PlacementConstraints
The placement constraints to use for tasks in the service.
virtual PlacementConstraint[] PlacementConstraints { get; }
Property Value
Remarks
For more information, see Amazon ECS Task Placement Constraints.
Default: - No constraints.
PlacementStrategies
The placement strategies to use for tasks in the service.
virtual PlacementStrategy[] PlacementStrategies { get; }
Property Value
Remarks
For more information, see Amazon ECS Task Placement Strategies.
Default: - No strategies.
SecurityGroup
(deprecated) The security groups to associate with the service.
virtual ISecurityGroup SecurityGroup { get; }
Property Value
Remarks
If you do not specify a security group, a new security group is created.
This property is only used for tasks that use the awsvpc network mode.
Default: - A new security group is created.
Stability: Deprecated
SecurityGroups
The security groups to associate with the service.
virtual ISecurityGroup[] SecurityGroups { get; }
Property Value
Remarks
If you do not specify a security group, a new security group is created.
This property is only used for tasks that use the awsvpc network mode.
Default: - A new security group is created.
TaskDefinition
The task definition to use for tasks in the service.
TaskDefinition TaskDefinition { get; }
Property Value
Remarks
[disable-awslint:ref-via-interface]
VpcSubnets
The subnets to associate with the service.
virtual ISubnetSelection VpcSubnets { get; }
Property Value
Remarks
This property is only used for tasks that use the awsvpc network mode.
Default: - Public subnets if assignPublicIp
is set, otherwise the first available one of Private, Isolated, Public, in that order.