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?
Rationale for Correct Answer (B):The file() function reads a file from disk and returns its content as a string. This is commonly used for public keys (.pub files).
Analysis of Incorrect Options:
A. fileset(): Returns a set of filenames matching a pattern, not file contents.
C. filebase64(): Reads file and returns Base64 encoded string — unnecessary for .pub.
D. templatefile(): Used for rendering templates with variables, not raw file contents.
Key Concept:Terraform’s file() function is used for injecting file content directly.
[Reference:Terraform Exam Objective – Read, Generate, and Modify Configurations., ]
Contribute your Thoughts:
Chosen Answer:
This is a voting comment (?). You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Submit