diff --git a/infra/main.tf b/infra/main.tf index 1d0dfe2..6d57ba1 100644 --- a/infra/main.tf +++ b/infra/main.tf @@ -136,7 +136,9 @@ resource "aws_lambda_permission" "apigw_lambda" { # More: http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-control-access-using-iam-policies-to-invoke-api.html source_arn = "arn:aws:execute-api:${var.region}:${data.aws_caller_identity.current.account_id}:${aws_api_gateway_rest_api.api.id}/*/${aws_api_gateway_method.method.http_method}${aws_api_gateway_resource.resource.path}" } -# create zip file from requirements.txt. Triggers only when the file is updated +# ======================================> HERE + +# # create zip file from requirements.txt. Triggers only when the file is updated # resource "null_resource" "lambda_layer" { # triggers = { # requirements = filesha1(local.requirements_path) @@ -156,15 +158,46 @@ resource "aws_lambda_permission" "apigw_lambda" { # } +# create zip file from requirements.txt. Triggers only when the file is updated +resource "null_resource" "lambda_layer" { + triggers = { + requirements = filesha1(local.requirements_path) + } + # the command to install python and dependencies to the machine and zips + provisioner "local-exec" { + command = < HERE +# resource "null_resource" "test_lamdazip" { +# provisioner "local-exec" { +# command = "/bin/bash make_lambda_layer/docker_install.sh" +# } +# } resource "aws_lambda_layer_version" "test_lambda_layer" { filename = "python.zip" layer_name = "test_lambda_layer" compatible_runtimes = ["python3.8"] - #depends_on = [null_resource.test_lamdazip] + # depends_on = [null_resource.test_lamdazip] } resource "aws_lambda_function" "lambda" { diff --git a/infra/vars.tf b/infra/vars.tf index d72ba99..0ab868d 100644 --- a/infra/vars.tf +++ b/infra/vars.tf @@ -59,3 +59,14 @@ variable "TFC_WORKSPACE_NAME" { type = string default = "" } + +# ==== Anne Lise ADDS +locals { + requirements_path = "../make_lamda_layer/requirements.txt" +} +variable "container_name" { + default = "lambda_docker" +} +variable "docker_image" { + default = "aws_lambda_builder_image" +}