Issue
I am newbee in Jenkins, i made a few pipelines to execute CI/CD in VM and other jobs.
Now, i have a request: I want to make a Job in Jenkins, when my job start, this create a EC2 instance in AWS, execute my pipeline in this Instance (for example, my pipeline could create a docker imagen, pull this to docker hub and make 2 pods in a cluster) and when the job is finished, kill this EC2 instance.
I was looking for a plugin to make this possible but i couldn't find any aws plugin to make this.
I want to ask if there exist any plugin to this request or maybe build a pipeline with stages to create a EC2 instance, conect and execute in and then kill the instance?
Any suggestion is welcome. Thank you so much.
Solution
You will need a permanently running master node for you to do anything. However, the master node doesn't require a lot of resources so you could get a very low performance machine (or run it in a containerized manner such as with AWS fargate) where you pay very little for the duration where your Jenkins container is online.
You could then connect better performing EC2 instances as agent nodes and for their availability, select "Bring this agent online when in demand, and take offline when idle". This will ensure that the machines are running only when they are needed.
This isn't the only way. You could very well do it in the way you mentioned, where the job starts on the master node before an EC2 instance is created, and the job continues on your newly created EC2 instance. However, this will be trickier since you would not be able see progess/logs via Jenkins.
Answered By - M B Answer Checked By - Candace Johnson (WPSolving Volunteer)