Skip to content

douernesto/ppro-aws

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deploy an EKS Cluster using Terraform

This code uses Terraform AWS provider and a single module modules/eks to reuse the code in multiple enviroments, in this case I created 2 directories for environment "dev-us-east-1" and "prod-us-east". I have only instiated the code on the "dev-us-east-1" environments for the purpose of the demo.

Requirements

  • Terraform 1.5.5
  • Terraform AWS Provider ~> 5.65.0

How it works

The code has already defined a default attributes to instantiate the code you can change the values as required, for example: tags, cluster name, subnet count, CIDR block, capacity type, instance type, node pool size, labels and taints. The module modules/eks does the following work:

  1. Create VPC
  2. Create Internet Gateway
  3. Create a Subnet
    1. Decided to make subnets private to reduce costs
  4. Create one Elastic IP per Subnet
  5. Create one NAT Gateway per Subnet
    • This is required to allocate the EIPs and hence the rest of the resources need to be created one per subnet
  6. Create Route Tables
  7. Create Routes and Associations
  8. Create Security Group
    • Allow all outbound IPv4 traffic
    • Allow all outbound IPv6 traffic
    • Allow all inboud traffic from the Worker Nodes
  9. Create SSH key pair
  10. Create IAM Role for EKS Cluster
    • Attach the policy
  11. Create EKS Cluster
  12. Create IAM Role for EKS Nodes Pools
    • Attach the policy
  13. Create EKS Nodes Pools
    • Set node configurations
  14. Outputs
    • name
    • endpoint
    • certificate_authority
    • vpc_id

Execution from Pipeline

To trigger a plan

  • Go to the repo Actions
  • Run a Manual Workflow Dispatch "Plan dev-us-east-1"
  • The Pipeline will run and show all the resources to be created on AWS with Terraform

Notes:

  • The pipeline doesnt a have backend on purpose to avoid costs, altought its connected to my personal account so the plan can succesfully run.
  • For this reason any apply wont work.

Execution Locally

  1. Clone the repository into your local machine
  2. Move to the directory you want to work on
    • For example environments/dev-us-east-1
  3. Export the following environment variables:
    • AWS_ACCESS_KEY_ID
    • AWS_SECRET_ACCESS_KEY
    • AWS_REGION
  4. The code has already defined a default attributes to instantiate the code you can change the values as required, for example: tags, cluster name, subnet count, CIDR block, capacity type, instance type, node pool size, labels and taints.
  5. Run terraform init
  6. Run terraform plan or terraform apply
  7. Run terraform destroy to remove the resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages