- Published on
Day 04: Infrastructure as Code with Terraform
- Authors
- Name
- Surya Harahap
- @suryaharahap18
Infrastructure as Code
Infrastructure as Code is provisioning infrastructure through software to achieve consistent and predictable environments. That means every time you use code to deploy infrastructure, it does so in a consistent way and that the environment you get at the end is predictable.1
When it comes to the actual code, there are two approaches to implementing Infrastructure as Code. There's declarative or imperative.
Terraform is an example of a declarative approach to deploying infrastructure as code.
Infrastructure as Code Benefits:
- Reusable components
- Automated deployment
- Repeatable process
- Consistent environments
- Documented architecture
What is Terraform?
Terraform is simply a tool to automate the deployment and management of infrastructure. The term infrastructure here can be a bit nebulous, but I like to think of it as any layer of technology that a developer consumes without having to deploy and manage it.
Networking, virtual machines, even containers can all fall under the moniker of infrastructure. The core of Terraform is an open source project maintained by HashiCorp. There is a paid version of Terraform available as either Terraform Cloud or Terraform Enterprise.
Pretty much any infrastructure service or really any service with an API probably can work with Terraform. The core functionality of Terraform is packaged in a single binary file compiled from Go
. HashiCorp offers compiled versions for multiple operating systems, so chances are there is a Terraform binary that will work for you, even if you're on a Raspberry Pi.
Install and Configure AWS CLI
check instalation terraform succesfull:
$ terraform version
#OUTPUT
#Terraform v1.7.5
#on darwin_amd64
Step 2:
Go to official website aws cli, and you can click download MacOS PKG installer. 2
Run the following command in the terminal to ensure the installation process has been completed properly.
$ aws --version
#OUTPUT:
#aws-cli/2.15.36 Python/3.11.8 Darwin/19.6.0 exe/x86_64 prompt/off
Footnotes
My reference, checkout out the course from pluralsight - terraform getting started. ↩