Skip to content

Instantly share code, notes, and snippets.

@simonswine
Created April 18, 2019 14:09
Show Gist options
  • Save simonswine/82d76d160bf6f2f01f4d0e5e52afd32c to your computer and use it in GitHub Desktop.
Save simonswine/82d76d160bf6f2f01f4d0e5e52afd32c to your computer and use it in GitHub Desktop.
Modify every instance of specific object in a terrafrom state
local x = import 'input.tfstate';
local modifyDNSManagedZone(o) = o {
primary+: {
attributes+: {
visibility: 'public',
},
},
};
local iter(o) =
if std.isObject(o) then
{
[v]: if std.startsWith(v, 'google_dns_managed_zone.') then
modifyDNSManagedZone(o[v])
else
iter(o[v])
for v in std.objectFields(o)
}
else if std.isArray(o) then
[iter(x) for x in o]
else
o
;
iter(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment