Commit eec7b512 authored by Ahmad's avatar Ahmad

inikt

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