@pulumiverse/scaleway
Version:
A Pulumi package for creating and managing Scaleway cloud resources.
217 lines • 7.98 kB
JavaScript
"use strict";
// *** 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.InstanceGroup = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Books and manages Autoscaling Instance groups.
*
* ## Example Usage
*
* ### Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as scaleway from "@pulumiverse/scaleway";
*
* const main = new scaleway.autoscaling.InstanceGroup("main", {
* name: "asg-group",
* templateId: mainScalewayAutoscalingInstanceTemplate.id,
* tags: [
* "terraform-test",
* "instance-group",
* ],
* capacities: [{
* maxReplicas: 5,
* minReplicas: 1,
* cooldownDelay: 300,
* }],
* loadBalancers: [{
* id: mainScalewayLb.id,
* backendIds: [mainScalewayLbBackend.id],
* privateNetworkId: mainScalewayVpcPrivateNetwork.id,
* }],
* });
* ```
*
* ### With template and policies
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as scaleway from "@pulumiverse/scaleway";
*
* const main = new scaleway.network.Vpc("main", {name: "TestAccAutoscalingVPC"});
* const mainPrivateNetwork = new scaleway.network.PrivateNetwork("main", {
* name: "TestAccAutoscalingVPC",
* vpcId: main.id,
* });
* const mainVolume = new scaleway.block.Volume("main", {
* iops: 5000,
* sizeInGb: 10,
* });
* const mainSnapshot = new scaleway.block.Snapshot("main", {
* name: "test-ds-block-snapshot-basic",
* volumeId: mainVolume.id,
* });
* const mainIp = new scaleway.loadbalancers.Ip("main", {});
* const mainLoadBalancer = new scaleway.loadbalancers.LoadBalancer("main", {
* ipId: mainIp.id,
* name: "test-lb",
* type: "lb-s",
* privateNetworks: [{
* privateNetworkId: mainPrivateNetwork.id,
* }],
* });
* const mainBackend = new scaleway.loadbalancers.Backend("main", {
* lbId: mainLoadBalancer.id,
* forwardProtocol: "tcp",
* forwardPort: 80,
* proxyProtocol: "none",
* });
* const mainInstanceTemplate = new scaleway.autoscaling.InstanceTemplate("main", {
* name: "autoscaling-instance-template-basic",
* commercialType: "PLAY2-MICRO",
* tags: [
* "terraform-test",
* "basic",
* ],
* volumes: [{
* name: "as-volume",
* volumeType: "sbs",
* boot: true,
* fromSnapshot: {
* snapshotId: mainSnapshot.id,
* },
* perfIops: 5000,
* }],
* publicIpsV4Count: 1,
* privateNetworkIds: [mainPrivateNetwork.id],
* });
* const mainInstanceGroup = new scaleway.autoscaling.InstanceGroup("main", {
* name: "autoscaling-instance-group-basic",
* templateId: mainInstanceTemplate.id,
* tags: [
* "terraform-test",
* "instance-group",
* ],
* capacities: [{
* maxReplicas: 5,
* minReplicas: 1,
* cooldownDelay: 300,
* }],
* loadBalancers: [{
* id: mainLoadBalancer.id,
* backendIds: [mainBackend.id],
* privateNetworkId: mainPrivateNetwork.id,
* }],
* deleteServersOnDestroy: true,
* });
* const up = new scaleway.autoscaling.InstancePolicy("up", {
* instanceGroupId: mainInstanceGroup.id,
* name: "scale-up-if-cpu-high",
* action: "scale_up",
* type: "flat_count",
* value: 1,
* priority: 1,
* metrics: [{
* name: "cpu scale up",
* managedMetric: "managed_metric_instance_cpu",
* operator: "operator_greater_than",
* aggregate: "aggregate_average",
* samplingRangeMin: 5,
* threshold: 70,
* }],
* });
* const down = new scaleway.autoscaling.InstancePolicy("down", {
* instanceGroupId: mainInstanceGroup.id,
* name: "scale-down-if-cpu-low",
* action: "scale_down",
* type: "flat_count",
* value: 1,
* priority: 2,
* metrics: [{
* name: "cpu scale down",
* managedMetric: "managed_metric_instance_cpu",
* operator: "operator_less_than",
* aggregate: "aggregate_average",
* samplingRangeMin: 5,
* threshold: 40,
* }],
* });
* ```
*
* ## Import
*
* Autoscaling Instance groups can be imported using `{zone}/{id}`, e.g.
*
* bash
*
* ```sh
* $ pulumi import scaleway:autoscaling/instanceGroup:InstanceGroup main fr-par-1/11111111-1111-1111-1111-111111111111
* ```
*/
class InstanceGroup extends pulumi.CustomResource {
/**
* Get an existing InstanceGroup 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 InstanceGroup(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of InstanceGroup. 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'] === InstanceGroup.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["capacities"] = state ? state.capacities : undefined;
resourceInputs["createdAt"] = state ? state.createdAt : undefined;
resourceInputs["deleteServersOnDestroy"] = state ? state.deleteServersOnDestroy : undefined;
resourceInputs["loadBalancers"] = state ? state.loadBalancers : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["projectId"] = state ? state.projectId : undefined;
resourceInputs["tags"] = state ? state.tags : undefined;
resourceInputs["templateId"] = state ? state.templateId : undefined;
resourceInputs["updatedAt"] = state ? state.updatedAt : undefined;
resourceInputs["zone"] = state ? state.zone : undefined;
}
else {
const args = argsOrState;
if ((!args || args.templateId === undefined) && !opts.urn) {
throw new Error("Missing required property 'templateId'");
}
resourceInputs["capacities"] = args ? args.capacities : undefined;
resourceInputs["deleteServersOnDestroy"] = args ? args.deleteServersOnDestroy : undefined;
resourceInputs["loadBalancers"] = args ? args.loadBalancers : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["projectId"] = args ? args.projectId : undefined;
resourceInputs["tags"] = args ? args.tags : undefined;
resourceInputs["templateId"] = args ? args.templateId : undefined;
resourceInputs["zone"] = args ? args.zone : undefined;
resourceInputs["createdAt"] = undefined /*out*/;
resourceInputs["updatedAt"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(InstanceGroup.__pulumiType, name, resourceInputs, opts);
}
}
exports.InstanceGroup = InstanceGroup;
/** @internal */
InstanceGroup.__pulumiType = 'scaleway:autoscaling/instanceGroup:InstanceGroup';
//# sourceMappingURL=instanceGroup.js.map