Skip to content

Instantly share code, notes, and snippets.

{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"sqs:DeleteMessage",
"sqs:ReceiveMessage",
"sqs:GetQueueAttributes"
],
"Resource": "${sqs_arn}",
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 = {
# 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
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 = {
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"
}
resource "aws_iam_role" "apiSQS" {
name = "apigateway_sqs"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:DescribeLogGroups",
"logs:DescribeLogStreams",
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
}
variable "environment" {
description = "Env"
default = "dev"
}
variable "name" {
description = "Application Name"
type = string
}
@DanielDaCosta
DanielDaCosta / model_instance.py
Created May 6, 2020 02:13
Model Instance Medium
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);