Last active
July 30, 2019 16:45
-
-
Save qtangs/1c9eda4543a51353a76ba2f259db941f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cloudwatch_event.tf | |
resource "aws_cloudwatch_event_rule" "fraud_detection_scheduled_rule" { | |
name = "fraud-detection-scheduled-rule" | |
schedule_expression = "rate(1 minute)" | |
... | |
} | |
# iam_lambda.tf | |
resource "aws_iam_role" "fraud_detection_lambda_role" { | |
name = "fraud-detection-lambda-role" | |
... | |
} | |
resource "aws_iam_role_policy_attachment" "fraud_detection_lambda" { | |
role = "${aws_iam_role.fraud_detection_lambda_role.name}" | |
policy_arn = "${aws_iam_policy.fraud_detection_lambda_policy.arn}" | |
} | |
resource "aws_iam_policy" "fraud_detection_lambda_policy" { | |
name = "sm-notebook-instance-policy" | |
description = "Policy for the Notebook Instance to manage training jobs, models and endpoints" | |
... | |
} | |
# s3_lambda.tf | |
resource "aws_s3_bucket" "fraud_detection_function_bucket" { | |
bucket = "${var.function_bucket_name}-${var.aws_region}" | |
acl = "private" | |
... | |
} | |
data "archive_file" "fraud_detection_archive" { | |
type = "zip" | |
source_file = "${path.module}/../source/fraud_detection/index.py" | |
output_path = "${path.module}/../dist/fraud_detection.zip" | |
} | |
resource "aws_s3_bucket_object" "s3_fraud_detection_archive" { | |
bucket = "${aws_s3_bucket.fraud_detection_function_bucket.id}" | |
key = "fraud-detection-using-machine-learning/${var.function_version}/fraud_detection.zip" | |
source = "${data.archive_file.fraud_detection_archive.output_path}" | |
} | |
# lambda.tf | |
resource "aws_lambda_function" "fraud_detection_event_processor" { | |
handler = "index.lambda_handler" | |
function_name = "fraud-detection-event-processor" | |
role = "${aws_iam_role.fraud_detection_lambda_role.arn}" | |
s3_bucket = "${aws_s3_bucket.fraud_detection_function_bucket.id}" | |
s3_key = "fraud-detection-using-machine-learning/${var.function_version}/fraud_detection.zip" | |
... | |
} | |
# iam_kinesis.tf | |
resource "aws_iam_role" "fraud_detection_firehose_role" { | |
name = "fraud-detection-firehose-role" | |
... | |
} | |
resource "aws_iam_role_policy_attachment" "fraud_detection_firehose" { | |
role = "${aws_iam_role.fraud_detection_firehose_role.name}" | |
policy_arn = "${aws_iam_policy.fraud_detection_firehose_policy.arn}" | |
} | |
resource "aws_iam_policy" "fraud_detection_firehose_policy" { | |
name = "fraud-detection-firehose-policy" | |
description = "Policy for the Amazon Kinesis Data Firehose to save data to S3 bucket" | |
... | |
} | |
# s3_kinesis.tf | |
resource "aws_s3_bucket" "s3_bucket_2" { | |
bucket = "${var.s3_bucket_name_2}-${var.aws_region}" | |
acl = "private" | |
... | |
} | |
# kinesis.tf | |
resource "aws_kinesis_firehose_delivery_stream" "fraud_detection_firehose_stream" { | |
name = "fraud-detection-firehose-stream" | |
destination = "s3" | |
s3_configuration { | |
bucket_arn = "${aws_s3_bucket.s3_bucket_2.arn}" | |
... | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment