@huaweicloudos/pulumi
Version:
A Pulumi package for creating and managing Huaweicloud cloud resources.
290 lines (289 loc) • 10.7 kB
TypeScript
import * as pulumi from "@pulumi/pulumi";
import { input as inputs, output as outputs } from "../types";
/**
* 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>
* ```
*/
export declare 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: string, id: pulumi.Input<pulumi.ID>, state?: PolicyState, opts?: pulumi.CustomResourceOptions): Policy;
/**
* 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: any): obj is Policy;
/**
* Specifies the operation for the AS policy.
* The default value is **resume**. The valid values are as follows:
* + **resume**: Enables the AS policy.
* + **pause**: Disables the AS policy.
*/
readonly action: pulumi.Output<string>;
readonly alarmId: pulumi.Output<string | undefined>;
/**
* Specifies the cooling duration (in seconds).
* The value ranges from 0 to 86400 and is 300 by default.
*/
readonly coolDownTime: pulumi.Output<number>;
/**
* The creation time of the AS policy, in UTC format.
*/
readonly createTime: pulumi.Output<string>;
/**
* Specifies the region in which to create the AS policy. If omitted, the
* provider-level region will be used. Changing this creates a new AS policy.
*/
readonly region: pulumi.Output<string>;
/**
* Specifies the AS group ID. Changing this creates a new AS policy.
*/
readonly scalingGroupId: pulumi.Output<string>;
/**
* Specifies the action of the AS policy.
* The object structure is documented below.
*/
readonly scalingPolicyAction: pulumi.Output<outputs.As.PolicyScalingPolicyAction>;
/**
* Specifies the name of the AS policy. The name contains only letters, digits,
* underscores(_), and hyphens(-), and cannot exceed 64 characters.
*/
readonly scalingPolicyName: pulumi.Output<string>;
/**
* Specifies the AS policy type. The value can be `ALARM`, `SCHEDULED` or `RECURRENCE`.
* + **ALARM**: indicates that the scaling action is triggered by an alarm.
* + **SCHEDULED**: indicates that the scaling action is triggered as scheduled.
* + **RECURRENCE**: indicates that the scaling action is triggered periodically.
*/
readonly scalingPolicyType: pulumi.Output<string>;
/**
* Specifies the periodic or scheduled AS policy.
* This parameter is mandatory when `scalingPolicyType` is set to `SCHEDULED` or `RECURRENCE`.
* The object structure is documented below.
*/
readonly scheduledPolicy: pulumi.Output<outputs.As.PolicyScheduledPolicy>;
/**
* The AS policy status. The value can be *INSERVICE*, *PAUSED* or *EXECUTING*.
*/
readonly status: pulumi.Output<string>;
/**
* Create a Policy resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args: PolicyArgs, opts?: pulumi.CustomResourceOptions);
}
/**
* Input properties used for looking up and filtering Policy resources.
*/
export interface PolicyState {
/**
* Specifies the operation for the AS policy.
* The default value is **resume**. The valid values are as follows:
* + **resume**: Enables the AS policy.
* + **pause**: Disables the AS policy.
*/
action?: pulumi.Input<string>;
alarmId?: pulumi.Input<string>;
/**
* Specifies the cooling duration (in seconds).
* The value ranges from 0 to 86400 and is 300 by default.
*/
coolDownTime?: pulumi.Input<number>;
/**
* The creation time of the AS policy, in UTC format.
*/
createTime?: pulumi.Input<string>;
/**
* Specifies the region in which to create the AS policy. If omitted, the
* provider-level region will be used. Changing this creates a new AS policy.
*/
region?: pulumi.Input<string>;
/**
* Specifies the AS group ID. Changing this creates a new AS policy.
*/
scalingGroupId?: pulumi.Input<string>;
/**
* Specifies the action of the AS policy.
* The object structure is documented below.
*/
scalingPolicyAction?: pulumi.Input<inputs.As.PolicyScalingPolicyAction>;
/**
* Specifies the name of the AS policy. The name contains only letters, digits,
* underscores(_), and hyphens(-), and cannot exceed 64 characters.
*/
scalingPolicyName?: pulumi.Input<string>;
/**
* Specifies the AS policy type. The value can be `ALARM`, `SCHEDULED` or `RECURRENCE`.
* + **ALARM**: indicates that the scaling action is triggered by an alarm.
* + **SCHEDULED**: indicates that the scaling action is triggered as scheduled.
* + **RECURRENCE**: indicates that the scaling action is triggered periodically.
*/
scalingPolicyType?: pulumi.Input<string>;
/**
* Specifies the periodic or scheduled AS policy.
* This parameter is mandatory when `scalingPolicyType` is set to `SCHEDULED` or `RECURRENCE`.
* The object structure is documented below.
*/
scheduledPolicy?: pulumi.Input<inputs.As.PolicyScheduledPolicy>;
/**
* The AS policy status. The value can be *INSERVICE*, *PAUSED* or *EXECUTING*.
*/
status?: pulumi.Input<string>;
}
/**
* The set of arguments for constructing a Policy resource.
*/
export interface PolicyArgs {
/**
* Specifies the operation for the AS policy.
* The default value is **resume**. The valid values are as follows:
* + **resume**: Enables the AS policy.
* + **pause**: Disables the AS policy.
*/
action?: pulumi.Input<string>;
alarmId?: pulumi.Input<string>;
/**
* Specifies the cooling duration (in seconds).
* The value ranges from 0 to 86400 and is 300 by default.
*/
coolDownTime?: pulumi.Input<number>;
/**
* Specifies the region in which to create the AS policy. If omitted, the
* provider-level region will be used. Changing this creates a new AS policy.
*/
region?: pulumi.Input<string>;
/**
* Specifies the AS group ID. Changing this creates a new AS policy.
*/
scalingGroupId: pulumi.Input<string>;
/**
* Specifies the action of the AS policy.
* The object structure is documented below.
*/
scalingPolicyAction?: pulumi.Input<inputs.As.PolicyScalingPolicyAction>;
/**
* Specifies the name of the AS policy. The name contains only letters, digits,
* underscores(_), and hyphens(-), and cannot exceed 64 characters.
*/
scalingPolicyName: pulumi.Input<string>;
/**
* Specifies the AS policy type. The value can be `ALARM`, `SCHEDULED` or `RECURRENCE`.
* + **ALARM**: indicates that the scaling action is triggered by an alarm.
* + **SCHEDULED**: indicates that the scaling action is triggered as scheduled.
* + **RECURRENCE**: indicates that the scaling action is triggered periodically.
*/
scalingPolicyType: pulumi.Input<string>;
/**
* Specifies the periodic or scheduled AS policy.
* This parameter is mandatory when `scalingPolicyType` is set to `SCHEDULED` or `RECURRENCE`.
* The object structure is documented below.
*/
scheduledPolicy?: pulumi.Input<inputs.As.PolicyScheduledPolicy>;
}