Skip to content

Commit 509e667

Browse files
authored
terraform/aws: remove variables (#14)
These are examples, not production-ready modules. Move variable defaults to actual resource properties to make these easier to evaluate.
1 parent 9ec1abe commit 509e667

File tree

14 files changed

+124
-445
lines changed

14 files changed

+124
-445
lines changed

terraform/aws/aws-ec2-autoscaling-dual-subnet/main.tf

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
locals {
2-
name = var.name != "" ? var.name : "example-${basename(path.cwd)}"
2+
name = "example-${basename(path.cwd)}"
33

4-
tags = length(var.tags) > 0 ? var.tags : {
4+
tags = {
55
Name = local.name
66
}
77
}
@@ -12,18 +12,23 @@ module "vpc" {
1212
name = local.name
1313
tags = local.tags
1414

15-
cidr = var.vpc_cidr_block
15+
cidr = "10.0.80.0/22"
1616

17-
public_subnets = var.public_subnets
18-
private_subnets = var.private_subnets
17+
public_subnets = ["10.0.80.0/24"]
18+
private_subnets = ["10.0.81.0/24"]
1919
}
2020

2121
resource "tailscale_tailnet_key" "main" {
2222
ephemeral = true
2323
preauthorized = true
2424
reusable = true
2525
recreate_if_invalid = "always"
26-
tags = var.tailscale_device_tags
26+
tags = [
27+
"tag:example-infra",
28+
"tag:example-exitnode",
29+
"tag:example-subnetrouter",
30+
"tag:example-appconnector",
31+
]
2732
}
2833

2934
resource "aws_network_interface" "primary" {
@@ -51,7 +56,7 @@ module "tailscale_aws_ec2_autoscaling" {
5156
source = "../internal-modules/aws-ec2-autoscaling/"
5257

5358
autoscaling_group_name = local.name
54-
instance_type = var.instance_type
59+
instance_type = "t4g.micro"
5560
instance_tags = local.tags
5661

5762
network_interfaces = [
@@ -60,9 +65,11 @@ module "tailscale_aws_ec2_autoscaling" {
6065
]
6166

6267
# Variables for Tailscale resources
63-
tailscale_hostname = local.name
64-
tailscale_auth_key = tailscale_tailnet_key.main.key
65-
tailscale_set_preferences = var.tailscale_set_preferences
68+
tailscale_hostname = local.name
69+
tailscale_auth_key = tailscale_tailnet_key.main.key
70+
tailscale_set_preferences = [
71+
"--auto-update",
72+
]
6673
tailscale_ssh = true
6774
tailscale_advertise_exit_node = true
6875

terraform/aws/aws-ec2-autoscaling-dual-subnet/variables.tf

Lines changed: 0 additions & 56 deletions
This file was deleted.

terraform/aws/aws-ec2-autoscaling-session-recorder/main.tf

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
locals {
2-
name = var.name != "" ? var.name : "example-${basename(path.cwd)}"
2+
name = "example-${basename(path.cwd)}"
33

4-
tags = length(var.tags) > 0 ? var.tags : {
4+
tags = {
55
Name = local.name
66
}
77
}
@@ -12,10 +12,10 @@ module "vpc" {
1212
name = local.name
1313
tags = local.tags
1414

15-
cidr = var.vpc_cidr_block
15+
cidr = "10.0.80.0/22"
1616

17-
public_subnets = var.public_subnets
18-
private_subnets = var.private_subnets
17+
public_subnets = ["10.0.80.0/24"]
18+
private_subnets = ["10.0.81.0/24"]
1919
}
2020

2121
resource "aws_vpc_endpoint" "recorder" {
@@ -116,15 +116,19 @@ resource "tailscale_tailnet_key" "recorder" {
116116
preauthorized = true
117117
reusable = true
118118
recreate_if_invalid = "always"
119-
tags = var.tailscale_device_tags_recorder
119+
tags = [
120+
"tag:example-sessionrecorder",
121+
]
120122
}
121123

122124
resource "tailscale_tailnet_key" "main" {
123125
ephemeral = true
124126
preauthorized = true
125127
reusable = true
126128
recreate_if_invalid = "always"
127-
tags = var.tailscale_device_tags
129+
tags = [
130+
"tag:example-infra",
131+
]
128132
}
129133

130134
resource "aws_network_interface" "primary" {
@@ -144,17 +148,18 @@ module "tailscale_aws_ec2_autoscaling" {
144148
source = "../internal-modules/aws-ec2-autoscaling/"
145149

146150
autoscaling_group_name = local.name
151+
instance_type = "t4g.micro"
152+
instance_tags = local.tags
147153

148154
network_interfaces = [aws_network_interface.primary.id]
149155

150-
instance_type = var.instance_type
151-
instance_tags = local.tags
152-
153156
# Variables for Tailscale resources
154-
tailscale_hostname = local.name
155-
tailscale_auth_key = tailscale_tailnet_key.main.key
156-
tailscale_set_preferences = var.tailscale_set_preferences
157-
tailscale_ssh = true
157+
tailscale_hostname = local.name
158+
tailscale_auth_key = tailscale_tailnet_key.main.key
159+
tailscale_set_preferences = [
160+
"--auto-update",
161+
]
162+
tailscale_ssh = true
158163

159164
#
160165
# Set up Tailscale Session Recorder (tsrecorder)

terraform/aws/aws-ec2-autoscaling-session-recorder/variables.tf

Lines changed: 0 additions & 60 deletions
This file was deleted.

terraform/aws/aws-ec2-autoscaling/main.tf

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
locals {
2-
name = var.name != "" ? var.name : "example-${basename(path.cwd)}"
2+
name = "example-${basename(path.cwd)}"
33

4-
tags = length(var.tags) > 0 ? var.tags : {
4+
tags = {
55
Name = local.name
66
}
77
}
@@ -12,18 +12,23 @@ module "vpc" {
1212
name = local.name
1313
tags = local.tags
1414

15-
cidr = var.vpc_cidr_block
15+
cidr = "10.0.80.0/22"
1616

17-
public_subnets = var.public_subnets
18-
private_subnets = var.private_subnets
17+
public_subnets = ["10.0.80.0/24"]
18+
private_subnets = ["10.0.81.0/24"]
1919
}
2020

2121
resource "tailscale_tailnet_key" "main" {
2222
ephemeral = true
2323
preauthorized = true
2424
reusable = true
2525
recreate_if_invalid = "always"
26-
tags = var.tailscale_device_tags
26+
tags = [
27+
"tag:example-infra",
28+
"tag:example-exitnode",
29+
"tag:example-subnetrouter",
30+
"tag:example-appconnector",
31+
]
2732
}
2833

2934
resource "aws_network_interface" "primary" {
@@ -43,16 +48,17 @@ module "tailscale_aws_ec2_autoscaling" {
4348
source = "../internal-modules/aws-ec2-autoscaling/"
4449

4550
autoscaling_group_name = local.name
51+
instance_type = "t4g.micro"
52+
instance_tags = local.tags
4653

4754
network_interfaces = [aws_network_interface.primary.id]
4855

49-
instance_type = var.instance_type
50-
instance_tags = local.tags
51-
5256
# Variables for Tailscale resources
53-
tailscale_auth_key = tailscale_tailnet_key.main.key
54-
tailscale_hostname = local.name
55-
tailscale_set_preferences = var.tailscale_set_preferences
57+
tailscale_auth_key = tailscale_tailnet_key.main.key
58+
tailscale_hostname = local.name
59+
tailscale_set_preferences = [
60+
"--auto-update",
61+
]
5662
tailscale_ssh = true
5763
tailscale_advertise_exit_node = true
5864

terraform/aws/aws-ec2-autoscaling/variables.tf

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)