gustavoapolinario / tfeks

Terraform/OpenTofu EKS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Caution

The .gitignore file is ignoring the backend.tf if you fork the repository make sure to comment the backend.tf

The Project

This repository is a lab to test Terraform/OpenTofu with EKS

TF Providers

  • hashicorp/aws
  • hashicorp/helm
  • hashicorp/kubernetes
  • gavinbunney/kubectl
  • cloudposse/tfstate-backend/aws
  • and more on each module

Modules

VPC

README

EKS

README

EBS CSi Driver

README

EKS External Secrets

README

EKS Load balancer controller

README

EKS RBAC default roles

README

Role create eks

README

How to start

Prepare your project

This command will install the providers needed for the project

terraform init

Create the tfvars file

Rename the terraform.tfvars.example file to terraform.tfvars. It has the a sample to use the project

mv terraform.tfvars.example terraform.tfvars

Create a role before create the EKS

Follow the steps on folder role-create-eks and create a role to create the EKS Cluster

cd role-create-eks
terraform init
terraform apply

Get the outputs to update the configurations

  • Update the provider.tf with the assume role
  • Put the auth_user/auth_role on the tfvars file to give access to your default user

Return to main project

cd ../

Creating the storage for tfstate and lock

To work as a team, and to the CI/CD is important to save the tfstate file of each environment

To work with the team, is important create a lock beatween everyone to noone run as same time the cloudformation, but create a pipeline is the best option

To save the state on S3 and use the dynamodb as lock, see the file tf-backend.tf and tf-backend-outputs.tf

Edit the tf-backend.tf with your informations. See the information of module: cloudposse/tfstate-backend

code tf-backend.tf

Run the apply for this resource to create the TF backend file

terraform apply -target=module.terraform_state_backend

After runned it, verify your backend.tf file

cat backend.tf

After verify the configuration generated by the module, run the init again to load the configuration

terraform init -force-copy

After create the EKS

Go to folder role-create-eks and delete the role

cd role-create-eks
terraform destroy

Return to main project

cd ../

Analyse the changes

This command will show the plan of execution with all changes

terraform plan

Apply all changes

This command will apply all changes maide in your IaC tf files to your environment

terraform apply

how to remove everything?

For exclude everything, use this command:

terraform destroy

About

Terraform/OpenTofu EKS

License:GNU General Public License v3.0


Languages

Language:HCL 100.0%