Terraform plan fails when content argument not provided in local_file

Hello,

I have been going through some of the labs and in many cases, with local_file resource type, terraform plan fails with the following error:
Error: Invalid combination of arguments
** on zoom.tf line 1, in resource “local_file” “zoom”:**
** 1: resource “local_file” “zoom” {**
“content_base64”: one of content,content_base64,sensitive_content,source
must be specified

According to the documentation, content is not a mandatory argument.

What am I missing here?

Thank you in advance for your help

Hello, @cstamatopoulos
Can you please share your TF file?

Hi, this is happening also for me in the labs with default resources. An example is this one:

resource "local_file" "speed_force" {
    filename = "/root/speed-force"
}

Hello, @mattupdis
According to the error, we need to specify one of the arguments as per the error screenshot: -

Hello and thank you for your answers.

@Tej_Singh_Rana , according to the error we need to specify one argument, I agree.
According to the documentation, none of these arguments are mandatory. Only filename is.
The solution of the lab, only has the filename argument.

These are my details:
Lab: Resource Dependencies
Step 9:

iac-server $ pwd
/root/terraform-projects/explicit-dependency

iac-server $ ls -lrta
total 8
drwxr-xr-x 4 root root 4096 Mar 18 21:21 …
drwxr-xr-x 2 root root 4096 Mar 18 21:21 .

main.tf (as per the solution suggested)
resource “local_file” “whale” {
filename = “/root/whale”
depends_on = [local_file.krill]
}
resource “local_file” “krill” {
filename = “/root/krill”
}

iac-server $ terraform init

Initializing the backend…

Initializing provider plugins…

  • Finding latest version of hashicorp/local…
  • Installing hashicorp/local v2.2.2…
  • Installed hashicorp/local v2.2.2 (self-signed, key ID 34365D9472D7468F)
  • hashicorp/local: version = “~> 2.2.2”

Terraform has been successfully initialized!

iac-server $ terraform plan

Error: Invalid combination of arguments

on main.tf line 5, in resource “local_file” “krill”:
5: resource “local_file” “krill” {

“content”: one of content,content_base64,sensitive_content,source must be
specified

Error: Invalid combination of arguments

on main.tf line 5, in resource “local_file” “krill”:
5: resource “local_file” “krill” {

“sensitive_content”: one of content,content_base64,sensitive_content,source
must be specified

Error: Invalid combination of arguments

on main.tf line 5, in resource “local_file” “krill”:
5: resource “local_file” “krill” {

“content_base64”: one of content,content_base64,sensitive_content,source
must be specified

Error: Invalid combination of arguments

on main.tf line 5, in resource “local_file” “krill”:
5: resource “local_file” “krill” {

“source”: one of content,content_base64,sensitive_content,source must be
specified

Is there any explanation why this terraform plan fails?

Thank you in advance

Hello, cstamatopoulos,
Thanks for highlighting this to us.
It seems like “content” option started to be a mandatory for creating local file but the Documentation is not updated yes on terraform site.
We have reported this issue to the team and will try to resolve it on priority and add this in the solution part.
Appreciate your patience and apologies for the inconvenience caused. mean while please add the content option in the resource block in the lab in order to get it succeed.
Thanks,
KodeKloud Support

1 Like

Hello @cstamatopoulos
This issue has been fixed.

Regards,
KodeKloud Support

Thank you for the immediate response :slightly_smiling_face:

hello I am getting the below error for this main.tfiac-server $ cat main.tf
resource “local_file” “games” {
filename = “/root/favorite-games”
sensitive_content = “FIFA 21”

and the error is
Warning: Attribute Deprecated

on main.tf line 3, in resource “local_file” “games”:
3: sensitive_content = “FIFA 21”

Use the local_sensitive_file resource instead