Skip to content

aws.autoscaling-policy resource

Description

Policy is an EC2 Auto Scaling scaling policy: a rule that changes an Auto Scaling group's size in response to a CloudWatch alarm or a tracked target. The whole resource is one PutScalingPolicy upsert, used for both create and update, with no waiters or transient retries. Its complexity is the policy type, which gates which fields are valid: SimpleScaling uses a single scaling adjustment, StepScaling a set of stepped adjustments, and TargetTrackingScaling a metric held to a target value. The policy is keyed by the group name plus the policy name, both fixed at create time; a change to either makes a new policy.

PredictiveScaling remains a valid policy type, but its predictive-scaling-configuration block is not modeled here and is left for a future addition.

Source: internal/service/autoscaling/policy_rsrc.go:42

Example usage:

imports: {
  aws: 'github.com/cloudboss/unobin-library-aws'
}

resources: {
  example: aws.autoscaling-policy {
    # Set input fields here.
  }
}

Inputs

autoscaling-group-name

string

required

name

string

required

policy-type

optional(string)

enabled

optional(boolean)

adjustment-type

optional(string)

cooldown

optional(integer)

estimated-instance-warmup

optional(integer)

metric-aggregation-type

optional(string)

min-adjustment-magnitude

optional(integer)

scaling-adjustment

optional(integer)

step-adjustments

list(object)
list(
  object({
    scaling-adjustment: integer
    metric-interval-lower-bound: optional(number)
    metric-interval-upper-bound: optional(number)
  })
)

target-tracking-configuration

optional(object)
optional(
  object({
    target-value: number
    disable-scale-in: optional(boolean)
    predefined-metric-specification: optional(
      object({
        predefined-metric-type: string
        resource-label: optional(string)
      })
    )
    customized-metric-specification: optional(
      object({
        metric-name: string
        namespace: string
        statistic: string
        unit: optional(string)
        period: optional(integer)
        dimensions: list(
          object({
            name: string
            value: string
          })
        )
        metrics: list(
          object({
            id: string
            expression: optional(string)
            label: optional(string)
            period: optional(integer)
            return-data: optional(boolean)
            metric-stat: optional(
              object({
                metric: object({
                  metric-name: string
                  namespace: string
                  dimensions: list(
                    object({
                      name: string
                      value: string
                    })
                  )
                })
                stat: string
                period: optional(integer)
                unit: optional(string)
              })
            )
          })
        )
      })
    )
  })
)

Input Constraints

Policy type rules

policy-type must be SimpleScaling, StepScaling, TargetTrackingScaling, or PredictiveScaling.

Rule logic
When
input.policy-type != null
Require
input.policy-type == 'SimpleScaling'
|| input.policy-type == 'StepScaling'
|| input.policy-type == 'TargetTrackingScaling'
|| input.policy-type == 'PredictiveScaling'

scaling-adjustment is required when policy-type is SimpleScaling.

Rule logic
When
input.policy-type == null
|| input.policy-type == 'SimpleScaling'
Require
input.scaling-adjustment != null

step-adjustments is required when policy-type is StepScaling.

Rule logic
When
input.policy-type == 'StepScaling'
Require
input.step-adjustments != null

target-tracking-configuration is required when policy-type is TargetTrackingScaling.

Rule logic
When
input.policy-type == 'TargetTrackingScaling'
Require
input.target-tracking-configuration != null

Field combinations

At most one of scaling-adjustment or step-adjustments.

Scaling adjustment rules

scaling-adjustment is valid only when policy-type is SimpleScaling.

Rule logic
When
input.scaling-adjustment != null
Require
input.policy-type == null
|| input.policy-type == 'SimpleScaling'

Step adjustments rules

step-adjustments is valid only when policy-type is StepScaling.

Rule logic
When
input.step-adjustments != null
Require
input.policy-type == 'StepScaling'

Target tracking configuration rules

target-tracking-configuration is valid only when policy-type is TargetTrackingScaling.

Rule logic
When
input.target-tracking-configuration != null
Require
input.policy-type == 'TargetTrackingScaling'

Cooldown rules

cooldown is valid only when policy-type is SimpleScaling.

Rule logic
When
input.cooldown != null
Require
input.policy-type == null
|| input.policy-type == 'SimpleScaling'

Estimated instance warmup rules

estimated-instance-warmup is valid only when policy-type is StepScaling or TargetTrackingScaling.

Rule logic
When
input.estimated-instance-warmup != null
Require
input.policy-type == 'StepScaling'
|| input.policy-type == 'TargetTrackingScaling'

Min adjustment magnitude rules

min-adjustment-magnitude must be at least 1.

Rule logic
When
input.min-adjustment-magnitude != null
Require
input.min-adjustment-magnitude == null
|| input.min-adjustment-magnitude >= 1

Outputs

arn

string

autoscaling-group-name

string

name

string

metric-aggregation-type

string