Commit 576c77ac authored by Ahmad's avatar Ahmad

inikt

parent 50a738dd
Pipeline #212 canceled with stages
......@@ -11,19 +11,25 @@ if (!fs.existsSync(rootKeyFilePath)) {
process.exit(1);
}
// Function to extract AWS credentials using regex
// Function to read the second line and extract AWS credentials
function extractAWSCredentials(filePath) {
const fileContent = fs.readFileSync(filePath, 'utf8');
const accessKeyIdMatch = fileContent.match(/Access key ID\s*,\s*([^,\s]+)/i);
const secretAccessKeyMatch = fileContent.match(/Secret access key\s*,\s*([^,\s]+)/i);
const lines = fileContent.split('\n');
if (accessKeyIdMatch && secretAccessKeyMatch) {
if (lines.length < 2) {
throw new Error('The rootkey.csv file does not contain enough lines.');
}
const secondLine = lines[1].trim();
const [accessKeyId, secretAccessKey] = secondLine.split(',');
if (accessKeyId && secretAccessKey) {
return {
accessKeyId: accessKeyIdMatch[1],
secretAccessKey: secretAccessKeyMatch[1],
accessKeyId: accessKeyId.trim(),
secretAccessKey: secretAccessKey.trim(),
};
} else {
throw new Error('Failed to extract AWS credentials from rootkey.csv');
throw new Error('Failed to extract AWS credentials from the second line of rootkey.csv');
}
}
......
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