The .gitignore file is ignoring the backend.tf if you fork the repository make sure to comment the backend.tf
This repository is a lab to test Terraform/OpenTofu with EKS
- hashicorp/aws
- hashicorp/helm
- hashicorp/kubernetes
- gavinbunney/kubectl
- cloudposse/tfstate-backend/aws
- and more on each module
This command will install the providers needed for the project
terraform init
Rename the terraform.tfvars.example file to terraform.tfvars. It has the a sample to use the project
mv terraform.tfvars.example terraform.tfvars
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 ../
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
Go to folder role-create-eks and delete the role
cd role-create-eks
terraform destroy
Return to main project
cd ../
This command will show the plan of execution with all changes
terraform plan
This command will apply all changes maide in your IaC tf files to your environment
terraform apply
For exclude everything, use this command:
terraform destroy