@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
368 lines (367 loc) • 17.1 kB
TypeScript
import * as pulumi from "@pulumi/pulumi";
import * as inputs from "../types/input";
import * as outputs from "../types/output";
/**
* Provides an Application AutoScaling Policy resource.
*
* ## Example Usage
*
* ### DynamoDB Table Autoscaling
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const dynamodbTableReadTarget = new aws.appautoscaling.Target("dynamodb_table_read_target", {
* maxCapacity: 100,
* minCapacity: 5,
* resourceId: "table/tableName",
* scalableDimension: "dynamodb:table:ReadCapacityUnits",
* serviceNamespace: "dynamodb",
* });
* const dynamodbTableReadPolicy = new aws.appautoscaling.Policy("dynamodb_table_read_policy", {
* name: pulumi.interpolate`DynamoDBReadCapacityUtilization:${dynamodbTableReadTarget.resourceId}`,
* policyType: "TargetTrackingScaling",
* resourceId: dynamodbTableReadTarget.resourceId,
* scalableDimension: dynamodbTableReadTarget.scalableDimension,
* serviceNamespace: dynamodbTableReadTarget.serviceNamespace,
* targetTrackingScalingPolicyConfiguration: {
* predefinedMetricSpecification: {
* predefinedMetricType: "DynamoDBReadCapacityUtilization",
* },
* targetValue: 70,
* },
* });
* ```
*
* ### ECS Service Autoscaling
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const ecsTarget = new aws.appautoscaling.Target("ecs_target", {
* maxCapacity: 4,
* minCapacity: 1,
* resourceId: "service/clusterName/serviceName",
* scalableDimension: "ecs:service:DesiredCount",
* serviceNamespace: "ecs",
* });
* const ecsPolicy = new aws.appautoscaling.Policy("ecs_policy", {
* name: "scale-down",
* policyType: "StepScaling",
* resourceId: ecsTarget.resourceId,
* scalableDimension: ecsTarget.scalableDimension,
* serviceNamespace: ecsTarget.serviceNamespace,
* stepScalingPolicyConfiguration: {
* adjustmentType: "ChangeInCapacity",
* cooldown: 60,
* metricAggregationType: "Maximum",
* stepAdjustments: [{
* metricIntervalUpperBound: "0",
* scalingAdjustment: -1,
* }],
* },
* });
* ```
*
* ### Preserve desired count when updating an autoscaled ECS Service
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const ecsService = new aws.ecs.Service("ecs_service", {
* name: "serviceName",
* cluster: "clusterName",
* taskDefinition: "taskDefinitionFamily:1",
* desiredCount: 2,
* });
* ```
*
* ### Aurora Read Replica Autoscaling
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const replicas = new aws.appautoscaling.Target("replicas", {
* serviceNamespace: "rds",
* scalableDimension: "rds:cluster:ReadReplicaCount",
* resourceId: `cluster:${example.id}`,
* minCapacity: 1,
* maxCapacity: 15,
* });
* const replicasPolicy = new aws.appautoscaling.Policy("replicas", {
* name: "cpu-auto-scaling",
* serviceNamespace: replicas.serviceNamespace,
* scalableDimension: replicas.scalableDimension,
* resourceId: replicas.resourceId,
* policyType: "TargetTrackingScaling",
* targetTrackingScalingPolicyConfiguration: {
* predefinedMetricSpecification: {
* predefinedMetricType: "RDSReaderAverageCPUUtilization",
* },
* targetValue: 75,
* scaleInCooldown: 300,
* scaleOutCooldown: 300,
* },
* });
* ```
*
* ### Create target tracking scaling policy using metric math
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const ecsTarget = new aws.appautoscaling.Target("ecs_target", {
* maxCapacity: 4,
* minCapacity: 1,
* resourceId: "service/clusterName/serviceName",
* scalableDimension: "ecs:service:DesiredCount",
* serviceNamespace: "ecs",
* });
* const example = new aws.appautoscaling.Policy("example", {
* name: "foo",
* policyType: "TargetTrackingScaling",
* resourceId: ecsTarget.resourceId,
* scalableDimension: ecsTarget.scalableDimension,
* serviceNamespace: ecsTarget.serviceNamespace,
* targetTrackingScalingPolicyConfiguration: {
* targetValue: 100,
* customizedMetricSpecification: {
* metrics: [
* {
* label: "Get the queue size (the number of messages waiting to be processed)",
* id: "m1",
* metricStat: {
* metric: {
* metricName: "ApproximateNumberOfMessagesVisible",
* namespace: "AWS/SQS",
* dimensions: [{
* name: "QueueName",
* value: "my-queue",
* }],
* },
* stat: "Sum",
* },
* returnData: false,
* },
* {
* label: "Get the ECS running task count (the number of currently running tasks)",
* id: "m2",
* metricStat: {
* metric: {
* metricName: "RunningTaskCount",
* namespace: "ECS/ContainerInsights",
* dimensions: [
* {
* name: "ClusterName",
* value: "default",
* },
* {
* name: "ServiceName",
* value: "web-app",
* },
* ],
* },
* stat: "Average",
* },
* returnData: false,
* },
* {
* label: "Calculate the backlog per instance",
* id: "e1",
* expression: "m1 / m2",
* returnData: true,
* },
* ],
* },
* },
* });
* ```
*
* ### MSK / Kafka Autoscaling
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const mskTarget = new aws.appautoscaling.Target("msk_target", {
* serviceNamespace: "kafka",
* scalableDimension: "kafka:broker-storage:VolumeSize",
* resourceId: example.arn,
* minCapacity: 1,
* maxCapacity: 8,
* });
* const targets = new aws.appautoscaling.Policy("targets", {
* name: "storage-size-auto-scaling",
* serviceNamespace: mskTarget.serviceNamespace,
* scalableDimension: mskTarget.scalableDimension,
* resourceId: mskTarget.resourceId,
* policyType: "TargetTrackingScaling",
* targetTrackingScalingPolicyConfiguration: {
* predefinedMetricSpecification: {
* predefinedMetricType: "KafkaBrokerStorageUtilization",
* },
* targetValue: 55,
* },
* });
* ```
*
* ## Import
*
* Using `pulumi import`, import Application AutoScaling Policy using the `service-namespace` , `resource-id`, `scalable-dimension` and `policy-name` separated by `/`. For example:
*
* ```sh
* $ pulumi import aws:appautoscaling/policy:Policy test-policy service-namespace/resource-id/scalable-dimension/policy-name
* ```
*/
export declare class Policy extends pulumi.CustomResource {
/**
* Get an existing Policy resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name: string, id: pulumi.Input<pulumi.ID>, state?: PolicyState, opts?: pulumi.CustomResourceOptions): Policy;
/**
* Returns true if the given object is an instance of Policy. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj: any): obj is Policy;
/**
* List of CloudWatch alarm ARNs associated with the scaling policy.
*/
readonly alarmArns: pulumi.Output<string[]>;
/**
* ARN assigned by AWS to the scaling policy.
*/
readonly arn: pulumi.Output<string>;
/**
* Name of the policy. Must be between 1 and 255 characters in length.
*/
readonly name: pulumi.Output<string>;
/**
* Policy type. Valid values are `StepScaling` and `TargetTrackingScaling`. Defaults to `StepScaling`. Certain services only support only one policy type. For more information see the [Target Tracking Scaling Policies](https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-target-tracking.html) and [Step Scaling Policies](https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-step-scaling-policies.html) documentation.
*/
readonly policyType: pulumi.Output<string | undefined>;
/**
* Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
*/
readonly region: pulumi.Output<string>;
/**
* Resource type and unique identifier string for the resource associated with the scaling policy. Documentation can be found in the `ResourceId` parameter at: [AWS Application Auto Scaling API Reference](https://docs.aws.amazon.com/autoscaling/application/APIReference/API_RegisterScalableTarget.html)
*/
readonly resourceId: pulumi.Output<string>;
/**
* Scalable dimension of the scalable target. Documentation can be found in the `ScalableDimension` parameter at: [AWS Application Auto Scaling API Reference](https://docs.aws.amazon.com/autoscaling/application/APIReference/API_RegisterScalableTarget.html)
*/
readonly scalableDimension: pulumi.Output<string>;
/**
* AWS service namespace of the scalable target. Documentation can be found in the `ServiceNamespace` parameter at: [AWS Application Auto Scaling API Reference](https://docs.aws.amazon.com/autoscaling/application/APIReference/API_RegisterScalableTarget.html)
*/
readonly serviceNamespace: pulumi.Output<string>;
/**
* Step scaling policy configuration, requires `policyType = "StepScaling"` (default). See supported fields below.
*/
readonly stepScalingPolicyConfiguration: pulumi.Output<outputs.appautoscaling.PolicyStepScalingPolicyConfiguration | undefined>;
/**
* Target tracking policy, requires `policyType = "TargetTrackingScaling"`. See supported fields below.
*/
readonly targetTrackingScalingPolicyConfiguration: pulumi.Output<outputs.appautoscaling.PolicyTargetTrackingScalingPolicyConfiguration | undefined>;
/**
* Create a Policy resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args: PolicyArgs, opts?: pulumi.CustomResourceOptions);
}
/**
* Input properties used for looking up and filtering Policy resources.
*/
export interface PolicyState {
/**
* List of CloudWatch alarm ARNs associated with the scaling policy.
*/
alarmArns?: pulumi.Input<pulumi.Input<string>[]>;
/**
* ARN assigned by AWS to the scaling policy.
*/
arn?: pulumi.Input<string>;
/**
* Name of the policy. Must be between 1 and 255 characters in length.
*/
name?: pulumi.Input<string>;
/**
* Policy type. Valid values are `StepScaling` and `TargetTrackingScaling`. Defaults to `StepScaling`. Certain services only support only one policy type. For more information see the [Target Tracking Scaling Policies](https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-target-tracking.html) and [Step Scaling Policies](https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-step-scaling-policies.html) documentation.
*/
policyType?: pulumi.Input<string>;
/**
* Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
*/
region?: pulumi.Input<string>;
/**
* Resource type and unique identifier string for the resource associated with the scaling policy. Documentation can be found in the `ResourceId` parameter at: [AWS Application Auto Scaling API Reference](https://docs.aws.amazon.com/autoscaling/application/APIReference/API_RegisterScalableTarget.html)
*/
resourceId?: pulumi.Input<string>;
/**
* Scalable dimension of the scalable target. Documentation can be found in the `ScalableDimension` parameter at: [AWS Application Auto Scaling API Reference](https://docs.aws.amazon.com/autoscaling/application/APIReference/API_RegisterScalableTarget.html)
*/
scalableDimension?: pulumi.Input<string>;
/**
* AWS service namespace of the scalable target. Documentation can be found in the `ServiceNamespace` parameter at: [AWS Application Auto Scaling API Reference](https://docs.aws.amazon.com/autoscaling/application/APIReference/API_RegisterScalableTarget.html)
*/
serviceNamespace?: pulumi.Input<string>;
/**
* Step scaling policy configuration, requires `policyType = "StepScaling"` (default). See supported fields below.
*/
stepScalingPolicyConfiguration?: pulumi.Input<inputs.appautoscaling.PolicyStepScalingPolicyConfiguration>;
/**
* Target tracking policy, requires `policyType = "TargetTrackingScaling"`. See supported fields below.
*/
targetTrackingScalingPolicyConfiguration?: pulumi.Input<inputs.appautoscaling.PolicyTargetTrackingScalingPolicyConfiguration>;
}
/**
* The set of arguments for constructing a Policy resource.
*/
export interface PolicyArgs {
/**
* Name of the policy. Must be between 1 and 255 characters in length.
*/
name?: pulumi.Input<string>;
/**
* Policy type. Valid values are `StepScaling` and `TargetTrackingScaling`. Defaults to `StepScaling`. Certain services only support only one policy type. For more information see the [Target Tracking Scaling Policies](https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-target-tracking.html) and [Step Scaling Policies](https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-step-scaling-policies.html) documentation.
*/
policyType?: pulumi.Input<string>;
/**
* Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
*/
region?: pulumi.Input<string>;
/**
* Resource type and unique identifier string for the resource associated with the scaling policy. Documentation can be found in the `ResourceId` parameter at: [AWS Application Auto Scaling API Reference](https://docs.aws.amazon.com/autoscaling/application/APIReference/API_RegisterScalableTarget.html)
*/
resourceId: pulumi.Input<string>;
/**
* Scalable dimension of the scalable target. Documentation can be found in the `ScalableDimension` parameter at: [AWS Application Auto Scaling API Reference](https://docs.aws.amazon.com/autoscaling/application/APIReference/API_RegisterScalableTarget.html)
*/
scalableDimension: pulumi.Input<string>;
/**
* AWS service namespace of the scalable target. Documentation can be found in the `ServiceNamespace` parameter at: [AWS Application Auto Scaling API Reference](https://docs.aws.amazon.com/autoscaling/application/APIReference/API_RegisterScalableTarget.html)
*/
serviceNamespace: pulumi.Input<string>;
/**
* Step scaling policy configuration, requires `policyType = "StepScaling"` (default). See supported fields below.
*/
stepScalingPolicyConfiguration?: pulumi.Input<inputs.appautoscaling.PolicyStepScalingPolicyConfiguration>;
/**
* Target tracking policy, requires `policyType = "TargetTrackingScaling"`. See supported fields below.
*/
targetTrackingScalingPolicyConfiguration?: pulumi.Input<inputs.appautoscaling.PolicyTargetTrackingScalingPolicyConfiguration>;
}