How to use the AutoScaling function from aws-sdk

Find comprehensive JavaScript aws-sdk.AutoScaling code examples handpicked from public code repositorys.

aws-sdk.AutoScaling is a client for managing Amazon EC2 Auto Scaling groups and instances.

70
71
72
73
74
75
76
77
78
79
return {
  async load(existingConfig) {
    if (!process.env.CONFIG_LOAD_FROM_AWS) return {};

    logger.info('Detecting AutoScalingGroup...');
    var autoscaling = new AWS.AutoScaling({ region: existingConfig.awsRegion });
    var params = { InstanceIds: [existingConfig.instanceId] };
    const data = await autoscaling.describeAutoScalingInstances(params).promise();
    if (!data.AutoScalingInstances || data.AutoScalingInstances.length === 0) {
      logger.info('Not running inside an AutoScalingGroup');
fork icon256
star icon256
watch icon15

56
57
58
59
60
61
62
63
64
65
66
67
  accessKeyId: process.env.AWS_ACCESS_KEY,
  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
  region: 'us-east-2',
});


const autoscaling = new AWS.AutoScaling();
const ec2 = new AWS.EC2();


const fetchWithTimeout = async (url, options, timeout = 5000) => {
  const controller = new AbortController();
fork icon99
star icon159
watch icon9

+ 45 other calls in file

How does aws-sdk.AutoScaling work?

The aws-sdk.AutoScaling module provides a client interface to the AWS Auto Scaling service, allowing you to manage and configure scalable resources such as Amazon EC2 instances or Spot Fleets, based on user-defined policies. The module includes methods for creating and deleting Auto Scaling groups, setting policies, launching and terminating instances, and more.

10
11
12
13
14
15
16
17
18
19
const express = require('express');
const app = express();
const getString = bent('string');
const AWS = require('aws-sdk');
const sns = new AWS.SNS({apiVersion: '2010-03-31'});
const autoscaling = new AWS.AutoScaling({apiVersion: '2011-01-01'});
const {Parser} = require('xml2js');
const parser = new Parser();
const {validatePayload} = require('verify-aws-sns-signature');

fork icon27
star icon31
watch icon0

58
59
60
61
62
63
64
65
66
67

var rds = new AWS.RDS({
  apiVersion: '2014-10-31'
})

var autoscaling = new AWS.AutoScaling()
const dynamodb = new AWS.DynamoDB()
var docClient = new AWS.DynamoDB.DocumentClient()
var SSM = new AWS.SSM()
var cloudwatch = new AWS.CloudWatch()
fork icon0
star icon1
watch icon0

Ai Example

1
2
3
4
5
6
7
8
9
10
11
12
const AWS = require("aws-sdk");
const autoScaling = new AWS.AutoScaling({ region: "us-east-1" });

const params = {
  AutoScalingGroupNames: ["my-asg"],
  MaxRecords: 10,
};

autoScaling.describeAutoScalingGroups(params, (err, data) => {
  if (err) console.log(err, err.stack);
  else console.log(data);
});

In this example, we first create a new instance of the AWS.AutoScaling class, which provides access to the Auto Scaling API in the specified region. We then define an object params with parameters for the describeAutoScalingGroups method, which retrieves information about the specified Auto Scaling groups. Finally, we call the method with our parameters and a callback function that logs the result to the console.