have jenkins start an EC2 instance and Terminating it have jenkins start an EC2 instance and Terminating it jenkins jenkins

have jenkins start an EC2 instance and Terminating it


Your requirement is valid and amazon knows:

When you stop an instance, we shut it down. We don't charge usage for a stopped instance, or data transfer fees, but we do charge for the storage for any Amazon EBS volumes.

Reference :
- https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Stop_Start.html

Here some approaches to start/stop your instaces

Amazon EC2 HTTP API

This is an api rest and you can perform a simple http request to start or stop your instance:

https://ec2.amazonaws.com/?Action=StartInstances&...

https://ec2.amazonaws.com/?Action=StopInstances&...

You can invoke this api from Jenkins in many ways : simple shell execution,groovy and scripted/declarative, pipelines.


AWS CLI

Here more about how suspend instances using aws cli:

You can invoke this api from Jenkins in many ways : simple shell execution,groovy and scripted/declarative, pipelines.


AWS Instance Scheduler

In 2018, AWS launched the AWS Instance Scheduler, a new and improved scheduling solution that enables customers to schedule Amazon EC2 instances.

With this tool you can automatically start and stop the Amazon EC2 and Amazon RDS instances.

Reference :

With this approach you don't need Jenkins :b