AWS CloudShell and Terraform
08 January 2021 Leave a comment
Amazon has a new service that can make using Hashicorp Terraform even easier. From the AWS service page:
AWS CloudShell is a browser-based shell that makes it easy to securely manage, explore, and interact with your AWS resources. CloudShell is pre-authenticated with your console credentials. Common development and operations tools are pre-installed, so no local installation or configuration is required.
Unfortunately, Terraform is not installed by default. But we can fix that very easily!
wget https://releases.hashicorp.com/terraform/0.14.4/terraform_0.14.4_linux_amd64.zip
unzip terraform_0.14.4_linux_amd64.zip
mkdir ~/bin
mv terraform ~/bin
Or, using my favorite, tfenv:
git clone https://github.com/tfutils/tfenv.git ~/.tfenv
mkdir ~/bin
ln -s ~/.tfenv/bin/* ~/bin/
tfenv install
And that is it! You do not need to use Access Key / Secret Access Key as the CloudShell is running as your AWS Management Console user/role. Also, beware of installing code outside of $HOME as it will not persist across sessions.