TERRAFORM-ASSOCIATE-004 · Question #249
TERRAFORM-ASSOCIATE-004 Question #249: Real Exam Question with Answer & Explanation
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
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?
Options
- Afileset("id_rsa.pub")
- Bfile("id_rsa.pub")
- Cfilebase64("id_rsa.pub")
- Dtemplatefile("id_rsa.pub")
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.