variables.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
variable "name" {
  description = "Name for the API"
  type        = string
}

variable "protocol_type" {
  description = "API type — HTTP or WEBSOCKET"
  type        = string
  default     = "HTTP"
  validation {
    condition     = contains(["HTTP", "WEBSOCKET"], var.protocol_type)
    error_message = "protocol_type must be HTTP or WEBSOCKET."
  }
}

variable "description" {
  description = "API description"
  type        = string
  default     = ""
}

variable "cors_configuration" {
  description = "CORS configuration for HTTP APIs"
  type = object({
    allow_origins     = optional(list(string), ["*"])
    allow_methods     = optional(list(string), ["GET", "POST", "PUT", "DELETE", "OPTIONS"])
    allow_headers     = optional(list(string), ["Content-Type", "Authorization"])
    expose_headers    = optional(list(string), [])
    max_age           = optional(number, 86400)
    allow_credentials = optional(bool, false)
  })
  default = null
}

variable "stages" {
  description = "Map of API stages to deploy"
  type = map(object({
    name                 = string
    auto_deploy          = optional(bool, true)
    throttle_burst_limit = optional(number, 5000)
    throttle_rate_limit  = optional(number, 10000)
    access_log_arn       = optional(string, null)
    access_log_format    = optional(string, "$context.requestId $context.identity.sourceIp $context.httpMethod $context.routeKey $context.status $context.responseLength $context.requestTime")
    default_route_settings = optional(object({
      throttling_burst_limit = optional(number, 5000)
      throttling_rate_limit  = optional(number, 10000)
    }), null)
  }))
  default = {
    default = {
      name = "$default"
    }
  }
}

variable "integrations" {
  description = "Map of API integrations"
  type = map(object({
    integration_type       = string # AWS_PROXY, HTTP_PROXY, MOCK
    integration_uri        = optional(string, null)
    integration_method     = optional(string, "POST")
    payload_format_version = optional(string, "2.0")
    timeout_milliseconds   = optional(number, 29000)
  }))
  default = {}
}

variable "routes" {
  description = "Map of API routes"
  type = map(object({
    route_key          = string
    integration_key    = optional(string, null)
    authorization_type = optional(string, "NONE")
    authorizer_id      = optional(string, null)
  }))
  default = {}
}

variable "custom_domain" {
  description = "Custom domain name configuration"
  type = object({
    domain_name         = string
    acm_certificate_arn = string
    endpoint_type       = optional(string, "REGIONAL")
    stage_key           = optional(string, "default")
    api_mapping_key     = optional(string, null)
  })
  default = null
}

variable "tags" {
  description = "Resource tags to apply to all resources"
  type        = map(string)
  default     = {}
}