Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate inputs section for Terragrunt #520

Closed
IbraheemAlSaady opened this issue Mar 24, 2022 · 1 comment
Closed

Generate inputs section for Terragrunt #520

IbraheemAlSaady opened this issue Mar 24, 2022 · 1 comment

Comments

@IbraheemAlSaady
Copy link

I'm trying to generate the following code

inputs = {
  someKey                     = dependency.outputs.someKey
  anotherKey                  = dependency.outputs.anotherKey
  yetAnotherKey               = dependency.outputs.yetAnotherKey
}

What's the best way to do that?

Thank you

@IbraheemAlSaady
Copy link
Author

According to this PR

I achieved the above config by doing this

rootBody.SetAttributeRaw("inputs", hclwrite.TokensForObject([]hclwrite.ObjectAttrTokens{
	{
		Name: hclwrite.TokensForTraversal(hcl.Traversal{
			hcl.TraverseRoot{Name: "someKey"},
		}),
		Value: hclwrite.TokensForTraversal(hcl.Traversal{
			hcl.TraverseRoot{Name: "dependency"},
			hcl.TraverseAttr{Name: "cluster"},
			hcl.TraverseAttr{Name: "outputs"},
			hcl.TraverseAttr{Name: "someKey"},
		}),
	},
	{
		Name: hclwrite.TokensForTraversal(hcl.Traversal{
			hcl.TraverseRoot{Name: "anotherKey"},
		}),
		Value: hclwrite.TokensForTraversal(hcl.Traversal{
			hcl.TraverseRoot{Name: "dependency"},
			hcl.TraverseAttr{Name: "cluster"},
			hcl.TraverseAttr{Name: "outputs"},
			hcl.TraverseAttr{Name: "anotherKey"},
		}),
	},
}))

P.S: today, that PR is merged to main but not yet released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant