Terraform is an Infrastructure as Code (IaC) tool by HashiCorp. It is used to manage the entire lifecycle of components in our infrastructure. Most po

Using Terraform Remote State on AWS

submited by
Style Pass
2021-07-19 23:00:04

Terraform is an Infrastructure as Code (IaC) tool by HashiCorp. It is used to manage the entire lifecycle of components in our infrastructure. Most popular terraform “providers” are AWS, Azure, GCP and Kubernetes but there are thousands of them. We can use a combination of these providers to build our infrastructure. These providers work like libraries and they have “data” and “resource” entities which correspond to cloud services, configuration or more dynamic variables. You still need to have an idea on capabilities of these services to use them, but they are usually pretty compact. An example dynamodb resource could look like this

My experience with terraform is creating IAM policies, lambda functions, cloudwatch alarms/triggers, s3 buckets and dynamodb tables on AWS. We can create these resources declaratively and then update or delete them when needed. These changes on resources should be version controlled in git, so we can see changes on terraform files with each commit.

One of the two most useful commands in terraform is plan which creates an execution plan in a human-readable format. Terraform creates an execution plan by comparing the existing remote resources and terraform files. It lists actions on resources which should be performed(create, update or delete) in order to synchronize our infrastructure with terraform configuration. The plan output can also be used by the apply command. So using them in order would look like this:

Leave a Comment