How to use the MetadataService function from aws-sdk

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

9
10
11
12
13
14
15
16
17
18

const region = 'us-east-1';

const s3 = new aws.S3({ region });
const ddb = new aws.DynamoDB({ region });
const meta = new aws.MetadataService();

class WARCannon {
        constructor() {
                this.settings = {
fork icon31
star icon212
watch icon3

21
22
23
24
25
26
27
28
29
30
    self.config.credentials = ms;
    setEmitter();
  });
} else {
  // however if it's set to specify a role, query it specifically.
  ms = new AWS.MetadataService();
  ms.request('/latest/meta-data/iam/security-credentials/' + this.config.iamRole, function(err, rdata) {
    var data = JSON.parse(rdata);

    if (err) { console.log('Failed to fetch IAM role credentials: ' + err); }
fork icon53
star icon80
watch icon5

2
3
4
5
6
7
8
9
10
11
var AWS = require('aws-sdk');
var memoize = require('./lib/util/memoizeWithOptions');
var promisifyAll = require('./lib/util/promisifyAll');

function metadataService(options) {
  return promisifyAll(new AWS.MetadataService(options));
}

/**
 * Returns an instance of AWS.MetadataService which has Promise methods
fork icon10
star icon26
watch icon8

17
18
19
20
21
22
23
24
25
26
}, opts);

/**
 * Initialize the metadata-service client
 */
this._service = new Aws.MetadataService({
  httpOptions: {
    timeout: options.timeout
  },
  host: options.host
fork icon10
star icon22
watch icon57

25
26
27
28
29
30
31
32
33
34

  if (!!metadata && metadata instanceof AWS.MetadataService) {
    return metadata;
  }

  return new AWS.MetadataService({host: opts.metadata.host});
}

/**
 * Get the instance's region from its metadata
fork icon5
star icon13
watch icon17

29
30
31
32
33
34
35
36
37
38

class Cloud extends AbstractCloud {
    constructor(options) {
        super(CLOUD_PROVIDERS.AWS, options);

        this.metadata = new AWS.MetadataService();
        this.s3 = {};
        this.s3FilePrefix = constants.STORAGE_FOLDER_NAME;
        this.ec2 = {};
        this._sessionToken = null;
fork icon1
star icon12
watch icon16

4
5
6
7
8
9
10
11
12

AWS.config.update({ region: 'us-east-1' });

const autoscaling = new AWS.AutoScaling();
const sqs = new AWS.SQS();
const meta = new AWS.MetadataService();
const s3 = new AWS.S3();

const { INSTANCE_ID, SQSQUEUE, AUTOSCALINGGROUP, REPORTBUCKET } = process.env;
fork icon1
star icon0
watch icon1

12
13
14
15
16
17
18
19
20
21
}

function getSeedRetriever(opts:AWSClientOptions, address:string = Client.DEFAULT_ADDRESS):SeedRetriever {
  return () => {
    return new Promise((resolve, reject) => {
      new AWS.MetadataService().request('/latest/dynamic/instance-identity/document', function(err, data) {
        if (err) {
          reject(err);
        } else {
          resolve(JSON.parse(data));
fork icon0
star icon1
watch icon7

+ 3 other calls in file

26
27
28
29
30
31
32
33
34
35
const options = {
  httpOptions: { timeout: 200 },
  maxRetries: 1
}

const meta = new aws.MetadataService(options)

let metadata

return new Promise((resolve, reject) => {
fork icon0
star icon0
watch icon17

32
33
34
35
36
37
38
39
40
41
}

if (config.dimensions['InstanceId'] != '')
  startup(config, startupTime, emitter, logger, units)
else {
  var metadata = new AWS.MetadataService()
  metadata.request('/latest/meta-data/instance-id', function(err, data) {
    if (err) {
      if (config.debug)
        logger.log('cloudwatch backend could not access meta-data service: ' + err.code)
fork icon0
star icon0
watch icon2