Infrastructure-as-code to stand up a Jenkins-centric toolchain VPC, EC2 hosts (Jenkins/Nexus/SonarQube), and an EKS cluster with ordered addon deployment matching the observed eksctl flow from the GitHub wiki.
- VPC with public/private subnets, IGW, route tables, and Kubernetes-ready subnet tags.
- Security groups for Jenkins, Nexus, and SonarQube.
- EC2 instances for Jenkins, Nexus, and SonarQube plus an SSH keypair written locally (
jenkins-key.pem). - EKS cluster (
secure-shop-eks) with a managed node group and addons sequenced as: control-plane/network (eks-pod-identity-agent,vpc-cni,kube-proxy,coredns) then node-dependent (aws-ebs-csi-driver,metrics-server). - Generated artifacts: Ansible inventory (
ansible/inventory/hosts.ini) and PEM keys for EC2 and EKS worker SSH access.
- Terraform >= 1.5
- AWS CLI configured with credentials and default region (or set
AWS_PROFILE/AWS_REGION) - kubectl (to interact with the EKS cluster)
- Optional: eksctl (for cross-checking with
jenkins-eks-cluster.yaml)
- Clone the repo and
cdinto it (Terraform files are at repo root; Ansible underansible/). - Configure the AWS CLI with valid credentials and default region (
aws configure) or setAWS_PROFILE/AWS_REGION. - (Optional) Update
variables.tfdefaults or provide overrides viaterraform.tfvars/-var.
terraform init
terraform plan -out=tfplan # recommended to lock the apply plan
terraform apply tfplanKey outputs: VPC, subnets/route tables/IGW, security groups, EC2 hosts (Jenkins/Nexus/SonarQube) with jenkins-key.pem, EKS cluster secure-shop-eks + node group, addons ordered as per eksctl run, generated Ansible inventory at ansible/inventory/hosts.ini.
Run Ansible from the repo root (inventory is generated under ansible/ from Terraform):
ansible-galaxy install -r ansible/requirements.yml
ansible-playbook -i ansible/inventory/hosts.ini ansible/site.ymlRoles executed: common, jenkins, nexus, sonarqube.
aws eks update-kubeconfig --name secure-shop-eks --region us-east-1
kubectl get nodes
kubectl get pods -AEnsure node(s) are Ready and core addons are Running before deploying workloads.
Alternative kubeconfig (Terraform-rendered):
terraform output -raw secure_shop_eks_kubeconfig > kubeconfig_secure_shop
export KUBECONFIG=$PWD/kubeconfig_secure_shop
kubectl config use-context secure-shop-eks
kubectl get nodesThis avoids mutating your default kubeconfig and uses the template output directly.
- PEM keys:
jenkins-key.pemandjenkins-cluster-key.pemwritten locally with0400permissions. - Ansible inventory:
ansible/inventory/hosts.inigenerated with public IPs for Jenkins/Nexus/SonarQube. - EKS kubeconfig (template output): see
secure_shop_eks_kubeconfigoutput for a rendered config usingtemplates/kubeconfig.tpl. - All outputs:
terraform outputafter apply.
- Control plane/network installed with the EKS module:
eks-pod-identity-agent,vpc-cni,kube-proxy,coredns. - Node-dependent addons applied after the node group is Ready via
aws_eks_addon:aws-ebs-csi-driver,metrics-server.
Expected deliverables are captured under Excution Example Screenshot/:
terraform destroyThis will remove the VPC, EC2 hosts, EKS cluster, and generated local keys/inventory.
For more architectural notes and diagrams, see the GitHub wiki: https://github.com/dx1004/DevSecOps-Infrastructure/wiki





