diff --git a/terraform/aws/aws-ec2-autoscaling-dual-subnet/README.md b/terraform/aws/aws-ec2-autoscaling-dual-subnet/README.md deleted file mode 100644 index 0f50503..0000000 --- a/terraform/aws/aws-ec2-autoscaling-dual-subnet/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# aws-ec2-autoscaling-dual-subnet - -> :information_source: This example is intended for users that have a AWS NAT Gateway that they specifically -want to route Internet-bound traffic through. A use case for this is if you have _static IP addresses_ (typically Elastic IPs) -that you want or need to use for all Internet-bound traffic such as restricting access to GitHub or Snowflake -to a custom allow-list of IP addrresses. - -![diagram for aws-ec2-autoscaling-dual-subnet](./assets/diagram-aws-ec2-autoscaling-dual-subnet.png) - -This module creates the following: - -- a VPC and related resources including a NAT Gateway -- two AWS Elastic Network Interfaces (ENI) - one for a public subnet and one for a private subnet -- an EC2 Launch Template using both ENIs and a userdata script to install and configure Tailscale - - the userdata script also configures custom routing on the instance to allow direct connections to the instance - through the public subnet and outgoing connectivity through the VPC's NAT Gateway -- an EC2 Autoscaling Group using the Launch Template with `min_size`, `max_size`, and `desired_capacity` set to `1` -- a Tailnet device key to authenticate instances launched by the ASG to your Tailnet - -## Considerations - -- The Auto Scaling Group does not define an `instance_refresh` policy as the ASG cannot do a rolling restart with externally manaaged network interfaces (ENIs) as required by this configuration. To update instances to the latest launch template, terminate instances in the ASG in the AWS Console or programmatically. This will release the ENI so the replacement instance can use it. -- Any advertised routes and exit nodes must still be approved in the Tailscale Admin Console. The code can be updated to use [Auto Approvers for routes](https://tailscale.com/kb/1018/acls/#auto-approvers-for-routes-and-exit-nodes) if this is configured in your ACLs. - -## To use - -Follow the documentation to configure the Terraform providers: - -- [Tailscale](https://registry.terraform.io/providers/tailscale/tailscale/latest/docs) -- [AWS](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) - -### Deploy - -```shell -terraform init -terraform apply -``` - -## To destroy - -```shell -terraform destroy -``` diff --git a/terraform/aws/aws-ec2-autoscaling-dual-subnet/assets/diagram-aws-ec2-autoscaling-dual-subnet.png b/terraform/aws/aws-ec2-autoscaling-dual-subnet/assets/diagram-aws-ec2-autoscaling-dual-subnet.png deleted file mode 100644 index 7293c08..0000000 Binary files a/terraform/aws/aws-ec2-autoscaling-dual-subnet/assets/diagram-aws-ec2-autoscaling-dual-subnet.png and /dev/null differ diff --git a/terraform/aws/aws-ec2-autoscaling-dual-subnet/outputs.tf b/terraform/aws/aws-ec2-autoscaling-dual-subnet/outputs.tf deleted file mode 100644 index 6344142..0000000 --- a/terraform/aws/aws-ec2-autoscaling-dual-subnet/outputs.tf +++ /dev/null @@ -1,25 +0,0 @@ -output "resource_name_prefix" { - value = local.name -} - -output "vpc_id" { - value = module.vpc.vpc_id -} - -output "vpc_cidr" { - value = module.vpc.vpc_cidr_block -} - -output "nat_public_ips" { - value = module.vpc.nat_public_ips -} - -output "autoscaling_group_name" { - value = module.tailscale_aws_ec2_autoscaling.autoscaling_group_name -} - -output "user_data_md5" { - description = "MD5 hash of the VM user_data script - for detecting changes" - value = module.tailscale_aws_ec2_autoscaling.user_data_md5 - sensitive = true -} diff --git a/terraform/aws/aws-ec2-autoscaling-relay-to-private-subnet/README.md b/terraform/aws/aws-ec2-autoscaling-relay-to-private-subnet/README.md new file mode 100644 index 0000000..d9782fc --- /dev/null +++ b/terraform/aws/aws-ec2-autoscaling-relay-to-private-subnet/README.md @@ -0,0 +1,54 @@ +# aws-ec2-autoscaling-relay-to-private-subnet + +> :information_source: This example is intended for users that have a AWS NAT Gateway that they need to route Internet-bound traffic through. A use case for this is if you have _static IP addresses_ (typically Elastic IPs) that need to use for Internet-bound traffic such as restricting access to GitHub or Snowflake to a custom allow-list of IP addrresses. AWS NAT Gateway is a Hard NAT which forces [DERP connections](https://tailscale.com/kb/1257/connection-types#derp-connections). This example deploys a [Peer Relay](https://tailscale.com/kb/1591/peer-relays) to a Public Subnet to relay traffic to an App Connector in a Private Subnet. + +![diagram for aws-ec2-autoscaling-relay-to-private-subnet](./assets/aws-ec2-autoscaling-relay-to-private-subnet.png) + +This module creates the following: + +- a VPC and related resources including a NAT Gateway, a public subnet, and a private subnet +- an EC2 Launch Template and Autoscaling Group for a Tailscale Peer Relay in the **_public_** subnet +- an EC2 Launch Template and Autoscaling Group for a Tailscale App Connector in the **_private_** subnet + +## Policy File Example + +```json +{ + "grants": [ + ////////////// + // Peer relays + ////////////// + { + "src": ["tag:example-infra"], + "dst": ["tag:example-relay"], + "app": { + "tailscale.com/cap/relay": [], + }, + }, + ] +} +``` + +## Considerations + +- Any advertised routes for the App Connector must still be approved in the Tailscale Admin Console. The code can be updated to use [Auto Approvers for routes](https://tailscale.com/kb/1018/acls/#auto-approvers-for-routes-and-exit-nodes) if this is configured in your ACLs. + +## To use + +Follow the documentation to configure the Terraform providers: + +- [Tailscale](https://registry.terraform.io/providers/tailscale/tailscale/latest/docs) +- [AWS](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) + +### Deploy + +```shell +terraform init +terraform apply +``` + +## To destroy + +```shell +terraform destroy +``` diff --git a/terraform/aws/aws-ec2-autoscaling-dual-subnet/assets/diagram-aws-ec2-autoscaling-dual-subnet.excalidraw b/terraform/aws/aws-ec2-autoscaling-relay-to-private-subnet/assets/aws-ec2-autoscaling-relay-to-private-subnet.excalidraw similarity index 71% rename from terraform/aws/aws-ec2-autoscaling-dual-subnet/assets/diagram-aws-ec2-autoscaling-dual-subnet.excalidraw rename to terraform/aws/aws-ec2-autoscaling-relay-to-private-subnet/assets/aws-ec2-autoscaling-relay-to-private-subnet.excalidraw index e7fb9f1..8465f5b 100644 --- a/terraform/aws/aws-ec2-autoscaling-dual-subnet/assets/diagram-aws-ec2-autoscaling-dual-subnet.excalidraw +++ b/terraform/aws/aws-ec2-autoscaling-relay-to-private-subnet/assets/aws-ec2-autoscaling-relay-to-private-subnet.excalidraw @@ -4,106 +4,106 @@ "source": "https://excalidraw.com", "elements": [ { - "type": "text", - "version": 105, - "versionNonce": 1132079261, - "index": "aW", + "type": "rectangle", + "version": 304, + "versionNonce": 1100376247, + "index": "aU", "isDeleted": false, - "id": "UCY96GdJOlDjK6M3yUl7z", + "id": "wY3CWINKYOXEEd0slhaC2", "fillStyle": "hachure", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, - "x": -291.89547453599516, - "y": 295.46816674362424, + "x": -241.66988859849516, + "y": 563.0092968095422, "strokeColor": "#1e1e1e", - "backgroundColor": "transparent", - "width": 36.439971923828125, - "height": 25, - "seed": 105486525, + "backgroundColor": "#ffec99", + "width": 505, + "height": 159, + "seed": 58609021, "groupIds": [], "frameId": null, - "roundness": null, + "roundness": { + "type": 3 + }, "boundElements": [], - "updated": 1719438436791, + "updated": 1763331804102, "link": null, - "locked": false, - "fontSize": 20, - "fontFamily": 1, - "text": "VPC", - "textAlign": "left", - "verticalAlign": "top", - "containerId": null, - "originalText": "VPC", - "autoResize": true, - "lineHeight": 1.25 + "locked": false }, { "type": "rectangle", - "version": 148, - "versionNonce": 1729100723, - "index": "aX", + "version": 389, + "versionNonce": 1809624057, + "index": "aV", "isDeleted": false, - "id": "OlwdZVBIFA_vJ9lE92Yu2", + "id": "FapJSWVKNP1aaKPrsw4vd", "fillStyle": "hachure", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, - "x": -244.63766203599516, - "y": 388.21426049362424, + "x": -241.66988859849516, + "y": 383.9554638017299, "strokeColor": "#1e1e1e", "backgroundColor": "#b2f2bb", - "width": 399, + "width": 505, "height": 159, - "seed": 1114732829, + "seed": 131853655, "groupIds": [], "frameId": null, "roundness": { "type": 3 }, "boundElements": [], - "updated": 1719438436791, + "updated": 1763331745440, "link": null, "locked": false }, { - "type": "rectangle", - "version": 241, - "versionNonce": 1321536765, - "index": "aY", + "type": "text", + "version": 109, + "versionNonce": 1767703095, + "index": "aW", "isDeleted": false, - "id": "wY3CWINKYOXEEd0slhaC2", + "id": "UCY96GdJOlDjK6M3yUl7z", "fillStyle": "hachure", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, - "x": -242.87203703599516, - "y": 563.2142604936242, + "x": -291.89547453599516, + "y": 295.46816674362424, "strokeColor": "#1e1e1e", - "backgroundColor": "#ffec99", - "width": 399, - "height": 159, - "seed": 58609021, + "backgroundColor": "transparent", + "width": 33, + "height": 25, + "seed": 105486525, "groupIds": [], "frameId": null, - "roundness": { - "type": 3 - }, + "roundness": null, "boundElements": [], - "updated": 1719438436791, + "updated": 1763331503209, "link": null, - "locked": false + "locked": false, + "fontSize": 20, + "fontFamily": 8, + "text": "VPC", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "VPC", + "autoResize": true, + "lineHeight": 1.25 }, { "type": "text", - "version": 283, - "versionNonce": 899419475, + "version": 289, + "versionNonce": 80390263, "index": "aZ", "isDeleted": false, "id": "i8ux7JldglWRqYgaQM1QW", @@ -114,24 +114,24 @@ "opacity": 100, "angle": 4.71238898038469, "x": -332.6375933714444, - "y": 454.214329158175, + "y": 450.9554638017298, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", - "width": 129.67987060546875, + "width": 143, "height": 25, "seed": 1219597789, "groupIds": [], "frameId": null, "roundness": null, "boundElements": [], - "updated": 1719438436791, + "updated": 1763331795564, "link": null, "locked": false, "fontSize": 20, - "fontFamily": 1, + "fontFamily": 8, "text": "Public Subnet", "textAlign": "left", - "verticalAlign": "top", + "verticalAlign": "middle", "containerId": null, "originalText": "Public Subnet", "autoResize": true, @@ -139,8 +139,8 @@ }, { "type": "text", - "version": 383, - "versionNonce": 200566109, + "version": 390, + "versionNonce": 401269305, "index": "aa", "isDeleted": false, "id": "4ymLWeOsU7n7ZZaLqb82Z", @@ -151,21 +151,21 @@ "opacity": 100, "angle": 4.71238898038469, "x": -337.5475894041592, - "y": 623.3043331254602, + "y": 630.0092968095422, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", - "width": 147.49986267089844, + "width": 154, "height": 25, "seed": 756863549, "groupIds": [], "frameId": null, "roundness": null, "boundElements": [], - "updated": 1719438436791, + "updated": 1763331804102, "link": null, "locked": false, "fontSize": 20, - "fontFamily": 1, + "fontFamily": 8, "text": "Private Subnet", "textAlign": "left", "verticalAlign": "top", @@ -175,253 +175,352 @@ "lineHeight": 1.25 }, { - "type": "rectangle", - "version": 210, - "versionNonce": 670362355, - "index": "ab", + "type": "text", + "version": 996, + "versionNonce": 1184176247, + "index": "aj", "isDeleted": false, - "id": "FDZ39cZRm9-Ct19Nr-WaF", + "id": "sMLmiNSxAfYCE_VGSI79m", "fillStyle": "solid", "strokeWidth": 1, "strokeStyle": "solid", - "roughness": 1, + "roughness": 2, "opacity": 100, "angle": 0, - "x": -214.2852399546299, - "y": 501.7473059240673, + "x": 81.35397869218747, + "y": 185.25569489517454, "strokeColor": "#1e1e1e", "backgroundColor": "#ffffff", - "width": 183, - "height": 112, - "seed": 1839301277, + "width": 88, + "height": 25, + "seed": 355423645, "groupIds": [], "frameId": null, - "roundness": { - "type": 3 - }, + "roundness": null, "boundElements": [ { - "type": "text", - "id": "s1YQtc3gZLYfMduD0JROA" - }, - { - "id": "4lciJNhcvcqiU-FwOwXgm", + "id": "dqJloQuPSkLjlq4MOLNka", "type": "arrow" } ], - "updated": 1719438436791, + "updated": 1763331759497, "link": null, - "locked": false + "locked": false, + "fontSize": 20, + "fontFamily": 8, + "text": "Internet", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "Internet", + "autoResize": true, + "lineHeight": 1.25 }, { "type": "text", - "version": 213, - "versionNonce": 188678013, - "index": "ac", + "version": 596, + "versionNonce": 1185195703, + "index": "ak", "isDeleted": false, - "id": "s1YQtc3gZLYfMduD0JROA", + "id": "Ro6gyiFbVtEsDtQhVHBfY", "fillStyle": "solid", "strokeWidth": 1, "strokeStyle": "solid", - "roughness": 1, + "roughness": 2, "opacity": 100, "angle": 0, - "x": -191.50518014017678, - "y": 532.7473059240673, + "x": -140.4632871391778, + "y": 185.25569489517454, "strokeColor": "#1e1e1e", "backgroundColor": "#ffffff", - "width": 137.43988037109375, - "height": 50, - "seed": 787556093, + "width": 77, + "height": 25, + "seed": 1800182269, "groupIds": [], "frameId": null, "roundness": null, - "boundElements": [], - "updated": 1719438449615, + "boundElements": [ + { + "id": "fIinrfejF9MDIuwmsaF6S", + "type": "arrow" + } + ], + "updated": 1763331759498, "link": null, "locked": false, "fontSize": 20, - "fontFamily": 1, - "text": "Tailscale\nApp Connector", - "textAlign": "center", - "verticalAlign": "middle", - "containerId": "FDZ39cZRm9-Ct19Nr-WaF", - "originalText": "Tailscale\nApp Connector", + "fontFamily": 8, + "text": "Tailnet", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "Tailnet", "autoResize": true, "lineHeight": 1.25 }, { - "type": "diamond", - "version": 146, - "versionNonce": 1117852819, - "index": "ad", + "type": "arrow", + "version": 2211, + "versionNonce": 1936257431, + "index": "al", "isDeleted": false, - "id": "TbYffIAaUHLROZQLip0O1", + "id": "dqJloQuPSkLjlq4MOLNka", "fillStyle": "solid", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, - "x": -3.637662035995163, - "y": 322.21426049362424, + "x": 125.58525194896063, + "y": 296.9127810170351, "strokeColor": "#1e1e1e", "backgroundColor": "#ffffff", - "width": 128, - "height": 128, - "seed": 59588445, + "width": 1.191823492973981, + "height": 84.65708612186057, + "seed": 704795229, "groupIds": [], "frameId": null, "roundness": { "type": 2 }, + "boundElements": [], + "updated": 1763331759498, + "link": null, + "locked": false, + "startBinding": { + "elementId": "cHPkS5EsVoh5BPgFFsUT8", + "focus": 0.015406794151970491, + "gap": 5.254328458744446 + }, + "endBinding": { + "elementId": "sMLmiNSxAfYCE_VGSI79m", + "focus": 0.02636555092012574, + "gap": 2 + }, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "arrow", + "points": [ + [ + 0, + 0 + ], + [ + -1.191823492973981, + -84.65708612186057 + ] + ] + }, + { + "type": "rectangle", + "version": 359, + "versionNonce": 744128509, + "index": "ao", + "isDeleted": false, + "id": "VNTbtogTpQa9SfqhRygVh", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": -315.60250578599516, + "y": 269.44797936569455, + "strokeColor": "#1e1e1e", + "backgroundColor": "transparent", + "width": 627, + "height": 484.00000000000006, + "seed": 284504957, + "groupIds": [], + "frameId": null, + "roundness": { + "type": 3 + }, + "boundElements": [], + "updated": 1719438436791, + "link": null, + "locked": false + }, + { + "type": "rectangle", + "version": 316, + "versionNonce": 1515600343, + "index": "asV", + "isDeleted": false, + "id": "FDZ39cZRm9-Ct19Nr-WaF", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 33.85397869218747, + "y": 586.5092968095422, + "strokeColor": "#1e1e1e", + "backgroundColor": "#ffffff", + "width": 183, + "height": 112, + "seed": 1839301277, + "groupIds": [], + "frameId": null, + "roundness": { + "type": 3 + }, "boundElements": [ { "type": "text", - "id": "LEV3HXZYCiV2uZ_j8FSK_" + "id": "s1YQtc3gZLYfMduD0JROA" }, { - "id": "dqJloQuPSkLjlq4MOLNka", + "id": "4lciJNhcvcqiU-FwOwXgm", + "type": "arrow" + }, + { + "id": "y55Fi2aoF7oiOyklx0gpk", "type": "arrow" } ], - "updated": 1719438436791, + "updated": 1763331804102, "link": null, "locked": false }, { "type": "text", - "version": 79, - "versionNonce": 51802653, - "index": "ae", + "version": 322, + "versionNonce": 1799553241, + "index": "at", "isDeleted": false, - "id": "LEV3HXZYCiV2uZ_j8FSK_", + "id": "s1YQtc3gZLYfMduD0JROA", "fillStyle": "solid", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, - "x": 39.322352307266556, - "y": 373.71426049362424, + "x": 53.85397869218747, + "y": 617.5092968095422, "strokeColor": "#1e1e1e", "backgroundColor": "#ffffff", - "width": 42.07997131347656, - "height": 25, - "seed": 835144637, + "width": 143, + "height": 50, + "seed": 787556093, "groupIds": [], "frameId": null, "roundness": null, "boundElements": [], - "updated": 1719438436791, + "updated": 1763331804103, "link": null, "locked": false, "fontSize": 20, - "fontFamily": 1, - "text": "NAT", + "fontFamily": 8, + "text": "Tailscale\nApp Connector", "textAlign": "center", "verticalAlign": "middle", - "containerId": "TbYffIAaUHLROZQLip0O1", - "originalText": "NAT", + "containerId": "FDZ39cZRm9-Ct19Nr-WaF", + "originalText": "Tailscale\nApp Connector", "autoResize": true, "lineHeight": 1.25 }, { - "type": "ellipse", - "version": 734, - "versionNonce": 894896691, - "index": "af", + "type": "rectangle", + "version": 451, + "versionNonce": 11941559, + "index": "b01", "isDeleted": false, - "id": "cLmj-y98IBXhXmbOl8QMR", + "id": "Dt7S1HiPH9ApEdlr4v3t3", "fillStyle": "solid", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, - "x": -164.2852399546298, - "y": 464.024812527756, + "x": -193.4632871391778, + "y": 407.4554638017299, "strokeColor": "#1e1e1e", "backgroundColor": "#ffffff", - "width": 81, - "height": 49, - "seed": 968936477, + "width": 183, + "height": 112, + "seed": 1949644983, "groupIds": [], "frameId": null, "roundness": { - "type": 2 + "type": 3 }, "boundElements": [ { "type": "text", - "id": "2aII4lGjupmh7Te3bAQF9" + "id": "BSwRx-wE4E-Hm9Gh7biKW" }, { "id": "fIinrfejF9MDIuwmsaF6S", "type": "arrow" + }, + { + "id": "y55Fi2aoF7oiOyklx0gpk", + "type": "arrow" } ], - "updated": 1719438436791, + "updated": 1763331795564, "link": null, "locked": false }, { "type": "text", - "version": 914, - "versionNonce": 627991741, - "index": "ag", + "version": 475, + "versionNonce": 1953268119, + "index": "b02", "isDeleted": false, - "id": "2aII4lGjupmh7Te3bAQF9", + "id": "BSwRx-wE4E-Hm9Gh7biKW", "fillStyle": "solid", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, - "x": -145.8930429252045, - "y": 476.20069638868557, + "x": -156.9632871391778, + "y": 438.4554638017299, "strokeColor": "#1e1e1e", "backgroundColor": "#ffffff", - "width": 43.93995666503906, - "height": 25, - "seed": 460013693, + "width": 110, + "height": 50, + "seed": 1889208791, "groupIds": [], "frameId": null, "roundness": null, "boundElements": [], - "updated": 1719438436794, + "updated": 1763331795564, "link": null, "locked": false, "fontSize": 20, - "fontFamily": 1, - "text": "ens6", + "fontFamily": 8, + "text": "Tailscale\nPeer Relay", "textAlign": "center", "verticalAlign": "middle", - "containerId": "cLmj-y98IBXhXmbOl8QMR", - "originalText": "ens6", + "containerId": "Dt7S1HiPH9ApEdlr4v3t3", + "originalText": "Tailscale\nPeer Relay", "autoResize": true, "lineHeight": 1.25 }, { - "type": "ellipse", - "version": 853, - "versionNonce": 1962757075, - "index": "ah", + "type": "diamond", + "version": 220, + "versionNonce": 1511571127, + "index": "b03", "isDeleted": false, - "id": "X6iHMvRD9iSSK46ySaRx2", + "id": "TbYffIAaUHLROZQLip0O1", "fillStyle": "solid", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, - "x": -75.65962981292932, - "y": 583.9367538899355, + "x": 61.35397869218747, + "y": 322.21426049362424, "strokeColor": "#1e1e1e", "backgroundColor": "#ffffff", - "width": 81, - "height": 49, - "seed": 1552427229, + "width": 128, + "height": 128, + "seed": 59588445, "groupIds": [], "frameId": null, "roundness": { @@ -430,176 +529,172 @@ "boundElements": [ { "type": "text", - "id": "EV0tFI3dhCVsIV9-avy6H" + "id": "LEV3HXZYCiV2uZ_j8FSK_" + }, + { + "id": "dqJloQuPSkLjlq4MOLNka", + "type": "arrow" }, { "id": "4lciJNhcvcqiU-FwOwXgm", "type": "arrow" } ], - "updated": 1719438436791, + "updated": 1763331712679, "link": null, "locked": false }, { "type": "text", - "version": 1040, - "versionNonce": 991741213, - "index": "ai", + "version": 156, + "versionNonce": 1892297561, + "index": "b04", "isDeleted": false, - "id": "EV0tFI3dhCVsIV9-avy6H", + "id": "LEV3HXZYCiV2uZ_j8FSK_", "fillStyle": "solid", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, - "x": -57.04743156280091, - "y": 596.1126377508651, + "x": 108.85397869218747, + "y": 373.71426049362424, "strokeColor": "#1e1e1e", "backgroundColor": "#ffffff", - "width": 43.49995422363281, + "width": 33, "height": 25, - "seed": 1319699773, + "seed": 835144637, "groupIds": [], "frameId": null, "roundness": null, "boundElements": [], - "updated": 1719438436794, + "updated": 1763331697303, "link": null, "locked": false, "fontSize": 20, - "fontFamily": 1, - "text": "ens5", + "fontFamily": 8, + "text": "NAT", "textAlign": "center", "verticalAlign": "middle", - "containerId": "X6iHMvRD9iSSK46ySaRx2", - "originalText": "ens5", + "containerId": "TbYffIAaUHLROZQLip0O1", + "originalText": "NAT", "autoResize": true, "lineHeight": 1.25 }, { - "type": "text", - "version": 920, - "versionNonce": 363485555, - "index": "aj", + "type": "ellipse", + "version": 802, + "versionNonce": 1179526103, + "index": "b05", "isDeleted": false, - "id": "sMLmiNSxAfYCE_VGSI79m", + "id": "cHPkS5EsVoh5BPgFFsUT8", "fillStyle": "solid", "strokeWidth": 1, "strokeStyle": "solid", - "roughness": 2, + "roughness": 1, "opacity": 100, "angle": 0, - "x": 19.136172192520462, - "y": 179.46294823776486, + "x": 84.85397869218747, + "y": 302.16672936569455, "strokeColor": "#1e1e1e", "backgroundColor": "#ffffff", - "width": 82.65992736816406, - "height": 25, - "seed": 355423645, + "width": 81, + "height": 49, + "seed": 308001757, "groupIds": [], "frameId": null, - "roundness": null, + "roundness": { + "type": 2 + }, "boundElements": [ + { + "type": "text", + "id": "DsgLC0n6qXuUnKCooQXSJ" + }, { "id": "dqJloQuPSkLjlq4MOLNka", "type": "arrow" } ], - "updated": 1719438436791, + "updated": 1763331700398, "link": null, - "locked": false, - "fontSize": 20, - "fontFamily": 1, - "text": "Internet", - "textAlign": "left", - "verticalAlign": "top", - "containerId": null, - "originalText": "Internet", - "autoResize": true, - "lineHeight": 1.25 + "locked": false }, { "type": "text", - "version": 500, - "versionNonce": 869821245, - "index": "ak", + "version": 989, + "versionNonce": 670558489, + "index": "b06", "isDeleted": false, - "id": "Ro6gyiFbVtEsDtQhVHBfY", + "id": "DsgLC0n6qXuUnKCooQXSJ", "fillStyle": "solid", "strokeWidth": 1, "strokeStyle": "solid", - "roughness": 2, + "roughness": 1, "opacity": 100, "angle": 0, - "x": -154.53179655747954, - "y": 184.72076073776486, + "x": 108.71615405413229, + "y": 314.3426132266241, "strokeColor": "#1e1e1e", "backgroundColor": "#ffffff", - "width": 70.63993835449219, + "width": 33, "height": 25, - "seed": 1800182269, + "seed": 1251096637, "groupIds": [], "frameId": null, "roundness": null, - "boundElements": [ - { - "id": "fIinrfejF9MDIuwmsaF6S", - "type": "arrow" - } - ], - "updated": 1719438436791, + "boundElements": [], + "updated": 1763331700398, "link": null, "locked": false, "fontSize": 20, - "fontFamily": 1, - "text": "Tailnet", - "textAlign": "left", - "verticalAlign": "top", - "containerId": null, - "originalText": "Tailnet", + "fontFamily": 8, + "text": "EIP", + "textAlign": "center", + "verticalAlign": "middle", + "containerId": "cHPkS5EsVoh5BPgFFsUT8", + "originalText": "EIP", "autoResize": true, "lineHeight": 1.25 }, { "type": "arrow", - "version": 2058, - "versionNonce": 1688515347, - "index": "al", + "version": 405, + "versionNonce": 1218720537, + "index": "b07", "isDeleted": false, - "id": "dqJloQuPSkLjlq4MOLNka", + "id": "4lciJNhcvcqiU-FwOwXgm", "fillStyle": "solid", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, - "x": 61.04127415127277, - "y": 298.912576868519, + "x": 126.03941933783054, + "y": 585.5092968095422, "strokeColor": "#1e1e1e", "backgroundColor": "#ffffff", - "width": 1.443560467840598, - "height": 92.44962863075415, - "seed": 704795229, + "width": 4.347936197746094e-7, + "height": 138.36452395263882, + "seed": 1045241629, "groupIds": [], "frameId": null, "roundness": { "type": 2 }, "boundElements": [], - "updated": 1719438436791, + "updated": 1763331804102, "link": null, "locked": false, "startBinding": { - "elementId": "cHPkS5EsVoh5BPgFFsUT8", - "focus": 0.015406794151970491, - "gap": 5.254328458744446 + "elementId": "FDZ39cZRm9-Ct19Nr-WaF", + "focus": 0.007491152849260278, + "gap": 1 }, "endBinding": { - "elementId": "sMLmiNSxAfYCE_VGSI79m", - "focus": 0.02636555092012574, - "gap": 2 + "elementId": "TbYffIAaUHLROZQLip0O1", + "focus": -0.010710007589175952, + "gap": 1 }, "lastCommittedPoint": null, "startArrowhead": null, @@ -610,16 +705,16 @@ 0 ], [ - -1.443560467840598, - -92.44962863075415 + 4.347936197746094e-7, + -138.36452395263882 ] ] }, { "type": "arrow", - "version": 814, - "versionNonce": 729938845, - "index": "am", + "version": 977, + "versionNonce": 4999127, + "index": "b08", "isDeleted": false, "id": "fIinrfejF9MDIuwmsaF6S", "fillStyle": "solid", @@ -628,12 +723,12 @@ "roughness": 1, "opacity": 100, "angle": 0, - "x": -118.77152731429601, - "y": 212.07318281913012, + "x": -101.38971766596134, + "y": 212.6081169765398, "strokeColor": "#1e1e1e", "backgroundColor": "#ffffff", - "width": 2.722756349132055, - "height": 249.9336680229984, + "width": 0.8166018758578559, + "height": 193.62373427988865, "seed": 237108925, "groupIds": [], "frameId": null, @@ -641,18 +736,18 @@ "type": 2 }, "boundElements": [], - "updated": 1719438436791, + "updated": 1763331795565, "link": null, "locked": false, "startBinding": { "elementId": "Ro6gyiFbVtEsDtQhVHBfY", - "focus": -0.016982465899330994, + "focus": -0.01650005352526318, "gap": 2.352422081365262 }, "endBinding": { - "elementId": "cLmj-y98IBXhXmbOl8QMR", - "focus": 0.049432799365621484, - "gap": 2.056470287828315 + "elementId": "Dt7S1HiPH9ApEdlr4v3t3", + "focus": -0.005280045002633896, + "gap": 1.223612545301421 }, "lastCommittedPoint": null, "startArrowhead": null, @@ -663,46 +758,50 @@ 0 ], [ - -2.722756349132055, - 249.9336680229984 + -0.8166018758578559, + 193.62373427988865 ] ] }, { "type": "arrow", - "version": 255, - "versionNonce": 1113774259, - "index": "an", + "version": 1087, + "versionNonce": 1002465273, + "index": "b09", "isDeleted": false, - "id": "4lciJNhcvcqiU-FwOwXgm", + "id": "y55Fi2aoF7oiOyklx0gpk", "fillStyle": "solid", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, - "x": -17.915402689395705, - "y": 585.2136593892355, + "x": -19.2637626989291, + "y": 515.7799398039883, "strokeColor": "#1e1e1e", "backgroundColor": "#ffffff", - "width": 74.38321447508974, - "height": 142.6794907440331, - "seed": 1045241629, + "width": 60.80938202411943, + "height": 75.3657473467166, + "seed": 632460375, "groupIds": [], "frameId": null, "roundness": { "type": 2 }, "boundElements": [], - "updated": 1719438436791, + "updated": 1763331804103, "link": null, "locked": false, "startBinding": { - "elementId": "X6iHMvRD9iSSK46ySaRx2", - "focus": 0.12097377146303424, - "gap": 1.015305220082741 + "elementId": "Dt7S1HiPH9ApEdlr4v3t3", + "focus": -0.2946386556947433, + "gap": 1.3877016394302444 + }, + "endBinding": { + "elementId": "FDZ39cZRm9-Ct19Nr-WaF", + "focus": -0.31129493498423455, + "gap": 1.292920622115296 }, - "endBinding": null, "lastCommittedPoint": null, "startArrowhead": null, "endArrowhead": "arrow", @@ -712,121 +811,18 @@ 0 ], [ - 74.38321447508974, - -142.6794907440331 + 60.80938202411943, + 75.3657473467166 ] ] - }, - { - "type": "rectangle", - "version": 359, - "versionNonce": 744128509, - "index": "ao", - "isDeleted": false, - "id": "VNTbtogTpQa9SfqhRygVh", - "fillStyle": "hachure", - "strokeWidth": 1, - "strokeStyle": "solid", - "roughness": 1, - "opacity": 100, - "angle": 0, - "x": -315.60250578599516, - "y": 269.44797936569455, - "strokeColor": "#1e1e1e", - "backgroundColor": "transparent", - "width": 627, - "height": 484.00000000000006, - "seed": 284504957, - "groupIds": [], - "frameId": null, - "roundness": { - "type": 3 - }, - "boundElements": [], - "updated": 1719438436791, - "link": null, - "locked": false - }, - { - "type": "ellipse", - "version": 765, - "versionNonce": 1015761491, - "index": "ap", - "isDeleted": false, - "id": "cHPkS5EsVoh5BPgFFsUT8", - "fillStyle": "solid", - "strokeWidth": 1, - "strokeStyle": "solid", - "roughness": 1, - "opacity": 100, - "angle": 0, - "x": 20.381869214004837, - "y": 304.16672936569455, - "strokeColor": "#1e1e1e", - "backgroundColor": "#ffffff", - "width": 81, - "height": 49, - "seed": 308001757, - "groupIds": [], - "frameId": null, - "roundness": { - "type": 2 - }, - "boundElements": [ - { - "type": "text", - "id": "DsgLC0n6qXuUnKCooQXSJ" - }, - { - "id": "dqJloQuPSkLjlq4MOLNka", - "type": "arrow" - } - ], - "updated": 1719438436791, - "link": null, - "locked": false - }, - { - "type": "text", - "version": 948, - "versionNonce": 1625299325, - "index": "aq", - "isDeleted": false, - "id": "DsgLC0n6qXuUnKCooQXSJ", - "fillStyle": "solid", - "strokeWidth": 1, - "strokeStyle": "solid", - "roughness": 1, - "opacity": 100, - "angle": 0, - "x": 41.94405678298091, - "y": 316.3426132266241, - "strokeColor": "#1e1e1e", - "backgroundColor": "#ffffff", - "width": 37.5999755859375, - "height": 25, - "seed": 1251096637, - "groupIds": [], - "frameId": null, - "roundness": null, - "boundElements": [], - "updated": 1719438436794, - "link": null, - "locked": false, - "fontSize": 20, - "fontFamily": 1, - "text": "EIP", - "textAlign": "center", - "verticalAlign": "middle", - "containerId": "cHPkS5EsVoh5BPgFFsUT8", - "originalText": "EIP", - "autoResize": true, - "lineHeight": 1.25 } ], "appState": { - "gridSize": null, - "viewBackgroundColor": "#ffffff" + "gridSize": 20, + "gridStep": 5, + "gridModeEnabled": false, + "viewBackgroundColor": "#ffffff", + "lockedMultiSelections": {} }, "files": {} } \ No newline at end of file diff --git a/terraform/aws/aws-ec2-autoscaling-relay-to-private-subnet/assets/aws-ec2-autoscaling-relay-to-private-subnet.png b/terraform/aws/aws-ec2-autoscaling-relay-to-private-subnet/assets/aws-ec2-autoscaling-relay-to-private-subnet.png new file mode 100644 index 0000000..ffe3c98 Binary files /dev/null and b/terraform/aws/aws-ec2-autoscaling-relay-to-private-subnet/assets/aws-ec2-autoscaling-relay-to-private-subnet.png differ diff --git a/terraform/aws/aws-ec2-autoscaling-dual-subnet/main.tf b/terraform/aws/aws-ec2-autoscaling-relay-to-private-subnet/main.tf similarity index 55% rename from terraform/aws/aws-ec2-autoscaling-dual-subnet/main.tf rename to terraform/aws/aws-ec2-autoscaling-relay-to-private-subnet/main.tf index 385a028..ccfe171 100644 --- a/terraform/aws/aws-ec2-autoscaling-dual-subnet/main.tf +++ b/terraform/aws/aws-ec2-autoscaling-relay-to-private-subnet/main.tf @@ -21,13 +21,14 @@ locals { ])}", ] + tailscale_peer_relay_port = 40000 + // Modify these to use your own VPC - vpc_cidr_block = module.vpc.vpc_cidr_block - vpc_id = module.vpc.vpc_id - subnet_id = module.vpc.public_subnets[0] - private_subnet_id = module.vpc.private_subnets[0] - security_group_ids = [aws_security_group.tailscale.id] - instance_type = "c7g.medium" + vpc_cidr_block = module.vpc.vpc_cidr_block + vpc_id = module.vpc.vpc_id + public_subnet_id = module.vpc.public_subnets[0] + private_subnet_id = module.vpc.private_subnets[0] + instance_type = "c7g.medium" } // Remove this to use your own VPC. @@ -46,35 +47,16 @@ resource "tailscale_tailnet_key" "main" { tags = local.tailscale_acl_tags } -resource "aws_network_interface" "primary" { - subnet_id = local.subnet_id - security_groups = local.security_group_ids - tags = merge(local.aws_tags, { Name = "${local.name}-primary" }) -} -resource "aws_eip" "primary" { - tags = local.aws_tags -} -resource "aws_eip_association" "primary" { - network_interface_id = aws_network_interface.primary.id - allocation_id = aws_eip.primary.id -} - -resource "aws_network_interface" "secondary" { - subnet_id = local.private_subnet_id - security_groups = local.security_group_ids - tags = merge(local.aws_tags, { Name = "${local.name}-secondary" }) -} - -module "tailscale_aws_ec2_autoscaling" { +module "connector" { source = "../internal-modules/aws-ec2-autoscaling/" autoscaling_group_name = local.name instance_type = local.instance_type instance_tags = local.aws_tags - network_interfaces = [ - aws_network_interface.primary.id, # first NIC must be in PUBLIC subnet - aws_network_interface.secondary.id, + subnet_id = local.private_subnet_id + security_group_ids = [ + aws_security_group.tailscale.id, ] # Variables for Tailscale resources @@ -87,6 +69,43 @@ module "tailscale_aws_ec2_autoscaling" { ] } +resource "tailscale_tailnet_key" "relay" { + ephemeral = true + preauthorized = true + reusable = true + recreate_if_invalid = "always" + tags = [ + "tag:example-relay", + ] +} + +module "relay" { + source = "../internal-modules/aws-ec2-autoscaling/" + + autoscaling_group_name = "${local.name}-relay" + instance_type = local.instance_type + instance_tags = merge(local.aws_tags, { + Name = "${local.name}-relay" + }) + + subnet_id = local.public_subnet_id + security_group_ids = [ + aws_security_group.tailscale.id, + aws_security_group.tailscale_peer_relay.id, + ] + + # Variables for Tailscale resources + tailscale_hostname = "${local.name}-relay" + tailscale_auth_key = tailscale_tailnet_key.relay.key + tailscale_set_preferences = [ + "--relay-server-port=${local.tailscale_peer_relay_port}", + ] + + depends_on = [ + module.vpc.nat_ids, # remove if using your own VPC otherwise ensure provisioned NAT gateway is available + ] +} + resource "aws_security_group" "tailscale" { vpc_id = local.vpc_id name = local.name @@ -120,3 +139,18 @@ resource "aws_security_group_rule" "internal_vpc_ingress_ipv4" { protocol = "-1" cidr_blocks = [local.vpc_cidr_block] } + +resource "aws_security_group" "tailscale_peer_relay" { + vpc_id = local.vpc_id + name = "${local.name}-relay" +} + +resource "aws_security_group_rule" "tailscale_peer_relay_ingress" { + security_group_id = aws_security_group.tailscale.id + type = "ingress" + from_port = local.tailscale_peer_relay_port + to_port = local.tailscale_peer_relay_port + protocol = "udp" + cidr_blocks = ["0.0.0.0/0"] + ipv6_cidr_blocks = ["::/0"] +} diff --git a/terraform/aws/aws-ec2-autoscaling-relay-to-private-subnet/outputs.tf b/terraform/aws/aws-ec2-autoscaling-relay-to-private-subnet/outputs.tf new file mode 100644 index 0000000..1113229 --- /dev/null +++ b/terraform/aws/aws-ec2-autoscaling-relay-to-private-subnet/outputs.tf @@ -0,0 +1,35 @@ +output "resource_name_prefix" { + value = local.name +} + +output "vpc_id" { + value = module.vpc.vpc_id +} + +output "vpc_cidr" { + value = module.vpc.vpc_cidr_block +} + +output "nat_public_ips" { + value = module.vpc.nat_public_ips +} + +output "connector_autoscaling_group_name" { + value = module.connector.autoscaling_group_name +} + +output "relay_autoscaling_group_name" { + value = module.relay.autoscaling_group_name +} + +output "connector_user_data_md5" { + description = "MD5 hash of the VM user_data script - for detecting changes" + value = module.connector.user_data_md5 + sensitive = true +} + +output "relay_user_data_md5" { + description = "MD5 hash of the VM user_data script - for detecting changes" + value = module.relay.user_data_md5 + sensitive = true +} diff --git a/terraform/aws/aws-ec2-autoscaling-dual-subnet/versions.tf b/terraform/aws/aws-ec2-autoscaling-relay-to-private-subnet/versions.tf similarity index 100% rename from terraform/aws/aws-ec2-autoscaling-dual-subnet/versions.tf rename to terraform/aws/aws-ec2-autoscaling-relay-to-private-subnet/versions.tf diff --git a/terraform/aws/aws-ec2-autoscaling-session-recorder/main.tf b/terraform/aws/aws-ec2-autoscaling-session-recorder/main.tf index b53d9cd..3dd660d 100644 --- a/terraform/aws/aws-ec2-autoscaling-session-recorder/main.tf +++ b/terraform/aws/aws-ec2-autoscaling-session-recorder/main.tf @@ -16,7 +16,7 @@ locals { // Modify these to use your own VPC vpc_cidr_block = module.vpc.vpc_cidr_block vpc_id = module.vpc.vpc_id - subnet_id = module.vpc.public_subnets[0] + subnet_id = module.vpc.private_subnets[0] security_group_ids = [aws_security_group.tailscale.id] instance_type = "c7g.medium" vpc_endpoint_route_table_ids = flatten([ @@ -141,19 +141,6 @@ resource "tailscale_tailnet_key" "main" { tags = local.tailscale_acl_tags } -resource "aws_network_interface" "primary" { - subnet_id = local.subnet_id - security_groups = local.security_group_ids - tags = local.aws_tags -} -resource "aws_eip" "primary" { - tags = local.aws_tags -} -resource "aws_eip_association" "primary" { - network_interface_id = aws_network_interface.primary.id - allocation_id = aws_eip.primary.id -} - module "tailscale_aws_ec2_autoscaling" { source = "../internal-modules/aws-ec2-autoscaling/" @@ -161,7 +148,8 @@ module "tailscale_aws_ec2_autoscaling" { instance_type = local.instance_type instance_tags = local.aws_tags - network_interfaces = [aws_network_interface.primary.id] + subnet_id = local.subnet_id + security_group_ids = local.security_group_ids # Variables for Tailscale resources tailscale_hostname = local.name diff --git a/terraform/aws/aws-ec2-autoscaling/main.tf b/terraform/aws/aws-ec2-autoscaling/main.tf index b68f3ba..31c5a58 100644 --- a/terraform/aws/aws-ec2-autoscaling/main.tf +++ b/terraform/aws/aws-ec2-autoscaling/main.tf @@ -45,19 +45,6 @@ resource "tailscale_tailnet_key" "main" { tags = local.tailscale_acl_tags } -resource "aws_network_interface" "primary" { - subnet_id = local.subnet_id - security_groups = local.security_group_ids - tags = local.aws_tags -} -resource "aws_eip" "primary" { - tags = local.aws_tags -} -resource "aws_eip_association" "primary" { - network_interface_id = aws_network_interface.primary.id - allocation_id = aws_eip.primary.id -} - module "tailscale_aws_ec2_autoscaling" { source = "../internal-modules/aws-ec2-autoscaling/" @@ -65,7 +52,8 @@ module "tailscale_aws_ec2_autoscaling" { instance_type = local.instance_type instance_tags = local.aws_tags - network_interfaces = [aws_network_interface.primary.id] + subnet_id = local.subnet_id + security_group_ids = local.security_group_ids # Variables for Tailscale resources tailscale_auth_key = tailscale_tailnet_key.main.key diff --git a/terraform/aws/internal-modules/aws-ec2-autoscaling/main.tf b/terraform/aws/internal-modules/aws-ec2-autoscaling/main.tf index f8d94f5..dbf1e44 100644 --- a/terraform/aws/internal-modules/aws-ec2-autoscaling/main.tf +++ b/terraform/aws/internal-modules/aws-ec2-autoscaling/main.tf @@ -7,18 +7,6 @@ module "tailscale_install_scripts" { additional_before_scripts = var.additional_before_scripts additional_after_scripts = var.additional_after_scripts - - primary_subnet_cidr = data.aws_subnet.selected[0].cidr_block - secondary_subnet_cidr = try(data.aws_subnet.selected[1].cidr_block, null) # only available if using dual subnets -} - -data "aws_network_interface" "selected" { - count = length(var.network_interfaces) - id = var.network_interfaces[count.index] -} -data "aws_subnet" "selected" { - count = length(var.network_interfaces) - id = data.aws_network_interface.selected[count.index].subnet_id } data "aws_ami" "ubuntu" { @@ -47,6 +35,12 @@ resource "aws_launch_template" "tailscale" { instance_type = var.instance_type key_name = var.instance_key_name + network_interfaces { + # associate_public_ip_address = true # TODO(clstokes): remove + subnet_id = var.subnet_id + security_groups = var.security_group_ids + } + dynamic "iam_instance_profile" { for_each = var.instance_profile_name != "" ? [1] : [] content { @@ -59,15 +53,16 @@ resource "aws_launch_template" "tailscale" { http_tokens = var.instance_metadata_options["http_tokens"] } - dynamic "network_interfaces" { - # https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/scenarios-enis.html#creating-dual-homed-instances-with-workloads-roles-on-distinct-subnets - for_each = var.network_interfaces - content { - delete_on_termination = false - device_index = network_interfaces.key - network_interface_id = network_interfaces.value - } - } + # TODO(clstokes): remove + # dynamic "network_interfaces" { + # # https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/scenarios-enis.html#creating-dual-homed-instances-with-workloads-roles-on-distinct-subnets + # for_each = var.network_interfaces + # content { + # delete_on_termination = false + # device_index = network_interfaces.key + # network_interface_id = network_interfaces.value + # } + # } tag_specifications { resource_type = "instance" @@ -91,8 +86,6 @@ resource "aws_autoscaling_group" "tailscale" { version = aws_launch_template.tailscale.latest_version } - availability_zones = [data.aws_network_interface.selected[0].availability_zone] - desired_capacity = 1 min_size = 0 max_size = 1 diff --git a/terraform/aws/internal-modules/aws-ec2-autoscaling/variables.tf b/terraform/aws/internal-modules/aws-ec2-autoscaling/variables.tf index b199934..8746e97 100644 --- a/terraform/aws/internal-modules/aws-ec2-autoscaling/variables.tf +++ b/terraform/aws/internal-modules/aws-ec2-autoscaling/variables.tf @@ -1,9 +1,11 @@ # # Variables for autoscaling resources # -variable "network_interfaces" { - description = "List of network interfaces to attach to instances - if attaching multiple for dual subnet routing, the first NIC must be the primary in the PUBLIC subnet" - type = list(string) +variable "security_group_ids" { + type = list(string) +} +variable "subnet_id" { + type = string } variable "autoscaling_group_name" { type = string diff --git a/terraform/internal-modules/tailscale-install-scripts/main.tf b/terraform/internal-modules/tailscale-install-scripts/main.tf index e5872d9..b87cd0d 100644 --- a/terraform/internal-modules/tailscale-install-scripts/main.tf +++ b/terraform/internal-modules/tailscale-install-scripts/main.tf @@ -9,7 +9,6 @@ locals { before_scripts = flatten([ # scripts to run BEFORE tailscale install var.additional_before_scripts, local.ip_forwarding_script, - local.netplan_dual_subnet_script, local.ethtool_udp_optimization_script, # run after netplan script ]), @@ -19,14 +18,6 @@ locals { } ) - netplan_dual_subnet_script = var.secondary_subnet_cidr == null ? "" : templatefile( - "${path.module}/scripts/additional-scripts/netplan-dual-subnet.tftpl", - { - primary_subnet_cidr = var.primary_subnet_cidr, - secondary_subnet_cidr = var.secondary_subnet_cidr, - } - ) - tailscale_arguments = [ "--authkey=${var.tailscale_auth_key}", "--hostname=${var.tailscale_hostname}", diff --git a/terraform/internal-modules/tailscale-install-scripts/variables-for-modules.tf b/terraform/internal-modules/tailscale-install-scripts/variables-for-modules.tf index c3d87c8..7ab2a4b 100644 --- a/terraform/internal-modules/tailscale-install-scripts/variables-for-modules.tf +++ b/terraform/internal-modules/tailscale-install-scripts/variables-for-modules.tf @@ -1,14 +1 @@ -# -# Variables for dual subnet routing resources -# Typically only used by other modules in this repo - not passed in by the examples themselves. -# -variable "primary_subnet_cidr" { - description = "For Dual Subnet only - the CIDR Block of the primary (PUBLIC) subnet. Used to derive the gateway IP." - type = string - default = null -} -variable "secondary_subnet_cidr" { - description = "For Dual Subnet only - the CIDR Block of the secondary (PRIVATE) subnet. Used to derive the gateway IP." - type = string - default = null -} +# TODO(clstokes): delete file