tl;dr - Has anyone come up with a way to programmatically generate mock_outputs when complex objects are in play?
Hey all, I’m using terragrunt for a multi-account setup and have hit a concern around mocking outputs. In general, I like the functionality as it keeps
plan-all available when dependencies aren’t yet in place. That said, with Terraform 0.12 I have been taking to using complex outputs from foundational modules like VPCs. Therein will nested objects such as subnet lists, security groups, etc.
To keep mocks up to date I’ve been mocking the pieces of the output needed for each module. For a basic CodeBuild module though, I am already using five separate dependency areas so my mocks are getting verbose (at least that’s my opinion ).
I thought to JSON encode them and load from a file into a local variable. This works, though I’m still on the hook for keeping the mocks up to date manually. Then I tried running
terraform output on my source VPC module, saving to JSON and then loading that into a local variable. Unfortunately, Terraform’s JSONified output doesn’t match as there are extra type and value keys. At this point I’m back to my tl;dr, which is my desire to not handcode my mock_outputs. Does anyone have a sophisticated approach here?