-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
60 lines (50 loc) · 2.09 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#####################################
# ------------ Gateway ------------ #
#####################################
resource "aws_api_gateway_rest_api" "this" {
name = local.gateway_name
}
resource "aws_api_gateway_resource" "this" {
for_each = local.api_resources
rest_api_id = local.rest_api.id
parent_id = local.rest_api.root_resource_id
path_part = each.value
}
resource "aws_api_gateway_authorizer" "this" {
for_each = local.authorizer
name = each.value.name
rest_api_id = local.rest_api.id
type = "COGNITO_USER_POOLS"
provider_arns = each.value.provider_arns
}
resource "aws_api_gateway_stage" "this" {
rest_api_id = local.rest_api.id
deployment_id = aws_api_gateway_deployment.this_gtw_deployment.id
stage_name = var.api_gtw.stage
}
resource "aws_api_gateway_method_settings" "this" {
rest_api_id = local.rest_api.id
stage_name = aws_api_gateway_stage.this.stage_name
method_path = "*/*"
settings {
metrics_enabled = var.api_gtw.settings.metrics_enabled
logging_level = var.api_gtw.settings.logging_level
data_trace_enabled = var.api_gtw.settings.data_trace_enabled
throttling_burst_limit = var.api_gtw.settings.throttling_burst_limit
throttling_rate_limit = var.api_gtw.settings.throttling_rate_limit
caching_enabled = var.api_gtw.settings.caching_enabled
cache_ttl_in_seconds = var.api_gtw.settings.cache_ttl_in_seconds
cache_data_encrypted = var.api_gtw.settings.cache_data_encrypted
require_authorization_for_cache_control = var.api_gtw.settings.require_authorization_for_cache_control
unauthorized_cache_control_header_strategy = var.api_gtw.settings.unauthorized_cache_control_header_strategy
}
}
resource "aws_api_gateway_deployment" "this_gtw_deployment" {
rest_api_id = local.rest_api.id
triggers = {
redeployment = sha1(jsonencode(local.deploy_trigger))
}
lifecycle {
create_before_destroy = true
}
}