All files / Nodejs/lib awsSetup.js

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43                                                                                     
// "use strict";
 
// const AWS = require('aws-sdk');
// const ini = require('ini');
// const fs = require('fs');
// const execSync = require("child_process").execSync;
 
// let currentProfile = null;
 
// module.exports = function (profile) {
//   console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^")
//   profile = profile || process.env.AWS_PROFILE || process.env.AWS_DEFAULT_PROFILE;
 
//   if (profile != currentProfile) {
//     let configFile = `${process.env.HOME}/.aws/config`;
//     if (fs.existsSync(configFile)) {
//       let config = ini.parse(fs.readFileSync(configFile, 'utf-8'));
//       console.log("config is", config);
 
//       let p = config[`profile ${profile}`];
//       if (p && profile !== 'default' && p.role_arn) {
//         let cacheFile = `${profile}--${p.role_arn.replace(/:/g, '_').replace(/[^A-Za-z0-9\-_]/g, '-')}`;
//         if (!fs.existsSync(cacheFile)) {
//           execSync('aws s3 ls')
//           //Then we need to get the credentials cached
 
 
//         }
 
 
//         let data = JSON.parse(fs.readFileSync(`${profile}--${p.role_arn.replace(/:/g, '_').replace(/[^A-Za-z0-9\-_]/g, '-')}`));
//         console.log(data);
//         AWS.config.credentials = new AWS.STS().credentialsFrom(data, data);
//       }
//     } else {
//       var credentials = new AWS.SharedIniFileCredentials({
//         profile: profile
//       });
//       AWS.config.credentials = credentials;
//       process.env.AWS_PROFILE = profile;
//     }
//   }
// }