阿里STS权限管理

  1. 打开地址  https://ram.console.aliyun.com/roles
  2. 创建用户来获取 accessKeyId accessKeySecret
  3. RAM角色管理,创建RAM角色,选择阿里云
  4. 给角色添加权限,可以添加无数个,最重要的是添加AliyunSTSAssumeRoleAccess
let OSS = require('ali-oss');
let STS = OSS.STS;
let sts = new STS({
    accessKeyId: 'LTAI5*******e4eSf',
    accessKeySecret: 'a0O********i4MdaE0cB'
});

async function assumeRole() {
    try {
        let token = await sts.assumeRole('acs:ram::11*********:role/y*****s', null, '3600', 'demo-bucket');
        console.log(token.credentials);
    } catch (e) {
        console.log(e);
    }
}
assumeRole();