Sentinel Selector Cannot Contain Dash?


I need to be able to select this from terraform apply output:

f = tfplan.module([“modname”]).resources[“resname”].foo-bar[0].applied

That gives me this fatal error:

“unknown identifier accessed: bar”

It’s apparently trying to give ‘-’ special meaning.

A similar selector without a dash works fine:

g = tfplan.module([“modname”]).resources[“resname”].foo[0].applied

How can I select data that contains a dash?

use [“foo-bar”]

f = tfplan.module([“modname”]).resources[“resname”][“foo-bar”]

I have a mock demoing usage of selectors here that might help: Sentinel Playground

1 Like

kardell2006g, thanks for the quick response.

But unfortunately, your playground example doesn’t help as I don’t need to access hash keys with dashes. I need to access variables with dashes:


kardell2006g, my apologies. I didn’t read your response carefully. Using the key works. Thanks.

@aisarosenbaum thanks for reaching out to the community for assistance.

I’ve observed that your policy currently utilizes an outdated version of the tfplan import. I’m uncertain whether you’re revising the logic in an existing policy or crafting a new one from the beginning. If it’s the latter, I suggest commencing with the more recent tfplan/v2 import. This choice simplifies the policy authoring process and ensures your policies remain relevant for the upcoming years.