# --------------------------------------------------------------------------- # Amazon API Gateway # --------------------------------------------------------------------------- resource "aws_api_gateway_rest_api" "this" { name = var.name description = var.description tags = var.tags } resource "aws_api_gateway_resource" "this" { path_part = "products" parent_id = aws_api_gateway_rest_api.this.root_resource_id rest_api_id = aws_api_gateway_rest_api.this.id } resource "aws_api_gateway_method" "stock_get" { rest_api_id = aws_api_gateway_rest_api.this.id resource_id = aws_api_gateway_resource.this.id http_method = "GET" authorization = "NONE" } resource "aws_api_gateway_method" "this" { rest_api_id = aws_api_gateway_rest_api.this.id resource_id = aws_api_gateway_resource.this.id http_method = "POST" authorization = "NONE" } resource "aws_api_gateway_method" "options" { rest_api_id = aws_api_gateway_rest_api.this.id resource_id = aws_api_gateway_resource.this.id http_method = "OPTIONS" authorization = "NONE" } resource "aws_api_gateway_integration" "stock_get" { rest_api_id = aws_api_gateway_rest_api.this.id resource_id = aws_api_gateway_resource.this.id http_method = aws_api_gateway_method.stock_get.http_method integration_http_method = "POST" type = "AWS_PROXY" uri = var.lambda[1].lambda_function_arn } resource "aws_api_gateway_integration" "this" { rest_api_id = aws_api_gateway_rest_api.this.id resource_id = aws_api_gateway_resource.this.id http_method = aws_api_gateway_method.this.http_method integration_http_method = "POST" type = "AWS" credentials = var.role_arn uri = var.sqs_arn request_parameters = { "integration.request.header.Content-Type" = "'application/x-www-form-urlencoded'" } request_templates = { "application/json" = <