java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.core.Construct
software.amazon.awscdk.core.Resource
software.amazon.awscdk.services.applicationautoscaling.ScalableTarget
All Implemented Interfaces:
IConstruct, IDependable, IResource, IScalableTarget, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:37.369Z") @Stability(Stable) public class ScalableTarget extends Resource implements IScalableTarget
Define a scalable target.

Example:

 import software.amazon.awscdk.services.lambda.*;
 Code code;
 Function handler = Function.Builder.create(this, "MyFunction")
         .runtime(Runtime.PYTHON_3_7)
         .handler("index.handler")
         .code(code)
         .reservedConcurrentExecutions(2)
         .build();
 Version fnVer = handler.getCurrentVersion();
 ScalableTarget target = ScalableTarget.Builder.create(this, "ScalableTarget")
         .serviceNamespace(ServiceNamespace.LAMBDA)
         .maxCapacity(100)
         .minCapacity(10)
         .resourceId(String.format("function:%s:%s", handler.getFunctionName(), fnVer.getVersion()))
         .scalableDimension("lambda:function:ProvisionedConcurrency")
         .build();
 target.scaleToTrackMetric("PceTracking", BasicTargetTrackingScalingPolicyProps.builder()
         .targetValue(0.9)
         .predefinedMetric(PredefinedMetric.LAMBDA_PROVISIONED_CONCURRENCY_UTILIZATION)
         .build());
 
  • Constructor Details

    • ScalableTarget

      protected ScalableTarget(software.amazon.jsii.JsiiObjectRef objRef)
    • ScalableTarget

      protected ScalableTarget(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • ScalableTarget

      @Stability(Stable) public ScalableTarget(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull ScalableTargetProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • fromScalableTargetId

      @Stability(Stable) @NotNull public static IScalableTarget fromScalableTargetId(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String scalableTargetId)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      scalableTargetId - This parameter is required.
    • addToRolePolicy

      @Stability(Stable) public void addToRolePolicy(@NotNull PolicyStatement statement)
      Add a policy statement to the role's policy.

      Parameters:
      statement - This parameter is required.
    • scaleOnMetric

      @Stability(Stable) @NotNull public StepScalingPolicy scaleOnMetric(@NotNull String id, @NotNull BasicStepScalingPolicyProps props)
      Scale out or in, in response to a metric.

      Parameters:
      id - This parameter is required.
      props - This parameter is required.
    • scaleOnSchedule

      @Stability(Stable) public void scaleOnSchedule(@NotNull String id, @NotNull ScalingSchedule action)
      Scale out or in based on time.

      Parameters:
      id - This parameter is required.
      action - This parameter is required.
    • scaleToTrackMetric

      @Stability(Stable) @NotNull public TargetTrackingScalingPolicy scaleToTrackMetric(@NotNull String id, @NotNull BasicTargetTrackingScalingPolicyProps props)
      Scale out or in in order to keep a metric around a target value.

      Parameters:
      id - This parameter is required.
      props - This parameter is required.
    • getRole

      @Stability(Stable) @NotNull public IRole getRole()
      The role used to give AutoScaling permissions to your resource.
    • getScalableTargetId

      @Stability(Stable) @NotNull public String getScalableTargetId()
      ID of the Scalable Target.

      Example value: service/ecsStack-MyECSCluster-AB12CDE3F4GH/ecsStack-MyECSService-AB12CDE3F4GH|ecs:service:DesiredCount|ecs

      Specified by:
      getScalableTargetId in interface IScalableTarget