@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
181 lines • 7.29 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScalingPlan = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Manages an AWS Auto Scaling scaling plan.
* More information can be found in the [AWS Auto Scaling User Guide](https://docs.aws.amazon.com/autoscaling/plans/userguide/what-is-aws-auto-scaling.html).
*
* > **NOTE:** The AWS Auto Scaling service uses an AWS IAM service-linked role to manage predictive scaling of Amazon EC2 Auto Scaling groups. The service attempts to automatically create this role the first time a scaling plan with predictive scaling enabled is created.
* An `aws.iam.ServiceLinkedRole` resource can be used to manually manage this role.
* See the [AWS documentation](https://docs.aws.amazon.com/autoscaling/plans/userguide/aws-auto-scaling-service-linked-roles.html#create-service-linked-role-manual) for more details.
*
* ## Example Usage
*
* ### Basic Dynamic Scaling
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
* import * as std from "@pulumi/std";
*
* const available = aws.getAvailabilityZones({});
* const example = new aws.autoscaling.Group("example", {
* namePrefix: "example",
* launchConfiguration: exampleAwsLaunchConfiguration.name,
* availabilityZones: [available.then(available => available.names?.[0])],
* minSize: 0,
* maxSize: 3,
* tags: [{
* key: "application",
* value: "example",
* propagateAtLaunch: true,
* }],
* });
* const exampleScalingPlan = new aws.autoscalingplans.ScalingPlan("example", {
* name: "example-dynamic-cost-optimization",
* applicationSource: {
* tagFilters: [{
* key: "application",
* values: ["example"],
* }],
* },
* scalingInstructions: [{
* maxCapacity: 3,
* minCapacity: 0,
* resourceId: std.format({
* input: "autoScalingGroup/%s",
* args: [example.name],
* }).then(invoke => invoke.result),
* scalableDimension: "autoscaling:autoScalingGroup:DesiredCapacity",
* serviceNamespace: "autoscaling",
* targetTrackingConfigurations: [{
* predefinedScalingMetricSpecification: {
* predefinedScalingMetricType: "ASGAverageCPUUtilization",
* },
* targetValue: 70,
* }],
* }],
* });
* ```
*
* ### Basic Predictive Scaling
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
* import * as std from "@pulumi/std";
*
* const available = aws.getAvailabilityZones({});
* const example = new aws.autoscaling.Group("example", {
* namePrefix: "example",
* launchConfiguration: exampleAwsLaunchConfiguration.name,
* availabilityZones: [available.then(available => available.names?.[0])],
* minSize: 0,
* maxSize: 3,
* tags: [{
* key: "application",
* value: "example",
* propagateAtLaunch: true,
* }],
* });
* const exampleScalingPlan = new aws.autoscalingplans.ScalingPlan("example", {
* name: "example-predictive-cost-optimization",
* applicationSource: {
* tagFilters: [{
* key: "application",
* values: ["example"],
* }],
* },
* scalingInstructions: [{
* disableDynamicScaling: true,
* maxCapacity: 3,
* minCapacity: 0,
* resourceId: std.format({
* input: "autoScalingGroup/%s",
* args: [example.name],
* }).then(invoke => invoke.result),
* scalableDimension: "autoscaling:autoScalingGroup:DesiredCapacity",
* serviceNamespace: "autoscaling",
* targetTrackingConfigurations: [{
* predefinedScalingMetricSpecification: {
* predefinedScalingMetricType: "ASGAverageCPUUtilization",
* },
* targetValue: 70,
* }],
* predictiveScalingMaxCapacityBehavior: "SetForecastCapacityToMaxCapacity",
* predictiveScalingMode: "ForecastAndScale",
* predefinedLoadMetricSpecification: {
* predefinedLoadMetricType: "ASGTotalCPUUtilization",
* },
* }],
* });
* ```
*
* ## Import
*
* Using `pulumi import`, import Auto Scaling scaling plans using the `name`. For example:
*
* ```sh
* $ pulumi import aws:autoscalingplans/scalingPlan:ScalingPlan example MyScale1
* ```
*/
class ScalingPlan extends pulumi.CustomResource {
/**
* Get an existing ScalingPlan 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, id, state, opts) {
return new ScalingPlan(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of ScalingPlan. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === ScalingPlan.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["applicationSource"] = state?.applicationSource;
resourceInputs["name"] = state?.name;
resourceInputs["region"] = state?.region;
resourceInputs["scalingInstructions"] = state?.scalingInstructions;
resourceInputs["scalingPlanVersion"] = state?.scalingPlanVersion;
}
else {
const args = argsOrState;
if (args?.applicationSource === undefined && !opts.urn) {
throw new Error("Missing required property 'applicationSource'");
}
if (args?.scalingInstructions === undefined && !opts.urn) {
throw new Error("Missing required property 'scalingInstructions'");
}
resourceInputs["applicationSource"] = args?.applicationSource;
resourceInputs["name"] = args?.name;
resourceInputs["region"] = args?.region;
resourceInputs["scalingInstructions"] = args?.scalingInstructions;
resourceInputs["scalingPlanVersion"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(ScalingPlan.__pulumiType, name, resourceInputs, opts);
}
}
exports.ScalingPlan = ScalingPlan;
/** @internal */
ScalingPlan.__pulumiType = 'aws:autoscalingplans/scalingPlan:ScalingPlan';
//# sourceMappingURL=scalingPlan.js.map