Terraform is an Infrastructure as Code (IAC) tool that is widely used by DevOps teams to automate infrastructure tasks. It is particularly useful for provisioning cloud resources, making it a key tool in managing cloud infrastructure. Terraform is cloud-agnostic, meaning it can work with multiple cloud service providers, and it is open-source. The tool is written in the Go programming language and was developed by HashiCorp.
Here are some useful Terraform commands that i learned:
terraform init: Initializes a working directory containing Terraform configuration files. This command is necessary to set up the directory for other Terraform commands.
terraform plan: Creates an execution plan, showing what actions Terraform will take to change the infrastructure to match the configuration.
terraform apply: Applies the changes required to reach the desired state of the configuration. It prompts for approval before making any changes.
terraform destroy: Destroys the infrastructure managed by Terraform. It prompts for approval before destroying any resources.
terraform fmt: Formats Terraform configuration files to a canonical format and style.
terraform validate: Validates the configuration files in a directory, ensuring that they are syntactically valid and internally consistent.
terraform show: Provides a human-readable output of the Terraform state or plan.
terraform output: Extracts the value of an output variable from the state file.
terraform state: Provides various subcommands to manipulate the Terraform state, such as listing resources, moving resources, and removing resources from the state.
terraform taint: Marks a resource for recreation during the next apply, effectively forcing it to be destroyed and recreated.
These commands are essential for managing infrastructure using Terraform and help automate the deployment and management of cloud resources.
Here is a YouTube link to a Terraform course that you used:
https://www.youtube.com/watch?v=OHzZ7KuioMA&t=8828s
I also did a end to end project on how we deployed a EKS cluster using terraform:
https://www.youtube.com/watch?v=wY8VFIAz_Og&t=6080s
I encountered several bugs :
The "You must be logged in to the server (Unauthorized)" error when connecting to the Amazon EKS API server is typically caused by issues with IAM authentication. Here are some common causes:
Incorrect IAM Entity: The IAM user or role configured in your AWS CLI or kubeconfig is not authorized to access the EKS cluster. This can happen if the IAM entity is not mapped in the
aws-auth
ConfigMap.Misconfigured kubeconfig: The kubeconfig file might not be updated with the correct IAM credentials or cluster information.
IAM Role Path Issues: If the IAM role ARN in the
aws-auth
ConfigMap includes a path, it can cause authentication failures. The path should be removed from the role ARN.Cluster Creator Access: If you are not the cluster creator, your IAM entity must be explicitly granted access through the
aws-auth
ConfigMap.AWS CLI Configuration: The AWS CLI might be configured with the wrong profile or credentials, leading to authentication issues.
By addressing these potential causes, you can resolve the unauthorized error and successfully connect to your EKS cluster.
Here is the link i used to fix it:
https://repost.aws/knowledge-center/eks-api-server-unauthorized-error