I am trying to create Lambda function using the below terraform script:
provider "aws" {
region = "us-east-1"
}
resource "aws_iam_role" "lambda_exec_role" {
name = "lambda_exec_role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}
resource "aws_lambda_function" "demo_lambda" {
function_name = "demo_lambda"
handler = "index.handler"
runtime = "nodejs4.3"
filename = "function.zip"
source_code_hash = "${base64sha256(file("function.zip"))}"
role = "${aws_iam_role.lambda_exec_role.arn}"
}
the zip file contains a single file:
index.js
exports.handler = function(event, context, callback) {
console.log('Event: ', JSON.stringify(event, null, '\t'));
console.log('Context: ', JSON.stringify(context, null, '\t'));
callback(null);
};
The 'apply' phase runs for very long duration around 15mins and its still running. sometime it says timeout.
Sometimes the function gets created some time not however in any case the process takes so much of time.
Is this the way the lambda function creation works or am i missing something over here?