Class Ec2Service
java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.ecs.BaseService
software.amazon.awscdk.services.ecs.Ec2Service
- All Implemented Interfaces:
IResource
,IConnectable
,IBaseService
,IEc2Service
,IService
,ILoadBalancerTarget
,IApplicationLoadBalancerTarget
,INetworkLoadBalancerTarget
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
,software.constructs.IDependable
@Generated(value="jsii-pacmak/1.104.0 (build e79254c)",
date="2024-12-06T14:43:18.356Z")
@Stability(Stable)
public class Ec2Service
extends BaseService
implements IEc2Service
This creates a service using the EC2 launch type on an ECS cluster.
Example:
Cluster cluster; TaskDefinition taskDefinition; Vpc vpc; Ec2Service service = Ec2Service.Builder.create(this, "Service").cluster(cluster).taskDefinition(taskDefinition).build(); LoadBalancer lb = LoadBalancer.Builder.create(this, "LB").vpc(vpc).build(); lb.addListener(LoadBalancerListener.builder().externalPort(80).build()); lb.addTarget(service.loadBalancerTarget(LoadBalancerTargetOptions.builder() .containerName("MyContainer") .containerPort(80) .build()));
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.elasticloadbalancingv2.IApplicationLoadBalancerTarget
IApplicationLoadBalancerTarget.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.ecs.IBaseService
IBaseService.Jsii$Default
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.ecs.IEc2Service
IEc2Service.Jsii$Default, IEc2Service.Jsii$Proxy
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.elasticloadbalancing.ILoadBalancerTarget
ILoadBalancerTarget.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.elasticloadbalancingv2.INetworkLoadBalancerTarget
INetworkLoadBalancerTarget.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.IResource
IResource.Jsii$Default
-
Constructor Summary
ModifierConstructorDescriptionprotected
Ec2Service
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
Ec2Service
(software.amazon.jsii.JsiiObjectRef objRef) Ec2Service
(software.constructs.Construct scope, String id, Ec2ServiceProps props) Constructs a new instance of the Ec2Service class. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPlacementConstraints
(@NotNull PlacementConstraint... constraints) Adds one or more placement constraints to use for tasks in the service.void
addPlacementStrategies
(@NotNull PlacementStrategy... strategies) Adds one or more placement strategies to use for tasks in the service.static IEc2Service
fromEc2ServiceArn
(software.constructs.Construct scope, String id, String ec2ServiceArn) Imports from the specified service ARN.static IBaseService
fromEc2ServiceAttributes
(software.constructs.Construct scope, String id, Ec2ServiceAttributes attrs) Imports from the specified service attributes.Methods inherited from class software.amazon.awscdk.services.ecs.BaseService
addVolume, associateCloudMapService, attachToApplicationTargetGroup, attachToClassicLB, attachToNetworkTargetGroup, autoScaleTaskCount, configureAwsVpcNetworkingWithSecurityGroups, configureAwsVpcNetworkingWithSecurityGroups, configureAwsVpcNetworkingWithSecurityGroups, configureAwsVpcNetworkingWithSecurityGroups, enableCloudMap, enableDeploymentAlarms, enableDeploymentAlarms, enableServiceConnect, enableServiceConnect, fromServiceArnWithCluster, getCloudmapService, getCloudMapService, getCluster, getConnections, getDeploymentAlarms, getLoadBalancers, getNetworkConfiguration, getServiceArn, getServiceName, getServiceRegistries, getTaskDefinition, loadBalancerTarget, metric, metric, metricCpuUtilization, metricCpuUtilization, metricMemoryUtilization, metricMemoryUtilization, registerLoadBalancerTargets, setCloudmapService, setDeploymentAlarms, setLoadBalancers, setNetworkConfiguration, setServiceRegistries
Methods inherited from class software.amazon.awscdk.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResource
Methods inherited from class software.constructs.Construct
getNode, isConstruct, toString
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.constructs.IConstruct
getNode
Methods inherited from interface software.amazon.awscdk.IResource
applyRemovalPolicy, getEnv, getStack
Methods inherited from interface software.amazon.awscdk.services.ecs.IService
getServiceArn, getServiceName
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
Ec2Service
protected Ec2Service(software.amazon.jsii.JsiiObjectRef objRef) -
Ec2Service
protected Ec2Service(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
Ec2Service
@Stability(Stable) public Ec2Service(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull Ec2ServiceProps props) Constructs a new instance of the Ec2Service class.- Parameters:
scope
- This parameter is required.id
- This parameter is required.props
- This parameter is required.
-
-
Method Details
-
fromEc2ServiceArn
@Stability(Stable) @NotNull public static IEc2Service fromEc2ServiceArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String ec2ServiceArn) Imports from the specified service ARN.- Parameters:
scope
- This parameter is required.id
- This parameter is required.ec2ServiceArn
- This parameter is required.
-
fromEc2ServiceAttributes
@Stability(Stable) @NotNull public static IBaseService fromEc2ServiceAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull Ec2ServiceAttributes attrs) Imports from the specified service attributes.- Parameters:
scope
- This parameter is required.id
- This parameter is required.attrs
- This parameter is required.
-
addPlacementConstraints
@Stability(Stable) public void addPlacementConstraints(@NotNull @NotNull PlacementConstraint... constraints) Adds one or more placement constraints to use for tasks in the service.For more information, see Amazon ECS Task Placement Constraints.
- Parameters:
constraints
- This parameter is required.
-
addPlacementStrategies
@Stability(Stable) public void addPlacementStrategies(@NotNull @NotNull PlacementStrategy... strategies) Adds one or more placement strategies to use for tasks in the service.For more information, see Amazon ECS Task Placement Strategies.
- Parameters:
strategies
- This parameter is required.
-