Page MenuHomePhabricator

[services] set terraform provider arguments conditionally
ClosedPublic

Authored by varun on Oct 11 2022, 11:26 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Dec 4, 7:07 PM
Unknown Object (File)
Mon, Nov 25, 10:34 PM
Unknown Object (File)
Mon, Nov 25, 8:18 PM
Unknown Object (File)
Sun, Nov 24, 12:37 PM
Unknown Object (File)
Sun, Nov 24, 12:37 PM
Unknown Object (File)
Nov 9 2024, 8:10 PM
Unknown Object (File)
Nov 9 2024, 8:10 PM
Unknown Object (File)
Nov 9 2024, 8:08 PM

Details

Summary

we want to be able to use the same terraform configuration for both localstack and our production environment. in order to do this, we need to set the provider arguments (things like access_key) conditionally. the default will still be the localstack settings, but now we can override these by changing the terraform workspace to something else (e.g. "prod").

Test Plan

from the services directory, run yarn init-local-cloud.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

services/terraform/main.tf
2 ↗(On Diff #17495)

as implied by the name, this is the default workspace when you initialize terraform

38–40 ↗(On Diff #17495)

unfortunately terraform does not give us a way to tweak their formatting rules... stuck with 120 character lines

45 ↗(On Diff #17495)

From SO: Using [*] with a non-list value automatically converts it into a zero-element list or a one-element list, depending on whether the value is null. That allows us to dynamically declare the endpoints block only if the override_endpoint attribute is non-null, and then write its value into all three of the overridden endpoint arguments.

Was able to run yarn init-local-cloud in services directory successfully.

This revision is now accepted and ready to land.Oct 11 2022, 5:51 PM
services/terraform/main.tf
38–40 ↗(On Diff #17495)

Thanks for proactively calling this out

45 ↗(On Diff #17495)

Thanks for providing context here