Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions terraform/global/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ resource "tfe_variable_set" "global" {
organization = "polar-sh"
}

resource "tfe_variable" "tailscale_version" {
key = "tailscale_version"
category = "terraform"
description = "Tailscale release installed on EC2 routers."
variable_set_id = tfe_variable_set.global.id

lifecycle {
ignore_changes = [value]
}
}

resource "tfe_variable" "planetscale_organization" {
key = "planetscale_organization"
category = "terraform"
Expand Down
1 change: 1 addition & 0 deletions terraform/modules/ec2_tailscale/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ resource "aws_instance" "this" {
tostring(var.tailscale_ssh),
join(",", var.advertise_routes),
join(",", var.advertise_tags),
var.tailscale_version,
]]
})}"

Expand Down
3 changes: 2 additions & 1 deletion terraform/modules/ec2_tailscale/tailscale-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ hostname="$3"
tailscale_ssh="$4"
advertise_routes="$5"
advertise_tags="$6"
tailscale_version="$7"

if [[ -n "$advertise_routes" ]]; then
sysctl -p /etc/sysctl.d/99-tailscale.conf
Expand All @@ -24,7 +25,7 @@ update-ca-trust
curl --fail --silent --show-error --location --retry 5 \
https://pkgs.tailscale.com/stable/amazon-linux/2023/tailscale.repo \
--output /etc/yum.repos.d/tailscale.repo
dnf install -y tailscale
dnf install -y "tailscale-${tailscale_version}"
systemctl enable --now tailscaled

umask 077
Expand Down
10 changes: 10 additions & 0 deletions terraform/modules/ec2_tailscale/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ variable "tailscale_oauth_secret_arn" {
type = string
}

variable "tailscale_version" {
description = "Tailscale release to install."
type = string

validation {
condition = can(regex("^[0-9]+\\.[0-9]+\\.[0-9]+$", var.tailscale_version))
error_message = "tailscale_version must be a release version such as 1.104.4."
}
}

variable "tailscale_oauth_secret_kms_key_arn" {
description = "Customer-managed KMS key encrypting the OAuth client secret, if used."
type = string
Expand Down
6 changes: 6 additions & 0 deletions terraform/production/tailscale.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
variable "tailscale_version" {
description = "Shared Tailscale release from the Global Settings variable set."
type = string
}

resource "aws_secretsmanager_secret" "ec2_tailscale" {
name = "polar-production-ec2-tailscale"

Expand All @@ -20,6 +25,7 @@ module "ec2_tailscale" {
advertise_routes = module.vpc.private_subnet_cidr_blocks
advertise_tags = ["tag:router", "tag:production"]
tailscale_oauth_secret_arn = aws_secretsmanager_secret.ec2_tailscale.arn
tailscale_version = var.tailscale_version
permissions_boundary_arn = data.aws_iam_policy.permission_boundary.arn

tags = {
Expand Down
6 changes: 6 additions & 0 deletions terraform/sandbox/tailscale.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
variable "tailscale_version" {
description = "Shared Tailscale release from the Global Settings variable set."
type = string
}

resource "aws_secretsmanager_secret" "ec2_tailscale" {
name = "polar-sandbox-ec2-tailscale"

Expand All @@ -20,6 +25,7 @@ module "ec2_tailscale" {
advertise_routes = module.vpc.secondary_private_subnet_cidr_blocks
advertise_tags = ["tag:router", "tag:sandbox"]
tailscale_oauth_secret_arn = aws_secretsmanager_secret.ec2_tailscale.arn
tailscale_version = var.tailscale_version
permissions_boundary_arn = data.aws_iam_policy.permission_boundary.arn

tags = {
Expand Down
6 changes: 6 additions & 0 deletions terraform/test/tailscale.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
variable "tailscale_version" {
description = "Shared Tailscale release from the Global Settings variable set."
type = string
}

resource "aws_secretsmanager_secret" "ec2_tailscale" {
count = local.test_enabled ? 1 : 0

Expand Down Expand Up @@ -27,6 +32,7 @@ module "ec2_tailscale" {
advertise_routes = module.vpc[0].secondary_private_subnet_cidr_blocks
advertise_tags = ["tag:router", "tag:test"]
tailscale_oauth_secret_arn = aws_secretsmanager_secret.ec2_tailscale[0].arn
tailscale_version = var.tailscale_version
permissions_boundary_arn = data.aws_iam_policy.permission_boundary.arn

tags = {
Expand Down
Loading