imohd23 / Terraws-script

This repo made to support this article, New Documentation is coming
MIT License
3 stars 18 forks source link

Invalid function argument while running a plan #2

Open manzajohn opened 2 years ago

manzajohn commented 2 years ago

Error: Invalid function argument

on main.tf line 79, in resource "aws_key_pair" "ec2key": 79: public_key = file(var.public_key_path) |---------------- | var.public_key_path is "./id_rsa.pub"

Invalid value for "path" parameter: no file exists at id_rsa.pub; this function works only with files that are distributed as part of the configuration source code, so if this file will be created by a resource in this configuration you must instead obtain this result from an attribute of that resource.

calidude25 commented 2 years ago

$ terraform plan ╷ │ Error: Invalid function argument │ │ on main.tf line 79, in resource "aws_key_pair" "ec2key": │ 79: public_key = file(var.public_key_path) │ ├──────────────── │ │ var.public_key_path is "./id_rsa.pub" │ │ Invalid value for "path" parameter: no file exists at ./id_rsa.pub; this function works only with files that are distributed as part of the configuration source code, so if this file will be created by a │ resource in this configuration you must instead obtain this result from an attribute of that resource.

calidude25 commented 2 years ago

solved

variable "public_key_path" { description = "Public key path" default = "/Users/USERNAME/.ssh/id_rsa.pub"

imohd23 commented 2 years ago

Yes, my mistake that I did not add the link of the article into the doc as I mentioned this step there. Thanks @calidude25 for the correction.