nerdexam
HashiCorp

TERRAFORM-ASSOCIATE-004 · Question #160

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 A. file("id_rsa.pub"). 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 particularl

Submitted by hassan_iq· Apr 18, 2026Work with Terraform Configurations

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

  • Afile("id_rsa.pub")
  • BtemplaTefil("id_rsa.pub")
  • Cfilebase64("id_rsa.pub")
  • Dfileset<"id_rsa.pub")

How the community answered

(45 responses)
  • A
    87% (39)
  • B
    2% (1)
  • C
    9% (4)
  • D
    2% (1)

Explanation

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.

Topics

#Terraform Functions#File System Interaction#Configuration Language

Community Discussion

No community discussion yet for this question.

Full TERRAFORM-ASSOCIATE-004 Practice