Commit ba5cb6a7 authored by Ahmad's avatar Ahmad

inikt

parent 94caa0b4
Pipeline #209 canceled with stages
......@@ -14,16 +14,21 @@ if (!fs.existsSync(rootKeyFilePath)) {
function getAWSCredentials() {
return new Promise((resolve, reject) => {
const credentials = {};
let credentials = null;
fs.createReadStream(rootKeyFilePath)
.pipe(csv())
.on('data', (row) => {
credentials.accessKeyId = row['Access key ID'];
credentials.secretAccessKey = row['Secret access key'];
console.log('Parsed row:', row); // Log the parsed row for debugging
if (row['Access key ID'] && row['Secret access key']) {
credentials = {
accessKeyId: row['Access key ID'].trim(),
secretAccessKey: row['Secret access key'].trim(),
};
}
})
.on('end', () => {
if (credentials.accessKeyId && credentials.secretAccessKey) {
if (credentials) {
resolve(credentials);
} else {
reject(new Error('Failed to load AWS credentials from rootkey.csv'));
......@@ -66,6 +71,7 @@ async function getLightsailInstances(region, credentials) {
async function main() {
try {
const credentials = await getAWSCredentials();
console.log('AWS Credentials Loaded:', credentials); // Log loaded credentials for debugging
const regions = getPemFilesAndRegions();
if (regions.length === 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment