Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam Terraform Associate All Questions

View all questions & answers for the Terraform Associate exam

Exam Terraform Associate topic 1 question 144 discussion

Actual exam question from HashiCorp's Terraform Associate
Question #: 144
Topic #: 1
[All Terraform Associate 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?

  • A. fileset("id_rsa.pub")
  • B. filebase64("id_rsa.pub")
  • C. templatefile("id_rsa.pub")
  • D. file("id_rsa.pub")
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Uma10
Highly Voted 2 years, 2 months ago
Selected Answer: D
file reads the contents of a file at the given path and returns them as a string. Source: https://www.terraform.io/language/functions/file
upvoted 9 times
...
ravi135
Most Recent 9 months, 2 weeks ago
D is right
upvoted 1 times
...
NashP
9 months, 3 weeks ago
D. file("id_rsa.pub") Explanation:To read the contents of a local file as a string in Terraform, you can use the file function. The correct syntax is: variable "public_key" { type = string default = file("id_rsa.pub") } This will read the contents of the "id_rsa.pub" file and assign it to the variable "public_key" as a string.
upvoted 2 times
...
Bere
10 months, 1 week ago
Selected Answer: D
Example: resource "aws_key_pair" "example" { key_name = "my-key-pair" public_key = file("${path.module}/id_rsa.pub") }
upvoted 1 times
...
camps
1 year, 7 months ago
Selected Answer: D
D. file("id_rsa.pub"). The file function is a built-in Terraform function that can be used to read the contents of a local file and return the contents as a string. The file function takes a single argument, which is the path to the file to read.
upvoted 1 times
...
RVivek
2 years, 1 month ago
Selected Answer: D
https://www.terraform.io/language/functions/file https://www.terraform.io/language/functions/fileset
upvoted 1 times
...
Pinky0289
2 years, 2 months ago
file ("file_path") reads the contents of the file and returns the string, so option D is corret.
upvoted 1 times
...
far12
2 years, 2 months ago
Selected Answer: D
the correct answer is D , explain : - file reads the contents of a file at the given path and returns them as a string. - filebase64 also reads the contents of a given file, but returns the raw bytes in that file Base64-encoded. -templatefile renders using a file from disk as a template.
upvoted 2 times
...
shopkitty
2 years, 2 months ago
Selected Answer: D
fileset returning file name with full path, file will read the content of the files.
upvoted 1 times
...
keiffo2
2 years, 2 months ago
https://www.terraform.io/language/functions/file Answer D
upvoted 1 times
...
Burakko
2 years, 2 months ago
Selected Answer: D
"file reads the contents of a file at the given path and returns them as a string." file(path)
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...