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 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:

Marg
1 months ago
Wait, is the correct answer 'file' or 'fileset'? I always get those two mixed up. Maybe I should just write my Terraform configs in crayon to make it easier.
upvoted 0 times
Patrick
20 days ago
C) filebase64(\'id_rsa.pub\')
upvoted 0 times
...
Lashawn
22 days ago
I think the correct answer is 'file'.
upvoted 0 times
...
Domingo
23 days ago
A) file(\'id_rsa.pub\')
upvoted 0 times
...
...
Sharen
1 months 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
1 months 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
2 months 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
Desirae
13 days ago
No, fileset(id_rsa.pub) is not the right function for this. It's file(id_rsa.pub) that you should use.
upvoted 0 times
...
Jettie
14 days ago
D) fileset(id_rsa.pub)
upvoted 0 times
...
Charlene
17 days ago
C) filebase64(id_rsa.pub)
upvoted 0 times
...
Sharee
1 months ago
A) file(id_rsa.pub)
upvoted 0 times
...
...
Cathrine
2 months ago
I think the answer is A) file(\'id_rsa.pub\')
upvoted 0 times
...
Suzi
2 months 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
2 months 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
Ronna
19 days ago
A) file(\'id_rsa.pub\') is the correct function to import file contents as a string.
upvoted 0 times
...
Raelene
28 days ago
C) filebase64(\'id_rsa.pub\')
upvoted 0 times
...
Casandra
30 days ago
A) file(\'id_rsa.pub\')
upvoted 0 times
...
...
Ria
2 months 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
2 months ago
Thanks for the tip! I'll make sure to use the file() function for that.
upvoted 0 times
...
Blondell
2 months ago
A) file(\'id_rsa.pub\')
upvoted 0 times
...
...

Save Cancel