Prior to the announcement of AWS CloudShell at re:Invent 2020, we had Instance Connect, Cloud9, and EC2 servers that helped us manage our systems. However, each of those demands the operation of an EC2 instance, which is expensive. With no personal API keys, using federated identities is considerably more problematic. With the announcement of AWS CloudShell, a browser-based shell that makes managing your AWS environment through the command line an absolute breeze.
AWS Using CloudShell, you can securely manage, explore, and interact with your AWS resources from a browser. When you log into your console, CloudShell authenticates you, So you don't need to worry about Access Key / Secret Key. CloudShell can be accessed directly from your browser and is free of charge.
Although some tools like git and aws-cli were preinstalled on AWS CloudShell, terraform was not, and that is what we are here to solve today. Let's get started without further ado.
Step 1: Initialize your cloud Shell Environment To check if your AWS CloudShell is available in your region, look for a shell icon in the top bar. Check out the image below. If you can't find the icon, it means AWS cloudShell is not available in that region yet.
Click on the icon or click here to access the shell.
Step 2: Install Terraform We'll make use of tfenv, Terraform version manager. It allows us to install and switch between multiple versions of Terraform.
Clone tfenv by running this command :
git clone https://github.com/tfutils/tfenv.git ~/.tfenv
Make sysmlink for
tfenv/bin/* scripts into a path
~/bin because it has already added to
ln -s ~/.tfenv/bin/* ~/bin/
Install Terraform with
tfenv. As of this moment the latest, the latest terraform is v.12.5
tfenv install 1.2.5
tfenv to use the installed version
tfenv use 1.2.5
To check if everything is set, we can check for the terraform version with
The output should look like the screenshot below if everything goes well.
We've seen how to use Terraform Version Manager to install Terraform on AWS CloudShell. We've also seen how AWS CloudShell can help you avoid using an Access Key / Secret Access Key because CloudShell is already authenticated with your console credentials.
PS: installing code outside of
$HOME as it will not persist across sessions.
Thank you for reading, and remember to sign up for my newsletter to be the first to learn when I publish a new piece.