BlackFriday 2024! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

HashiCorp Exam VA-002-P Topic 10 Question 90 Discussion

Actual exam question for HashiCorp's VA-002-P exam
Question #: 90
Topic #: 10
[All VA-002-P Questions]

What is the result of the following terraform function call?

lookup({a="hello", b="goodbye"}, "c", "what?")

Show Suggested Answer Hide Answer
Suggested Answer: C

lookup retrieves the value of a single element from a map, given its key. If the given key does not exist, the given default value is returned instead. In this case, the function call is searching for the key 'c'. But since there is no key 'c', the default vault 'what?' is returned.

https://www.terraform.io/docs/configuration/functions/lookup.html


Contribute your Thoughts:

Lanie
3 months ago
Terraform, more like 'terrifying', am I right? Anyway, the answer is C. Unless the map is actually a mystical artifact that bends the laws of reality, in which case all bets are off.
upvoted 0 times
Shawana
2 months ago
I'm pretty sure it's C) what?
upvoted 0 times
...
Adolph
2 months ago
Really? I thought it was B) hello
upvoted 0 times
...
Art
2 months ago
No, it's actually A) goodbye
upvoted 0 times
...
Lucy
2 months ago
C) what?
upvoted 0 times
...
...
Virgie
3 months ago
This question is a real head-scratcher. I'm going to go with C and hope the terraform gods are feeling generous today.
upvoted 0 times
...
Fabiola
3 months ago
D, obviously. The function is returning the key 'c' since it's not found in the map. What kind of sorcery is this terraform thing anyway?
upvoted 0 times
Suzi
2 months ago
I think you're mistaken. The correct answer is 'what?' since the key 'c' is not in the map.
upvoted 0 times
...
Francene
2 months ago
No, it actually returns 'what?' because the key 'c' is not found in the map.
upvoted 0 times
...
...
Genevive
4 months ago
I agree with Ayesha, the function lookup will return the value associated with key 'c', which is 'goodbye'. So, the correct answer is A) goodbye.
upvoted 0 times
...
Ayesha
4 months ago
I think the result is 'goodbye' because the function lookup searches for the key 'c' in the map and returns the corresponding value, which is 'goodbye'.
upvoted 0 times
...
Kanisha
4 months ago
C) what?
upvoted 0 times
...
Paris
4 months ago
Hold up, is this a trick question? If the map doesn't have the key 'c', shouldn't it just return the default value 'what?'? I'm going with C.
upvoted 0 times
Teresita
2 months ago
Looks like we all agree on option C then.
upvoted 0 times
...
Dick
2 months ago
Yeah, that makes sense. Option C it is.
upvoted 0 times
...
Alpha
2 months ago
I agree, I'm going with option C as well.
upvoted 0 times
...
Emmett
3 months ago
I think it should return the default value 'what?' if the key 'c' is not found.
upvoted 0 times
...
...
Goldie
4 months ago
I think the answer is B. The function call is looking for the key 'c', but the map only has keys 'a' and 'b', so it should return the value for 'a', which is 'hello'.
upvoted 0 times
...
Suzan
4 months ago
The result is clearly C. 'what?' is the default value returned when the key 'c' is not found in the map.
upvoted 0 times
Nathan
2 months ago
Oh, I see. So 'what?' is the default value if the key is not found.
upvoted 0 times
...
Leota
2 months ago
No, it's actually A) goodbye
upvoted 0 times
...
Vannessa
3 months ago
I think the answer is C) what?
upvoted 0 times
...
Celestine
3 months ago
Oh, I see. 'what?' is the default value if the key 'c' is not found.
upvoted 0 times
...
Verona
3 months ago
No, it's actually A) goodbye.
upvoted 0 times
...
Jina
3 months ago
I think the answer is C) what?
upvoted 0 times
...
...
Genevive
4 months ago
B) hello
upvoted 0 times
...
Ayesha
4 months ago
A) goodbye
upvoted 0 times
...

Save Cancel