This file contains hidden or 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
| { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Action": [ | |
| "sqs:DeleteMessage", | |
| "sqs:ReceiveMessage", | |
| "sqs:GetQueueAttributes" | |
| ], | |
| "Resource": "${sqs_arn}", |
This file contains hidden or 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
| resource "aws_api_gateway_deployment" "api" { | |
| rest_api_id = aws_api_gateway_rest_api.apiGateway.id | |
| stage_name = var.environment | |
| depends_on = [ | |
| aws_api_gateway_integration.api, | |
| ] | |
| # Redeploy when there are new updates | |
| triggers = { |
This file contains hidden or 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
| # Mapping SQS Response | |
| resource "aws_api_gateway_method_response" "http200" { | |
| rest_api_id = aws_api_gateway_rest_api.apiGateway.id | |
| resource_id = aws_api_gateway_resource.form_score.id | |
| http_method = aws_api_gateway_method.method_form_score.http_method | |
| status_code = 200 | |
| } | |
| resource "aws_api_gateway_integration_response" "http200" { | |
| rest_api_id = aws_api_gateway_rest_api.apiGateway.id |
This file contains hidden or 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
| resource "aws_api_gateway_integration" "api" { | |
| rest_api_id = aws_api_gateway_rest_api.apiGateway.id | |
| resource_id = aws_api_gateway_resource.form_score.id | |
| http_method = aws_api_gateway_method.method_form_score.http_method | |
| type = "AWS" | |
| integration_http_method = "POST" | |
| credentials = aws_iam_role.apiSQS.arn | |
| uri = "arn:aws:apigateway:${var.region}:sqs:path/${aws_sqs_queue.queue.name}" | |
| request_parameters = { |
This file contains hidden or 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
| resource "aws_api_gateway_rest_api" "apiGateway" { | |
| name = "api-gateway-SQS" | |
| description = "POST records to SQS queue" | |
| } | |
| resource "aws_api_gateway_resource" "form_score" { | |
| rest_api_id = aws_api_gateway_rest_api.apiGateway.id | |
| parent_id = aws_api_gateway_rest_api.apiGateway.root_resource_id | |
| path_part = "form-score" | |
| } |
This file contains hidden or 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
| resource "aws_iam_role" "apiSQS" { | |
| name = "apigateway_sqs" | |
| assume_role_policy = <<EOF | |
| { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Action": "sts:AssumeRole", | |
| "Principal": { |
This file contains hidden or 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
| { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Effect": "Allow", | |
| "Action": [ | |
| "logs:CreateLogGroup", | |
| "logs:CreateLogStream", | |
| "logs:DescribeLogGroups", | |
| "logs:DescribeLogStreams", |
This file contains hidden or 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
| resource "aws_sqs_queue" "queue" { | |
| name = "apigateway-queue" | |
| delay_seconds = 0 | |
| max_message_size = 262144 | |
| message_retention_seconds = 86400 | |
| receive_wait_time_seconds = 10 | |
| tags = { | |
| Product = local.app_name | |
| } |
This file contains hidden or 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
| variable "environment" { | |
| description = "Env" | |
| default = "dev" | |
| } | |
| variable "name" { | |
| description = "Application Name" | |
| type = string | |
| } |
This file contains hidden or 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
| model = Model(inputs=main_input, outputs=output_array) | |
| model.compile(optimizer='adadelta', | |
| loss=loss_array, | |
| metrics=metrics_array) | |
| model.fit(X_train, y_train_output, | |
| epochs=40, batch_size=512, | |
| class_weight=classes_weights, verbose=0); |