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:

Ammie
3 days ago
I think the answer is A. The file() function is the built-in Terraform function that can read the contents of a local file and return it as a string.
upvoted 0 times
...
Becky
12 days ago
Okay, let me read through the options and see if I can identify the three correct ones.
upvoted 0 times
...
Marg
12 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
11 months ago
C) filebase64(\'id_rsa.pub\')
upvoted 0 times
...
Lashawn
12 months ago
I think the correct answer is 'file'.
upvoted 0 times
...
Domingo
12 months ago
A) file(\'id_rsa.pub\')
upvoted 0 times
...
...
Sharen
1 years 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 years 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
1 years 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
11 months 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
11 months ago
D) fileset(id_rsa.pub)
upvoted 0 times
...
Charlene
11 months ago
C) filebase64(id_rsa.pub)
upvoted 0 times
...
Sharee
12 months ago
A) file(id_rsa.pub)
upvoted 0 times
...
...
Cathrine
1 years ago
I think the answer is A) file(\'id_rsa.pub\')
upvoted 0 times
...
Suzi
1 years 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
1 years 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
11 months ago
A) file(\'id_rsa.pub\') is the correct function to import file contents as a string.
upvoted 0 times
...
Raelene
12 months ago
C) filebase64(\'id_rsa.pub\')
upvoted 0 times
...
Casandra
12 months ago
A) file(\'id_rsa.pub\')
upvoted 0 times
...
...
Ria
1 years 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
1 years ago
Thanks for the tip! I'll make sure to use the file() function for that.
upvoted 0 times
...
Blondell
1 years ago
A) file(\'id_rsa.pub\')
upvoted 0 times
...
...

Save Cancel