Class Ec2Service
java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.core.Construct
software.amazon.awscdk.core.Resource
software.amazon.awscdk.services.ecs.BaseService
software.amazon.awscdk.services.ecs.Ec2Service
- All Implemented Interfaces:
IConstruct,IDependable,IResource,IConnectable,IBaseService,IEc2Service,IService,ILoadBalancerTarget,IApplicationLoadBalancerTarget,INetworkLoadBalancerTarget,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct
@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)",
date="2023-06-19T16:30:47.288Z")
@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 ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.services.elasticloadbalancingv2.IApplicationLoadBalancerTarget
IApplicationLoadBalancerTarget.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.ecs.IBaseService
IBaseService.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct
IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.ecs.IEc2Service
IEc2Service.Jsii$Default, IEc2Service.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.services.elasticloadbalancing.ILoadBalancerTarget
ILoadBalancerTarget.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.elasticloadbalancingv2.INetworkLoadBalancerTarget
INetworkLoadBalancerTarget.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.core.IResource
IResource.Jsii$Default -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedEc2Service(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedEc2Service(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 TypeMethodDescriptionvoidaddPlacementConstraints(@NotNull PlacementConstraint... constraints) Adds one or more placement constraints to use for tasks in the service.voidaddPlacementStrategies(@NotNull PlacementStrategy... strategies) Adds one or more placement strategies to use for tasks in the service.static IEc2ServicefromEc2ServiceArn(software.constructs.Construct scope, String id, String ec2ServiceArn) Imports from the specified service ARN.static IBaseServicefromEc2ServiceAttributes(software.constructs.Construct scope, String id, Ec2ServiceAttributes attrs) Imports from the specified service attributes.validate()Validates this Ec2Service.Methods inherited from class software.amazon.awscdk.services.ecs.BaseService
associateCloudMapService, attachToApplicationTargetGroup, attachToClassicLB, attachToNetworkTargetGroup, autoScaleTaskCount, configureAwsVpcNetworking, configureAwsVpcNetworking, configureAwsVpcNetworking, configureAwsVpcNetworking, configureAwsVpcNetworkingWithSecurityGroups, configureAwsVpcNetworkingWithSecurityGroups, configureAwsVpcNetworkingWithSecurityGroups, configureAwsVpcNetworkingWithSecurityGroups, enableCloudMap, fromServiceArnWithCluster, getCloudmapService, getCloudMapService, getCluster, getConnections, getLoadBalancers, getNetworkConfiguration, getServiceArn, getServiceName, getServiceRegistries, getTaskDefinition, loadBalancerTarget, metric, metric, metricCpuUtilization, metricCpuUtilization, metricMemoryUtilization, metricMemoryUtilization, registerLoadBalancerTargets, setCloudmapService, setLoadBalancers, setNetworkConfiguration, setServiceRegistriesMethods inherited from class software.amazon.awscdk.core.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isResourceMethods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesizeMethods inherited from class software.constructs.Construct
toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.awscdk.core.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.core.IResource
applyRemovalPolicy, getEnv, getStackMethods inherited from interface software.amazon.awscdk.services.ecs.IService
getServiceArn, getServiceNameMethods 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.
-
validate
Validates this Ec2Service.
-