Skip to content

Commit

Permalink
Merge pull request #4 from hazelops/feature/updates
Browse files Browse the repository at this point in the history
Minor README Updates and Minor restructuring
  • Loading branch information
AutomationD authored May 13, 2024
2 parents bda475c + 352ccbc commit 08e22d3
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 97 deletions.
172 changes: 101 additions & 71 deletions README.md

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions data.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generate userdata for Tailscale instance
data "template_file" "ec2_user_data" {
template = file("${path.module}/ec2_user_data.yml.tpl")
template = file("${path.module}/templates/ec2_user_data.tpl.yml")

vars = {
auth_key = tailscale_tailnet_key.this.key
Expand All @@ -9,9 +9,8 @@ data "template_file" "ec2_user_data" {
}
}

# Download latest AMI info for Amazon Linux 2023
# Get latest AMI info for Amazon Linux 2023
data "aws_ami" "this" {

most_recent = true

filter {
Expand Down
2 changes: 1 addition & 1 deletion examples/minimal/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ variable "vpc_cidr_block" {}
variable "ssh_key_id" {}
variable "aws_key_name" {}

# Obtain Tailscale auth key from AWS SSM Parameter Store
# Obtain Tailscale api key from AWS SSM Parameter Store
data "aws_ssm_parameter" "tailscale_api_token" {
name = "/${var.env}/global/tailscale_api_token"
}
Expand Down
4 changes: 4 additions & 0 deletions locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
locals {
name = "${var.env}-${var.name}"
tags = concat(["tag:${var.env}"], var.tags)
}
2 changes: 1 addition & 1 deletion output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ output "security_group_id" {
value = element(aws_security_group.this.*.id, 0)
}

output "autoscaling_group_id"{
output "autoscaling_group_id" {
value = aws_autoscaling_group.this.id
}

Expand Down
2 changes: 1 addition & 1 deletion security.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ resource "aws_security_group" "this" {
}

tags = {
Name = local.name
Name = local.name
}

lifecycle {
Expand Down
File renamed without changes.
37 changes: 18 additions & 19 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
variable "env" {
type = string
type = string
description = "Environment name (typically dev/prod)"
}
variable "vpc_id" {
type = string
type = string
description = "VPC ID where the Tailscale instance will be placed"
}

variable "ec2_key_pair_name" {
type = string
type = string
description = "EC2 key pair name to use for Tailscale instance"
}

variable "subnets" {
Expand All @@ -16,26 +19,26 @@ variable "subnets" {

variable "ami_id" {
type = string
description = "Optional AMI ID for Tailscale instance. Otherwise latest Amazon Linux will be used. One might want to lock this down to avoid unexpected upgrades."
default = ""
description = "Optional AMI ID for Tailscale instance. Otherwise latest Amazon Linux will be used."
}

variable "name" {
type = string
default = "tailscale-router"
description = "Set a name for Tailscale instance"
description = "Name for Tailscale instance"
}

variable "instance_type" {
type = string
default = "t3.nano"
description = "Set type of Tailscale instance"
description = "Type of Tailscale instance"
}

variable "public_ip_enabled" {
type = bool
default = false
description = "Enable Public IP for Tailscale instance"
description = "Wheter to enable a public IP for Tailscale instance"
}

variable "ext_security_groups" {
Expand All @@ -56,6 +59,7 @@ variable "ssm_role_arn" {
}

variable "asg" {
type = map(any)
default = {
min_size = 1
max_size = 1
Expand All @@ -66,45 +70,40 @@ variable "asg" {
variable "monitoring_enabled" {
type = bool
default = true
description = "Enable monitoring for the Auto Scaling Group"
description = "Whether to enable monitoring for the Auto Scaling Group"
}

variable "api_token" {
type = string
description = "Set Tailscale API access token here"
description = "Tailscale API access token"
}

variable "key_expiry" {
type = number
default = 7776000
description = "The expiry of the key in seconds. Defaults to 7776000 (90 days)"
description = "Expiry of the key in seconds. Defaults to 7776000 (90 days)"
}

variable "key_reusable" {
type = bool
default = true
description = "Indicates if the key is reusable or single-use"
description = "Indicates whether the key is reusable"
}

variable "key_ephemeral" {
type = bool
default = true
description = "Indicates if the key is ephemeral"
description = "Indicates whether the key is ephemeral"
}

variable "key_preauthorized" {
type = bool
default = true
description = "Determines whether or not the machines authenticated by the key will be authorized for the tailnet by default"
description = "Determines whether or not the machines authenticated by the key will be authorized for the Tailnet by default"
}

variable "tags" {
type = list(string)
default = []
description = "A device is automatically tagged when it is authenticated with this key"
}

locals {
name = "${var.env}-${var.name}"
tags = concat(["tag:${var.env}"], var.tags)
description = "List of tags for the Tailnet device. It would be automatically tagged when it is authenticated with this key"
}
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
source = "hashicorp/aws"
version = ">=4.30.0"
}
template = {
Expand Down

0 comments on commit 08e22d3

Please sign in to comment.