This post is part of “ ” series explaining how to use concepts with . In this part, I will show you how to setup a cluster on using & as shown in the diagram below (1 and 2 ) in less than : IaC Infrastracture as Code Terraform Swarm AWS Ansible Terraform Master Workers 1 min All the templates and playbooks used in this tutorial, can be found on my . Github Note: I did some tutorials about how to get started with on , so make sure you read it before you go through this post. Terraform AWS 1 — Setup EC2 Cluster using Terraform 1.1 — Global Variables This file contains environment specific configuration like region name, instance type … 1.2 — Config AWS as Provider 1.3 — Security Group This allows all the traffic: SG inbound/outbound 1.4 — EC2 Instances script to install latest version of : Bootstrap Docker 2 — Transform to Swarm Cluster with Ansible The is self explanatory: playbook Now we defined all the required templates and playbook, we only need to type 2 commands to bring up the swarm cluster: |terraform apply |ansible -i hosts playbook.yml Note: Make sure to update the file with the of each instance. hosts public ip EC2 Setting up the in action is show below: Swarm cluster