Skip to content

Commit

Permalink
function with elartic search policy
Browse files Browse the repository at this point in the history
  • Loading branch information
clamorisse committed Oct 25, 2016
1 parent 207bbc3 commit d692e18
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
3 changes: 2 additions & 1 deletion infrastructure/modules/iam/iam_lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ resource "aws_iam_role_policy_attachment" "lambda_execute" {
}


# Inline policy for permissions to access resources
# Inline policy for permissions to access
# S3 and ElasticSearch resources

resource "aws_iam_role_policy" "lambda_policy" {
name = "${var.app_name}-access-resources-policy"
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/modules/s3/buckets_for_lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ resource "aws_s3_bucket" "source" {
}

resource "aws_s3_bucket" "target" {
bucket = "${var.source_bucket}resize"
bucket = "${var.source_bucket}analyzed"
acl = "private"

tags {
Expand Down
8 changes: 4 additions & 4 deletions infrastructure/terraform/main_terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ module "s3_buckets" {
resource "template_file" "lambda_policy" {
template = "${file("${var.lambda_role_policy_tmpl}")}"
vars {
input_bucket_name = "${module.s3_buckets.source-bucket-id}"
html_bucket_name = "${module.s3_buckets.target-bucket-id}"
source_bucket_name = "${module.s3_buckets.source-bucket-id}"
target_bucket_name = "${module.s3_buckets.target-bucket-id}"
}
}

Expand Down Expand Up @@ -74,8 +74,8 @@ module "lambda_function" {
source_id = "${module.s3_buckets.source-bucket-id}"

events = "s3:ObjectCreated:*"
filter_prefix = "images/"
filter_suffix = ".jpg"
filter_prefix = "data/"
filter_suffix = ".csv"
}

output "lambda_function_arn" { value = "${module.lambda_function.lambda_function_arn}" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::${input_bucket_name}"
"arn:aws:s3:::${source_bucket_name}"
]
},
{
Expand All @@ -25,7 +25,7 @@
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::${input_bucket_name}/*"
"arn:aws:s3:::${source_bucket_name}/*"
]
},
{
Expand All @@ -34,7 +34,7 @@
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::${html_bucket_name}"
"arn:aws:s3:::${target_bucket_name}"
]
},
{
Expand All @@ -47,8 +47,15 @@
"s3:PutObjectAcl"
],
"Resource": [
"arn:aws:s3:::${html_bucket_name}/*"
"arn:aws:s3:::${target_bucket_name}/*"
]
},
{
"Action": [
"es:*"
],
"Effect": "Allow",
"Resource": "arn:aws:es:us-west-2:123456789012:domain/streaming-logs/*"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/terraform/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ env = "dev"

source_bucket = "source_bvc_files"
lambda_role_policy_tmpl = "template_files/lambda_policy_s3_resources.tmpl"
lambda_function_zip_file = "template_files/lambda_resize_image.zip"
lambda_function_zip_file = "../../function/lambda_analyze_csv.zip"

0 comments on commit d692e18

Please sign in to comment.