From 12fef945731fefa9b8b6c052f20d574ea156b761 Mon Sep 17 00:00:00 2001 From: Graham Pengelly Date: Fri, 22 Apr 2016 20:43:33 +0100 Subject: [PATCH] Use a `null_resource` to zip the lambda source `files/rename_email_files_with_request_id.zip` is now created by a `null_resource`. The resource is rebuilt when the source (files/rename_email_files_with_request_id.py) is changed. --- .../rename_email_files_with_request_id.zip | Bin 773 -> 0 bytes .../resources/email_alert_notifications.tf | 16 +++++++++++++--- .../rename_email_files_with_request_id.zip | Bin 773 -> 0 bytes 3 files changed, 13 insertions(+), 3 deletions(-) delete mode 100644 projects/email_alert_notifications/files/rename_email_files_with_request_id.zip delete mode 100644 projects/email_alert_notifications/resources/rename_email_files_with_request_id.zip diff --git a/projects/email_alert_notifications/files/rename_email_files_with_request_id.zip b/projects/email_alert_notifications/files/rename_email_files_with_request_id.zip deleted file mode 100644 index 54e7df4ac70092c01942f77a0352298cc988fc07..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 773 zcmWIWW@Zs#U|`^2&|NmoW6j6id8$kd47#ig45|z=3`MDViMgrqskw=nIq_+kIjP0* z<(VZJ@kObHrK!aw@tG-l1(l&8oD9rv4N~C`I;6r&E4UdLS-vtdFo2Dn8WP(*+d-uE zdw7R{Oy-u|OZamYM9R#kTw1QCE3!#xaq(Hd#eLTDiVNS=zrT7hW0qO&XN8%sEuYW( z{qVykv7p^6FC;xHs5aQ7QE_X&%A7}S#_H1-u4m!EX?)8S9jhXQnkQ_pfMTuKkQT%i3eP28)( zY(dG1n@xM>pOOOa4?MRBW|eZC&sB@!^xR!~Dze^SVX$Evr#&3K-dS?cz5%Ed6Q;K{eooid%dkAKxM z{RKCdf7Q9Abm*GLyQn{pdcJY?bzgQW(X4LlEpN}7=^5v)h&y^y)UnmQI-DqC4 z>Z5s|-}`qHH{_}B{hI2*r0^{QB6^o-x3i xkx7mjS1ObMrcMS1V1i;;(g5wX%a0x26(fwfec{;!fYVj0!-`-3;@sJLB9Y1 diff --git a/projects/email_alert_notifications/resources/email_alert_notifications.tf b/projects/email_alert_notifications/resources/email_alert_notifications.tf index 02e4347..6e8d172 100644 --- a/projects/email_alert_notifications/resources/email_alert_notifications.tf +++ b/projects/email_alert_notifications/resources/email_alert_notifications.tf @@ -41,13 +41,23 @@ resource "aws_iam_role_policy" "write_to_logs" { policy = "${file("templates/write_to_logs_policy.json")}" } -resource "aws_lambda_function" "rename_email_files_with_request_id"{ - filename = "rename_email_files_with_request_id.zip" +resource "aws_lambda_function" "rename_email_files_with_request_id" { + depends_on = ["null_resource.build_rename_email_files_with_request_id"] + filename = "files/rename_email_files_with_request_id.zip" function_name = "rename_email_files_with_request_id" role = "${aws_iam_role.lambda_execute_and_write_to_email_alert_bucket.arn}" handler = "rename_email_files_with_request_id.lambda_handler" runtime = "python2.7" - source_code_hash = "${base64sha256(file("rename_email_files_with_request_id.zip"))}" + source_code_hash = "${base64sha256(file("files/rename_email_files_with_request_id.py"))}" +} + +resource "null_resource" "build_rename_email_files_with_request_id" { + triggers { + source_code_hash = "${base64sha256(file("files/rename_email_files_with_request_id.py"))}" + } + provisioner "local-exec" { + command = "zip -j files/rename_email_files_with_request_id.zip files/rename_email_files_with_request_id.py" + } } diff --git a/projects/email_alert_notifications/resources/rename_email_files_with_request_id.zip b/projects/email_alert_notifications/resources/rename_email_files_with_request_id.zip deleted file mode 100644 index d371ba800e6c16fa86cfd249492193393a460085..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 773 zcmWIWW@Zs#U|`^2n6rAS$C{73^HiA_7<5?~7*rW#7>ZK!5_41IQ*#qDbK=u7b5e`r z%QH(d;)_xXOH+$W;xkk93MxZGI2o8ZEF{Cjtt7)sE4UdLS-vtdFo2Dn8WP(*+d-uE zdw7R{Oy-u|OZamYM9R#kTw1QCE3!#xaq(Hd#eLTDiVNS=zrT7hW0qO&XN8%sEuYW( z{qVykv7p^6FC;xHs5aQ7QE_X&%A7}S#_H1-u4m!EX?)8S9jhXQnkQ_pfMTuKkQT%i3eP28)( zY(dG1n@xM>pOOOa4?MRBW|eZC&sB@!^xR!~Dze^SVX$Evr#&3K-dS?cz5%Ed6Q;K{eooid%dkAKxM z{RKCdf7Q9Abm*GLyQn{pdcJY?bzgQW(X4LlEpN}7=^5v)h&y^y)UnmQI-DqC4 z>Z5s|-}`qHH{_}B{hI2*r0^{QB6^o-x3i xkx7mjS1ObMrcMS1V1i;;(g5wX%a0x26(fwfec{;!fYVj0!-`-3;>9aK)(P0