Terraform Design Pattern – multiple providers

Having gotten to grips with terraform over the past few months, there’s an awful lot I’ve learned from the multitude of useful posts and books published on the subject, but also from getting firsthand experience.

One of the design patters in terraform that has piqued my interest was the use of multiple providers, as given in the aws_vpc_peering_connection_accepter example in the terraform documentation.  Though fairly lightly covered in the documentation, it does lend itself to a good many use cases.

The most popular one being the ability for the provider to assume a different role (even across different accounts) to setup and manage resources.  I’ve found this incredibly useful as a design pattern, as it also allows for finer-grained permissions management of such resources.  With the ability to call dynamic applications to provide creds to the AWS provider, using the credential_process parameter, it will no doubt be plausible to make sure that the only resource allocation in AWS is managed by your master terraform configuration.

How do you use multiple providers in terraform?

Leave a Reply