What is infrastructure as code?
It’s 2020, I shouldn’t have to explain this…instead here’s a good post explaining it. What I’m going to say is that Infrastructure as Code (IaC) is a must, no debate needed! Let’s setup infrastructure as code environment using homebrew, terragrunt, terraform CLI, the AWS CLI, git, and GitLab.
I know that’s a lot of tools, but it’s worth it in the long run! Do make sure you have an AWS account already. Follow this guide to sign up.
Mac OS: Install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install terragrunt
If you know Terraform, I’m going to wrap that with Terragrunt.
“Terragrunt is a thin wrapper that provides extra tools for keeping your configurations DRY, working with multiple Terraform modules, and managing remote state.” – Gruntwork
Install AWS CLI
brew install awscli
pip install awscli
Code source management: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
GitLab sign up
I’m going to also use GitLab for code repositories and pipelines. GitLab has a free version on the cloud. Sign up and create a new project.
You’ll have to add your ssh keys to your project. Follow the instructions on that page on how to create or add existing keys.
Let’s copy down (clone) the empty project into our workstation
Here’s another blog about git commands
Lastly add this awesome utility to your toolbox. Pre-commit allows you git code to be checked for various types of error or formatting issues before it commits your code to the server. For example it can fix your trailing whitespaces or end of line formatting or check if your Terraform is formatted correctly and so on. Here’s a full list of the the various checks.
Next we’ll setup our AWS access keys, setup Terragrunt, setup Terraform, and manage AWS from code! Finally I’ll push the code to GitLab. Sign up below to get notified when that blog gets posted!
As always if you see any errors, mistakes, have suggestions or questions please comment below. Don’t forget to like, share, and subscribe for more!
Post image by: Image by 024-657-834 from Pixabay
5 thoughts on “Setup infrastructure as code environment”
[…] If you haven’t setup your AWS CLI be sure to visit this page “Setup infrastructure as code environment“. You’ll need the following IAM policy in order to list the […]
[…] with Terragrunt. I’m assuming you know what both of these tools are… if not checkout my introduction posts on how to setup your development environment. Or if you need a introduction to Terraform modules […]
[…] https://cloudly.engineer/2020/setup-infrastructure-as-code-environment/aws/ […]
[…] If you haven’t installed Terraform or Terragrunt then you must follow this guide […]
[…] and if you are deploying this exact code then you’ll need Terragrunt too. Here’s a Setup infrastructure as code environment instructions and if you’re new to Terragrunt then checkout Intro to Terragrunt and Terraform […]