Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services terraform不检测对lambda源文件的更改_Amazon Web Services_Aws Lambda_Terraform_Aws Glue - Fatal编程技术网

Amazon web services terraform不检测对lambda源文件的更改

Amazon web services terraform不检测对lambda源文件的更改,amazon-web-services,aws-lambda,terraform,aws-glue,Amazon Web Services,Aws Lambda,Terraform,Aws Glue,在mymain.tf中,我有以下内容: data "template_file" "lambda_script_temp_file" { template = "${file("../../../fn/lambda_script.py")}" } data "template_file" "library_temp_file" { template = "${file("../../../library.py")}" } data "template_file" "init_temp

在my
main.tf
中,我有以下内容:

data "template_file" "lambda_script_temp_file" {
  template = "${file("../../../fn/lambda_script.py")}"
}

data "template_file" "library_temp_file" {
  template = "${file("../../../library.py")}"
}

data "template_file" "init_temp_file" {
  template = "${file("../../../__init__.py")}"
}

data "archive_file" "lambda_resources_zip" {
  type        = "zip"
  output_path = "${path.module}/lambda_resources.zip"

  source {
    content   = "${data.template_file.lambda_script_temp_file.rendered}"
    filename  = "lambda_script.py"
  }

  source {
    content   = "${data.template_file.library_temp_file.rendered}"
    filename  = "library.py"
  }

  source {
    content   = "${data.template_file.init_temp_file.rendered}"
    filename  = "__init__.py"
  }
}

resource "aws_lambda_function" "MyLambdaFunction" {
  filename          = "${data.archive_file.lambda_resources_zip.output_path}"
  function_name     = "awesome_lambda"
  role              = "${var.my_role_arn}"
  handler           = "lambda_script.lambda_handler"
  runtime           = "python3.6"
  timeout           = "300"
}
问题是,当我在新的
地形应用时修改一个源文件,比如
lambda_script.py
,即使存档文件(
lambda_resources_zip
)得到更新,lambda函数的脚本也不会得到更新(新的存档文件不会被上传)

我知道为了避免这种情况,我可以先运行
terraformdestroy
,但这不是我的用例的选项


*我正在使用Terraform v0.11.10

我通过在资源定义中添加以下行来解决问题:

source_code_hash  = "${data.archive_file.lambda_resources_zip.output_base64sha256}"

修改源文件时,散列值将更改并触发源文件更新。

能否确认您使用的Terraform版本?