Initially before I start, I assume you would have a basic understanding about AWS EC2 and Jenkins, if not please refer these below links:
and have a clear understanding on ECS and Jenkins which enables you to visualize how dockers containers act as Jenkins slave agents.
Initially create a IAM user with following Permissions
Next you will need a role as well to call the ECS cluster with the following permissions
Then we create a ECS cluster: Eg:
Next I will be illustrating through some screenshots for you to create the launch configuration and connect it to this Fargate cluster..
I have used the above image but this may defer with your region and AWS updates.
Also you will need this mentioned role permissions in your instance to work with the cluster
And I’ll be allowing public IP’s as the plugin in Jenkins needs to communicate
Then use the below options for auto-scaling:
In here I choose CPU as the scaling policy, you may choose any option to scale as well:
Then you are done with the AWS item list.
We will now configure the Jenkins end now:
Make sure to Specify the CPU and Memory limits and the ECR Image from AWS. (Note that this docker image needs to be pushed manually)
Finally you could see a Production grade Jenkins Build Cluster where you could even build 50–60 builds at the same time by scaling up the farget cluster.
Please comment if there is any improvements you believe in…..