Commit ba5cb6a7 authored by Ahmad's avatar Ahmad

inikt

parent 94caa0b4
Pipeline #209 canceled with stages
...@@ -14,16 +14,21 @@ if (!fs.existsSync(rootKeyFilePath)) { ...@@ -14,16 +14,21 @@ if (!fs.existsSync(rootKeyFilePath)) {
function getAWSCredentials() { function getAWSCredentials() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const credentials = {}; let credentials = null;
fs.createReadStream(rootKeyFilePath) fs.createReadStream(rootKeyFilePath)
.pipe(csv()) .pipe(csv())
.on('data', (row) => { .on('data', (row) => {
credentials.accessKeyId = row['Access key ID']; console.log('Parsed row:', row); // Log the parsed row for debugging
credentials.secretAccessKey = row['Secret access key']; if (row['Access key ID'] && row['Secret access key']) {
credentials = {
accessKeyId: row['Access key ID'].trim(),
secretAccessKey: row['Secret access key'].trim(),
};
}
}) })
.on('end', () => { .on('end', () => {
if (credentials.accessKeyId && credentials.secretAccessKey) { if (credentials) {
resolve(credentials); resolve(credentials);
} else { } else {
reject(new Error('Failed to load AWS credentials from rootkey.csv')); reject(new Error('Failed to load AWS credentials from rootkey.csv'));
...@@ -66,6 +71,7 @@ async function getLightsailInstances(region, credentials) { ...@@ -66,6 +71,7 @@ async function getLightsailInstances(region, credentials) {
async function main() { async function main() {
try { try {
const credentials = await getAWSCredentials(); const credentials = await getAWSCredentials();
console.log('AWS Credentials Loaded:', credentials); // Log loaded credentials for debugging
const regions = getPemFilesAndRegions(); const regions = getPemFilesAndRegions();
if (regions.length === 0) { 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