@Generated(value="jsii-pacmak/1.63.2 (build a8a8833)", date="2022-08-08T20:48:12.802Z") @Stability(value=Stable) public abstract class BaseService extends Resource implements IBaseService, IApplicationLoadBalancerTarget, INetworkLoadBalancerTarget, ILoadBalancerTarget
Example:
// Example automatically generated from non-compiling source. May contain errors. 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());
software.amazon.jsii.JsiiObject.InitializationMode
IBaseService.Jsii$Default
IApplicationLoadBalancerTarget.Jsii$Default
INetworkLoadBalancerTarget.Jsii$Default
ILoadBalancerTarget.Jsii$Default
Modifier | Constructor and Description |
---|---|
protected |
BaseService(software.constructs.Construct scope,
String id,
BaseServiceProps props,
Object additionalProps,
TaskDefinition taskDefinition)
Constructs a new instance of the BaseService class.
|
protected |
BaseService(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
BaseService(software.amazon.jsii.JsiiObjectRef objRef) |
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 |
configureAwsVpcNetworkingWithSecurityGroups(IVpc vpc)
This method is called to create a networkConfiguration.
|
protected void |
configureAwsVpcNetworkingWithSecurityGroups(IVpc vpc,
Boolean assignPublicIp)
This method is called to create a networkConfiguration.
|
protected void |
configureAwsVpcNetworkingWithSecurityGroups(IVpc vpc,
Boolean assignPublicIp,
SubnetSelection vpcSubnets)
This method is called to create a networkConfiguration.
|
protected void |
configureAwsVpcNetworkingWithSecurityGroups(IVpc vpc,
Boolean assignPublicIp,
SubnetSelection vpcSubnets,
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,
String id,
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 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.
|
String |
getServiceArn()
The Amazon Resource Name (ARN) of the service.
|
String |
getServiceName()
The name of the service.
|
protected 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(String metricName)
This method returns the specified CloudWatch metric name for this service.
|
Metric |
metric(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(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(List<CfnService.ServiceRegistryProperty> value)
The details of the service discovery registries to assign to this service.
|
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResource
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
applyRemovalPolicy, getEnv, getStack
protected BaseService(software.amazon.jsii.JsiiObjectRef objRef)
protected BaseService(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable) protected BaseService(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull BaseServiceProps props, @NotNull Object additionalProps, @NotNull 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.@Stability(value=Stable) @NotNull public static IBaseService fromServiceArnWithCluster(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull 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.@Stability(value=Stable) public void associateCloudMapService(@NotNull AssociateCloudMapServiceOptions options)
options
- This parameter is required.@Stability(value=Stable) @NotNull public LoadBalancerTargetProps attachToApplicationTargetGroup(@NotNull 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.@Stability(value=Stable) public void attachToClassicLB(@NotNull LoadBalancer loadBalancer)
Don't call this. Call loadBalancer.addTarget()
instead.
attachToClassicLB
in interface ILoadBalancerTarget
loadBalancer
- This parameter is required.@Stability(value=Stable) @NotNull public LoadBalancerTargetProps attachToNetworkTargetGroup(@NotNull 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.@Stability(value=Stable) @NotNull public ScalableTaskCount autoScaleTaskCount(@NotNull EnableScalingProps props)
props
- This parameter is required.@Stability(value=Stable) protected void configureAwsVpcNetworkingWithSecurityGroups(@NotNull IVpc vpc, @Nullable Boolean assignPublicIp, @Nullable SubnetSelection vpcSubnets, @Nullable List<ISecurityGroup> securityGroups)
vpc
- This parameter is required.assignPublicIp
- vpcSubnets
- securityGroups
- @Stability(value=Stable) protected void configureAwsVpcNetworkingWithSecurityGroups(@NotNull IVpc vpc, @Nullable Boolean assignPublicIp, @Nullable SubnetSelection vpcSubnets)
vpc
- This parameter is required.assignPublicIp
- vpcSubnets
- @Stability(value=Stable) protected void configureAwsVpcNetworkingWithSecurityGroups(@NotNull IVpc vpc, @Nullable Boolean assignPublicIp)
vpc
- This parameter is required.assignPublicIp
- @Stability(value=Stable) protected void configureAwsVpcNetworkingWithSecurityGroups(@NotNull IVpc vpc)
vpc
- This parameter is required.@Stability(value=Stable) @NotNull public Service enableCloudMap(@NotNull CloudMapOptions options)
options
- This parameter is required.@Stability(value=Stable) @NotNull public IEcsLoadBalancerTarget loadBalancerTarget(@NotNull 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.@Stability(value=Stable) @NotNull public Metric metric(@NotNull String metricName, @Nullable MetricOptions props)
metricName
- This parameter is required.props
- @Stability(value=Stable) @NotNull public Metric metric(@NotNull String metricName)
metricName
- This parameter is required.@Stability(value=Stable) @NotNull public Metric metricCpuUtilization(@Nullable MetricOptions props)
Default: average over 5 minutes
props
- @Stability(value=Stable) @NotNull public Metric metricCpuUtilization()
Default: average over 5 minutes
@Stability(value=Stable) @NotNull public Metric metricMemoryUtilization(@Nullable MetricOptions props)
Default: average over 5 minutes
props
- @Stability(value=Stable) @NotNull public Metric metricMemoryUtilization()
Default: average over 5 minutes
@Stability(value=Stable) public void registerLoadBalancerTargets(@NotNull 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.@Stability(value=Stable) @NotNull public ICluster getCluster()
getCluster
in interface IBaseService
@Stability(value=Stable) @NotNull public Connections getConnections()
getConnections
in interface IConnectable
@Stability(value=Stable) @NotNull public String getServiceArn()
getServiceArn
in interface IService
@Stability(value=Stable) @NotNull public String getServiceName()
getServiceName
in interface IService
@Stability(value=Stable) @NotNull public TaskDefinition getTaskDefinition()
@Stability(value=Stable) @Nullable public IService getCloudMapService()
@Stability(value=Stable) @NotNull protected List<CfnService.LoadBalancerProperty> getLoadBalancers()
@Stability(value=Stable) protected void setLoadBalancers(@NotNull List<CfnService.LoadBalancerProperty> value)
@Stability(value=Stable) @NotNull protected List<CfnService.ServiceRegistryProperty> getServiceRegistries()
For more information, see Service Discovery.
@Stability(value=Stable) protected void setServiceRegistries(@NotNull List<CfnService.ServiceRegistryProperty> value)
For more information, see Service Discovery.
@Stability(value=Stable) @Nullable protected Service getCloudmapService()
@Stability(value=Stable) protected void setCloudmapService(@Nullable Service value)
@Stability(value=Stable) @Nullable protected CfnService.NetworkConfigurationProperty getNetworkConfiguration()
@Stability(value=Stable) protected void setNetworkConfiguration(@Nullable CfnService.NetworkConfigurationProperty value)
Copyright © 2022. All rights reserved.