@@ -160388,6 +160388,22 @@ async function getImageId(imageNameMatch) {
160388160388 }
160389160389}
160390160390
160391+ async function sendstart(command) {
160392+ const ec2 = new EC2Client({region: process.env.AWS_REGION});
160393+
160394+ ec2.send(command, (err, data) => {
160395+ if (err) {
160396+ console.log(err, err.stack);
160397+ core.error(`Error: ${err}`)
160398+ throw err;
160399+ } else {
160400+ const ec2InstanceIds = data.Instances.map(x => x.InstanceId); //[0].InstanceId; pass all instances instead of just first id
160401+ core.info(`AWS EC2 instance(s) ${ec2InstanceIds} is started`);
160402+ return ec2InstanceIds;
160403+ }
160404+ });
160405+ }
160406+
160391160407async function startEc2Instance(label, githubRegistrationToken) {
160392160408 const userData = buildUserDataScript(githubRegistrationToken, label);
160393160409
@@ -160413,23 +160429,25 @@ async function startEc2Instance(label, githubRegistrationToken) {
160413160429 }
160414160430 }
160415160431
160416- const ec2 = new EC2Client({region: process.env.AWS_REGION});
160432+ // const ec2 = new EC2Client({region: process.env.AWS_REGION});
160417160433
160418160434 const runInstancesCommand = new RunInstancesCommand(params);
160419160435
160420- console.log("beforesend")
160421- await ec2.send(runInstancesCommand, (err, data) => {
160422- if (err) {
160423- console.log(err, err.stack);
160424- core.error(`AWS EC2 instance failed to start - error: ${err}`)
160425- throw err;
160426- } else {
160427- const ec2InstanceIds = data.Instances.map(x => x.InstanceId); //[0].InstanceId; pass all instances instead of just first id
160428- core.info(`AWS EC2 instance(s) ${ec2InstanceIds} is started`);
160429- return ec2InstanceIds;
160430- }
160431- });
160432- console.log("aftersend")
160436+ //console.log("beforesend")
160437+ const instanceIds = await sendstart(runInstancesCommand)
160438+ return instanceIds
160439+ // await ec2.send(runInstancesCommand, (err, data) => {
160440+ // if (err) {
160441+ // console.log(err, err.stack);
160442+ // core.error(`AWS EC2 instance failed to start - error: ${err}`)
160443+ // throw err;
160444+ // } else {
160445+ // const ec2InstanceIds = data.Instances.map(x => x.InstanceId); //[0].InstanceId; pass all instances instead of just first id
160446+ // core.info(`AWS EC2 instance(s) ${ec2InstanceIds} is started`);
160447+ // return ec2InstanceIds;
160448+ // }
160449+ // });
160450+ // console.log("aftersend")
160433160451}
160434160452
160435160453async function terminateEc2Instance() {
0 commit comments