Skip to content

Commit f38a8ca

Browse files
irvingpopclaude
andauthored
Move admin SSH CIDR to a variable and add it as an output (#191)
* Move admin SSH CIDR to a variable and add it as an output The admin home IP changed. Move the SSH CIDR to the admin_ssh_cidr variable, set in the git-ignored terraform.tfvars, so the IP is not committed to git. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Validate admin_ssh_cidr is a single IPv4 /32 Reject malformed values and wide ranges such as 0.0.0.0/0 at plan time. Addresses review feedback on the PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 3263bb7 commit f38a8ca

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎terraform/asg.tf‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ output "ecs_ami_name" {
1616
value = local.ecs_ami["image_name"]
1717
}
1818

19+
output "admin_ssh_cidr" {
20+
description = "CIDR allowed to SSH to the ECS instances"
21+
value = var.admin_ssh_cidr
22+
}
23+
1924
# https://registry.terraform.io/modules/terraform-aws-modules/autoscaling/aws/latest
2025
module "autoscaling" {
2126
source = "terraform-aws-modules/autoscaling/aws"
@@ -150,7 +155,7 @@ module "autoscaling_sg" {
150155
ingress_with_cidr_blocks = [
151156
{
152157
rule = "ssh-tcp"
153-
cidr_blocks = "71.237.173.68/32"
158+
cidr_blocks = var.admin_ssh_cidr
154159
}
155160
]
156161

‎terraform/variables.tf‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
variable "admin_ssh_cidr" {
2+
description = "CIDR allowed to SSH to the ECS instances. Set in terraform.tfvars, which git ignores."
3+
type = string
4+
5+
validation {
6+
condition = can(cidrhost(var.admin_ssh_cidr, 0)) && endswith(var.admin_ssh_cidr, "/32")
7+
error_message = "admin_ssh_cidr must be a single IPv4 address in CIDR form, such as 203.0.113.10/32."
8+
}
9+
}

0 commit comments

Comments
 (0)