Nested for_each with Terraform

Terraform provides a for_each iterator which allows you to loop over elements of a list, and perform an operation with each element. For example, to grant multiple permissions for myself on a Snowflake schema, I could do something like this: resource "snowflake_schema_grant" "write_permissions" { for_each = toset(["CREATE TABLE", "CREATE VIEW", "USAGE"]) database_name = "MY_DATABASE" privilege = each.key roles = "DAVE" schema_name = "MY_SCHEMA" } This loops over each element in the for_each list, and substitutes it as the privilege using each....

August 19, 2021 · 2 min · Dave Perrett

Working with local Terraform providers

I recently submitted a small fix to @chronark’s Vercel provider. The fix itself was pretty trivial, but it took me quite a while to figure out how to actually run Terraform against a local copy of the provider in order to make sure it actually worked. I found the answer eventually in the Terraform CLI documentation. As a convenience for provider development, Terraform supports a special additional block dev_overrides in provider_installation blocks....

August 19, 2021 · 2 min · Dave Perrett