Reputation: 8165
My index.html
is in the same level of where my terraform resource file is located
terraform
│ └── site
│ ├── index.html
│ ├── s3.tf
│ └── variables.tf
My config looks like this
resource "aws_s3_bucket_object" "index" {
key = "index.html"
acl = "public-read"
bucket = aws_s3_bucket.my_example_site.id
source = "index.html"
etag = filemd5("index.html")
}
When I apply, I get this error
│ Error: Error in function call
│
│ on modules/terraform/site/s3.tf line 15, in resource "aws_s3_bucket_object" "index":
│ 15: etag = filemd5("index.html")
│
│ Call to function "filemd5" failed: open index.html: no such file or directory.
Upvotes: 0
Views: 1279
Reputation: 1823
You need a proper reference to your path. You're running terraform out of your root, not the module. Thus as the comments suggest, you need to you ${path.module}
to properly tell terraform where the file is.
Upvotes: 1