Skip to content

Commit

Permalink
terraform/aws: remove variables (#14)
Browse files Browse the repository at this point in the history
These are examples, not production-ready modules. Move variable defaults to actual resource properties to make these easier to evaluate.
  • Loading branch information
clstokes authored Jun 17, 2024
1 parent 9ec1abe commit 509e667
Show file tree
Hide file tree
Showing 14 changed files with 124 additions and 445 deletions.
27 changes: 17 additions & 10 deletions terraform/aws/aws-ec2-autoscaling-dual-subnet/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
locals {
name = var.name != "" ? var.name : "example-${basename(path.cwd)}"
name = "example-${basename(path.cwd)}"

tags = length(var.tags) > 0 ? var.tags : {
tags = {
Name = local.name
}
}
Expand All @@ -12,18 +12,23 @@ module "vpc" {
name = local.name
tags = local.tags

cidr = var.vpc_cidr_block
cidr = "10.0.80.0/22"

public_subnets = var.public_subnets
private_subnets = var.private_subnets
public_subnets = ["10.0.80.0/24"]
private_subnets = ["10.0.81.0/24"]
}

resource "tailscale_tailnet_key" "main" {
ephemeral = true
preauthorized = true
reusable = true
recreate_if_invalid = "always"
tags = var.tailscale_device_tags
tags = [
"tag:example-infra",
"tag:example-exitnode",
"tag:example-subnetrouter",
"tag:example-appconnector",
]
}

resource "aws_network_interface" "primary" {
Expand Down Expand Up @@ -51,7 +56,7 @@ module "tailscale_aws_ec2_autoscaling" {
source = "../internal-modules/aws-ec2-autoscaling/"

autoscaling_group_name = local.name
instance_type = var.instance_type
instance_type = "t4g.micro"
instance_tags = local.tags

network_interfaces = [
Expand All @@ -60,9 +65,11 @@ module "tailscale_aws_ec2_autoscaling" {
]

# Variables for Tailscale resources
tailscale_hostname = local.name
tailscale_auth_key = tailscale_tailnet_key.main.key
tailscale_set_preferences = var.tailscale_set_preferences
tailscale_hostname = local.name
tailscale_auth_key = tailscale_tailnet_key.main.key
tailscale_set_preferences = [
"--auto-update",
]
tailscale_ssh = true
tailscale_advertise_exit_node = true

Expand Down
56 changes: 0 additions & 56 deletions terraform/aws/aws-ec2-autoscaling-dual-subnet/variables.tf

This file was deleted.

33 changes: 19 additions & 14 deletions terraform/aws/aws-ec2-autoscaling-session-recorder/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
locals {
name = var.name != "" ? var.name : "example-${basename(path.cwd)}"
name = "example-${basename(path.cwd)}"

tags = length(var.tags) > 0 ? var.tags : {
tags = {
Name = local.name
}
}
Expand All @@ -12,10 +12,10 @@ module "vpc" {
name = local.name
tags = local.tags

cidr = var.vpc_cidr_block
cidr = "10.0.80.0/22"

public_subnets = var.public_subnets
private_subnets = var.private_subnets
public_subnets = ["10.0.80.0/24"]
private_subnets = ["10.0.81.0/24"]
}

resource "aws_vpc_endpoint" "recorder" {
Expand Down Expand Up @@ -116,15 +116,19 @@ resource "tailscale_tailnet_key" "recorder" {
preauthorized = true
reusable = true
recreate_if_invalid = "always"
tags = var.tailscale_device_tags_recorder
tags = [
"tag:example-sessionrecorder",
]
}

resource "tailscale_tailnet_key" "main" {
ephemeral = true
preauthorized = true
reusable = true
recreate_if_invalid = "always"
tags = var.tailscale_device_tags
tags = [
"tag:example-infra",
]
}

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

autoscaling_group_name = local.name
instance_type = "t4g.micro"
instance_tags = local.tags

network_interfaces = [aws_network_interface.primary.id]

instance_type = var.instance_type
instance_tags = local.tags

# Variables for Tailscale resources
tailscale_hostname = local.name
tailscale_auth_key = tailscale_tailnet_key.main.key
tailscale_set_preferences = var.tailscale_set_preferences
tailscale_ssh = true
tailscale_hostname = local.name
tailscale_auth_key = tailscale_tailnet_key.main.key
tailscale_set_preferences = [
"--auto-update",
]
tailscale_ssh = true

#
# Set up Tailscale Session Recorder (tsrecorder)
Expand Down
60 changes: 0 additions & 60 deletions terraform/aws/aws-ec2-autoscaling-session-recorder/variables.tf

This file was deleted.

30 changes: 18 additions & 12 deletions terraform/aws/aws-ec2-autoscaling/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
locals {
name = var.name != "" ? var.name : "example-${basename(path.cwd)}"
name = "example-${basename(path.cwd)}"

tags = length(var.tags) > 0 ? var.tags : {
tags = {
Name = local.name
}
}
Expand All @@ -12,18 +12,23 @@ module "vpc" {
name = local.name
tags = local.tags

cidr = var.vpc_cidr_block
cidr = "10.0.80.0/22"

public_subnets = var.public_subnets
private_subnets = var.private_subnets
public_subnets = ["10.0.80.0/24"]
private_subnets = ["10.0.81.0/24"]
}

resource "tailscale_tailnet_key" "main" {
ephemeral = true
preauthorized = true
reusable = true
recreate_if_invalid = "always"
tags = var.tailscale_device_tags
tags = [
"tag:example-infra",
"tag:example-exitnode",
"tag:example-subnetrouter",
"tag:example-appconnector",
]
}

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

autoscaling_group_name = local.name
instance_type = "t4g.micro"
instance_tags = local.tags

network_interfaces = [aws_network_interface.primary.id]

instance_type = var.instance_type
instance_tags = local.tags

# Variables for Tailscale resources
tailscale_auth_key = tailscale_tailnet_key.main.key
tailscale_hostname = local.name
tailscale_set_preferences = var.tailscale_set_preferences
tailscale_auth_key = tailscale_tailnet_key.main.key
tailscale_hostname = local.name
tailscale_set_preferences = [
"--auto-update",
]
tailscale_ssh = true
tailscale_advertise_exit_node = true

Expand Down
56 changes: 0 additions & 56 deletions terraform/aws/aws-ec2-autoscaling/variables.tf

This file was deleted.

Loading

0 comments on commit 509e667

Please sign in to comment.