Page MenuHomePhabricator

[services] set terraform provider arguments conditionally
ClosedPublic

Authored by varun on Oct 11 2022, 11:26 AM.
Tags
None
Referenced Files
F3500246: D5345.id17495.diff
Fri, Dec 20, 1:06 AM
F3499583: D5345.id17499.diff
Thu, Dec 19, 11:35 PM
F3499582: D5345.id17495.diff
Thu, Dec 19, 11:35 PM
F3499533: D5345.id.diff
Thu, Dec 19, 11:34 PM
F3499488: D5345.diff
Thu, Dec 19, 11:23 PM
F3497604: D5345.diff
Thu, Dec 19, 7:20 PM
Unknown Object (File)
Wed, Dec 4, 7:07 PM
Unknown Object (File)
Mon, Nov 25, 10:34 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
Branch
terraform (branched from master)
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

services/terraform/main.tf
2

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

38–40

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

45

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

Thanks for proactively calling this out

45

Thanks for providing context here