Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Commit

Permalink
Get lambda from S3
Browse files Browse the repository at this point in the history
This commit moves the lambda source code out of this repo and now pulls
it from S3 (`govuk-lambda-applications-<environment>`)

The lambda zip file version needs to be passed in as an environment
variable `TF_VAR_rename_email_files_with_request_id_version`
  • Loading branch information
gpeng committed May 19, 2016
1 parent bd1ef1c commit 2d35845
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 51 deletions.
1 change: 0 additions & 1 deletion projects/email_alert_notifications/files/.gitignore

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@ variable "s3_bucket_name" {
default = "govuk-email-alert-notifications"
}

variable "environment"{
}

variable "rename_email_files_with_request_id_version"{
}

variable "lambda_bucket"{
default = "govuk-lambda-applications"
}

resource "template_file" "s3_bucket_policy" {
template = "${file("templates/email_alert_s3_bucket_policy.json")}"
vars {
account_id = "${element(split(":", aws_iam_role.lambda_execute_and_write_to_email_alert_bucket.arn), 4)}"
bucket_name = "${var.s3_bucket_name}"
bucket_name = "${var.s3_bucket_name}-${var.environment}"
lambda_role = "${aws_iam_role.lambda_execute_and_write_to_email_alert_bucket.arn}"
}
}
Expand All @@ -19,13 +29,13 @@ resource "template_file" "put_and_delete_to_email_alert_bucket_policy" {
}

resource "aws_s3_bucket" "email_alert_inbox_bucket" {
bucket = "${var.s3_bucket_name}"
bucket = "${var.s3_bucket_name}-${var.environment}"
acl = "public-read"
policy = "${template_file.s3_bucket_policy.rendered}"
}

resource "aws_iam_role" "lambda_execute_and_write_to_email_alert_bucket" {
name = "lambda_execute_and_write_to_email_alert_bucket"
name = "lambda_execute_and_write_to_email_alert_bucket"
assume_role_policy = "${file("templates/lambda_assume_role_policy.json")}"
}

Expand All @@ -42,12 +52,13 @@ resource "aws_iam_role_policy" "write_to_logs" {
}

resource "aws_lambda_function" "rename_email_files_with_request_id"{
filename = "rename_email_files_with_request_id.zip"
s3_bucket = "${var.lambda_bucket}-${var.environment}"
s3_key="rename_email_files_with_request_id.zip"
s3_object_version="${var.rename_email_files_with_request_id_version}"
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"))}"
}

resource "aws_lambda_permission" "allow_email_alert_inbox_bucket" {
Expand Down

This file was deleted.

This file was deleted.

Binary file not shown.

0 comments on commit 2d35845

Please sign in to comment.