TERRAFORM-ASSOCIATE-004 · Question #249
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?
The correct answer is B. file("id_rsa.pub"). The file() function in Terraform reads the contents of a file at the given path and returns it as a string. It is commonly used to import public SSH keys, certificates, or other plain-text file contents directly into a configuration (e.g., file("id_rsa.pub")). The other options s
Question
Options
- Afileset("id_rsa.pub")
- Bfile("id_rsa.pub")
- Cfilebase64("id_rsa.pub")
- Dtemplatefile("id_rsa.pub")
How the community answered
(54 responses)- A4% (2)
- B94% (51)
- D2% (1)
Explanation
The file() function in Terraform reads the contents of a file at the given path and returns it as a string. It is commonly used to import public SSH keys, certificates, or other plain-text file contents directly into a configuration (e.g., file("id_rsa.pub")). The other options serve different purposes: fileset() returns a set of file paths matching a pattern, filebase64() reads a file and returns its contents Base64-encoded (useful for binary files), and templatefile() reads a file and renders it as a template with variable substitution - it does not simply return the raw string contents.
Topics
Community Discussion
No community discussion yet for this question.