Repository navigation
Move admin SSH CIDR to a variable and add it as an output #191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,11 @@ output "ecs_ami_name" { | |
| value = local.ecs_ami["image_name"] | ||
| } | ||
|
|
||
| output "admin_ssh_cidr" { | ||
| description = "CIDR allowed to SSH to the ECS instances" | ||
| value = var.admin_ssh_cidr | ||
| } | ||
|
|
||
| # https://registry.terraform.io/modules/terraform-aws-modules/autoscaling/aws/latest | ||
| module "autoscaling" { | ||
| source = "terraform-aws-modules/autoscaling/aws" | ||
|
|
@@ -150,7 +155,7 @@ module "autoscaling_sg" { | |
| ingress_with_cidr_blocks = [ | ||
| { | ||
| rule = "ssh-tcp" | ||
| cidr_blocks = "71.237.173.68/32" | ||
| cidr_blocks = var.admin_ssh_cidr | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. low bug, confidence medium, pass review No validation of CIDR format in required variable The variable is a bare string with no validation block. An empty or malformed value (for example an unset tfvars entry set to an empty string) will only fail at apply time inside the AWS API, or could yield an unintended rule. A validation using cidrhost or can(cidrnetmask) would catch this at plan time. Model output from untrusted input. Check it before you act on it. |
||
| } | ||
| ] | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| variable "admin_ssh_cidr" { | ||
| description = "CIDR allowed to SSH to the ECS instances. Set in terraform.tfvars, which git ignores." | ||
| type = string | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. low security, confidence low, pass security No validation on SSH CIDR variable admin_ssh_cidr accepts any string and feeds the security group SSH ingress rule. An operator could set 0.0.0.0/0 by mistake, which would expose SSH to the internet. The input comes from the operator's tfvars, so the impact is limited, but a validation block could reject overly broad ranges. The old value was a fixed /32. Model output from untrusted input. Check it before you act on it. |
||
|
|
||
| validation { | ||
| condition = can(cidrhost(var.admin_ssh_cidr, 0)) && endswith(var.admin_ssh_cidr, "/32") | ||
| error_message = "admin_ssh_cidr must be a single IPv4 address in CIDR form, such as 203.0.113.10/32." | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
low security, confidence low, pass security
Admin IP exposed via Terraform output
The output prints the admin SSH CIDR to the CLI, to CI logs and to remote state readers. This partly defeats the goal of keeping the admin IP out of public view. The exposure is minor, since the value is a single allowlisted IP and not a credential. An attacker would need access to the logs or the state.
Model output from untrusted input. Check it before you act on it.