aliyun / nodejs-sts-sdk

Alibaba Cloud STS client for Node.js
MIT License
5 stars 0 forks source link

Alibaba Cloud STS client for Node.js

npm version Travis Build Status Appveyor Build status codecov license

Installation

npm install @alicloud/sts-sdk

Node.js >= 8.5.0 required.

Usage

const StsClient = require('@alicloud/sts-sdk');

const sts = new StsClient({
  endpoint: 'sts.aliyuncs.com', // check this from sts console
  accessKeyId: '***************', // check this from aliyun console
  accessKeySecret: '***************', // check this from aliyun console
});

async function demo() {
  const res1 = await sts.assumeRole(`acs:ram::${accountID}:role/${roleName}`, 'xxx');
  console.log(res1);
  const res2 = await sts.getCallerIdentity();
  console.log(res2);
}

demo();

API Doc

Method: assumeRole()

Arguments

Returns

Method: getCallerIdentity()

Returns

Method (Japan only): generateSessionAccessKey()

Returns

Test & Coverage

You should set environment variables before running the test or coverage. For example:

ACCESS_KEY=<your access key> SECRET_KEY=<your secret key> ENDPOINT=sts.aliyuncs.com npm run test
ACCESS_KEY=<your access key> SECRET_KEY=<your secret key> ENDPOINT=sts.aliyuncs.com npm run cov

License

MIT