forked from masterpointio/terraform-aws-tailscale
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariables.tf
More file actions
314 lines (271 loc) · 10.2 KB
/
variables.tf
File metadata and controls
314 lines (271 loc) · 10.2 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
#################################
## Subnet Router EC2 Instance ##
###############################
variable "vpc_id" {
type = string
description = "The ID of the VPC which the Tailscale Subnet Router EC2 instance will run in."
}
variable "subnet_ids" {
type = list(string)
description = "The Subnet IDs which the Tailscale Subnet Router EC2 instance will run in. These *should* be private subnets."
}
variable "additional_security_group_ids" {
default = []
type = list(string)
description = "Additional Security Group IDs to associate with the Tailscale Subnet Router EC2 instance."
}
variable "additional_security_group_rules" {
description = "Additional security group rules that will be attached to the primary security group"
type = map(object({
type = string
from_port = number
to_port = number
protocol = string
description = optional(string)
cidr_blocks = optional(list(string))
ipv6_cidr_blocks = optional(list(string))
prefix_list_ids = optional(list(string))
self = optional(bool)
}))
default = {}
}
variable "create_run_shell_document" {
default = true
type = bool
description = "Whether or not to create the SSM-SessionManagerRunShell SSM Document."
}
variable "session_logging_enabled" {
default = true
type = bool
description = <<EOF
To enable CloudWatch and S3 session logging or not.
Note this does not apply to SSH sessions as AWS cannot log those sessions.
EOF
}
variable "session_logging_kms_key_alias" {
default = "alias/session_logging"
type = string
description = <<EOF
Alias name for `session_logging` KMS Key.
This is only applied if 2 conditions are met: (1) `session_logging_kms_key_arn` is unset,
(2) `session_logging_encryption_enabled` = true.
EOF
}
variable "session_logging_ssm_document_name" {
default = "SSM-SessionManagerRunShell-Tailscale"
type = string
description = <<EOF
Name for `session_logging` SSM document.
This is only applied if 2 conditions are met: (1) `session_logging_enabled` = true,
(2) `create_run_shell_document` = true.
EOF
}
variable "allow_ssl_requests_only" {
description = "Whether or not to allow SSL requests only. If set to `true` this will create a bucket policy that `Deny` if SSL is not used in the requests using the `aws:SecureTransport` condition."
type = bool
default = false
}
variable "allow_encrypted_uploads_only" {
description = "Whether or not to allow encrypted uploads only. If set to `true` this will create a bucket policy that `Deny` if encryption header is missing in the requests."
type = bool
default = false
}
variable "key_pair_name" {
default = null
type = string
description = "The name of the key-pair to associate with the Tailscale Subnet Router EC2 instance."
}
variable "user_data" {
default = ""
type = string
description = <<EOF
The user_data to use for the Tailscale Subnet Router EC2 instance.
You can use this to automate installation of all the required command line tools.
EOF
}
variable "ami" {
default = ""
type = string
description = <<EOF
The AMI to use for the Tailscale Subnet Router EC2 instance.
If not provided, the latest Amazon Linux 2 AMI will be used.
Note: This will update periodically as AWS releases updates to their AL2 AMI.
Pin to a specific AMI if you would like to avoid these updates.
EOF
}
variable "architecture" {
default = "arm64"
type = string
description = "The architecture of the AMI (e.g., x86_64, arm64)"
}
variable "instance_type" {
default = "t4g.nano"
type = string
description = "The instance type to use for the Tailscale Subnet Router EC2 instance."
}
variable "monitoring_enabled" {
description = "Enable detailed monitoring of instances"
type = bool
default = true
}
variable "associate_public_ip_address" {
description = "Associate public IP address with subnet router"
type = bool
default = null
}
variable "max_size" {
description = "Maximum number of instances in the Auto Scaling Group. Must be >= desired_capacity."
type = number
default = 2
}
variable "min_size" {
description = "Minimum number of instances in the Auto Scaling Group"
type = number
default = 1
}
variable "desired_capacity" {
description = "Desired number of instances in the Auto Scaling Group"
type = number
default = 1
}
variable "journald_system_max_use" {
description = "Disk space the journald may use up at most"
type = string
default = "200M"
}
variable "journald_max_retention_sec" {
description = "The maximum time to store journal entries."
type = string
default = "7d"
}
################
## Tailscale ##
##############
variable "primary_tag" {
default = null
type = string
description = "The primary tag to apply to the Tailscale Subnet Router machine. Do not include the `tag:` prefix. This must match the OAuth client's tag. If not provided, the module will use the module's ID as the primary tag, which is configured in context.tf"
}
variable "additional_tags" {
default = []
type = list(string)
description = "Additional Tailscale tags to apply to the Tailscale Subnet Router machine in addition to `primary_tag`. These should not include the `tag:` prefix."
}
variable "ssh_enabled" {
type = bool
default = true
description = "Enable SSH access to the Tailscale Subnet Router EC2 instance. Defaults to true."
}
variable "exit_node_enabled" {
type = bool
default = false
description = "Advertise Tailscale Subnet Router EC2 instance as exit node. Defaults to false."
}
variable "advertise_routes" {
default = []
type = list(string)
description = <<EOF
The routes (expressed as CIDRs) to advertise as part of the Tailscale Subnet Router.
Example: ["10.0.2.0/24", "0.0.1.0/24"]
EOF
validation {
condition = can([for route in var.advertise_routes : cidrsubnet(route, 0, 0)])
error_message = "All elements in the list must be valid CIDR blocks."
}
}
variable "authkey_config" {
default = {
"tailscale_tailnet_key" = {
"ephemeral": false,
"expiry": 7776000,
"preauthorized": true,
"reusable" = true,
}
}
description = <<-EOT
Configuration for the auth key used in `tailscale up` command.
One of `tailscale_oauth_client` or `tailscale_tailnet_key` must be set.
For both options, the `description` is taken from `module.this.id` and the `tags` from what is passed to the `tailscale up command` via `--advertise-tags=<tags>` flag.
Minimal `scopes` required for `tailscale_oauth_client` are `["auth_keys", "devices:core", "devices:routes", "dns"]`.
For additional information, please visit:
- [tailscale up command](https://tailscale.com/docs/reference/tailscale-cli/up)
- [Terraform tailscale_oauth_client](https://registry.terraform.io/providers/tailscale/tailscale/latest/docs/resources/oauth_client)
- [Terraform tailscale_tailnet_key](https://registry.terraform.io/providers/tailscale/tailscale/latest/docs/resources/tailnet_key)
EOT
type = object({
tailscale_oauth_client = optional(object({
scopes = list(string)
}))
tailscale_tailnet_key = optional(object({
ephemeral = bool
expiry = number
preauthorized = bool
reusable = bool
}))
})
validation {
condition = (
var.authkey_config.tailscale_oauth_client != null ||
var.authkey_config.tailscale_tailnet_key != null
)
error_message = "At least one of 'tailscale_oauth_client' or 'tailscale_tailnet_key' must be defined in authkey_config."
}
validation {
condition = (
var.authkey_config.tailscale_oauth_client == null && var.authkey_config.tailscale_tailnet_key != null ||
var.authkey_config.tailscale_oauth_client != null && var.authkey_config.tailscale_tailnet_key == null
)
error_message = "Only one of 'tailscale_oauth_client' or 'tailscale_tailnet_key' must be defined in authkey_config."
}
validation {
condition = var.authkey_config.tailscale_oauth_client == null ? true : setintersection(
var.authkey_config.tailscale_oauth_client.scopes,
["auth_keys", "devices:core", "devices:routes", "dns"],
) == toset(["auth_keys", "devices:core", "devices:routes", "dns"])
error_message = "The 'tailscale_oauth_client.scopes' must include at least: auth_keys, devices:core, devices:routes and dns."
}
}
variable "tailscaled_extra_flags" {
default = []
type = list(string)
description = <<-EOT
Extra flags to pass to Tailscale daemon for advanced configuration. Example: ["--state=mem:"]
See more in the [docs](https://tailscale.com/kb/1278/tailscaled#flags-to-tailscaled).
EOT
}
variable "tailscale_up_extra_flags" {
default = []
type = list(string)
description = <<-EOT
Extra flags to pass to `tailscale up` for advanced configuration.
See more in the [docs](https://tailscale.com/kb/1241/tailscale-up).
EOT
}
variable "tailscale_set_extra_flags" {
default = []
type = list(string)
description = <<-EOT
Extra flags to pass to `tailscale set` after `tailscale up` for persistent preference changes that don't require reauthentication.
See more in the [docs](https://tailscale.com/docs/reference/tailscale-cli#set).
EOT
}
variable "ssm_state_enabled" {
default = false
type = bool
description = <<-EOT
Control if tailscaled state is stored in AWS SSM (including preferences and keys).
This tells the Tailscale daemon to write + read state from SSM,
which unlocks important features like retaining the existing tailscale machine name.
See more in the [docs](https://tailscale.com/kb/1278/tailscaled#flags-to-tailscaled).
EOT
}
variable "ssm_policy_name" {
default = "ssm"
type = string
description = <<EOF
The name of the SSM policy to create.
This is used to attach the SSM policy to the Tailscale Subnet Router EC2 instance.
This is only applied if `ssm_state_enabled` is true.
Multiple instances of this module can be used in the same account by setting a unique `ssm_policy_name` for each instance.
EOF
}