All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.awsnative.autoscaling.kotlin.ScalingPolicy.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 1.11.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.awsnative.autoscaling.kotlin

import com.pulumi.awsnative.autoscaling.kotlin.outputs.ScalingPolicyPredictiveScalingConfiguration
import com.pulumi.awsnative.autoscaling.kotlin.outputs.ScalingPolicyStepAdjustment
import com.pulumi.awsnative.autoscaling.kotlin.outputs.ScalingPolicyTargetTrackingConfiguration
import com.pulumi.core.Output
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import com.pulumi.awsnative.autoscaling.kotlin.outputs.ScalingPolicyPredictiveScalingConfiguration.Companion.toKotlin as scalingPolicyPredictiveScalingConfigurationToKotlin
import com.pulumi.awsnative.autoscaling.kotlin.outputs.ScalingPolicyStepAdjustment.Companion.toKotlin as scalingPolicyStepAdjustmentToKotlin
import com.pulumi.awsnative.autoscaling.kotlin.outputs.ScalingPolicyTargetTrackingConfiguration.Companion.toKotlin as scalingPolicyTargetTrackingConfigurationToKotlin

/**
 * Builder for [ScalingPolicy].
 */
@PulumiTagMarker
public class ScalingPolicyResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: ScalingPolicyArgs = ScalingPolicyArgs()

    public var opts: CustomResourceOptions = CustomResourceOptions()

    /**
     * @param name The _unique_ name of the resulting resource.
     */
    public fun name(`value`: String) {
        this.name = value
    }

    /**
     * @param block The arguments to use to populate this resource's properties.
     */
    public suspend fun args(block: suspend ScalingPolicyArgsBuilder.() -> Unit) {
        val builder = ScalingPolicyArgsBuilder()
        block(builder)
        this.args = builder.build()
    }

    /**
     * @param block A bag of options that control this resource's behavior.
     */
    public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
        this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
    }

    internal fun build(): ScalingPolicy {
        val builtJavaResource = com.pulumi.awsnative.autoscaling.ScalingPolicy(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return ScalingPolicy(builtJavaResource)
    }
}

/**
 * The AWS::AutoScaling::ScalingPolicy resource specifies an Amazon EC2 Auto Scaling scaling policy so that the Auto Scaling group can scale the number of instances available for your application.
 */
public class ScalingPolicy internal constructor(
    override val javaResource: com.pulumi.awsnative.autoscaling.ScalingPolicy,
) : KotlinCustomResource(javaResource, ScalingPolicyMapper) {
    /**
     * Specifies how the scaling adjustment is interpreted. The valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity.
     */
    public val adjustmentType: Output?
        get() = javaResource.adjustmentType().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The ARN of the AutoScaling scaling policy
     */
    public val arn: Output
        get() = javaResource.arn().applyValue({ args0 -> args0 })

    /**
     * The name of the Auto Scaling group.
     */
    public val autoScalingGroupName: Output
        get() = javaResource.autoScalingGroupName().applyValue({ args0 -> args0 })

    /**
     * The duration of the policy's cooldown period, in seconds. When a cooldown period is specified here, it overrides the default cooldown period defined for the Auto Scaling group.
     */
    public val cooldown: Output?
        get() = javaResource.cooldown().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The estimated time, in seconds, until a newly launched instance can contribute to the CloudWatch metrics. If not provided, the default is to use the value from the default cooldown period for the Auto Scaling group. Valid only if the policy type is TargetTrackingScaling or StepScaling.
     */
    public val estimatedInstanceWarmup: Output?
        get() = javaResource.estimatedInstanceWarmup().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The aggregation type for the CloudWatch metrics. The valid values are Minimum, Maximum, and Average. If the aggregation type is null, the value is treated as Average. Valid only if the policy type is StepScaling.
     */
    public val metricAggregationType: Output?
        get() = javaResource.metricAggregationType().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The minimum value to scale by when the adjustment type is PercentChangeInCapacity. For example, suppose that you create a step scaling policy to scale out an Auto Scaling group by 25 percent and you specify a MinAdjustmentMagnitude of 2. If the group has 4 instances and the scaling policy is performed, 25 percent of 4 is 1. However, because you specified a MinAdjustmentMagnitude of 2, Amazon EC2 Auto Scaling scales out the group by 2 instances.
     */
    public val minAdjustmentMagnitude: Output?
        get() = javaResource.minAdjustmentMagnitude().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Returns the name of a scaling policy.
     */
    public val policyName: Output
        get() = javaResource.policyName().applyValue({ args0 -> args0 })

    /**
     * One of the following policy types: TargetTrackingScaling, StepScaling, SimpleScaling (default), PredictiveScaling
     */
    public val policyType: Output?
        get() = javaResource.policyType().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * A predictive scaling policy. Includes support for predefined metrics only.
     */
    public val predictiveScalingConfiguration: Output?
        get() = javaResource.predictiveScalingConfiguration().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    scalingPolicyPredictiveScalingConfigurationToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * The amount by which to scale, based on the specified adjustment type. A positive value adds to the current capacity while a negative number removes from the current capacity. For exact capacity, you must specify a positive value. Required if the policy type is SimpleScaling. (Not used with any other policy type.)
     */
    public val scalingAdjustment: Output?
        get() = javaResource.scalingAdjustment().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * A set of adjustments that enable you to scale based on the size of the alarm breach. Required if the policy type is StepScaling. (Not used with any other policy type.)
     */
    public val stepAdjustments: Output>?
        get() = javaResource.stepAdjustments().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.let({ args0 ->
                        scalingPolicyStepAdjustmentToKotlin(args0)
                    })
                })
            }).orElse(null)
        })

    /**
     * A target tracking scaling policy. Includes support for predefined or customized metrics.
     */
    public val targetTrackingConfiguration: Output?
        get() = javaResource.targetTrackingConfiguration().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    scalingPolicyTargetTrackingConfigurationToKotlin(args0)
                })
            }).orElse(null)
        })
}

public object ScalingPolicyMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.awsnative.autoscaling.ScalingPolicy::class == javaResource::class

    override fun map(javaResource: Resource): ScalingPolicy = ScalingPolicy(
        javaResource as
            com.pulumi.awsnative.autoscaling.ScalingPolicy,
    )
}

/**
 * @see [ScalingPolicy].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [ScalingPolicy].
 */
public suspend fun scalingPolicy(
    name: String,
    block: suspend ScalingPolicyResourceBuilder.() -> Unit,
): ScalingPolicy {
    val builder = ScalingPolicyResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [ScalingPolicy].
 * @param name The _unique_ name of the resulting resource.
 */
public fun scalingPolicy(name: String): ScalingPolicy {
    val builder = ScalingPolicyResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy