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
c3665d55
Commit
c3665d55
authored
Nov 04, 2024
by
Ahmad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inikt
parent
1eef3fe2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
13 deletions
+6
-13
create.js
create.js
+6
-13
No files found.
create.js
View file @
c3665d55
...
@@ -85,7 +85,7 @@ async function downloadSSHKey(region) {
...
@@ -85,7 +85,7 @@ async function downloadSSHKey(region) {
const
sleep
=
(
ms
)
=>
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
ms
));
const
sleep
=
(
ms
)
=>
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
ms
));
async
function
main
()
{
async
function
main
()
{
try
{
// Extract credentials
// Extract credentials
const
credentials
=
extractAWSCredentials
(
rootKeyFilePath
);
const
credentials
=
extractAWSCredentials
(
rootKeyFilePath
);
console
.
log
(
'
AWS Credentials Loaded:
'
,
credentials
);
console
.
log
(
'
AWS Credentials Loaded:
'
,
credentials
);
...
@@ -97,8 +97,8 @@ async function main() {
...
@@ -97,8 +97,8 @@ async function main() {
});
});
// Define the regions and required instances
// Define the regions and required instances
cons
t
regions
=
[
'
us-west-2
'
,
'
us-east-1
'
,
'
us-east-2
'
];
le
t
regions
=
[
'
us-west-2
'
,
'
us-east-1
'
,
'
us-east-2
'
];
cons
t
requiredInstances
=
[
'
Ubuntu-1
'
,
'
Ubuntu-2
'
];
le
t
requiredInstances
=
[
'
Ubuntu-1
'
,
'
Ubuntu-2
'
];
// Loop through each region and check/create instances
// Loop through each region and check/create instances
for
(
const
region
of
regions
)
{
for
(
const
region
of
regions
)
{
...
@@ -109,8 +109,8 @@ async function main() {
...
@@ -109,8 +109,8 @@ async function main() {
if
(
!
exists
)
{
if
(
!
exists
)
{
console
.
log
(
`Instance
${
instanceName
}
does not exist in region
${
region
}
, creating...`
);
console
.
log
(
`Instance
${
instanceName
}
does not exist in region
${
region
}
, creating...`
);
await
createLightsailInstance
(
lightsail
,
region
,
instanceName
);
await
createLightsailInstance
(
lightsail
,
region
,
instanceName
);
console
.
log
(
`Waiting
6
0 seconds before creating the next instance...`
);
console
.
log
(
`Waiting
3
0 seconds before creating the next instance...`
);
await
sleep
(
6
0000
);
// Wait for 60 seconds to avoid hitting rate limits
await
sleep
(
3
0000
);
// Wait for 60 seconds to avoid hitting rate limits
}
else
{
}
else
{
console
.
log
(
`Instance
${
instanceName
}
already exists in region
${
region
}
, skipping creation.`
);
console
.
log
(
`Instance
${
instanceName
}
already exists in region
${
region
}
, skipping creation.`
);
}
}
...
@@ -118,18 +118,11 @@ async function main() {
...
@@ -118,18 +118,11 @@ async function main() {
}
}
// Download and verify SSH keys for all regions after creating instances
// Download and verify SSH keys for all regions after creating instances
for
(
const
region
of
regions
)
{
const
keyFilePath
=
await
downloadSSHKey
(
region
);
}
console
.
log
(
'
All Done
'
);
console
.
log
(
'
All Done
'
);
}
catch
(
error
)
{
console
.
error
(
'
Error:
'
,
error
.
message
);
}
}
}
main
().
catch
(
console
.
error
);
main
().
catch
(
console
.
error
);
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