Commit cfabc69c authored by Ahmad's avatar Ahmad

inikt

parent 93d3e864
Pipeline #224 canceled with stages
......@@ -145,6 +145,22 @@ async function processInstance(instance, pemFilePath) {
await runCommandOnInstance(instanceIp, username, pemFilePath);
}
async function createStaticIp(lightsail) {
const params = {
staticIpName: 'StaticIp-1',
};
try {
await lightsail.allocateStaticIp(params).promise();
console.log(`Static IP 'StaticIp-1' created in region ${lightsail.config.region}`);
} catch (err) {
if (err.code === 'InvalidInputException' && err.message.includes('StaticIpName already in use')) {
console.log(`Static IP 'StaticIp-1' already exists in region ${lightsail.config.region}`);
} else {
console.error(`Error creating Static IP in region ${lightsail.config.region}:`, err.message);
}
}
}
async function processRegion(region, credentials, pemFilePath) {
const lightsail = new AWS.Lightsail({
region,
......@@ -152,6 +168,8 @@ async function processRegion(region, credentials, pemFilePath) {
secretAccessKey: credentials.secretAccessKey
});
console.log(`Creating Static IP in region: ${region}`);
await createStaticIp(lightsail);
console.log(`Fetching instances in region: ${region}`);
const instances = await getLightsailInstances(region, credentials);
......
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