

Doc AWS SDK 예제 GitHub 리포지토리에서 더 많은 SDK 예제를 사용할 수 있습니다. [AWS](https://github.com/awsdocs/aws-doc-sdk-examples) 

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

# AWS SDKs를 사용한 Application Auto Scaling 코드 예제
<a name="application-auto-scaling_code_examples"></a>

다음 코드 예제에서는 AWS 소프트웨어 개발 키트(SDK)와 함께 Application Auto Scaling을 사용하는 방법을 보여줍니다.

*작업*은 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 작업은 개별 서비스 함수를 직접 호출하는 방법을 보여주며, 관련 시나리오의 컨텍스트에 맞는 작업을 볼 수 있습니다.

**추가 리소스**
+  **[Application Auto Scaling 사용 설명서](https://docs.aws.amazon.com/autoscaling/application/userguide/what-is-application-auto-scaling.html)** - Application Auto Scaling에 대한 자세한 정보입니다.
+ **[애플리케이션 Auto Scaling API 참조](https://docs.aws.amazon.com/autoscaling/application/APIReference/Welcome.html)** - 사용 가능한 모든 애플리케이션 Auto Scaling 작업에 대한 세부 정보입니다.
+ **[AWS 개발자 센터](https://aws.amazon.com/developer/code-examples/?awsf.sdk-code-examples-product=product%23)** - 범주 또는 전체 텍스트 검색을 기준으로 필터링할 수 있는 코드 예제입니다.
+ **[AWS SDK 예제](https://github.com/awsdocs/aws-doc-sdk-examples)** - 기본 언어로 된 전체 코드가 포함된 GitHub 리포지토리. 코드 설정 및 실행을 위한 지침이 포함되어 있습니다.

**Contents**
+ [기본 사항](application-auto-scaling_code_examples_basics.md)
  + [작업](application-auto-scaling_code_examples_actions.md)
    + [`DeleteScalingPolicy`](application-auto-scaling_example_application-auto-scaling_DeleteScalingPolicy_section.md)
    + [`DeleteScheduledAction`](application-auto-scaling_example_application-auto-scaling_DeleteScheduledAction_section.md)
    + [`DeregisterScalableTarget`](application-auto-scaling_example_application-auto-scaling_DeregisterScalableTarget_section.md)
    + [`DescribeScalableTargets`](application-auto-scaling_example_application-auto-scaling_DescribeScalableTargets_section.md)
    + [`DescribeScalingActivities`](application-auto-scaling_example_application-auto-scaling_DescribeScalingActivities_section.md)
    + [`DescribeScalingPolicies`](application-auto-scaling_example_application-auto-scaling_DescribeScalingPolicies_section.md)
    + [`DescribeScheduledActions`](application-auto-scaling_example_application-auto-scaling_DescribeScheduledActions_section.md)
    + [`PutScalingPolicy`](application-auto-scaling_example_application-auto-scaling_PutScalingPolicy_section.md)
    + [`PutScheduledAction`](application-auto-scaling_example_application-auto-scaling_PutScheduledAction_section.md)
    + [`RegisterScalableTarget`](application-auto-scaling_example_application-auto-scaling_RegisterScalableTarget_section.md)

# AWS SDKs를 사용한 Application Auto Scaling의 기본 예제
<a name="application-auto-scaling_code_examples_basics"></a>

다음 코드 예제에서는 Application Auto Scaling의 기본 기능을 AWS SDK와 함께 사용하는 방법을 보여줍니다.

**Contents**
+ [작업](application-auto-scaling_code_examples_actions.md)
  + [`DeleteScalingPolicy`](application-auto-scaling_example_application-auto-scaling_DeleteScalingPolicy_section.md)
  + [`DeleteScheduledAction`](application-auto-scaling_example_application-auto-scaling_DeleteScheduledAction_section.md)
  + [`DeregisterScalableTarget`](application-auto-scaling_example_application-auto-scaling_DeregisterScalableTarget_section.md)
  + [`DescribeScalableTargets`](application-auto-scaling_example_application-auto-scaling_DescribeScalableTargets_section.md)
  + [`DescribeScalingActivities`](application-auto-scaling_example_application-auto-scaling_DescribeScalingActivities_section.md)
  + [`DescribeScalingPolicies`](application-auto-scaling_example_application-auto-scaling_DescribeScalingPolicies_section.md)
  + [`DescribeScheduledActions`](application-auto-scaling_example_application-auto-scaling_DescribeScheduledActions_section.md)
  + [`PutScalingPolicy`](application-auto-scaling_example_application-auto-scaling_PutScalingPolicy_section.md)
  + [`PutScheduledAction`](application-auto-scaling_example_application-auto-scaling_PutScheduledAction_section.md)
  + [`RegisterScalableTarget`](application-auto-scaling_example_application-auto-scaling_RegisterScalableTarget_section.md)

# AWS SDKs를 사용한 Application Auto Scaling 작업
<a name="application-auto-scaling_code_examples_actions"></a>

다음 코드 예제에서는 AWS SDKs를 사용하여 개별 Application Auto Scaling 작업을 수행하는 방법을 보여줍니다. 각 예시에는 GitHub에 대한 링크가 포함되어 있습니다. 여기에서 코드 설정 및 실행에 대한 지침을 찾을 수 있습니다.

 다음 예제에는 가장 일반적으로 사용되는 작업만 포함되어 있습니다. 전체 목록은 [Application Auto Scaling API 참조](https://docs.aws.amazon.com/autoscaling/application/APIReference/Welcome.html)를 참조하세요.

**Topics**
+ [`DeleteScalingPolicy`](application-auto-scaling_example_application-auto-scaling_DeleteScalingPolicy_section.md)
+ [`DeleteScheduledAction`](application-auto-scaling_example_application-auto-scaling_DeleteScheduledAction_section.md)
+ [`DeregisterScalableTarget`](application-auto-scaling_example_application-auto-scaling_DeregisterScalableTarget_section.md)
+ [`DescribeScalableTargets`](application-auto-scaling_example_application-auto-scaling_DescribeScalableTargets_section.md)
+ [`DescribeScalingActivities`](application-auto-scaling_example_application-auto-scaling_DescribeScalingActivities_section.md)
+ [`DescribeScalingPolicies`](application-auto-scaling_example_application-auto-scaling_DescribeScalingPolicies_section.md)
+ [`DescribeScheduledActions`](application-auto-scaling_example_application-auto-scaling_DescribeScheduledActions_section.md)
+ [`PutScalingPolicy`](application-auto-scaling_example_application-auto-scaling_PutScalingPolicy_section.md)
+ [`PutScheduledAction`](application-auto-scaling_example_application-auto-scaling_PutScheduledAction_section.md)
+ [`RegisterScalableTarget`](application-auto-scaling_example_application-auto-scaling_RegisterScalableTarget_section.md)

# AWS SDK 또는 CLI와 `DeleteScalingPolicy` 함께 사용
<a name="application-auto-scaling_example_application-auto-scaling_DeleteScalingPolicy_section"></a>

다음 코드 예시는 `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
```
+  API 세부 정보는 *AWS CLI 명령 참조*의 [DeleteScalingPolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/application-autoscaling/delete-scaling-policy.html)를 참조하세요.

------
#### [ Java ]

**SDK for Java 2.x**  
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/appautoscale#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

```
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);
    }
}
```
+  API 세부 정보는 *AWS SDK for Java 2.x API 참조*의 [DeleteScalingPolicy](https://docs.aws.amazon.com/goto/SdkForJavaV2/application-autoscaling-2016-02-06/DeleteScalingPolicy)를 참조하세요.

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**예제 1: 이 cmdlet은 Application Auto Scaling 규모 조정 가능 대상에 대해 지정된 조정 정책을 삭제합니다.**  

```
Remove-AASScalingPolicy -ServiceNamespace AppStream -PolicyName "default-scale-out" -ResourceId fleet/Test -ScalableDimension appstream:fleet:DesiredCapacity
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V4)*의 [DeleteScalingPolicy](https://docs.aws.amazon.com/powershell/v4/reference)를 참조하세요.

**Tools for PowerShell V5**  
**예제 1: 이 cmdlet은 Application Auto Scaling 규모 조정 가능 대상에 대해 지정된 조정 정책을 삭제합니다.**  

```
Remove-AASScalingPolicy -ServiceNamespace AppStream -PolicyName "default-scale-out" -ResourceId fleet/Test -ScalableDimension appstream:fleet:DesiredCapacity
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V5)*의 [DeleteScalingPolicy](https://docs.aws.amazon.com/powershell/v5/reference)를 참조하세요.

------

# CLI로 `DeleteScheduledAction` 사용
<a name="application-auto-scaling_example_application-auto-scaling_DeleteScheduledAction_section"></a>

다음 코드 예시는 `DeleteScheduledAction`의 사용 방법을 보여 줍니다.

------
#### [ CLI ]

**AWS CLI**  
**예약된 작업을 삭제하는 방법**  
다음 `delete-scheduled-action` 예제에서는 지정된 Amazon AppStream 2.0 플릿에서 지정된 예약된 작업을 삭제합니다.  

```
aws application-autoscaling delete-scheduled-action \
    --service-namespace appstream \
    --scalable-dimension appstream:fleet:DesiredCapacity \
    --resource-id fleet/sample-fleet \
    --scheduled-action-name my-recurring-action
```
이 명령은 출력을 생성하지 않습니다.  
자세한 내용은 [https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-scheduled-scaling.html](https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-scheduled-scaling.html)Application Auto Scaling 사용 설명서의 *예약된 조정*을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [DeleteScheduledAction](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/application-autoscaling/delete-scheduled-action.html)을 참조하세요.

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**예제 1: 이 cmdlet은 Application Auto Scaling 규모 조정 가능 대상에 대해 지정된 예약된 작업을 삭제합니다.**  

```
Remove-AASScheduledAction -ServiceNamespace AppStream -ScheduledActionName WeekDaysFleetScaling -ResourceId fleet/MyFleet -ScalableDimension appstream:fleet:DesiredCapacity
```
**출력:**  

```
Confirm
Are you sure you want to perform this action?
Performing the operation "Remove-AASScheduledAction (DeleteScheduledAction)" on target "WeekDaysFleetScaling".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): Y
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V4)*의 [DeleteScheduledAction](https://docs.aws.amazon.com/powershell/v4/reference)을 참조하세요.

**Tools for PowerShell V5**  
**예제 1: 이 cmdlet은 Application Auto Scaling 규모 조정 가능 대상에 대해 지정된 예약된 작업을 삭제합니다.**  

```
Remove-AASScheduledAction -ServiceNamespace AppStream -ScheduledActionName WeekDaysFleetScaling -ResourceId fleet/MyFleet -ScalableDimension appstream:fleet:DesiredCapacity
```
**출력:**  

```
Confirm
Are you sure you want to perform this action?
Performing the operation "Remove-AASScheduledAction (DeleteScheduledAction)" on target "WeekDaysFleetScaling".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): Y
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V5)*의 [DeleteScheduledAction](https://docs.aws.amazon.com/powershell/v5/reference)을 참조하세요.

------

# CLI로 `DeregisterScalableTarget` 사용
<a name="application-auto-scaling_example_application-auto-scaling_DeregisterScalableTarget_section"></a>

다음 코드 예시는 `DeregisterScalableTarget`의 사용 방법을 보여 줍니다.

------
#### [ CLI ]

**AWS CLI**  
**확장 가능 대상의 등록을 취소하는 방법**  
이 예제에서는 기본 클러스터에서 실행 중인 웹앱이라고 하는 Amazon ECS 서비스에 대한 확장 가능 대상의 등록을 취소합니다.  
명령:  

```
aws application-autoscaling deregister-scalable-target --service-namespace ecs --scalable-dimension ecs:service:DesiredCount --resource-id service/default/web-app
```
이 예제에서는 사용자 지정 리소스에 대한 확장 가능 대상의 등록을 취소합니다. custom-resource-id.txt 파일에는 리소스 ID를 식별하는 문자열이 포함되어 있으며 이는 사용자 지정 리소스의 경우 Amazon API Gateway 엔드포인트를 통하는 사용자 지정 리소스에 대한 경로입니다.  
명령:  

```
aws application-autoscaling deregister-scalable-target --service-namespace custom-resource --scalable-dimension custom-resource:ResourceType:Property --resource-id file://~/custom-resource-id.txt
```
custom-resource-id.txt 파일의 콘텐츠:  

```
https://example.execute-api.us-west-2.amazonaws.com/prod/scalableTargetDimensions/1-23456789
```
+  API 세부 정보는 *AWS CLI 명령 참조*의 [DeregisterScalableTarget](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/application-autoscaling/deregister-scalable-target.html)을 참조하세요.

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**예제 1: 이 cmdlet에서는 Application Auto Scaling 규모 조정 가능 대상의 등록을 취소합니다. 규모 조정 가능 대상의 등록을 취소하면 연결된 조정 정책이 삭제됩니다.**  

```
Remove-AASScalableTarget -ResourceId fleet/MyFleet -ScalableDimension appstream:fleet:DesiredCapacity -ServiceNamespace AppStream
```
**출력:**  

```
Confirm
Are you sure you want to perform this action?
Performing the operation "Remove-AASScalableTarget (DeregisterScalableTarget)" on target "fleet/MyFleet".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): Y
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V4)*의 [DeregisterScalableTarget](https://docs.aws.amazon.com/powershell/v4/reference)을 참조하세요.

**Tools for PowerShell V5**  
**예제 1: 이 cmdlet에서는 Application Auto Scaling 규모 조정 가능 대상의 등록을 취소합니다. 규모 조정 가능 대상의 등록을 취소하면 연결된 조정 정책이 삭제됩니다.**  

```
Remove-AASScalableTarget -ResourceId fleet/MyFleet -ScalableDimension appstream:fleet:DesiredCapacity -ServiceNamespace AppStream
```
**출력:**  

```
Confirm
Are you sure you want to perform this action?
Performing the operation "Remove-AASScalableTarget (DeregisterScalableTarget)" on target "fleet/MyFleet".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): Y
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V5)*의 [DeregisterScalableTarget](https://docs.aws.amazon.com/powershell/v5/reference)을 참조하세요.

------

# CLI로 `DescribeScalableTargets` 사용
<a name="application-auto-scaling_example_application-auto-scaling_DescribeScalableTargets_section"></a>

다음 코드 예시는 `DescribeScalableTargets`의 사용 방법을 보여 줍니다.

------
#### [ CLI ]

**AWS CLI**  
**확장 가능 대상을 설명하는 방법**  
다음 `describe-scalable-targets` 예제에서는 `ecs` 서비스 네임스페이스에 대한 확장 가능 대상을 설명합니다.  

```
aws application-autoscaling describe-scalable-targets \
    --service-namespace ecs
```
출력:  

```
{
    "ScalableTargets": [
        {
            "ServiceNamespace": "ecs",
            "ScalableDimension": "ecs:service:DesiredCount",
            "ResourceId": "service/default/web-app",
            "MinCapacity": 1,
            "MaxCapacity": 10,
            "RoleARN": "arn:aws:iam::123456789012:role/aws-service-role/ecs.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_ECSService",
            "CreationTime": 1462558906.199,
            "SuspendedState": {
                "DynamicScalingOutSuspended": false,
                "ScheduledScalingSuspended": false,
                "DynamicScalingInSuspended": false
            },
            "ScalableTargetARN": "arn:aws:application-autoscaling:us-west-2:123456789012:scalable-target/1234abcd56ab78cd901ef1234567890ab123"
        }
    ]
}
```
자세한 내용은 *Application Auto Scaling 사용 설명서*의 [Application Auto Scaling과 함께 사용할 수 있는AWS 서비스](https://docs.aws.amazon.com/autoscaling/application/userguide/integrated-services-list.html)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [DescribeScalableTargets](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/application-autoscaling/describe-scalable-targets.html)를 참조하세요.

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**예제 1: 이 예제에서는 지정된 네임스페이스의 Application Auto Scaling 규모 조정 가능 대상에 대한 정보를 제공합니다.**  

```
Get-AASScalableTarget -ServiceNamespace "AppStream"
```
**출력:**  

```
CreationTime      : 11/7/2019 2:30:03 AM
MaxCapacity       : 5
MinCapacity       : 1
ResourceId        : fleet/Test
RoleARN           : arn:aws:iam::012345678912:role/aws-service-role/appstream.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_AppStreamFleet
ScalableDimension : appstream:fleet:DesiredCapacity
ServiceNamespace  : appstream
SuspendedState    : Amazon.ApplicationAutoScaling.Model.SuspendedState
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V4)*의 [DescribeScalableTargets](https://docs.aws.amazon.com/powershell/v4/reference)을 참조하세요.

**Tools for PowerShell V5**  
**예제 1: 이 예제에서는 지정된 네임스페이스의 Application Auto Scaling 규모 조정 가능 대상에 대한 정보를 제공합니다.**  

```
Get-AASScalableTarget -ServiceNamespace "AppStream"
```
**출력:**  

```
CreationTime      : 11/7/2019 2:30:03 AM
MaxCapacity       : 5
MinCapacity       : 1
ResourceId        : fleet/Test
RoleARN           : arn:aws:iam::012345678912:role/aws-service-role/appstream.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_AppStreamFleet
ScalableDimension : appstream:fleet:DesiredCapacity
ServiceNamespace  : appstream
SuspendedState    : Amazon.ApplicationAutoScaling.Model.SuspendedState
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V5)*의 [DescribeScalableTargets](https://docs.aws.amazon.com/powershell/v5/reference)을 참조하세요.

------

# CLI로 `DescribeScalingActivities` 사용
<a name="application-auto-scaling_example_application-auto-scaling_DescribeScalingActivities_section"></a>

다음 코드 예시는 `DescribeScalingActivities`의 사용 방법을 보여 줍니다.

------
#### [ CLI ]

**AWS CLI**  
**예제 1: 지정된 Amazon ECS 서비스에 대한 스케일링 활동을 설명하는 방법**  
다음 `describe-scaling-activities` 예제에서는 `default` 클러스터에서 실행 중인 `web-app`이라고 하는 Amazon ECS 서비스에 대한 스케일링 활동을 설명합니다. 출력은 조정 정책에 의해 시작되는 스케일링 활동을 표시합니다.  

```
aws application-autoscaling describe-scaling-activities \
    --service-namespace ecs \
    --resource-id service/default/web-app
```
출력:  

```
{
    "ScalingActivities": [
        {
            "ScalableDimension": "ecs:service:DesiredCount",
            "Description": "Setting desired count to 1.",
            "ResourceId": "service/default/web-app",
            "ActivityId": "e6c5f7d1-dbbb-4a3f-89b2-51f33e766399",
            "StartTime": 1462575838.171,
            "ServiceNamespace": "ecs",
            "EndTime": 1462575872.111,
            "Cause": "monitor alarm web-app-cpu-lt-25 in state ALARM triggered policy web-app-cpu-lt-25",
            "StatusMessage": "Successfully set desired count to 1. Change successfully fulfilled by ecs.",
            "StatusCode": "Successful"
        }
    ]
}
```
자세한 내용은 *Application Auto Scaling 사용 설명서*의 [Application Auto Scaling에 대한 스케일링 활동](https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-scaling-activities.html)을 참조하세요.  
**예제 2: 지정된 DynamoDB 테이블에 대한 스케일링 활동을 설명하는 방법**  
다음 `describe-scaling-activities` 예제에서는 `TestTable`이라고 하는 DynamoDB에 대한 스케일링 활동을 설명합니다. 출력은 두 가지 다른 예약된 작업에 의해 시작되는 스케일링 활동을 표시합니다.  

```
aws application-autoscaling describe-scaling-activities \
    --service-namespace dynamodb \
    --resource-id table/TestTable
```
출력:  

```
{
    "ScalingActivities": [
        {
            "ScalableDimension": "dynamodb:table:WriteCapacityUnits",
            "Description": "Setting write capacity units to 10.",
            "ResourceId": "table/my-table",
            "ActivityId": "4d1308c0-bbcf-4514-a673-b0220ae38547",
            "StartTime": 1561574415.086,
            "ServiceNamespace": "dynamodb",
            "EndTime": 1561574449.51,
            "Cause": "maximum capacity was set to 10",
            "StatusMessage": "Successfully set write capacity units to 10. Change successfully fulfilled by dynamodb.",
            "StatusCode": "Successful"
        },
        {
            "ScalableDimension": "dynamodb:table:WriteCapacityUnits",
            "Description": "Setting min capacity to 5 and max capacity to 10",
            "ResourceId": "table/my-table",
            "ActivityId": "f2b7847b-721d-4e01-8ef0-0c8d3bacc1c7",
            "StartTime": 1561574414.644,
            "ServiceNamespace": "dynamodb",
            "Cause": "scheduled action name my-second-scheduled-action was triggered",
            "StatusMessage": "Successfully set min capacity to 5 and max capacity to 10",
            "StatusCode": "Successful"
        },
        {
            "ScalableDimension": "dynamodb:table:WriteCapacityUnits",
            "Description": "Setting write capacity units to 15.",
            "ResourceId": "table/my-table",
            "ActivityId": "d8ea4de6-9eaa-499f-b466-2cc5e681ba8b",
            "StartTime": 1561574108.904,
            "ServiceNamespace": "dynamodb",
            "EndTime": 1561574140.255,
            "Cause": "minimum capacity was set to 15",
            "StatusMessage": "Successfully set write capacity units to 15. Change successfully fulfilled by dynamodb.",
            "StatusCode": "Successful"
        },
        {
            "ScalableDimension": "dynamodb:table:WriteCapacityUnits",
            "Description": "Setting min capacity to 15 and max capacity to 20",
            "ResourceId": "table/my-table",
            "ActivityId": "3250fd06-6940-4e8e-bb1f-d494db7554d2",
            "StartTime": 1561574108.512,
            "ServiceNamespace": "dynamodb",
            "Cause": "scheduled action name my-first-scheduled-action was triggered",
            "StatusMessage": "Successfully set min capacity to 15 and max capacity to 20",
            "StatusCode": "Successful"
        }
    ]
}
```
자세한 내용은 *Application Auto Scaling 사용 설명서*의 [Application Auto Scaling에 대한 스케일링 활동](https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-scaling-activities.html)을 참조하세요.  
+  API 세부 정보는 **AWS CLI 명령 참조의 [DescribeScalingActivities](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/application-autoscaling/describe-scaling-activities.html)를 참조하세요.

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**예제 1: 이전 6주 동안 지정된 서비스 네임스페이스의 조정 활동에 대한 설명이 포함된 정보를 제공합니다.**  

```
Get-AASScalingActivity -ServiceNamespace AppStream
```
**출력:**  

```
ActivityId        : 2827409f-b639-4cdb-a957-8055d5d07434
Cause             : monitor alarm Appstream2-MyFleet-default-scale-in-Alarm in state ALARM triggered policy default-scale-in
Description       : Setting desired capacity to 2.
Details           :
EndTime           : 12/14/2019 11:32:49 AM
ResourceId        : fleet/MyFleet
ScalableDimension : appstream:fleet:DesiredCapacity
ServiceNamespace  : appstream
StartTime         : 12/14/2019 11:32:14 AM
StatusCode        : Successful
StatusMessage     : Successfully set desired capacity to 2. Change successfully fulfilled by appstream.
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V4)*의 [DescribeScalingActivities](https://docs.aws.amazon.com/powershell/v4/reference)를 참조하세요.

**Tools for PowerShell V5**  
**예제 1: 이전 6주 동안 지정된 서비스 네임스페이스의 조정 활동에 대한 설명이 포함된 정보를 제공합니다.**  

```
Get-AASScalingActivity -ServiceNamespace AppStream
```
**출력:**  

```
ActivityId        : 2827409f-b639-4cdb-a957-8055d5d07434
Cause             : monitor alarm Appstream2-MyFleet-default-scale-in-Alarm in state ALARM triggered policy default-scale-in
Description       : Setting desired capacity to 2.
Details           :
EndTime           : 12/14/2019 11:32:49 AM
ResourceId        : fleet/MyFleet
ScalableDimension : appstream:fleet:DesiredCapacity
ServiceNamespace  : appstream
StartTime         : 12/14/2019 11:32:14 AM
StatusCode        : Successful
StatusMessage     : Successfully set desired capacity to 2. Change successfully fulfilled by appstream.
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V5)*의 [DescribeScalingActivities](https://docs.aws.amazon.com/powershell/v5/reference)를 참조하세요.

------

# AWS SDK 또는 CLI와 `DescribeScalingPolicies` 함께 사용
<a name="application-auto-scaling_example_application-auto-scaling_DescribeScalingPolicies_section"></a>

다음 코드 예시는 `DescribeScalingPolicies`의 사용 방법을 보여 줍니다.

------
#### [ CLI ]

**AWS CLI**  
**조정 정책을 설명하는 방법**  
이 예제 명령은 ECS 서비스 네임스페이스에 대한 조정 정책을 설명합니다.  
명령:  

```
aws application-autoscaling describe-scaling-policies --service-namespace ecs
```
출력:  

```
{
    "ScalingPolicies": [
        {
            "PolicyName": "web-app-cpu-gt-75",
            "ScalableDimension": "ecs:service:DesiredCount",
            "ResourceId": "service/default/web-app",
            "CreationTime": 1462561899.23,
            "StepScalingPolicyConfiguration": {
                "Cooldown": 60,
                "StepAdjustments": [
                    {
                        "ScalingAdjustment": 200,
                        "MetricIntervalLowerBound": 0.0
                    }
                ],
                "AdjustmentType": "PercentChangeInCapacity"
            },
            "PolicyARN": "arn:aws:autoscaling:us-west-2:012345678910:scalingPolicy:6d8972f3-efc8-437c-92d1-6270f29a66e7:resource/ecs/service/default/web-app:policyName/web-app-cpu-gt-75",
            "PolicyType": "StepScaling",
            "Alarms": [
                {
                    "AlarmName": "web-app-cpu-gt-75",
                    "AlarmARN": "arn:aws:cloudwatch:us-west-2:012345678910:alarm:web-app-cpu-gt-75"
                }
            ],
            "ServiceNamespace": "ecs"
        },
        {
            "PolicyName": "web-app-cpu-lt-25",
            "ScalableDimension": "ecs:service:DesiredCount",
            "ResourceId": "service/default/web-app",
            "CreationTime": 1462562575.099,
            "StepScalingPolicyConfiguration": {
                "Cooldown": 1,
                "StepAdjustments": [
                    {
                        "ScalingAdjustment": -50,
                        "MetricIntervalUpperBound": 0.0
                    }
                ],
                "AdjustmentType": "PercentChangeInCapacity"
            },
            "PolicyARN": "arn:aws:autoscaling:us-west-2:012345678910:scalingPolicy:6d8972f3-efc8-437c-92d1-6270f29a66e7:resource/ecs/service/default/web-app:policyName/web-app-cpu-lt-25",
            "PolicyType": "StepScaling",
            "Alarms": [
                {
                    "AlarmName": "web-app-cpu-lt-25",
                    "AlarmARN": "arn:aws:cloudwatch:us-west-2:012345678910:alarm:web-app-cpu-lt-25"
                }
            ],
            "ServiceNamespace": "ecs"
        }
    ]
}
```
+  API 세부 정보는 *AWS CLI 명령 참조*의 [DescribeScalingPolicies](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/application-autoscaling/describe-scaling-policies.html)를 참조하세요.

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**예제 1: 이 cmdlet에서는 지정된 서비스 네임스페이스에 대한 Application Auto Scaling 조정 정책을 설명합니다.**  

```
Get-AASScalingPolicy -ServiceNamespace AppStream
```
**출력:**  

```
Alarms                                   : {Appstream2-LabFleet-default-scale-out-Alarm}
CreationTime                             : 9/3/2019 2:48:15 AM
PolicyARN                                : arn:aws:autoscaling:us-west-2:012345678912:scalingPolicy:5659b069-b5cd-4af1-9f7f-3e956d36233e:resource/appstream/fleet/LabFleet:
                                           policyName/default-scale-out
PolicyName                               : default-scale-out
PolicyType                               : StepScaling
ResourceId                               : fleet/LabFleet
ScalableDimension                        : appstream:fleet:DesiredCapacity
ServiceNamespace                         : appstream
StepScalingPolicyConfiguration           : Amazon.ApplicationAutoScaling.Model.StepScalingPolicyConfiguration
TargetTrackingScalingPolicyConfiguration :

Alarms                                   : {Appstream2-LabFleet-default-scale-in-Alarm}
CreationTime                             : 9/3/2019 2:48:15 AM
PolicyARN                                : arn:aws:autoscaling:us-west-2:012345678912:scalingPolicy:5659b069-b5cd-4af1-9f7f-3e956d36233e:resource/appstream/fleet/LabFleet:
                                           policyName/default-scale-in
PolicyName                               : default-scale-in
PolicyType                               : StepScaling
ResourceId                               : fleet/LabFleet
ScalableDimension                        : appstream:fleet:DesiredCapacity
ServiceNamespace                         : appstream
StepScalingPolicyConfiguration           : Amazon.ApplicationAutoScaling.Model.StepScalingPolicyConfiguration
TargetTrackingScalingPolicyConfiguration :
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V4)*의 [DescribeScalingPolicies](https://docs.aws.amazon.com/powershell/v4/reference)를 참조하세요.

**Tools for PowerShell V5**  
**예제 1: 이 cmdlet에서는 지정된 서비스 네임스페이스에 대한 Application Auto Scaling 조정 정책을 설명합니다.**  

```
Get-AASScalingPolicy -ServiceNamespace AppStream
```
**출력:**  

```
Alarms                                   : {Appstream2-LabFleet-default-scale-out-Alarm}
CreationTime                             : 9/3/2019 2:48:15 AM
PolicyARN                                : arn:aws:autoscaling:us-west-2:012345678912:scalingPolicy:5659b069-b5cd-4af1-9f7f-3e956d36233e:resource/appstream/fleet/LabFleet:
                                           policyName/default-scale-out
PolicyName                               : default-scale-out
PolicyType                               : StepScaling
ResourceId                               : fleet/LabFleet
ScalableDimension                        : appstream:fleet:DesiredCapacity
ServiceNamespace                         : appstream
StepScalingPolicyConfiguration           : Amazon.ApplicationAutoScaling.Model.StepScalingPolicyConfiguration
TargetTrackingScalingPolicyConfiguration :

Alarms                                   : {Appstream2-LabFleet-default-scale-in-Alarm}
CreationTime                             : 9/3/2019 2:48:15 AM
PolicyARN                                : arn:aws:autoscaling:us-west-2:012345678912:scalingPolicy:5659b069-b5cd-4af1-9f7f-3e956d36233e:resource/appstream/fleet/LabFleet:
                                           policyName/default-scale-in
PolicyName                               : default-scale-in
PolicyType                               : StepScaling
ResourceId                               : fleet/LabFleet
ScalableDimension                        : appstream:fleet:DesiredCapacity
ServiceNamespace                         : appstream
StepScalingPolicyConfiguration           : Amazon.ApplicationAutoScaling.Model.StepScalingPolicyConfiguration
TargetTrackingScalingPolicyConfiguration :
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V5)*의 [DescribeScalingPolicies](https://docs.aws.amazon.com/powershell/v5/reference)를 참조하세요.

------
#### [ Rust ]

**SDK for Rust**  
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/rustv1/examples/applicationautoscaling#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

```
async fn show_policies(client: &Client) -> Result<(), Error> {
    let response = client
        .describe_scaling_policies()
        .service_namespace(ServiceNamespace::Ec2)
        .send()
        .await?;
    println!("Auto Scaling Policies:");
    for policy in response.scaling_policies() {
        println!("{:?}\n", policy);
    }
    println!("Next token: {:?}", response.next_token());

    Ok(())
}
```
+  API 세부 정보는 *AWS SDK for Rust API 참조*의 [DescribeScalingPolicies](https://docs.rs/aws-sdk-applicationautoscaling/latest/aws_sdk_applicationautoscaling/client/struct.Client.html#method.describe_scaling_policies)를 참조하세요.

------

# CLI로 `DescribeScheduledActions` 사용
<a name="application-auto-scaling_example_application-auto-scaling_DescribeScheduledActions_section"></a>

다음 코드 예시는 `DescribeScheduledActions`의 사용 방법을 보여 줍니다.

------
#### [ CLI ]

**AWS CLI**  
**예약된 작업을 설명하는 방법**  
다음 `describe-scheduled-actions` 예제에서는 지정된 서비스 네임스페이스에 대한 예약된 작업의 세부 정보를 표시합니다.  

```
aws application-autoscaling describe-scheduled-actions \
    --service-namespace dynamodb
```
출력:  

```
{
    "ScheduledActions": [
        {
            "ScalableDimension": "dynamodb:table:WriteCapacityUnits",
            "Schedule": "at(2019-05-20T18:35:00)",
            "ResourceId": "table/my-table",
            "CreationTime": 1561571888.361,
            "ScheduledActionARN": "arn:aws:autoscaling:us-west-2:123456789012:scheduledAction:2d36aa3b-cdf9-4565-b290-81db519b227d:resource/dynamodb/table/my-table:scheduledActionName/my-first-scheduled-action",
            "ScalableTargetAction": {
                "MinCapacity": 15,
                "MaxCapacity": 20
            },
            "ScheduledActionName": "my-first-scheduled-action",
            "ServiceNamespace": "dynamodb"
        },
        {
            "ScalableDimension": "dynamodb:table:WriteCapacityUnits",
            "Schedule": "at(2019-05-20T18:40:00)",
            "ResourceId": "table/my-table",
            "CreationTime": 1561571946.021,
            "ScheduledActionARN": "arn:aws:autoscaling:us-west-2:123456789012:scheduledAction:2d36aa3b-cdf9-4565-b290-81db519b227d:resource/dynamodb/table/my-table:scheduledActionName/my-second-scheduled-action",
            "ScalableTargetAction": {
                "MinCapacity": 5,
                "MaxCapacity": 10
            },
            "ScheduledActionName": "my-second-scheduled-action",
            "ServiceNamespace": "dynamodb"
        }
    ]
}
```
자세한 내용은 [https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-scheduled-scaling.html](https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-scheduled-scaling.html)Application Auto Scaling 사용 설명서의 *예약된 조정*을 참조하세요.  
+  API 세부 정보는 **AWS CLI 명령 참조의 [DescribeScheduledActions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/application-autoscaling/describe-scheduled-actions.html) 섹션을 참조하세요.

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**예제 1: 이 cmdlet에서는 실행되지 않았거나 종료 시간에 도달하지 않은 Auto Scaling 그룹에 예약된 작업을 나열합니다.**  

```
Get-AASScheduledAction -ServiceNamespace AppStream
```
**출력:**  

```
CreationTime         : 12/22/2019 9:25:52 AM
EndTime              : 1/1/0001 12:00:00 AM
ResourceId           : fleet/MyFleet
ScalableDimension    : appstream:fleet:DesiredCapacity
ScalableTargetAction : Amazon.ApplicationAutoScaling.Model.ScalableTargetAction
Schedule             : cron(0 0 8 ? * MON-FRI *)
ScheduledActionARN   : arn:aws:autoscaling:us-west-2:012345678912:scheduledAction:4897ca24-3caa-4bf1-8484-851a089b243c:resource/appstream/fleet/MyFleet:scheduledActionName
                       /WeekDaysFleetScaling
ScheduledActionName  : WeekDaysFleetScaling
ServiceNamespace     : appstream
StartTime            : 1/1/0001 12:00:00 AM
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V4)*의 [DescribeScheduledActions](https://docs.aws.amazon.com/powershell/v4/reference)을 참조하세요.

**Tools for PowerShell V5**  
**예제 1: 이 cmdlet에서는 실행되지 않았거나 종료 시간에 도달하지 않은 Auto Scaling 그룹에 예약된 작업을 나열합니다.**  

```
Get-AASScheduledAction -ServiceNamespace AppStream
```
**출력:**  

```
CreationTime         : 12/22/2019 9:25:52 AM
EndTime              : 1/1/0001 12:00:00 AM
ResourceId           : fleet/MyFleet
ScalableDimension    : appstream:fleet:DesiredCapacity
ScalableTargetAction : Amazon.ApplicationAutoScaling.Model.ScalableTargetAction
Schedule             : cron(0 0 8 ? * MON-FRI *)
ScheduledActionARN   : arn:aws:autoscaling:us-west-2:012345678912:scheduledAction:4897ca24-3caa-4bf1-8484-851a089b243c:resource/appstream/fleet/MyFleet:scheduledActionName
                       /WeekDaysFleetScaling
ScheduledActionName  : WeekDaysFleetScaling
ServiceNamespace     : appstream
StartTime            : 1/1/0001 12:00:00 AM
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V5)*의 [DescribeScheduledActions](https://docs.aws.amazon.com/powershell/v5/reference)을 참조하세요.

------

# CLI로 `PutScalingPolicy` 사용
<a name="application-auto-scaling_example_application-auto-scaling_PutScalingPolicy_section"></a>

다음 코드 예시는 `PutScalingPolicy`의 사용 방법을 보여 줍니다.

------
#### [ CLI ]

**AWS CLI**  
**예 1: 사전 정의된 지표 사양을 사용하여 대상 추적 조정 정책 적용**  
다음 `put-scaling-policy` 예제에서는 기본 클러스터에서 미리 정의된 지표 사양이 있는 대상 추적 조정 정책을 웹앱이라고 하는 Amazon ECS 서비스에 적용합니다. 이 정책은 60초의 스케일 아웃 및 스케일 인 휴지 기간을 사용하여 서비스의 평균 CPU 사용률을 75%로 유지합니다. 출력에는 ARN과 사용자를 대신하여 생성된 두 개의 CloudWatch 경보 이름이 포함됩니다.  

```
aws application-autoscaling put-scaling-policy --service-namespace ecs \
--scalable-dimension ecs:service:DesiredCount \
--resource-id service/default/web-app \
--policy-name cpu75-target-tracking-scaling-policy --policy-type TargetTrackingScaling \
--target-tracking-scaling-policy-configuration file://config.json
```
이 예제에서는 현재 디렉터리에 다음 콘텐츠가 포함된 config.json 파일이 있다고 가정합니다.  

```
{
     "TargetValue": 75.0,
     "PredefinedMetricSpecification": {
         "PredefinedMetricType": "ECSServiceAverageCPUUtilization"
     },
     "ScaleOutCooldown": 60,
    "ScaleInCooldown": 60
}
```
출력:  

```
{
    "PolicyARN": "arn:aws:autoscaling:us-west-2:012345678910:scalingPolicy:6d8972f3-efc8-437c-92d1-6270f29a66e7:resource/ecs/service/default/web-app:policyName/cpu75-target-tracking-scaling-policy",
    "Alarms": [
        {
            "AlarmARN": "arn:aws:cloudwatch:us-west-2:012345678910:alarm:TargetTracking-service/default/web-app-AlarmHigh-d4f0770c-b46e-434a-a60f-3b36d653feca",
            "AlarmName": "TargetTracking-service/default/web-app-AlarmHigh-d4f0770c-b46e-434a-a60f-3b36d653feca"
        },
        {
            "AlarmARN": "arn:aws:cloudwatch:us-west-2:012345678910:alarm:TargetTracking-service/default/web-app-AlarmLow-1b437334-d19b-4a63-a812-6c67aaf2910d",
            "AlarmName": "TargetTracking-service/default/web-app-AlarmLow-1b437334-d19b-4a63-a812-6c67aaf2910d"
        }
    ]
}
```
**예 2: 사용자 지정된 지표 사양을 사용하여 대상 추적 조정 정책 적용**  
다음 `put-scaling-policy` 예제에서는 기본 클러스터에서 사용자 지정 지표 사양이 있는 대상 추적 조정 정책을 웹앱이라고 하는 Amazon ECS 서비스에 적용합니다. 이 정책은 60초의 스케일 아웃 및 스케일 인 휴지 기간을 사용하여 서비스의 평균 사용률을 75%로 유지합니다. 출력에는 ARN과 사용자를 대신하여 생성된 두 개의 CloudWatch 경보 이름이 포함됩니다.  

```
aws application-autoscaling put-scaling-policy --service-namespace ecs \
--scalable-dimension ecs:service:DesiredCount \
--resource-id service/default/web-app \
--policy-name cms75-target-tracking-scaling-policy
--policy-type TargetTrackingScaling \
--target-tracking-scaling-policy-configuration file://config.json
```
이 예제에서는 현재 디렉터리에 다음 콘텐츠가 포함된 config.json 파일이 있다고 가정합니다.  

```
{
    "TargetValue":75.0,
    "CustomizedMetricSpecification":{
        "MetricName":"MyUtilizationMetric",
        "Namespace":"MyNamespace",
        "Dimensions": [
            {
                "Name":"MyOptionalMetricDimensionName",
                "Value":"MyOptionalMetricDimensionValue"
            }
        ],
        "Statistic":"Average",
        "Unit":"Percent"
    },
    "ScaleOutCooldown": 60,
    "ScaleInCooldown": 60
}
```
출력:  

```
{
    "PolicyARN": "arn:aws:autoscaling:us-west-2:012345678910:scalingPolicy: 8784a896-b2ba-47a1-b08c-27301cc499a1:resource/ecs/service/default/web-app:policyName/cms75-target-tracking-scaling-policy",
    "Alarms": [
        {
            "AlarmARN": "arn:aws:cloudwatch:us-west-2:012345678910:alarm:TargetTracking-service/default/web-app-AlarmHigh-9bc77b56-0571-4276-ba0f-d4178882e0a0",
            "AlarmName": "TargetTracking-service/default/web-app-AlarmHigh-9bc77b56-0571-4276-ba0f-d4178882e0a0"
        },
        {
            "AlarmARN": "arn:aws:cloudwatch:us-west-2:012345678910:alarm:TargetTracking-service/default/web-app-AlarmLow-9b6ad934-6d37-438e-9e05-02836ddcbdc4",
            "AlarmName": "TargetTracking-service/default/web-app-AlarmLow-9b6ad934-6d37-438e-9e05-02836ddcbdc4"
        }
    ]
}
```
**예 3: 스케일 아웃을 위한 대상 추적 조정 정책 적용**  
다음 `put-scaling-policy` 예제에서는 기본 클러스터에서 대상 추적 조정 정책을 `web-app`이라고 하는 Amazon ECS 서비스에 적용합니다. 정책은 Application Load Balancer의 `RequestCountPerTarget` 지표가 임계값을 초과할 때 ECS 서비스를 스케일 아웃하는 데 사용됩니다. 출력에는 ARN과 사용자를 대신하여 생성된 CloudWatch 경보 이름이 포함됩니다.  

```
aws application-autoscaling put-scaling-policy \
    --service-namespace ecs \
    --scalable-dimension ecs:service:DesiredCount \
    --resource-id service/default/web-app \
    --policy-name alb-scale-out-target-tracking-scaling-policy \
    --policy-type TargetTrackingScaling \
    --target-tracking-scaling-policy-configuration file://config.json
```
`config.json`의 콘텐츠:  

```
{
     "TargetValue": 1000.0,
     "PredefinedMetricSpecification": {
         "PredefinedMetricType": "ALBRequestCountPerTarget",
         "ResourceLabel": "app/EC2Co-EcsEl-1TKLTMITMM0EO/f37c06a68c1748aa/targetgroup/EC2Co-Defau-LDNM7Q3ZH1ZN/6d4ea56ca2d6a18d"
     },
     "ScaleOutCooldown": 60,
    "ScaleInCooldown": 60,
    "DisableScaleIn": true
}
```
출력:  

```
{
    "PolicyARN": "arn:aws:autoscaling:us-west-2:123456789012:scalingPolicy:6d8972f3-efc8-437c-92d1-6270f29a66e7:resource/ecs/service/default/web-app:policyName/alb-scale-out-target-tracking-scaling-policy",
    "Alarms": [
        {
            "AlarmName": "TargetTracking-service/default/web-app-AlarmHigh-d4f0770c-b46e-434a-a60f-3b36d653feca",
            "AlarmARN": "arn:aws:cloudwatch:us-west-2:123456789012:alarm:TargetTracking-service/default/web-app-AlarmHigh-d4f0770c-b46e-434a-a60f-3b36d653feca"
        }
    ]
}
```
자세한 내용은 *AWS Application Auto Scaling 사용 설명서*의 [Application Auto Scaling에 대한 대상 추적 조정 정책](https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-target-tracking.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [PutScalingPolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/application-autoscaling/put-scaling-policy.html)를 참조하세요.

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**예제 1: 이 cmdlet에서는 Application Auto Scaling 규모 조정 가능 대상에 대한 정책을 생성 또는 업데이트합니다. 각 규모 조정 가능 대상은 서비스 네임스페이스, 리소스 ID 및 규모 조정 가능 차원으로 식별됩니다.**  

```
Set-AASScalingPolicy -ServiceNamespace AppStream -PolicyName ASFleetScaleInPolicy -PolicyType StepScaling  -ResourceId fleet/MyFleet -ScalableDimension appstream:fleet:DesiredCapacity -StepScalingPolicyConfiguration_AdjustmentType ChangeInCapacity -StepScalingPolicyConfiguration_Cooldown 360 -StepScalingPolicyConfiguration_MetricAggregationType Average -StepScalingPolicyConfiguration_StepAdjustments @{ScalingAdjustment = -1; MetricIntervalUpperBound = 0}
```
**출력:**  

```
Alarms    PolicyARN
------    ---------
{}        arn:aws:autoscaling:us-west-2:012345678912:scalingPolicy:4897ca24-3caa-4bf1-8484-851a089b243c:resource/appstream/fleet/MyFleet:policyName/ASFleetScaleInPolicy
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V4)*의 [PutScalingPolicy](https://docs.aws.amazon.com/powershell/v4/reference)를 참조하세요.

**Tools for PowerShell V5**  
**예제 1: 이 cmdlet에서는 Application Auto Scaling 규모 조정 가능 대상에 대한 정책을 생성 또는 업데이트합니다. 각 규모 조정 가능 대상은 서비스 네임스페이스, 리소스 ID 및 규모 조정 가능 차원으로 식별됩니다.**  

```
Set-AASScalingPolicy -ServiceNamespace AppStream -PolicyName ASFleetScaleInPolicy -PolicyType StepScaling  -ResourceId fleet/MyFleet -ScalableDimension appstream:fleet:DesiredCapacity -StepScalingPolicyConfiguration_AdjustmentType ChangeInCapacity -StepScalingPolicyConfiguration_Cooldown 360 -StepScalingPolicyConfiguration_MetricAggregationType Average -StepScalingPolicyConfiguration_StepAdjustments @{ScalingAdjustment = -1; MetricIntervalUpperBound = 0}
```
**출력:**  

```
Alarms    PolicyARN
------    ---------
{}        arn:aws:autoscaling:us-west-2:012345678912:scalingPolicy:4897ca24-3caa-4bf1-8484-851a089b243c:resource/appstream/fleet/MyFleet:policyName/ASFleetScaleInPolicy
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V5)*의 [PutScalingPolicy](https://docs.aws.amazon.com/powershell/v5/reference)를 참조하세요.

------

# CLI로 `PutScheduledAction` 사용
<a name="application-auto-scaling_example_application-auto-scaling_PutScheduledAction_section"></a>

다음 코드 예시는 `PutScheduledAction`의 사용 방법을 보여 줍니다.

------
#### [ CLI ]

**AWS CLI**  
**DynamoDB 테이블에 예약된 작업을 추가하는 방법**  
이 예제에서는 TestTable이라고 하는 DynamoDB 테이블에 예약된 작업을 추가하여 반복 일정으로 스케일 아웃합니다. 지정된 일정(UTC 기준 매일 오후 12시 15분)에서 현재 용량이 MinCapacity에 대해 지정된 값보다 작은 경우 Application Auto Scaling은 MinCapacity에 의해 지정된 값으로 스케일 아웃됩니다.  
명령:  

```
aws application-autoscaling put-scheduled-action --service-namespace dynamodb --scheduled-action-name my-recurring-action --schedule "cron(15 12 * * ? *)" --resource-id table/TestTable --scalable-dimension dynamodb:table:WriteCapacityUnits --scalable-target-action MinCapacity=6
```
자세한 내용은 *Application Auto Scaling 사용 설명서*의 예약된 조정을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [PutScheduledAction](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/application-autoscaling/put-scheduled-action.html)을 참조하세요.

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**예제 1: 이 cmdlet에서는 Application Auto Scaling 규모 조정 가능 대상에 대한 예약된 작업을 생성 또는 업데이트합니다. 각 규모 조정 가능 대상은 서비스 네임스페이스, 리소스 ID 및 규모 조정 가능 차원으로 식별됩니다.**  

```
Set-AASScheduledAction -ServiceNamespace AppStream -ResourceId fleet/MyFleet -Schedule "cron(0 0 8 ? * MON-FRI *)" -ScalableDimension appstream:fleet:DesiredCapacity -ScheduledActionName WeekDaysFleetScaling -ScalableTargetAction_MinCapacity 5 -ScalableTargetAction_MaxCapacity 10
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V4)*의 [PutScheduledAction](https://docs.aws.amazon.com/powershell/v4/reference)을 참조하세요.

**Tools for PowerShell V5**  
**예제 1: 이 cmdlet에서는 Application Auto Scaling 규모 조정 가능 대상에 대한 예약된 작업을 생성 또는 업데이트합니다. 각 규모 조정 가능 대상은 서비스 네임스페이스, 리소스 ID 및 규모 조정 가능 차원으로 식별됩니다.**  

```
Set-AASScheduledAction -ServiceNamespace AppStream -ResourceId fleet/MyFleet -Schedule "cron(0 0 8 ? * MON-FRI *)" -ScalableDimension appstream:fleet:DesiredCapacity -ScheduledActionName WeekDaysFleetScaling -ScalableTargetAction_MinCapacity 5 -ScalableTargetAction_MaxCapacity 10
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V5)*의 [PutScheduledAction](https://docs.aws.amazon.com/powershell/v5/reference)을 참조하세요.

------

# AWS SDK 또는 CLI와 `RegisterScalableTarget` 함께 사용
<a name="application-auto-scaling_example_application-auto-scaling_RegisterScalableTarget_section"></a>

다음 코드 예시는 `RegisterScalableTarget`의 사용 방법을 보여 줍니다.

------
#### [ CLI ]

**AWS CLI**  
**예제 1: ECS 서비스를 확장 가능 대상으로 등록하는 방법**  
다음 `register-scalable-target` 예제에서는 Application Auto Scaling에 Amazon ECS 서비스를 등록합니다. 또한 키 이름 `environment` 및 `production` 값을 갖는 태그를 확장 가능 대상에 추가합니다.  

```
aws application-autoscaling register-scalable-target \
    --service-namespace ecs \
    --scalable-dimension ecs:service:DesiredCount \
    --resource-id service/default/web-app \
    --min-capacity 1 --max-capacity 10 \
    --tags environment=production
```
출력:  

```
{
    "ScalableTargetARN": "arn:aws:application-autoscaling:us-west-2:123456789012:scalable-target/1234abcd56ab78cd901ef1234567890ab123"
}
```
다른 AWS 서비스 및 사용자 지정 리소스에 대한 예제는 [AWS Application Auto Scaling 사용 설명서의 Application Auto Scaling과 함께 사용할 수 있는 서비스의](https://docs.aws.amazon.com/autoscaling/application/userguide/integrated-services-list.html) 주제를 참조하세요. * Auto Scaling *  
**예제 2: 확장 가능 대상에 대한 스케일링 활동을 중단하는 방법**  
다음 `register-scalable-target` 예제에서는 기존 확장 가능 대상에 대한 조정 활동을 중단합니다.  

```
aws application-autoscaling register-scalable-target \
    --service-namespace dynamodb \
    --scalable-dimension dynamodb:table:ReadCapacityUnits \
    --resource-id table/my-table \
    --suspended-state DynamicScalingInSuspended=true,DynamicScalingOutSuspended=true,ScheduledScalingSuspended=true
```
출력:  

```
{
    "ScalableTargetARN": "arn:aws:application-autoscaling:us-west-2:123456789012:scalable-target/1234abcd56ab78cd901ef1234567890ab123"
}
```
자세한 내용은 *Application Auto Scaling 사용 설명서*의 [Application Auto Scaling에 대한 스케일링 중단 및 재개](https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-suspend-resume-scaling.html)를 참조하세요.  
**예제 3: 확장 가능 대상에 대한 스케일링 활동을 재개하는 방법**  
다음 `register-scalable-target` 예제에서는 기존 확장 가능 대상에 대한 조정 활동을 재개합니다.  

```
aws application-autoscaling register-scalable-target \
    --service-namespace dynamodb \
    --scalable-dimension dynamodb:table:ReadCapacityUnits \
    --resource-id table/my-table \
    --suspended-state DynamicScalingInSuspended=false,DynamicScalingOutSuspended=false,ScheduledScalingSuspended=false
```
출력:  

```
{
    "ScalableTargetARN": "arn:aws:application-autoscaling:us-west-2:123456789012:scalable-target/1234abcd56ab78cd901ef1234567890ab123"
}
```
자세한 내용은 *Application Auto Scaling 사용 설명서*의 [Application Auto Scaling에 대한 스케일링 중단 및 재개](https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-suspend-resume-scaling.html)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [RegisterScalableTarget](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/application-autoscaling/register-scalable-target.html)을 참조하세요.

------
#### [ Java ]

**SDK for Java 2.x**  
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/appautoscale#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

```
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.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.PolicyType;
import software.amazon.awssdk.services.applicationautoscaling.model.PredefinedMetricSpecification;
import software.amazon.awssdk.services.applicationautoscaling.model.PutScalingPolicyRequest;
import software.amazon.awssdk.services.applicationautoscaling.model.RegisterScalableTargetRequest;
import software.amazon.awssdk.services.applicationautoscaling.model.ScalingPolicy;
import software.amazon.awssdk.services.applicationautoscaling.model.ServiceNamespace;
import software.amazon.awssdk.services.applicationautoscaling.model.ScalableDimension;
import software.amazon.awssdk.services.applicationautoscaling.model.MetricType;
import software.amazon.awssdk.services.applicationautoscaling.model.TargetTrackingScalingPolicyConfiguration;
import java.util.List;

/**
 * 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 EnableDynamoDBAutoscaling {
    public static void main(String[] args) {
        final String usage = """

            Usage:
               <tableId> <roleARN> <policyName>\s

            Where:
               tableId - The table Id value (for example, table/Music).
               roleARN - The ARN of the role that has ApplicationAutoScaling permissions.
               policyName - The name of the policy to create.
               
            """;

        if (args.length != 3) {
            System.out.println(usage);
            System.exit(1);
        }

        System.out.println("This example registers an Amazon DynamoDB table, which is the resource to scale.");
        String tableId = args[0];
        String roleARN = args[1];
        String policyName = args[2];
        ServiceNamespace ns = ServiceNamespace.DYNAMODB;
        ScalableDimension tableWCUs = ScalableDimension.DYNAMODB_TABLE_WRITE_CAPACITY_UNITS;
        ApplicationAutoScalingClient appAutoScalingClient = ApplicationAutoScalingClient.builder()
            .region(Region.US_EAST_1)
            .build();

        registerScalableTarget(appAutoScalingClient, tableId, roleARN, ns, tableWCUs);
        verifyTarget(appAutoScalingClient, tableId, ns, tableWCUs);
        configureScalingPolicy(appAutoScalingClient, tableId, ns, tableWCUs, policyName);
    }

    public static void registerScalableTarget(ApplicationAutoScalingClient appAutoScalingClient, String tableId, String roleARN, ServiceNamespace ns, ScalableDimension tableWCUs) {
        try {
            RegisterScalableTargetRequest targetRequest = RegisterScalableTargetRequest.builder()
                .serviceNamespace(ns)
                .scalableDimension(tableWCUs)
                .resourceId(tableId)
                .roleARN(roleARN)
                .minCapacity(5)
                .maxCapacity(10)
                .build();

            appAutoScalingClient.registerScalableTarget(targetRequest);
            System.out.println("You have registered " + tableId);

        } catch (ApplicationAutoScalingException e) {
            System.err.println(e.awsErrorDetails().errorMessage());
        }
    }

    // Verify that the target was created.
    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);
    }

    // Configure a scaling policy.
    public static void configureScalingPolicy(ApplicationAutoScalingClient appAutoScalingClient, String tableId, ServiceNamespace ns, ScalableDimension tableWCUs, String policyName) {
        // Check if the policy exists before creating a new one.
        DescribeScalingPoliciesResponse describeScalingPoliciesResponse = appAutoScalingClient.describeScalingPolicies(DescribeScalingPoliciesRequest.builder()
            .serviceNamespace(ns)
            .resourceId(tableId)
            .scalableDimension(tableWCUs)
            .build());

        if (!describeScalingPoliciesResponse.scalingPolicies().isEmpty()) {
            // If policies exist, consider updating an existing policy instead of creating a new one.
            System.out.println("Policy already exists. Consider updating it instead.");
            List<ScalingPolicy> polList = describeScalingPoliciesResponse.scalingPolicies();
            for (ScalingPolicy pol : polList) {
                System.out.println("Policy name:" +pol.policyName());
            }
        } else {
            // If no policies exist, proceed with creating a new policy.
            PredefinedMetricSpecification specification = PredefinedMetricSpecification.builder()
                .predefinedMetricType(MetricType.DYNAMO_DB_WRITE_CAPACITY_UTILIZATION)
                .build();

            TargetTrackingScalingPolicyConfiguration policyConfiguration = TargetTrackingScalingPolicyConfiguration.builder()
                .predefinedMetricSpecification(specification)
                .targetValue(50.0)
                .scaleInCooldown(60)
                .scaleOutCooldown(60)
                .build();

            PutScalingPolicyRequest putScalingPolicyRequest = PutScalingPolicyRequest.builder()
                .targetTrackingScalingPolicyConfiguration(policyConfiguration)
                .serviceNamespace(ns)
                .scalableDimension(tableWCUs)
                .resourceId(tableId)
                .policyName(policyName)
                .policyType(PolicyType.TARGET_TRACKING_SCALING)
                .build();

            try {
                appAutoScalingClient.putScalingPolicy(putScalingPolicyRequest);
                System.out.println("You have successfully created a scaling policy for an Application Auto Scaling scalable target");
            } catch (ApplicationAutoScalingException e) {
                System.err.println("Error: " + e.awsErrorDetails().errorMessage());
            }
        }
    }
}
```
+  API 세부 정보는 *AWS SDK for Java 2.x API 참조*의 [RegisterScalableTarget](https://docs.aws.amazon.com/goto/SdkForJavaV2/application-autoscaling-2016-02-06/RegisterScalableTarget)을 참조하세요.

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**예제 1: 이 cmdlet에서는 규모 조정 가능 대상을 등록하거나 업데이트합니다. 규모 조정 가능 대상은 Application Auto Scaling에서 스케일 아웃 및 스케일 인할 수 있는 리소스입니다.**  

```
Add-AASScalableTarget -ServiceNamespace AppStream -ResourceId fleet/MyFleet -ScalableDimension appstream:fleet:DesiredCapacity -MinCapacity 2 -MaxCapacity 10
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V4)*의 [RegisterScalableTarget](https://docs.aws.amazon.com/powershell/v4/reference)을 참조하세요.

**Tools for PowerShell V5**  
**예제 1: 이 cmdlet에서는 규모 조정 가능 대상을 등록하거나 업데이트합니다. 규모 조정 가능 대상은 Application Auto Scaling에서 스케일 아웃 및 스케일 인할 수 있는 리소스입니다.**  

```
Add-AASScalableTarget -ServiceNamespace AppStream -ResourceId fleet/MyFleet -ScalableDimension appstream:fleet:DesiredCapacity -MinCapacity 2 -MaxCapacity 10
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V5)*의 [RegisterScalableTarget](https://docs.aws.amazon.com/powershell/v5/reference)을 참조하세요.

------