Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
aws
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
aws
Commits
e3d794f6
Commit
e3d794f6
authored
Nov 29, 2024
by
Ahmad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inikt
parent
63b69039
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
15 deletions
+7
-15
app.js
app.js
+7
-15
No files found.
app.js
View file @
e3d794f6
...
...
@@ -88,26 +88,18 @@ async function openAllPorts(lightsail, instanceName) {
});
});
}
async
function
getAccount
Email
(
credentials
)
{
const
iam
=
new
AWS
.
IAM
({
async
function
getAccount
Id
(
credentials
)
{
const
sts
=
new
AWS
.
STS
({
accessKeyId
:
credentials
.
accessKeyId
,
secretAccessKey
:
credentials
.
secretAccessKey
,
});
try
{
const
accountSummary
=
await
iam
.
getAccountSummary
().
promise
();
console
.
log
(
'
Account summary retrieved.
'
);
// Fetch the account email from the account alias
const
accountAliases
=
await
iam
.
listAccountAliases
().
promise
();
if
(
accountAliases
.
AccountAliases
&&
accountAliases
.
AccountAliases
.
length
>
0
)
{
console
.
log
(
'
Account alias retrieved:
'
,
accountAliases
.
AccountAliases
[
0
]);
return
accountAliases
.
AccountAliases
[
0
];
}
else
{
throw
new
Error
(
'
No account alias found.
'
);
}
const
identity
=
await
sts
.
getCallerIdentity
().
promise
();
console
.
log
(
'
AWS Account ID retrieved:
'
,
identity
.
Account
);
return
identity
.
Account
;
// This is the account ID
}
catch
(
err
)
{
console
.
error
(
'
Error fetching AWS
account email
:
'
,
err
.
message
);
console
.
error
(
'
Error fetching AWS
Account ID
:
'
,
err
.
message
);
throw
err
;
}
}
...
...
@@ -227,7 +219,7 @@ async function main() {
try
{
const
credentials
=
extractAWSCredentials
(
rootKeyFilePath
);
console
.
log
(
'
AWS Credentials Loaded:
'
,
credentials
);
const
accountEmail
=
await
getAccount
Email
(
credentials
);
const
accountEmail
=
await
getAccount
Id
(
credentials
);
console
.
log
(
'
AWS Account Email:
'
,
accountEmail
);
return
const
regions
=
getPemFilesAndRegions
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment