@huaweicloudos/pulumi
Version:
A Pulumi package for creating and managing Huaweicloud cloud resources.
179 lines • 6.98 kB
JavaScript
;
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.Policy = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Manages an AS policy resource within HuaweiCloud.
*
* ## Example Usage
* ### AS Recurrence Policy
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const asGroupId = config.requireObject("asGroupId");
* const myAspolicy = new huaweicloud.as.Policy("myAspolicy", {
* scalingPolicyName: "my_aspolicy",
* scalingPolicyType: "RECURRENCE",
* scalingGroupId: asGroupId,
* scalingPolicyAction: {
* operation: "ADD",
* instanceNumber: 1,
* },
* scheduledPolicy: {
* launchTime: "07:00",
* recurrenceType: "Daily",
* startTime: "2022-11-30T12:00Z",
* endTime: "2022-12-30T12:00Z",
* },
* });
* ```
* ### AS Scheduled Policy
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const asGroupId = config.requireObject("asGroupId");
* const myAspolicy1 = new huaweicloud.as.Policy("myAspolicy1", {
* scalingPolicyName: "my_aspolicy_1",
* scalingPolicyType: "SCHEDULED",
* scalingGroupId: asGroupId,
* scalingPolicyAction: {
* operation: "REMOVE",
* instanceNumber: 1,
* },
* scheduledPolicy: {
* launchTime: "2022-12-22T12:00Z",
* },
* });
* ```
* ### AS Alarm Policy
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const asGroupId = config.requireObject("asGroupId");
* const alarmRule = new huaweicloud.cse.Alarmrule("alarmRule", {
* alarmName: "as_alarm_rule",
* metric: {
* namespace: "SYS.AS",
* metricName: "cpu_util",
* dimensions: [{
* name: "AutoScalingGroup",
* value: asGroupId,
* }],
* },
* conditions: [{
* period: 300,
* filter: "average",
* comparisonOperator: ">=",
* value: 60,
* unit: "%",
* count: 1,
* }],
* alarmActions: [{
* type: "autoscaling",
* notificationLists: [],
* }],
* });
* const myAspolicy2 = new huaweicloud.as.Policy("myAspolicy2", {
* scalingPolicyName: "my_aspolicy_2",
* scalingPolicyType: "ALARM",
* scalingGroupId: asGroupId,
* alarmId: alarmRule.id,
* coolDownTime: 900,
* scalingPolicyAction: {
* operation: "ADD",
* instanceNumber: 1,
* },
* });
* ```
*
* ## Import
*
* AS policies can be imported by their `id`, e.g. bash
*
* ```sh
* $ pulumi import huaweicloud:As/policy:Policy test <id>
* ```
*/
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, id, state, opts) {
return new Policy(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* 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) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === Policy.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["action"] = state ? state.action : undefined;
resourceInputs["alarmId"] = state ? state.alarmId : undefined;
resourceInputs["coolDownTime"] = state ? state.coolDownTime : undefined;
resourceInputs["createTime"] = state ? state.createTime : undefined;
resourceInputs["region"] = state ? state.region : undefined;
resourceInputs["scalingGroupId"] = state ? state.scalingGroupId : undefined;
resourceInputs["scalingPolicyAction"] = state ? state.scalingPolicyAction : undefined;
resourceInputs["scalingPolicyName"] = state ? state.scalingPolicyName : undefined;
resourceInputs["scalingPolicyType"] = state ? state.scalingPolicyType : undefined;
resourceInputs["scheduledPolicy"] = state ? state.scheduledPolicy : undefined;
resourceInputs["status"] = state ? state.status : undefined;
}
else {
const args = argsOrState;
if ((!args || args.scalingGroupId === undefined) && !opts.urn) {
throw new Error("Missing required property 'scalingGroupId'");
}
if ((!args || args.scalingPolicyName === undefined) && !opts.urn) {
throw new Error("Missing required property 'scalingPolicyName'");
}
if ((!args || args.scalingPolicyType === undefined) && !opts.urn) {
throw new Error("Missing required property 'scalingPolicyType'");
}
resourceInputs["action"] = args ? args.action : undefined;
resourceInputs["alarmId"] = args ? args.alarmId : undefined;
resourceInputs["coolDownTime"] = args ? args.coolDownTime : undefined;
resourceInputs["region"] = args ? args.region : undefined;
resourceInputs["scalingGroupId"] = args ? args.scalingGroupId : undefined;
resourceInputs["scalingPolicyAction"] = args ? args.scalingPolicyAction : undefined;
resourceInputs["scalingPolicyName"] = args ? args.scalingPolicyName : undefined;
resourceInputs["scalingPolicyType"] = args ? args.scalingPolicyType : undefined;
resourceInputs["scheduledPolicy"] = args ? args.scheduledPolicy : undefined;
resourceInputs["createTime"] = undefined /*out*/;
resourceInputs["status"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Policy.__pulumiType, name, resourceInputs, opts);
}
}
exports.Policy = Policy;
/** @internal */
Policy.__pulumiType = 'huaweicloud:As/policy:Policy';
//# sourceMappingURL=policy.js.map