@Generated(value="jsii-pacmak/1.74.0 (build 6d08790)", date="2023-03-28T21:34:28.648Z") public abstract class BaseService extends Resource implements IBaseService, IApplicationLoadBalancerTarget, INetworkLoadBalancerTarget, ILoadBalancerTarget
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());
IBaseService.Jsii$Default
IApplicationLoadBalancerTarget.Jsii$Default
INetworkLoadBalancerTarget.Jsii$Default
ILoadBalancerTarget.Jsii$Default
Modifier | Constructor and Description |
---|---|
protected |
BaseService(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
BaseService(software.amazon.jsii.JsiiObjectRef objRef) |
protected |
BaseService(software.constructs.Construct scope,
java.lang.String id,
BaseServiceProps props,
java.lang.Object additionalProps,
TaskDefinition taskDefinition)
Constructs a new instance of the BaseService class.
|
Modifier and Type | Method and Description |
---|---|
void |
associateCloudMapService(AssociateCloudMapServiceOptions options)
Associates this service with a CloudMap service.
|
LoadBalancerTargetProps |
attachToApplicationTargetGroup(IApplicationTargetGroup targetGroup)
This method is called to attach this service to an Application Load Balancer.
|
void |
attachToClassicLB(LoadBalancer loadBalancer)
Registers the service as a target of a Classic Load Balancer (CLB).
|
LoadBalancerTargetProps |
attachToNetworkTargetGroup(INetworkTargetGroup targetGroup)
This method is called to attach this service to a Network Load Balancer.
|
ScalableTaskCount |
autoScaleTaskCount(EnableScalingProps props)
An attribute representing the minimum and maximum task count for an AutoScalingGroup.
|
protected void |
configureAwsVpcNetworking(IVpc vpc)
Deprecated.
use configureAwsVpcNetworkingWithSecurityGroups instead.
|
protected void |
configureAwsVpcNetworking(IVpc vpc,
java.lang.Boolean assignPublicIp)
Deprecated.
use configureAwsVpcNetworkingWithSecurityGroups instead.
|
protected void |
configureAwsVpcNetworking(IVpc vpc,
java.lang.Boolean assignPublicIp,
SubnetSelection vpcSubnets)
Deprecated.
use configureAwsVpcNetworkingWithSecurityGroups instead.
|
protected void |
configureAwsVpcNetworking(IVpc vpc,
java.lang.Boolean assignPublicIp,
SubnetSelection vpcSubnets,
ISecurityGroup securityGroup)
Deprecated.
use configureAwsVpcNetworkingWithSecurityGroups instead.
|
protected void |
configureAwsVpcNetworkingWithSecurityGroups(IVpc vpc)
This method is called to create a networkConfiguration.
|
protected void |
configureAwsVpcNetworkingWithSecurityGroups(IVpc vpc,
java.lang.Boolean assignPublicIp)
This method is called to create a networkConfiguration.
|
protected void |
configureAwsVpcNetworkingWithSecurityGroups(IVpc vpc,
java.lang.Boolean assignPublicIp,
SubnetSelection vpcSubnets)
This method is called to create a networkConfiguration.
|
protected void |
configureAwsVpcNetworkingWithSecurityGroups(IVpc vpc,
java.lang.Boolean assignPublicIp,
SubnetSelection vpcSubnets,
java.util.List<ISecurityGroup> securityGroups)
This method is called to create a networkConfiguration.
|
Service |
enableCloudMap(CloudMapOptions options)
Enable CloudMap service discovery for the service.
|
static IBaseService |
fromServiceArnWithCluster(software.constructs.Construct scope,
java.lang.String id,
java.lang.String serviceArn)
Import an existing ECS/Fargate Service using the service cluster format.
|
protected Service |
getCloudmapService()
The details of the AWS Cloud Map service.
|
IService |
getCloudMapService()
The CloudMap service created for this service, if any.
|
ICluster |
getCluster()
The cluster that hosts the service.
|
Connections |
getConnections()
The security groups which manage the allowed network traffic for the service.
|
protected java.util.List<CfnService.LoadBalancerProperty> |
getLoadBalancers()
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.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.
|
java.lang.String |
getServiceArn()
The Amazon Resource Name (ARN) of the service.
|
java.lang.String |
getServiceName()
The name of the service.
|
protected java.util.List<CfnService.ServiceRegistryProperty> |
getServiceRegistries()
The details of the service discovery registries to assign to this service.
|
TaskDefinition |
getTaskDefinition()
The task definition to use for tasks in the service.
|
IEcsLoadBalancerTarget |
loadBalancerTarget(LoadBalancerTargetOptions options)
Return a load balancing target for a specific container and port.
|
Metric |
metric(java.lang.String metricName)
This method returns the specified CloudWatch metric name for this service.
|
Metric |
metric(java.lang.String metricName,
MetricOptions props)
This method returns the specified CloudWatch metric name for this service.
|
Metric |
metricCpuUtilization()
This method returns the CloudWatch metric for this service's CPU utilization.
|
Metric |
metricCpuUtilization(MetricOptions props)
This method returns the CloudWatch metric for this service's CPU utilization.
|
Metric |
metricMemoryUtilization()
This method returns the CloudWatch metric for this service's memory utilization.
|
Metric |
metricMemoryUtilization(MetricOptions props)
This method returns the CloudWatch metric for this service's memory utilization.
|
void |
registerLoadBalancerTargets(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 void |
setCloudmapService(Service value)
The details of the AWS Cloud Map service.
|
protected void |
setLoadBalancers(java.util.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.
|
protected void |
setNetworkConfiguration(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.
|
protected void |
setServiceRegistries(java.util.List<CfnService.ServiceRegistryProperty> value)
The details of the service discovery registries to assign to this service.
|
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isResource
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applyRemovalPolicy, getEnv, getStack
getNode
protected BaseService(software.amazon.jsii.JsiiObjectRef objRef)
protected BaseService(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
protected BaseService(software.constructs.Construct scope, java.lang.String id, BaseServiceProps props, java.lang.Object additionalProps, TaskDefinition taskDefinition)
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.public static IBaseService fromServiceArnWithCluster(software.constructs.Construct scope, java.lang.String id, java.lang.String serviceArn)
The format is the "new" format "arn:aws:ecs:region:aws_account_id:service/cluster-name/service-name".
scope
- This parameter is required.id
- This parameter is required.serviceArn
- This parameter is required.public void associateCloudMapService(AssociateCloudMapServiceOptions options)
options
- This parameter is required.public LoadBalancerTargetProps attachToApplicationTargetGroup(IApplicationTargetGroup targetGroup)
Don't call this function directly. Instead, call listener.addTargets()
to add this service to a load balancer.
attachToApplicationTargetGroup
in interface IApplicationLoadBalancerTarget
targetGroup
- This parameter is required.public void attachToClassicLB(LoadBalancer loadBalancer)
Don't call this. Call loadBalancer.addTarget()
instead.
attachToClassicLB
in interface ILoadBalancerTarget
loadBalancer
- This parameter is required.public LoadBalancerTargetProps attachToNetworkTargetGroup(INetworkTargetGroup targetGroup)
Don't call this function directly. Instead, call listener.addTargets()
to add this service to a load balancer.
attachToNetworkTargetGroup
in interface INetworkLoadBalancerTarget
targetGroup
- This parameter is required.public ScalableTaskCount autoScaleTaskCount(EnableScalingProps props)
props
- This parameter is required.@Deprecated protected void configureAwsVpcNetworking(IVpc vpc, java.lang.Boolean assignPublicIp, SubnetSelection vpcSubnets, ISecurityGroup securityGroup)
vpc
- This parameter is required.assignPublicIp
- vpcSubnets
- securityGroup
- @Deprecated protected void configureAwsVpcNetworking(IVpc vpc, java.lang.Boolean assignPublicIp, SubnetSelection vpcSubnets)
vpc
- This parameter is required.assignPublicIp
- vpcSubnets
- @Deprecated protected void configureAwsVpcNetworking(IVpc vpc, java.lang.Boolean assignPublicIp)
vpc
- This parameter is required.assignPublicIp
- @Deprecated protected void configureAwsVpcNetworking(IVpc vpc)
vpc
- This parameter is required.protected void configureAwsVpcNetworkingWithSecurityGroups(IVpc vpc, java.lang.Boolean assignPublicIp, SubnetSelection vpcSubnets, java.util.List<ISecurityGroup> securityGroups)
vpc
- This parameter is required.assignPublicIp
- vpcSubnets
- securityGroups
- protected void configureAwsVpcNetworkingWithSecurityGroups(IVpc vpc, java.lang.Boolean assignPublicIp, SubnetSelection vpcSubnets)
vpc
- This parameter is required.assignPublicIp
- vpcSubnets
- protected void configureAwsVpcNetworkingWithSecurityGroups(IVpc vpc, java.lang.Boolean assignPublicIp)
vpc
- This parameter is required.assignPublicIp
- protected void configureAwsVpcNetworkingWithSecurityGroups(IVpc vpc)
vpc
- This parameter is required.public Service enableCloudMap(CloudMapOptions options)
options
- This parameter is required.public IEcsLoadBalancerTarget loadBalancerTarget(LoadBalancerTargetOptions options)
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 Service
object 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());
options
- This parameter is required.public Metric metric(java.lang.String metricName, MetricOptions props)
metricName
- This parameter is required.props
- public Metric metric(java.lang.String metricName)
metricName
- This parameter is required.public Metric metricCpuUtilization(MetricOptions props)
Default: average over 5 minutes
props
- public Metric metricCpuUtilization()
Default: average over 5 minutes
public Metric metricMemoryUtilization(MetricOptions props)
Default: average over 5 minutes
props
- public Metric metricMemoryUtilization()
Default: average over 5 minutes
public void registerLoadBalancerTargets(EcsTarget... targets)
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());
targets
- This parameter is required.public ICluster getCluster()
getCluster
in interface IBaseService
public Connections getConnections()
getConnections
in interface IConnectable
public java.lang.String getServiceArn()
getServiceArn
in interface IService
public java.lang.String getServiceName()
getServiceName
in interface IService
public TaskDefinition getTaskDefinition()
public IService getCloudMapService()
protected java.util.List<CfnService.LoadBalancerProperty> getLoadBalancers()
protected void setLoadBalancers(java.util.List<CfnService.LoadBalancerProperty> value)
protected java.util.List<CfnService.ServiceRegistryProperty> getServiceRegistries()
For more information, see Service Discovery.
protected void setServiceRegistries(java.util.List<CfnService.ServiceRegistryProperty> value)
For more information, see Service Discovery.
protected Service getCloudmapService()
protected void setCloudmapService(Service value)
protected CfnService.NetworkConfigurationProperty getNetworkConfiguration()
protected void setNetworkConfiguration(CfnService.NetworkConfigurationProperty value)