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
eec7b512
Commit
eec7b512
authored
Nov 29, 2024
by
Ahmad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inikt
parent
e3d794f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
app.js
app.js
+11
-5
No files found.
app.js
View file @
eec7b512
...
@@ -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
;
}
}
}
}
...
...
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