Bootstrap FreeKB - Amazon Web Services (AWS) Elastic Kubernetes Service (EKS) - Provision Cluster using learn-terraform-provision-eks-cluster
Amazon Web Services (AWS) Elastic Kubernetes Service (EKS) - Provision Cluster using learn-terraform-provision-eks-cluster


https://developer.hashicorp.com/terraform/tutorials/kubernetes/eks contain the walk through on how to provision an AWS Elastic Kubernetes Service (EKS) Cluster using Terraform. However, when I tried, I ran into problems, so here is what I did.

On a Linux EC2 instances, I cloned the learn-terraform-provision-eks-cluster repo.

git clone https://github.com/hashicorp/learn-terraform-provision-eks-cluster

 

And then move into the learn-terraform-provision-eks-cluster directory.

cd learn-terraform-provision-eks-cluster

 

The next step is to use the export command to set the TF_CLOUD_ORGANIZATION variable. But first, you'll need a Terraform Cloud Organization. So I had to first create a Terraform Cloud Organization at https://app.terraform.io/. Let's say you've a Terraform Cloud Organization named myOrganization. Then, I was able to use the export command to create the TF_CLOUD_ORGANIZATION variable.

export TF_CLOUD_ORGANIZATION=myOrganization

 

And then use the terraform login command to log into Terraform Cloud. I got a prompt with a URL to get a token, I went to the URL, got a token, and pasted the token in the prompt, and was successfully logged into Terraform Cloud.

terraform login

 

At this point, I went added and used the terraform init command, and there were no problems.

terraform init

 

However, when I would issue the terraform plan or terraform apply command, something like this would be returned.

Error: no EC2 IMDS role found, operation error ec2imds: GetMetadata, canceled, context deadline exceeded

 

I had to also add my AWS Access Key and Secret Key in Terraform Cloud.

  1. After logging into Terraform Cloud, in the left panel, select Settings.
  2. Select Variable sets.
  3. Select Create variable set.
  4. Name the variable set AWS Credentials
  5. Select Add Variable
    • Key = AWS_ACCESS_KEY_ID
    • Value = your AWS access key ID
    • Checkmark Sensitive
    • Select Add variable
  6. Select Add Variable
    • ​​Key = AWS_SECRET_ACCESS_KEY
    • Value = your AWS secret access key
    • Checkmark Sensitive
    • Select Add variable
  7. Select Create variable set

And unfortunately, I had to update main.tf to include my access key and secret key.

provider "aws" {
  access_key = "abcdefg123456789"
  secret_key = "abcdefg123456789abcdefg123456789"
  region     = "us-east-1"
}

 

Then terraform apply ran successfully and the Elastic Kubernetes Service (EKS) Cluster was created.

 

And in Terraform Cloud > Workspaces > your_workspace, the Run List should display the state of the Run.

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter a92263 in the box below so that we can be sure you are a human.