@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
191 lines • 7.78 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.Target = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Provides an Application AutoScaling ScalableTarget resource. To manage policies which get attached to the target, see the `aws.appautoscaling.Policy` resource.
*
* > **NOTE:** Scalable targets created before 2023-03-20 may not have an assigned `arn`. These resource cannot use `tags` or participate in `defaultTags`. To prevent `pulumi preview` showing differences that can never be reconciled, use the `lifecycle.ignore_changes` meta-argument. See the example below.
*
* > **NOTE:** The [Application Auto Scaling service automatically attempts to manage IAM Service-Linked Roles](https://docs.aws.amazon.com/autoscaling/application/userguide/security_iam_service-with-iam.html#security_iam_service-with-iam-roles) when registering certain service namespaces for the first time. To manually manage this role, see the `aws.iam.ServiceLinkedRole` 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/${example.name}`,
* scalableDimension: "dynamodb:table:ReadCapacityUnits",
* serviceNamespace: "dynamodb",
* });
* ```
*
* ### DynamoDB Index Autoscaling
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const dynamodbIndexReadTarget = new aws.appautoscaling.Target("dynamodb_index_read_target", {
* maxCapacity: 100,
* minCapacity: 5,
* resourceId: `table/${example.name}/index/${indexName}`,
* scalableDimension: "dynamodb:index:ReadCapacityUnits",
* serviceNamespace: "dynamodb",
* });
* ```
*
* ### 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/${example.name}/${exampleAwsEcsService.name}`,
* scalableDimension: "ecs:service:DesiredCount",
* serviceNamespace: "ecs",
* });
* ```
*
* ### 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,
* });
* ```
*
* ### Suppressing `tagsAll` Differences For Older Resources
*
* ```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/${example.name}/${exampleAwsEcsService.name}`,
* scalableDimension: "ecs:service:DesiredCount",
* serviceNamespace: "ecs",
* });
* ```
*
* ### 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,
* });
* ```
*
* ## Import
*
* Using `pulumi import`, import Application AutoScaling Target using the `service-namespace` , `resource-id` and `scalable-dimension` separated by `/`. For example:
*
* ```sh
* $ pulumi import aws:appautoscaling/target:Target test-target service-namespace/resource-id/scalable-dimension
* ```
*/
class Target extends pulumi.CustomResource {
/**
* Get an existing Target 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 Target(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of Target. 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'] === Target.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["arn"] = state?.arn;
resourceInputs["maxCapacity"] = state?.maxCapacity;
resourceInputs["minCapacity"] = state?.minCapacity;
resourceInputs["region"] = state?.region;
resourceInputs["resourceId"] = state?.resourceId;
resourceInputs["roleArn"] = state?.roleArn;
resourceInputs["scalableDimension"] = state?.scalableDimension;
resourceInputs["serviceNamespace"] = state?.serviceNamespace;
resourceInputs["suspendedState"] = state?.suspendedState;
resourceInputs["tags"] = state?.tags;
resourceInputs["tagsAll"] = state?.tagsAll;
}
else {
const args = argsOrState;
if (args?.maxCapacity === undefined && !opts.urn) {
throw new Error("Missing required property 'maxCapacity'");
}
if (args?.minCapacity === undefined && !opts.urn) {
throw new Error("Missing required property 'minCapacity'");
}
if (args?.resourceId === undefined && !opts.urn) {
throw new Error("Missing required property 'resourceId'");
}
if (args?.scalableDimension === undefined && !opts.urn) {
throw new Error("Missing required property 'scalableDimension'");
}
if (args?.serviceNamespace === undefined && !opts.urn) {
throw new Error("Missing required property 'serviceNamespace'");
}
resourceInputs["maxCapacity"] = args?.maxCapacity;
resourceInputs["minCapacity"] = args?.minCapacity;
resourceInputs["region"] = args?.region;
resourceInputs["resourceId"] = args?.resourceId;
resourceInputs["roleArn"] = args?.roleArn;
resourceInputs["scalableDimension"] = args?.scalableDimension;
resourceInputs["serviceNamespace"] = args?.serviceNamespace;
resourceInputs["suspendedState"] = args?.suspendedState;
resourceInputs["tags"] = args?.tags;
resourceInputs["arn"] = undefined /*out*/;
resourceInputs["tagsAll"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Target.__pulumiType, name, resourceInputs, opts);
}
}
exports.Target = Target;
/** @internal */
Target.__pulumiType = 'aws:appautoscaling/target:Target';
//# sourceMappingURL=target.js.map
;