Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TDR-3364 - Create API Gateway resource #24

Merged
merged 2 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions terraform/root_main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,19 @@ module "reference_generator_lambda" {
timeout_seconds = 60
memory_size = 1024
tags = local.hosting_common_tags
lambda_invoke_permissions = {
"apigateway.amazonaws.com" = "${module.reference_generator_api_gateway.api_execution_arn}/*/GET/counter"
}
}

module "reference_generator_api_gateway" {
source = "./da-terraform-modules/apigateway"
api_definition = templatefile("./templates/api_gateway/reference_generator.json.tpl", {
environment = local.hosting_environment
title = "${upper(var.project)}ReferenceGenerator"
thanhz marked this conversation as resolved.
Show resolved Hide resolved
lambda_arn = module.reference_generator_lambda.lambda_arn,
})
api_name = "${upper(var.project)}ReferenceGenerator"
thanhz marked this conversation as resolved.
Show resolved Hide resolved
environment = local.hosting_environment
common_tags = local.hosting_common_tags
}
56 changes: 56 additions & 0 deletions terraform/templates/api_gateway/reference_generator.json.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"swagger" : "2.0",
"info" : {
"description" : "API Gateway for Reference Generator",
"version" : "2023-09-11T11:10:51Z",
"title" : "${title}"
},
"basePath" : "/${environment}",
"schemes" : [ "https" ],
"paths" : {
"/counter" : {
"get" : {
"produces" : [ "application/json" ],
"parameters" : [ {
"name" : "numberofrefs",
"in" : "query",
"required" : true,
"type" : "string"
} ],
"responses" : {
"200" : {
"description" : "200 response",
"schema" : {
"$ref" : "#/definitions/Empty"
}
}
},
"x-amazon-apigateway-request-validator" : "Validate query string parameters and headers",
"x-amazon-apigateway-integration" : {
"type" : "aws_proxy",
"httpMethod" : "POST",
"uri" : "arn:aws:apigateway:eu-west-2:lambda:path/2015-03-31/functions/${lambda_arn}/invocations",
"responses" : {
"default" : {
"statusCode" : "200"
}
},
"passthroughBehavior" : "when_no_match",
"contentHandling" : "CONVERT_TO_TEXT"
}
}
}
},
"definitions" : {
"Empty" : {
"type" : "object",
"title" : "Empty Schema"
}
},
"x-amazon-apigateway-request-validators" : {
"Validate query string parameters and headers" : {
"validateRequestParameters" : true,
"validateRequestBody" : false
}
}
}