Class BaseService
- All Implemented Interfaces:
- IConstruct,- IDependable,- IResource,- IConnectable,- IBaseService,- IService,- ILoadBalancerTarget,- IApplicationLoadBalancerTarget,- INetworkLoadBalancerTarget,- software.amazon.jsii.JsiiSerializable,- software.constructs.IConstruct
- Direct Known Subclasses:
- Ec2Service,- ExternalService,- FargateService
Example:
 import software.amazon.awscdk.services.ecs.*;
 IBaseService service = BaseService.fromServiceArnWithCluster(this, "EcsService", "arn:aws:ecs:us-east-1:123456789012:service/myClusterName/myServiceName");
 Pipeline pipeline = new Pipeline(this, "MyPipeline");
 Artifact buildOutput = new Artifact();
 // add source and build stages to the pipeline as usual...
 IStage deployStage = pipeline.addStage(StageOptions.builder()
         .stageName("Deploy")
         .actions(List.of(
             EcsDeployAction.Builder.create()
                     .actionName("DeployAction")
                     .service(service)
                     .input(buildOutput)
                     .build()))
         .build());
 - 
Nested Class SummaryNested classes/interfaces inherited from class software.constructs.Constructsoftware.constructs.Construct.BuilderNested classes/interfaces inherited from class software.amazon.jsii.JsiiObjectsoftware.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.services.elasticloadbalancingv2.IApplicationLoadBalancerTargetIApplicationLoadBalancerTarget.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.ecs.IBaseServiceIBaseService.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstructIConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.constructs.IConstructsoftware.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.elasticloadbalancing.ILoadBalancerTargetILoadBalancerTarget.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.elasticloadbalancingv2.INetworkLoadBalancerTargetINetworkLoadBalancerTarget.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.core.IResourceIResource.Jsii$Default
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedBaseService(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedBaseService(software.amazon.jsii.JsiiObjectRef objRef) protectedBaseService(software.constructs.Construct scope, String id, BaseServiceProps props, Object additionalProps, TaskDefinition taskDefinition) Constructs a new instance of the BaseService class.
- 
Method SummaryModifier and TypeMethodDescriptionvoidAssociates this service with a CloudMap service.attachToApplicationTargetGroup(IApplicationTargetGroup targetGroup) This method is called to attach this service to an Application Load Balancer.voidattachToClassicLB(LoadBalancer loadBalancer) Registers the service as a target of a Classic Load Balancer (CLB).attachToNetworkTargetGroup(INetworkTargetGroup targetGroup) This method is called to attach this service to a Network Load Balancer.An attribute representing the minimum and maximum task count for an AutoScalingGroup.protected voidDeprecated.use configureAwsVpcNetworkingWithSecurityGroups instead.protected voidconfigureAwsVpcNetworking(IVpc vpc, Boolean assignPublicIp) Deprecated.use configureAwsVpcNetworkingWithSecurityGroups instead.protected voidconfigureAwsVpcNetworking(IVpc vpc, Boolean assignPublicIp, SubnetSelection vpcSubnets) Deprecated.use configureAwsVpcNetworkingWithSecurityGroups instead.protected voidconfigureAwsVpcNetworking(IVpc vpc, Boolean assignPublicIp, SubnetSelection vpcSubnets, ISecurityGroup securityGroup) Deprecated.use configureAwsVpcNetworkingWithSecurityGroups instead.protected voidThis method is called to create a networkConfiguration.protected voidconfigureAwsVpcNetworkingWithSecurityGroups(IVpc vpc, Boolean assignPublicIp) This method is called to create a networkConfiguration.protected voidconfigureAwsVpcNetworkingWithSecurityGroups(IVpc vpc, Boolean assignPublicIp, SubnetSelection vpcSubnets) This method is called to create a networkConfiguration.protected voidconfigureAwsVpcNetworkingWithSecurityGroups(IVpc vpc, Boolean assignPublicIp, SubnetSelection vpcSubnets, List<ISecurityGroup> securityGroups) This method is called to create a networkConfiguration.enableCloudMap(CloudMapOptions options) Enable CloudMap service discovery for the service.static IBaseServicefromServiceArnWithCluster(software.constructs.Construct scope, String id, String serviceArn) Import an existing ECS/Fargate Service using the service cluster format.protected ServiceThe details of the AWS Cloud Map service.The CloudMap service created for this service, if any.The cluster that hosts the service.The security groups which manage the allowed network traffic for the service.protected List<CfnService.LoadBalancerProperty>A list of Elastic Load Balancing load balancer objects, containing the load balancer name, the container name (as it appears in a container definition), and the container port to access from the load balancer.protected CfnService.NetworkConfigurationPropertyA list of Elastic Load Balancing load balancer objects, containing the load balancer name, the container name (as it appears in a container definition), and the container port to access from the load balancer.The Amazon Resource Name (ARN) of the service.The name of the service.protected List<CfnService.ServiceRegistryProperty>The details of the service discovery registries to assign to this service.The task definition to use for tasks in the service.Return a load balancing target for a specific container and port.This method returns the specified CloudWatch metric name for this service.metric(String metricName, MetricOptions props) This method returns the specified CloudWatch metric name for this service.This method returns the CloudWatch metric for this service's CPU utilization.This method returns the CloudWatch metric for this service's CPU utilization.This method returns the CloudWatch metric for this service's memory utilization.This method returns the CloudWatch metric for this service's memory utilization.voidregisterLoadBalancerTargets(@NotNull EcsTarget... targets) Use this function to create all load balancer targets to be registered in this service, add them to target groups, and attach target groups to listeners accordingly.protected voidsetCloudmapService(Service value) The details of the AWS Cloud Map service.protected voidA list of Elastic Load Balancing load balancer objects, containing the load balancer name, the container name (as it appears in a container definition), and the container port to access from the load balancer.protected voidA list of Elastic Load Balancing load balancer objects, containing the load balancer name, the container name (as it appears in a container definition), and the container port to access from the load balancer.protected voidThe details of the service discovery registries to assign to this service.Methods inherited from class software.amazon.awscdk.core.ResourceapplyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isResourceMethods inherited from class software.amazon.awscdk.core.ConstructgetNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validateMethods inherited from class software.constructs.ConstructtoStringMethods inherited from class software.amazon.jsii.JsiiObjectjsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.awscdk.core.IConstructgetNodeMethods inherited from interface software.amazon.awscdk.core.IResourceapplyRemovalPolicy, getEnv, getStackMethods inherited from interface software.amazon.jsii.JsiiSerializable$jsii$toJson
- 
Constructor Details- 
BaseServiceprotected BaseService(software.amazon.jsii.JsiiObjectRef objRef) 
- 
BaseServiceprotected BaseService(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) 
- 
BaseService@Stability(Stable) protected BaseService(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull BaseServiceProps props, @NotNull Object additionalProps, @NotNull TaskDefinition taskDefinition) Constructs a new instance of the BaseService class.- Parameters:
- scope- This parameter is required.
- id- This parameter is required.
- props- This parameter is required.
- additionalProps- This parameter is required.
- taskDefinition- This parameter is required.
 
 
- 
- 
Method Details- 
fromServiceArnWithCluster@Stability(Stable) @NotNull public static IBaseService fromServiceArnWithCluster(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String serviceArn) Import an existing ECS/Fargate Service using the service cluster format.The format is the "new" format "arn:aws:ecs:region:aws_account_id:service/cluster-name/service-name". - Parameters:
- scope- This parameter is required.
- id- This parameter is required.
- serviceArn- This parameter is required.
- See Also:
 
- 
associateCloudMapService@Stability(Stable) public void associateCloudMapService(@NotNull AssociateCloudMapServiceOptions options) Associates this service with a CloudMap service.- Parameters:
- options- This parameter is required.
 
- 
attachToApplicationTargetGroup@Stability(Stable) @NotNull public LoadBalancerTargetProps attachToApplicationTargetGroup(@NotNull IApplicationTargetGroup targetGroup) This method is called to attach this service to an Application Load Balancer.Don't call this function directly. Instead, call listener.addTargets()to add this service to a load balancer.- Specified by:
- attachToApplicationTargetGroupin interface- IApplicationLoadBalancerTarget
- Parameters:
- targetGroup- This parameter is required.
 
- 
attachToClassicLBRegisters the service as a target of a Classic Load Balancer (CLB).Don't call this. Call loadBalancer.addTarget()instead.- Specified by:
- attachToClassicLBin interface- ILoadBalancerTarget
- Parameters:
- loadBalancer- This parameter is required.
 
- 
attachToNetworkTargetGroup@Stability(Stable) @NotNull public LoadBalancerTargetProps attachToNetworkTargetGroup(@NotNull INetworkTargetGroup targetGroup) This method is called to attach this service to a Network Load Balancer.Don't call this function directly. Instead, call listener.addTargets()to add this service to a load balancer.- Specified by:
- attachToNetworkTargetGroupin interface- INetworkLoadBalancerTarget
- Parameters:
- targetGroup- This parameter is required.
 
- 
autoScaleTaskCount@Stability(Stable) @NotNull public ScalableTaskCount autoScaleTaskCount(@NotNull EnableScalingProps props) An attribute representing the minimum and maximum task count for an AutoScalingGroup.- Parameters:
- props- This parameter is required.
 
- 
configureAwsVpcNetworking@Stability(Deprecated) @Deprecated protected void configureAwsVpcNetworking(@NotNull IVpc vpc, @Nullable Boolean assignPublicIp, @Nullable SubnetSelection vpcSubnets, @Nullable ISecurityGroup securityGroup) Deprecated.use configureAwsVpcNetworkingWithSecurityGroups instead.(deprecated) This method is called to create a networkConfiguration.- Parameters:
- vpc- This parameter is required.
- assignPublicIp-
- vpcSubnets-
- securityGroup-
 
- 
configureAwsVpcNetworking@Stability(Deprecated) @Deprecated protected void configureAwsVpcNetworking(@NotNull IVpc vpc, @Nullable Boolean assignPublicIp, @Nullable SubnetSelection vpcSubnets) Deprecated.use configureAwsVpcNetworkingWithSecurityGroups instead.(deprecated) This method is called to create a networkConfiguration.- Parameters:
- vpc- This parameter is required.
- assignPublicIp-
- vpcSubnets-
 
- 
configureAwsVpcNetworking@Stability(Deprecated) @Deprecated protected void configureAwsVpcNetworking(@NotNull IVpc vpc, @Nullable Boolean assignPublicIp) Deprecated.use configureAwsVpcNetworkingWithSecurityGroups instead.(deprecated) This method is called to create a networkConfiguration.- Parameters:
- vpc- This parameter is required.
- assignPublicIp-
 
- 
configureAwsVpcNetworkingDeprecated.use configureAwsVpcNetworkingWithSecurityGroups instead.(deprecated) This method is called to create a networkConfiguration.- Parameters:
- vpc- This parameter is required.
 
- 
configureAwsVpcNetworkingWithSecurityGroups@Stability(Stable) protected void configureAwsVpcNetworkingWithSecurityGroups(@NotNull IVpc vpc, @Nullable Boolean assignPublicIp, @Nullable SubnetSelection vpcSubnets, @Nullable List<ISecurityGroup> securityGroups) This method is called to create a networkConfiguration.- Parameters:
- vpc- This parameter is required.
- assignPublicIp-
- vpcSubnets-
- securityGroups-
 
- 
configureAwsVpcNetworkingWithSecurityGroups@Stability(Stable) protected void configureAwsVpcNetworkingWithSecurityGroups(@NotNull IVpc vpc, @Nullable Boolean assignPublicIp, @Nullable SubnetSelection vpcSubnets) This method is called to create a networkConfiguration.- Parameters:
- vpc- This parameter is required.
- assignPublicIp-
- vpcSubnets-
 
- 
configureAwsVpcNetworkingWithSecurityGroups@Stability(Stable) protected void configureAwsVpcNetworkingWithSecurityGroups(@NotNull IVpc vpc, @Nullable Boolean assignPublicIp) This method is called to create a networkConfiguration.- Parameters:
- vpc- This parameter is required.
- assignPublicIp-
 
- 
configureAwsVpcNetworkingWithSecurityGroupsThis method is called to create a networkConfiguration.- Parameters:
- vpc- This parameter is required.
 
- 
enableCloudMapEnable CloudMap service discovery for the service.- Parameters:
- options- This parameter is required.
- Returns:
- The created CloudMap service
 
- 
loadBalancerTarget@Stability(Stable) @NotNull public IEcsLoadBalancerTarget loadBalancerTarget(@NotNull LoadBalancerTargetOptions options) Return a load balancing target for a specific container and port.Use this function to create a load balancer target if you want to load balance to another container than the first essential container or the first mapped port on the container. Use the return value of this function where you would normally use a load balancer target, instead of the Serviceobject itself.Example: ApplicationListener listener; BaseService service; listener.addTargets("ECS", AddApplicationTargetsProps.builder() .port(80) .targets(List.of(service.loadBalancerTarget(LoadBalancerTargetOptions.builder() .containerName("MyContainer") .containerPort(1234) .build()))) .build());- Parameters:
- options- This parameter is required.
 
- 
metric@Stability(Stable) @NotNull public Metric metric(@NotNull String metricName, @Nullable MetricOptions props) This method returns the specified CloudWatch metric name for this service.- Parameters:
- metricName- This parameter is required.
- props-
 
- 
metricThis method returns the specified CloudWatch metric name for this service.- Parameters:
- metricName- This parameter is required.
 
- 
metricCpuUtilizationThis method returns the CloudWatch metric for this service's CPU utilization.Default: average over 5 minutes - Parameters:
- props-
 
- 
metricCpuUtilizationThis method returns the CloudWatch metric for this service's CPU utilization.Default: average over 5 minutes 
- 
metricMemoryUtilizationThis method returns the CloudWatch metric for this service's memory utilization.Default: average over 5 minutes - Parameters:
- props-
 
- 
metricMemoryUtilizationThis method returns the CloudWatch metric for this service's memory utilization.Default: average over 5 minutes 
- 
registerLoadBalancerTargetsUse this function to create all load balancer targets to be registered in this service, add them to target groups, and attach target groups to listeners accordingly.Alternatively, you can use listener.addTargets()to create targets and add them to target groups.Example: ApplicationListener listener; BaseService service; service.registerLoadBalancerTargets(EcsTarget.builder() .containerName("web") .containerPort(80) .newTargetGroupId("ECS") .listener(ListenerConfig.applicationListener(listener, AddApplicationTargetsProps.builder() .protocol(ApplicationProtocol.HTTPS) .build())) .build());- Parameters:
- targets- This parameter is required.
 
- 
getClusterThe cluster that hosts the service.- Specified by:
- getClusterin interface- IBaseService
 
- 
getConnectionsThe security groups which manage the allowed network traffic for the service.- Specified by:
- getConnectionsin interface- IConnectable
 
- 
getServiceArnThe Amazon Resource Name (ARN) of the service.- Specified by:
- getServiceArnin interface- IService
 
- 
getServiceNameThe name of the service.- Specified by:
- getServiceNamein interface- IService
 
- 
getTaskDefinitionThe task definition to use for tasks in the service.
- 
getCloudMapServiceThe CloudMap service created for this service, if any.
- 
getLoadBalancersA list of Elastic Load Balancing load balancer objects, containing the load balancer name, the container name (as it appears in a container definition), and the container port to access from the load balancer.
- 
setLoadBalancers@Stability(Stable) protected void setLoadBalancers(@NotNull List<CfnService.LoadBalancerProperty> value) A list of Elastic Load Balancing load balancer objects, containing the load balancer name, the container name (as it appears in a container definition), and the container port to access from the load balancer.
- 
getServiceRegistries@Stability(Stable) @NotNull protected List<CfnService.ServiceRegistryProperty> getServiceRegistries()The details of the service discovery registries to assign to this service.For more information, see Service Discovery. 
- 
setServiceRegistries@Stability(Stable) protected void setServiceRegistries(@NotNull List<CfnService.ServiceRegistryProperty> value) The details of the service discovery registries to assign to this service.For more information, see Service Discovery. 
- 
getCloudmapServiceThe details of the AWS Cloud Map service.
- 
setCloudmapServiceThe details of the AWS Cloud Map service.
- 
getNetworkConfiguration@Stability(Stable) @Nullable protected CfnService.NetworkConfigurationProperty getNetworkConfiguration()A list of Elastic Load Balancing load balancer objects, containing the load balancer name, the container name (as it appears in a container definition), and the container port to access from the load balancer.
- 
setNetworkConfiguration@Stability(Stable) protected void setNetworkConfiguration(@Nullable CfnService.NetworkConfigurationProperty value) A list of Elastic Load Balancing load balancer objects, containing the load balancer name, the container name (as it appears in a container definition), and the container port to access from the load balancer.
 
-