Reputation: 71
terraform apply gives me the following error:
Error: Error creating Lambda function: InvalidSignatureException: Signature expired: 20190628T091524Z is now earlier than 20190628T092024Z (20190628T092524Z - 5 min.)
Many have recommended to fix the time on the local machine from where i am running the terraform command, but that seems not the problem for me. My local machine time is correct, no issues there.
This one did not solve my problem :( Terraform apply failed due to mismatch time
Upvotes: 3
Views: 4685
Reputation: 60074
I Think its happen due to slow internet issue, So I fix this by following steps.
Here is the working code.
resource "null_resource" "npm" {
provisioner "local-exec" {
command = "cd ../lambda-functions/loadbalancer-to-es && npm install --prod=only && chmod -R 777 node_modules"
}
}
resource "aws_s3_bucket_object" "file_upload" {
bucket = "${var.env_prefix_name}${var.s3_suffix}"
key = "lambda-functions/loadbalancer-to-es.zip"
source = "${data.archive_file.source.output_path}"
# etag = "${filemd5("../lambda-functions/loadbalancer-to-es.zip")}"
}
# Zip the Lambda function on the fly
data "archive_file" "source" {
type = "zip"
source_dir = "../lambda-functions/loadbalancer-to-es"
output_path = "../lambda-functions/loadbalancer-to-es.zip"
depends_on = ["null_resource.npm"]
}
# Created AWS Lamdba Function: Memory Size, NodeJS version, handler, endpoint, doctype and environment settings
resource "aws_lambda_function" "elb_logs_to_elasticsearch" {
function_name = "${var.env_prefix_name}-alb-logs-to-elk-test"
s3_bucket = "${var.env_prefix_name}${var.s3_suffix}"
s3_key = "${aws_s3_bucket_object.file_upload.key}"
description = "elb-logs-to-elasticsearch"
memory_size = 1024
timeout = 900
runtime = "nodejs8.10"
role = "${aws_iam_role.role.arn}"
depends_on = ["null_resource.npm" ]
source_code_hash = "${base64sha256(data.archive_file.source.output_path)}"
handler = "index.handler"
environment {
variables = {
ELK_DOCKTYPE = "some env"
}
}
}
Upvotes: 9