Commit c3665d55 authored by Ahmad's avatar Ahmad

inikt

parent 1eef3fe2
......@@ -85,7 +85,7 @@ async function downloadSSHKey(region) {
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
async function main() {
try {
// Extract credentials
const credentials = extractAWSCredentials(rootKeyFilePath);
console.log('AWS Credentials Loaded:', credentials);
......@@ -97,8 +97,8 @@ async function main() {
});
// Define the regions and required instances
const regions = ['us-west-2', 'us-east-1', 'us-east-2'];
const requiredInstances = ['Ubuntu-1', 'Ubuntu-2'];
let regions = ['us-west-2', 'us-east-1', 'us-east-2'];
let requiredInstances = ['Ubuntu-1', 'Ubuntu-2'];
// Loop through each region and check/create instances
for (const region of regions) {
......@@ -109,8 +109,8 @@ async function main() {
if (!exists) {
console.log(`Instance ${instanceName} does not exist in region ${region}, creating...`);
await createLightsailInstance(lightsail, region, instanceName);
console.log(`Waiting 60 seconds before creating the next instance...`);
await sleep(60000); // Wait for 60 seconds to avoid hitting rate limits
console.log(`Waiting 30 seconds before creating the next instance...`);
await sleep(30000); // Wait for 60 seconds to avoid hitting rate limits
} else {
console.log(`Instance ${instanceName} already exists in region ${region}, skipping creation.`);
}
......@@ -118,18 +118,11 @@ async function main() {
}
// 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');
} catch (error) {
console.error('Error:', error.message);
}
}
main().catch(console.error);
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