-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from futurice/remove-cloudfront-from-aws-lambda…
…-api Remove CloudFront from aws_lambda_api
- Loading branch information
Showing
8 changed files
with
167 additions
and
332 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
resource "aws_api_gateway_rest_api" "this" { | ||
name = "${local.prefix_with_domain}" | ||
description = "${var.comment_prefix}${var.api_domain}" | ||
} | ||
|
||
resource "aws_api_gateway_deployment" "this" { | ||
rest_api_id = "${aws_api_gateway_rest_api.this.id}" | ||
|
||
depends_on = [ | ||
"aws_api_gateway_integration.proxy_root", | ||
"aws_api_gateway_integration.proxy_other", | ||
] | ||
} | ||
|
||
resource "aws_api_gateway_stage" "this" { | ||
stage_name = "${var.stage_name}" | ||
description = "${var.comment_prefix}${var.api_domain}" | ||
rest_api_id = "${aws_api_gateway_rest_api.this.id}" | ||
deployment_id = "${aws_api_gateway_deployment.this.id}" | ||
tags = "${var.tags}" | ||
} | ||
|
||
resource "aws_api_gateway_method_settings" "this" { | ||
rest_api_id = "${aws_api_gateway_rest_api.this.id}" | ||
stage_name = "${aws_api_gateway_stage.this.stage_name}" | ||
method_path = "*/*" | ||
|
||
settings { | ||
metrics_enabled = "${var.api_gateway_cloudwatch_metrics}" | ||
logging_level = "${var.api_gateway_logging_level}" | ||
data_trace_enabled = "${var.api_gateway_logging_level == "OFF" ? false : true}" | ||
throttling_rate_limit = "${var.throttling_rate_limit}" | ||
throttling_burst_limit = "${var.throttling_burst_limit}" | ||
} | ||
} | ||
|
||
resource "aws_api_gateway_domain_name" "this" { | ||
domain_name = "${var.api_domain}" | ||
regional_certificate_arn = "${aws_acm_certificate_validation.this.certificate_arn}" | ||
|
||
endpoint_configuration { | ||
types = ["REGIONAL"] | ||
} | ||
} | ||
|
||
resource "aws_api_gateway_base_path_mapping" "this" { | ||
api_id = "${aws_api_gateway_rest_api.this.id}" | ||
stage_name = "${aws_api_gateway_stage.this.stage_name}" | ||
domain_name = "${aws_api_gateway_domain_name.this.domain_name}" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Add root resource to the API (it it needs to be included separately from the "proxy" resource defined below), which forwards to our Lambda: | ||
|
||
resource "aws_api_gateway_method" "proxy_root" { | ||
rest_api_id = "${aws_api_gateway_rest_api.this.id}" | ||
resource_id = "${aws_api_gateway_rest_api.this.root_resource_id}" | ||
http_method = "ANY" | ||
authorization = "NONE" | ||
} | ||
|
||
resource "aws_api_gateway_integration" "proxy_root" { | ||
rest_api_id = "${aws_api_gateway_rest_api.this.id}" | ||
resource_id = "${aws_api_gateway_method.proxy_root.resource_id}" | ||
http_method = "${aws_api_gateway_method.proxy_root.http_method}" | ||
integration_http_method = "POST" | ||
type = "AWS_PROXY" | ||
uri = "${local.function_invoke_arn}" | ||
} | ||
|
||
# Add a "proxy" resource, that matches all paths (except the root, defined above) and forwards them to our Lambda: | ||
|
||
resource "aws_api_gateway_resource" "proxy_other" { | ||
rest_api_id = "${aws_api_gateway_rest_api.this.id}" | ||
parent_id = "${aws_api_gateway_rest_api.this.root_resource_id}" | ||
path_part = "{proxy+}" | ||
} | ||
|
||
resource "aws_api_gateway_method" "proxy_other" { | ||
rest_api_id = "${aws_api_gateway_rest_api.this.id}" | ||
resource_id = "${aws_api_gateway_resource.proxy_other.id}" | ||
http_method = "ANY" | ||
authorization = "NONE" | ||
} | ||
|
||
resource "aws_api_gateway_integration" "proxy_other" { | ||
rest_api_id = "${aws_api_gateway_rest_api.this.id}" | ||
resource_id = "${aws_api_gateway_method.proxy_other.resource_id}" | ||
http_method = "${aws_api_gateway_method.proxy_other.http_method}" | ||
integration_http_method = "POST" | ||
type = "AWS_PROXY" | ||
uri = "${local.function_invoke_arn}" | ||
} | ||
|
||
resource "aws_api_gateway_method_response" "proxy_other" { | ||
rest_api_id = "${aws_api_gateway_rest_api.this.id}" | ||
resource_id = "${aws_api_gateway_resource.proxy_other.id}" | ||
http_method = "${aws_api_gateway_method.proxy_other.http_method}" | ||
status_code = "200" | ||
|
||
response_models = { | ||
"application/json" = "Empty" | ||
} | ||
} | ||
|
||
resource "aws_api_gateway_integration_response" "proxy_other" { | ||
depends_on = ["aws_api_gateway_integration.proxy_other"] | ||
rest_api_id = "${aws_api_gateway_rest_api.this.id}" | ||
resource_id = "${aws_api_gateway_resource.proxy_other.id}" | ||
http_method = "${aws_api_gateway_method.proxy_other.http_method}" | ||
status_code = "${aws_api_gateway_method_response.proxy_other.status_code}" | ||
|
||
response_templates = { | ||
"application/json" = "" | ||
} | ||
} |
Oops, something went wrong.