Skip to content

Verify the shape of terraform output #678

Answered by gcagle3
niksheridan asked this question in How do I
Discussion options

You must be logged in to vote

Hello @niksheridan! It seems like your approach to use a struct to represent the expected shape of Terraform output is reasonable. I believe the issue you are encountering is likely due to how Terraform output is returned as type map[string]string (via OutputMap).

In your test function, you're using the IsType function to assert that the value retrieved from the map is of type NsgEntry. This will most likely always fail since the values in the actualTfOutput are of type map[string]string instead of NsgEntry. If you modify the logic so that it performs a type assertion to convert the values of actualTfOutput to NsgEntry structs, then you should be able to perform a proper comparison.

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@niksheridan
Comment options

@gcagle3
Comment options

gcagle3 Apr 3, 2023
Collaborator

@niksheridan
Comment options

@niksheridan
Comment options

Answer selected by gcagle3
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@gcagle3
Comment options

gcagle3 Apr 17, 2023
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment