aws-lambda - DevOps : AWS Lambda . zip 与 Terraform

标签 aws-lambda azure-devops terraform

我编写了 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 - 所以不明白它是如何被构建找不到的?

关于我做错了什么的任何提示/线索,非常欢迎。

enter image description here

最佳答案

伙计们,恐怕我刚刚在这里不知所措 - 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/

相关文章:

python - AWS Lambda 函数中的音频文件到文本转换

git - Devops Azure 没有足够的钩子(Hook)权限(对于协作者)

terraform 错误消息行号

amazon-web-services - 在与创建角色的文件夹不同的文件夹中访问 role_arn

python - 使用 Boto3 超时的 AWS Lambda 函数

javascript - 使用 AWS Lambda 在 JavaScript 中存储和读取 HTML 文件

amazon-web-services - 用户账户未收到 AWS Cognito 验证电子邮件

azure-devops - VSTS持续集成触发器无法正常工作

azure-devops - 为什么我在 Azure DevOps Build Pipeline 中的测试会运行两次?

terraform - 访问 terraform.tfvars 中的 terragrunt 变量