Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

HashiCorp Exam Terraform-Associate-003 Topic 5 Question 26 Discussion

Actual exam question for HashiCorp's Terraform-Associate-003 exam
Question #: 26
Topic #: 5
[All Terraform-Associate-003 Questions]

You're writing a Terraform configuration that needs to read input from a local file called id_rsa.pub . Which built-in Terraform function can you use to import the file's contents as a string?

Show Suggested Answer Hide Answer
Suggested Answer: A

To import the contents of a local file as a string in Terraform, you can use the built-in file function. By specifying file('id_rsa.pub'), Terraform reads the contents of the id_rsa.pub file and uses it as a string within your Terraform configuration. This function is particularly useful for scenarios where you need to include file data directly into your configuration, such as including an SSH public key for provisioning cloud instances. Reference = This information is a standard part of Terraform's functionality with built-in functions, as outlined in Terraform's official documentation and commonly used in various Terraform configurations.


Contribute your Thoughts:

Sharen
6 days ago
I'm not sure, but I think C) filebase64(\'id_rsa.pub\') might also work since it reads the file contents as base64 encoded string.
upvoted 0 times
...
Virgie
8 days ago
I agree with Cathrine, because the file() function is used to read the contents of a file as a string.
upvoted 0 times
...
Aleisha
11 days ago
D) fileset(\id_rsa.pub\) sounds like it might work, but isn't that more for getting a list of files in a directory? I probably should have paid more attention in class.
upvoted 0 times
...
Cathrine
14 days ago
I think the answer is A) file(\'id_rsa.pub\')
upvoted 0 times
...
Suzi
15 days ago
C) filebase64(\id_rsa.pub\) looks promising, but I'm not sure if it's the right one for this task. Does it return the file contents as a base64-encoded string?
upvoted 0 times
...
Art
17 days ago
I thought it was B) templatefile(\id_rsa.pub\). Isn't that the function we use to read files? Oh well, guess I need to study more Terraform.
upvoted 0 times
...
Ria
26 days ago
The correct answer is A) file(\id_rsa.pub\). The file() function is used to read the contents of a file and return it as a string. Easy peasy!
upvoted 0 times
Bobbie
11 days ago
Thanks for the tip! I'll make sure to use the file() function for that.
upvoted 0 times
...
Blondell
17 days ago
A) file(\'id_rsa.pub\')
upvoted 0 times
...
...

Save Cancel