我编写了 Terraform 来在 AWS 中创建一个 Lambda 函数。
这包括指定我压缩的 python 代码。
从命令行运行到我的技术框,一切顺利。
terraform apply 操作将我的 zip 移入 AWS 并用于创建 lambda。
代码的关键部分:
resource "aws_lambda_function" "meta_lambda" {
filename = "get_resources.zip"
source_code_hash = filebase64sha256("get_resources.zip")
.....
现在,要将其引入其他环境,我必须通过 Azure DevOps 推送我的 Terraform。
但是,当我尝试在 DevOps 中构建时,我得到以下信息:
Error: Error in function call on main.tf line 140, in resource "aws_lambda_function" "meta_lambda": 140: source_code_hash = filebase64sha256("get_resources.zip") Call to function "filebase64sha256" failed: no file exists at get_resources.zip.
我有一种感觉,我在这里错过了一个关键概念,因为我可以在 repo 中看到 .zip - 所以不明白它是如何被构建找不到的?
关于我做错了什么的任何提示/线索,非常欢迎。
最佳答案
伙计们,恐怕我刚刚在这里不知所措 - terraform 和 DevOps 的新手!
我和我们的(更多)技术人员谈过话,他们已经解决了这个问题。
The reason I think yours if failing is becuase the Tar Terraform step needs to use a different command line so it gets the zip file included into the artifacts. tar -cvpf terraform.tar .terraform .tf tfplan tar --recursion -cvpf terraform.tar --exclude='/.git' --exclude='.gitignore' .
..这对你来说意味着什么!
无论他们做什么,它都有效!
由于对此有赏金,我仍然会分配它,因为我很感激您的投入!
对不起,如果这是一个新手错误。
关于aws-lambda - DevOps : AWS Lambda . zip 与 Terraform,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60458743/