Addendum1: To create the key.pem file for Terraform

Rangaswamy P V
1 min readMar 28, 2023

--

This article is an Addendum to the Article Terraform scripts to create a K8s Cluster using “kubeadm” in AWS from scratch . The purpose is to create a key.pem file to be used for AWS instance

Log into your AWS console.

Navigate to the “Network & Security” on the left hand side panel of the AWS console. In the key Pairs option create a key Pair and it will automatically download the “key.pem” file to the browser. Transfer this to the box which runs the Terraform script and use it as a parameter in the key-path value. The Name of the key goes by what ever you gave when creating. The key.pem file will look similar to the one shown below….

-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEApj/rVQmAfVSjUWDXyHM9YiCir4urnUDEe4HpmsqL/9ET8fdN
XP5gWJjVfxHdMUeOpx0+vrHeq2GJtx2gAM31BhIGknJaxSW/O67b4KpwYFwqPtJc
.
.
.
.
.
rs30SvQLnbaPxSIkxsNxRhHjY48140by3VetDY28rO3/F1OMnd4P
-----END RSA PRIVATE KEY-----

If you already use a existing key pair file and if that Private key for it is in the form as shown below then first you need to convert it to an openssl format to look something like the one shown above.

ssh-rsa ........

You can use “ puttygen.exe” a windows utility to convert it. “puttygen” will to convert it to the Openssl format using PKCS #8 format .

If you don’t do this then you will get the “key not found” error when you run the terraform apply command.

The main Terraform article can be found here .

--

--