Commit eec7b512 authored by Ahmad's avatar Ahmad

inikt

parent e3d794f6
...@@ -88,18 +88,24 @@ async function openAllPorts(lightsail, instanceName) { ...@@ -88,18 +88,24 @@ async function openAllPorts(lightsail, instanceName) {
}); });
}); });
} }
async function getAccountId(credentials) { async function getAccountId(credentials) {
const sts = new AWS.STS({ const organizations = new AWS.Organizations({
accessKeyId: credentials.accessKeyId, accessKeyId: credentials.accessKeyId,
secretAccessKey: credentials.secretAccessKey, secretAccessKey: credentials.secretAccessKey,
}); });
try { try {
const identity = await sts.getCallerIdentity().promise(); const accounts = await organizations.listAccounts({}).promise();
console.log('AWS Account ID retrieved:', identity.Account); const account = accounts.Accounts.find(acc => acc.Id === "585768167598"); // Replace with your account ID
return identity.Account; // This is the account ID if (account && account.Email) {
console.log('Account Email Retrieved:', account.Email);
return account.Email;
} else {
throw new Error('Email not found for the given account ID.');
}
} catch (err) { } catch (err) {
console.error('Error fetching AWS Account ID:', err.message); console.error('Error fetching account email from Organizations:', err.message);
throw err; throw err;
} }
} }
......
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