Skip to content

Commit

Permalink
Merge pull request #3 from clamorisse/tf-modules
Browse files Browse the repository at this point in the history
Tf modules
  • Loading branch information
clamorisse authored Oct 27, 2016
2 parents 738cbd5 + a87018c commit fc090c0
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
**/*.swp
**/.terraform
**/*.txt
**/data/
76 changes: 76 additions & 0 deletions function/CA4PExc1500.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
250,-0.0256949260814017
252,-0.0270272860010951
254,-0.0327872787004928
256,-0.0371097828070816
258,-0.0429010768388392
260,-0.0426052199306443
262,-0.0412157327979558
264,-0.0394880452637343
266,-0.0399674210622376
268,-0.0403498813652126
270,-0.0398058039788283
272,-0.0385701770396058
274,-0.0399543712356269
276,-0.0384657784267202
278,-0.0399452454827523
280,-0.0389192370870597
282,-0.0403395692644643
284,-0.038818488775324
286,-0.0371004745391495
288,-0.034300146012046
290,-0.0343555393319949
292,-0.0325255521080489
294,-0.0335480927176492
296,-0.0312144551925534
298,-0.0321710166088702
300,-0.0298897609052747
302,-0.030277514144917
304,-0.028405092170104
306,-0.0291736630772039
308,-0.0272576200036503
310,-0.0291184522723125
312,-0.0273513414856726
314,-0.029106406278518
316,-0.0247949443329075
318,-0.0235853257893776
320,-0.017981657236722
322,-0.0148194013506114
324,-0.00604692462128126
326,0.00280225406096003
328,0.0224389487132688
330,0.0455236356999452
332,0.0889444241649936
334,0.131575104946158
336,0.206950173389305
338,0.280954553750684
340,0.393305347691185
342,0.484329257163716
344,0.591718379266289
346,0.636909107501369
348,0.672097098010586
350,0.631201861653586
352,0.588916773133784
354,0.486830626026647
356,0.399045446249316
358,0.284552838109144
360,0.209365760175214
362,0.132171929184158
364,0.0953267019529111
366,0.0560549370323052
368,0.0431797773316299
370,0.0254204234349334
372,0.0209203321774046
374,0.0129384011680964
376,0.0110501003832816
378,0.00755958204051834
380,0.00738372878262457
382,0.00613013323599197
384,0.0067299415951816
386,0.00626032122650119
388,0.00697876437306078
390,0.00613962401898157
392,0.00600595911662712
394,0.00452693922248586
396,0.00433665814929732
398,0.0133319948895784
400,0.0184269027194744
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 fc090c0

Please sign in to comment.