0
votes

I was just learning Terraform and created a single Terraform configuration containing every region in AWS (and multiple Availability Zones per region). As a sidenote, it took over 3 minutes to plan the configuration.

I got feedback that it is better to create independent Terraform configurations based on how the system can fail, so if there was a failure in one region, you could run your Terraform configuration in another region independently of the failed region.

But I'm wondering, given Availability Zones could fail, is it better to create 1 Terraform Configuration per Availability Zone in AWS then? So say you covered every region and AZ, you would have over 100 independent Terraform "projects" which you would plan and apply separately. Is this typically how larger Terraform projects work? What is best practice for large projects covering multiple regions, how are they typically managed in Terraform?

1

1 Answers

1
votes

It all depends on how your infrastructure is setup but generally it would be per region.

You would split it by a logical factor such as one of the below:

  • Network (Per VPC)
  • Application (Per app, such as only the load balancers or Lambdas only used by that app or service)
  • Business function (Per business department).
  • Environment (Production vs QA vs Development)

The point of infrastructure as code is to make your life easier not harder, so spend time planning how to organise it in a way that makes sense to you and your organisation.

By a rule of thumb when you roll out your configuration it should run in it's entirety. You should not need to run multiple terraform plan and apply commands just to get a working network. Whilst day to day this makes your life easier in a DR scenario you do not want to be thinking about which configurations you would need to apply.

Remember in large projects that the usage of modules will actually make it easier to navigate the structure whilst improving reusability.