DeleteScalingPolicyAWS SDKOR와 함께 사용 CLI - AWS SDK코드 예제

AWS 문서 AWS SDK SDK 예제 GitHub 리포지토리에 더 많은 예제가 있습니다.

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

DeleteScalingPolicyAWS SDKOR와 함께 사용 CLI

다음 코드 예제는 DeleteScalingPolicy의 사용 방법을 보여 줍니다.

CLI
AWS CLI

조정 정책을 삭제하려면

이 예제는 기본 클러스터에서 실행되는 Amazon ECS 서비스 웹 앱에 대한 조정 정책을 삭제합니다.

명령:

aws application-autoscaling delete-scaling-policy --policy-name web-app-cpu-lt-25 --scalable-dimension ecs:service:DesiredCount --resource-id service/default/web-app --service-namespace ecs
Java
SDK자바 2.x의 경우
참고

더 많은 내용이 있습니다. GitHub AWS 코드 예시 리포지토리에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요.

import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.applicationautoscaling.ApplicationAutoScalingClient; import software.amazon.awssdk.services.applicationautoscaling.model.ApplicationAutoScalingException; import software.amazon.awssdk.services.applicationautoscaling.model.DeleteScalingPolicyRequest; import software.amazon.awssdk.services.applicationautoscaling.model.DeregisterScalableTargetRequest; import software.amazon.awssdk.services.applicationautoscaling.model.DescribeScalableTargetsRequest; import software.amazon.awssdk.services.applicationautoscaling.model.DescribeScalableTargetsResponse; import software.amazon.awssdk.services.applicationautoscaling.model.DescribeScalingPoliciesRequest; import software.amazon.awssdk.services.applicationautoscaling.model.DescribeScalingPoliciesResponse; import software.amazon.awssdk.services.applicationautoscaling.model.ScalableDimension; import software.amazon.awssdk.services.applicationautoscaling.model.ServiceNamespace; /** * Before running this Java V2 code example, set up your development environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class DisableDynamoDBAutoscaling { public static void main(String[] args) { final String usage = """ Usage: <tableId> <policyName>\s Where: tableId - The table Id value (for example, table/Music).\s policyName - The name of the policy (for example, $Music5-scaling-policy). """; if (args.length != 2) { System.out.println(usage); System.exit(1); } ApplicationAutoScalingClient appAutoScalingClient = ApplicationAutoScalingClient.builder() .region(Region.US_EAST_1) .build(); ServiceNamespace ns = ServiceNamespace.DYNAMODB; ScalableDimension tableWCUs = ScalableDimension.DYNAMODB_TABLE_WRITE_CAPACITY_UNITS; String tableId = args[0]; String policyName = args[1]; deletePolicy(appAutoScalingClient, policyName, tableWCUs, ns, tableId); verifyScalingPolicies(appAutoScalingClient, tableId, ns, tableWCUs); deregisterScalableTarget(appAutoScalingClient, tableId, ns, tableWCUs); verifyTarget(appAutoScalingClient, tableId, ns, tableWCUs); } public static void deletePolicy(ApplicationAutoScalingClient appAutoScalingClient, String policyName, ScalableDimension tableWCUs, ServiceNamespace ns, String tableId) { try { DeleteScalingPolicyRequest delSPRequest = DeleteScalingPolicyRequest.builder() .policyName(policyName) .scalableDimension(tableWCUs) .serviceNamespace(ns) .resourceId(tableId) .build(); appAutoScalingClient.deleteScalingPolicy(delSPRequest); System.out.println(policyName +" was deleted successfully."); } catch (ApplicationAutoScalingException e) { System.err.println(e.awsErrorDetails().errorMessage()); } } // Verify that the scaling policy was deleted public static void verifyScalingPolicies(ApplicationAutoScalingClient appAutoScalingClient, String tableId, ServiceNamespace ns, ScalableDimension tableWCUs) { DescribeScalingPoliciesRequest dscRequest = DescribeScalingPoliciesRequest.builder() .scalableDimension(tableWCUs) .serviceNamespace(ns) .resourceId(tableId) .build(); DescribeScalingPoliciesResponse response = appAutoScalingClient.describeScalingPolicies(dscRequest); System.out.println("DescribeScalableTargets result: "); System.out.println(response); } public static void deregisterScalableTarget(ApplicationAutoScalingClient appAutoScalingClient, String tableId, ServiceNamespace ns, ScalableDimension tableWCUs) { try { DeregisterScalableTargetRequest targetRequest = DeregisterScalableTargetRequest.builder() .scalableDimension(tableWCUs) .serviceNamespace(ns) .resourceId(tableId) .build(); appAutoScalingClient.deregisterScalableTarget(targetRequest); System.out.println("The scalable target was deregistered."); } catch (ApplicationAutoScalingException e) { System.err.println(e.awsErrorDetails().errorMessage()); } } public static void verifyTarget(ApplicationAutoScalingClient appAutoScalingClient, String tableId, ServiceNamespace ns, ScalableDimension tableWCUs) { DescribeScalableTargetsRequest dscRequest = DescribeScalableTargetsRequest.builder() .scalableDimension(tableWCUs) .serviceNamespace(ns) .resourceIds(tableId) .build(); DescribeScalableTargetsResponse response = appAutoScalingClient.describeScalableTargets(dscRequest); System.out.println("DescribeScalableTargets result: "); System.out.println(response); } }
PowerShell
에 대한 도구 PowerShell

예 1: 이 cmdlet은 Application Auto Scaling 확장 가능 대상에 대해 지정된 조정 정책을 삭제합니다.

Remove-AASScalingPolicy -ServiceNamespace AppStream -PolicyName "default-scale-out" -ResourceId fleet/Test -ScalableDimension appstream:fleet:DesiredCapacity
  • API자세한 내용은 Cmdlet 참조를 참조하십시오 DeleteScalingPolicy.AWS Tools for PowerShell