Skip to content

Commit

Permalink
Merge pull request #186 from trussworks/sg-vpc-ports
Browse files Browse the repository at this point in the history
Fix inputs for check_vpc_sg_open_only_to_authorized_ports rule
  • Loading branch information
jsarnovsky authored Jul 12, 2023
2 parents d50d890 + 797d879 commit 78d6c14
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 24 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,7 @@ No modules.
| resource\_types | A list that specifies the types of AWS resources for which AWS Config records configuration changes (for example, AWS::EC2::Instance or AWS::CloudTrail::Trail). See relevant part of AWS Docs for available types. | `list(string)` | `[]` | no |
| s3\_bucket\_public\_access\_prohibited\_exclusion | Comma-separated list of known allowed public Amazon S3 bucket names. | `string` | `"example,CSV"` | no |
| tags | Tags to apply to AWS Config resources | `map(string)` | `{}` | no |
| vpc\_sg\_authorized\_TCP\_ports | Comma-separated list of TCP ports authorized to be open to 0.0.0.0/0. Ranges are defined by dash. example, '443,1020-1025' | `string` | `"none"` | no |
| vpc\_sg\_authorized\_UDP\_ports | Comma-separated list of UDP ports authorized to be open to 0.0.0.0/0. Ranges are defined by dash. example, '500,1020-1025' | `string` | `"none"` | no |
| vpc\_sg\_authorized\_ports | Object with values as Comma-separated list of ports authorized to be open to 0.0.0.0/0. Ranges are defined by dash. example, '443,1020-1025' | ```object({ authorizedTcpPorts = optional(string, null) authorizedUdpPorts = optional(string, null) })``` | `{}` | no |

## Outputs

Expand Down
4 changes: 0 additions & 4 deletions config-policies/vpc_sg_authorized_ports.tpl

This file was deleted.

8 changes: 2 additions & 6 deletions config-rules.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,8 @@ locals {
}
)

aws_config_vpc_sg_authorized_ports = templatefile("${path.module}/config-policies/vpc_sg_authorized_ports.tpl",
{
vpc_sg_authorized_TCP_ports = var.vpc_sg_authorized_TCP_ports
vpc_sg_authorized_UDP_ports = var.vpc_sg_authorized_UDP_ports
}
)
aws_config_vpc_sg_authorized_ports = jsonencode({ for k, v in var.vpc_sg_authorized_ports : k => tostring(v) if v != null })

}


Expand Down
19 changes: 7 additions & 12 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -525,18 +525,13 @@ variable "check_vpc_sg_open_only_to_authorized_ports" {
default = false
}

variable "vpc_sg_authorized_TCP_ports" {
description = "Comma-separated list of TCP ports authorized to be open to 0.0.0.0/0. Ranges are defined by dash. example, '443,1020-1025'"
type = string
#default value can't be blank
default = "none"
}

variable "vpc_sg_authorized_UDP_ports" {
description = "Comma-separated list of UDP ports authorized to be open to 0.0.0.0/0. Ranges are defined by dash. example, '500,1020-1025'"
type = string
#default value can't be blank
default = "none"
variable "vpc_sg_authorized_ports" {
description = "Object with values as Comma-separated list of ports authorized to be open to 0.0.0.0/0. Ranges are defined by dash. example, '443,1020-1025'"
type = object({
authorizedTcpPorts = optional(string, null)
authorizedUdpPorts = optional(string, null)
})
default = {}
}

variable "resource_types" {
Expand Down

0 comments on commit 78d6c14

Please sign in to comment.