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?
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?
To read the contents of a local file as a string in a Terraform configuration, you can use the built-in function `file()`. This function reads the contents of a file at the given path and returns them as a string, making it suitable for reading the contents of the file `id_rsa.pub`.
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
"file reads the contents of a file at the given path and returns them as a string." file(path)
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.
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.
D is right
Example: resource "aws_key_pair" "example" { key_name = "my-key-pair" public_key = file("${path.module}/id_rsa.pub") }
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.
https://www.terraform.io/language/functions/file https://www.terraform.io/language/functions/fileset
file ("file_path") reads the contents of the file and returns the string, so option D is corret.
fileset returning file name with full path, file will read the content of the files.
https://www.terraform.io/language/functions/file Answer D