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
|
# Variables ====================================================================
variable "name_prefix" {
description = "Prefix prepended to resource names created by this module"
type = string
validation {
condition = length(trimspace(var.name_prefix)) > 0
error_message = "name_prefix must not be empty."
}
}
variable "aws_region" {
description = "AWS region to build service_name endpoints against (e.g. com.amazonaws.<region>.<service>)"
type = string
validation {
condition = can(regex("^[a-z]{2}-[a-z]+-[0-9]$", var.aws_region))
error_message = "aws_region must be a valid AWS region format e.g. us-west-2."
}
}
variable "vpc_id" {
description = "VPC ID in which to create endpoints"
type = string
}
variable "vpc_cidr_block" {
description = "Primary VPC CIDR block, used to scope the interface endpoint security group's ingress rule"
type = string
validation {
condition = can(cidrhost(var.vpc_cidr_block, 0))
error_message = "vpc_cidr_block must be valid IPv4 CIDR notation."
}
}
variable "subnet_ids" {
description = "Subnet IDs to place Interface endpoint ENIs in. Required when any endpoint in var.endpoints has type = \"Interface\"."
type = list(string)
default = []
}
variable "route_table_ids" {
description = "Route table IDs to associate with Gateway endpoints. Required when any endpoint in var.endpoints has type = \"Gateway\"."
type = list(string)
default = []
}
variable "endpoints" {
description = <<-EOT
Map of endpoint definitions to create. No default — the caller decides
which services are needed. service_name is the short AWS service name
(e.g. "s3", "kms"). type must be "Gateway" or "Interface".
EOT
type = map(object({
service_name = string
type = string
private_dns_enabled = optional(bool, true)
policy = optional(string, null)
}))
validation {
condition = alltrue([
for k, v in var.endpoints : contains(["Gateway", "Interface"], v.type)
])
error_message = "Each endpoint's type must be either \"Gateway\" or \"Interface\"."
}
validation {
condition = alltrue([
for k, v in var.endpoints : length(trimspace(v.service_name)) > 0
])
error_message = "Each endpoint's service_name must not be empty."
}
}
variable "tags" {
description = "Resource tags to apply to all resources"
type = map(string)
default = {}
}
|