当我运行 terraform 脚本时收到此消息:
Warning: Deprecated Resource
using archive_file as a resource is deprecated; consider using the data source instead
问题是我该怎么做?我尝试阅读有关数据源的信息,但没有清除任何内容。
我在 lambda 定义中使用 archive_file 来压缩 lambda 源并获取目标 zip 哈希值。
resource "archive_file" "archive_csv_validate" {
type = "zip"
source_dir = "lambda/csv-validate"
output_path = "artifacts/csv-validate.zip"
}
resource "aws_lambda_function" "lambda_csv_validate_function" {
function_name = "csv-validate"
filename = archive_file.archive_csv_validate.output_path
source_code_hash = archive_file.archive_csv_validate.output_base64sha256
handler = "main.main"
role = aws_iam_role.lambda_iam_role.arn
runtime = "python3.9"
timeout = 900
}
最佳答案
Archive_file 现在是数据源。 您可以将代码转换为:
data "archive_file" "archive_csv_validate" {
type = "zip"
source_dir = "lambda/csv-validate"
output_path = "artifacts/csv-validate.zip"
}
resource "aws_lambda_function" "lambda_csv_validate_function" {
function_name = "csv-validate"
filename = data.archive_file.archive_csv_validate.output_path
source_code_hash = data.archive_file.archive_csv_validate.output_base64sha256
handler = "main.main"
role = aws_iam_role.lambda_iam_role.arn
runtime = "python3.9"
timeout = 900
}
关于terraform - 不推荐使用 archive_file 作为资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72888293/