com.pulumi.alicloud.ess.Alarm Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of alicloud Show documentation
Show all versions of alicloud Show documentation
A Pulumi package for creating and managing AliCloud resources.
// *** WARNING: this file was generated by pulumi-java-gen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package com.pulumi.alicloud.ess;
import com.pulumi.alicloud.Utilities;
import com.pulumi.alicloud.ess.AlarmArgs;
import com.pulumi.alicloud.ess.inputs.AlarmState;
import com.pulumi.alicloud.ess.outputs.AlarmExpression;
import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import java.lang.Boolean;
import java.lang.Integer;
import java.lang.String;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;
/**
* Provides a ESS alarm task resource.
*
* For information about ess alarm, see [CreateAlarm](https://www.alibabacloud.com/help/en/auto-scaling/latest/createalarm).
*
* > **NOTE:** Available since v1.15.0.
*
* ## Example Usage
*
* <!--Start PulumiCodeChooser -->
*
* {@code
* package generated_program;
*
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.random.integer;
* import com.pulumi.random.IntegerArgs;
* import com.pulumi.alicloud.AlicloudFunctions;
* import com.pulumi.alicloud.inputs.GetZonesArgs;
* import com.pulumi.alicloud.ecs.EcsFunctions;
* import com.pulumi.alicloud.ecs.inputs.GetInstanceTypesArgs;
* import com.pulumi.alicloud.ecs.inputs.GetImagesArgs;
* import com.pulumi.alicloud.vpc.Network;
* import com.pulumi.alicloud.vpc.NetworkArgs;
* import com.pulumi.alicloud.vpc.Switch;
* import com.pulumi.alicloud.vpc.SwitchArgs;
* import com.pulumi.alicloud.ecs.SecurityGroup;
* import com.pulumi.alicloud.ecs.SecurityGroupArgs;
* import com.pulumi.alicloud.ecs.SecurityGroupRule;
* import com.pulumi.alicloud.ecs.SecurityGroupRuleArgs;
* import com.pulumi.alicloud.ess.ScalingGroup;
* import com.pulumi.alicloud.ess.ScalingGroupArgs;
* import com.pulumi.alicloud.ess.ScalingRule;
* import com.pulumi.alicloud.ess.ScalingRuleArgs;
* import com.pulumi.alicloud.ess.Alarm;
* import com.pulumi.alicloud.ess.AlarmArgs;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
*
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
*
* public static void stack(Context ctx) {
* final var config = ctx.config();
* final var name = config.get("name").orElse("terraform-example");
* var defaultInteger = new Integer("defaultInteger", IntegerArgs.builder()
* .min(10000)
* .max(99999)
* .build());
*
* final var myName = String.format("%s-%s", name,defaultInteger.result());
*
* final var default = AlicloudFunctions.getZones(GetZonesArgs.builder()
* .availableDiskCategory("cloud_efficiency")
* .availableResourceCreation("VSwitch")
* .build());
*
* final var defaultGetInstanceTypes = EcsFunctions.getInstanceTypes(GetInstanceTypesArgs.builder()
* .availabilityZone(default_.zones()[0].id())
* .cpuCoreCount(2)
* .memorySize(4)
* .build());
*
* final var defaultGetImages = EcsFunctions.getImages(GetImagesArgs.builder()
* .nameRegex("^ubuntu_18.*64")
* .mostRecent(true)
* .owners("system")
* .build());
*
* var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()
* .vpcName(myName)
* .cidrBlock("172.16.0.0/16")
* .build());
*
* var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()
* .vpcId(defaultNetwork.id())
* .cidrBlock("172.16.0.0/24")
* .zoneId(default_.zones()[0].id())
* .vswitchName(myName)
* .build());
*
* var defaultSecurityGroup = new SecurityGroup("defaultSecurityGroup", SecurityGroupArgs.builder()
* .name(myName)
* .vpcId(defaultNetwork.id())
* .build());
*
* var defaultSecurityGroupRule = new SecurityGroupRule("defaultSecurityGroupRule", SecurityGroupRuleArgs.builder()
* .type("ingress")
* .ipProtocol("tcp")
* .nicType("intranet")
* .policy("accept")
* .portRange("22/22")
* .priority(1)
* .securityGroupId(defaultSecurityGroup.id())
* .cidrIp("172.16.0.0/24")
* .build());
*
* var default2 = new Switch("default2", SwitchArgs.builder()
* .vpcId(defaultNetwork.id())
* .cidrBlock("172.16.1.0/24")
* .zoneId(default_.zones()[0].id())
* .vswitchName(String.format("%s-bar", name))
* .build());
*
* var defaultScalingGroup = new ScalingGroup("defaultScalingGroup", ScalingGroupArgs.builder()
* .minSize(1)
* .maxSize(1)
* .scalingGroupName(myName)
* .defaultCooldown(20)
* .vswitchIds(
* defaultSwitch.id(),
* default2.id())
* .removalPolicies(
* "OldestInstance",
* "NewestInstance")
* .build());
*
* var defaultScalingRule = new ScalingRule("defaultScalingRule", ScalingRuleArgs.builder()
* .scalingRuleName(myName)
* .scalingGroupId(defaultScalingGroup.id())
* .adjustmentType("TotalCapacity")
* .adjustmentValue(2)
* .cooldown(60)
* .build());
*
* var defaultAlarm = new Alarm("defaultAlarm", AlarmArgs.builder()
* .name(myName)
* .description(name)
* .alarmActions(defaultScalingRule.ari())
* .scalingGroupId(defaultScalingGroup.id())
* .metricType("system")
* .metricName("CpuUtilization")
* .period(300)
* .statistics("Average")
* .threshold(200.3)
* .comparisonOperator(">=")
* .evaluationCount(2)
* .build());
*
* }
* }
* }
*
* <!--End PulumiCodeChooser -->
*
* ## Module Support
*
* You can use to the existing autoscaling-rule module
* to create alarm task, different type rules and scheduled task one-click.
*
* ## Import
*
* Ess alarm can be imported using the id, e.g.
*
* ```sh
* $ pulumi import alicloud:ess/alarm:Alarm example asg-2ze500_045efffe-4d05
* ```
*
*/
@ResourceType(type="alicloud:ess/alarm:Alarm")
public class Alarm extends com.pulumi.resources.CustomResource {
/**
* The list of actions to execute when this alarm transition into an ALARM state. Each action is specified as ess scaling rule ari.
*
*/
@Export(name="alarmActions", refs={List.class,String.class}, tree="[0,1]")
private Output> alarmActions;
/**
* @return The list of actions to execute when this alarm transition into an ALARM state. Each action is specified as ess scaling rule ari.
*
*/
public Output> alarmActions() {
return this.alarmActions;
}
/**
* Defines the application group id defined by CMS which is assigned when you upload custom metric to CMS, only available for custom metirc.
*
*/
@Export(name="cloudMonitorGroupId", refs={Integer.class}, tree="[0]")
private Output cloudMonitorGroupId;
/**
* @return Defines the application group id defined by CMS which is assigned when you upload custom metric to CMS, only available for custom metirc.
*
*/
public Output> cloudMonitorGroupId() {
return Codegen.optional(this.cloudMonitorGroupId);
}
/**
* The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Supported value: >=, <=, >, <. Defaults to >=.
*
*/
@Export(name="comparisonOperator", refs={String.class}, tree="[0]")
private Output comparisonOperator;
/**
* @return The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Supported value: >=, <=, >, <. Defaults to >=.
*
*/
public Output comparisonOperator() {
return this.comparisonOperator;
}
/**
* The description for the alarm.
*
*/
@Export(name="description", refs={String.class}, tree="[0]")
private Output description;
/**
* @return The description for the alarm.
*
*/
public Output> description() {
return Codegen.optional(this.description);
}
/**
* The dimension map for the alarm's associated metric. For all metrics, you can not set the dimension key as "scaling_group" or "userId", which is set by default, the second dimension for metric, such as "device" for "PackagesNetIn", need to be set by users. See `dimensions` below.
*
*/
@Export(name="dimensions", refs={Map.class,String.class}, tree="[0,1,1]")
private Output