英文:
Terraform aws_s3_bucket_object, Call to function "filemd5" failed: open <file>
问题
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.
英文:
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.
答案1
得分: 1
你需要为你的路径提供适当的引用。你正在在根目录而不是模块中运行 terraform。因此,正如评论中建议的那样,你需要使用 ${path.module}
来正确告诉 terraform 文件的位置。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论