Skip to content
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

Supporting more rules for egress #165

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,28 @@ resource "aws_security_group_rule" "ingress_cidr_blocks" {
security_group_id = join("", aws_security_group.default.*.id)
}

resource "aws_security_group_rule" "egress" {
resource "aws_security_group_rule" "egress_cidr_blocks" {
count = local.enabled && var.egress_enabled ? 1 : 0
description = "Allow outbound traffic"
description = "Allow outbound traffic from existing CIDR blocks"
type = "egress"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
cidr_blocks = var.egress_allowed_cidr_blocks
security_group_id = join("", aws_security_group.default.*.id)
}

resource "aws_security_group_rule" "egress_security_groups" {
count = local.enabled && var.egress_enabled ? length(var.security_groups) : 0
vale21 marked this conversation as resolved.
Show resolved Hide resolved
description = "Allow outbound traffic from existing security groups"
type = "egress"
from_port = 0
to_port = 0
protocol = "-1"
source_security_group_id = var.egress_security_groups[count.index]
security_group_id = join("", aws_security_group.default.*.id)
}

# The name "primary" is poorly chosen. We actually mean standalone or regional.
# The primary cluster of a global database is actually created with the "secondary" cluster resource below.
resource "aws_rds_cluster" "primary" {
Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ variable "security_groups" {
description = "List of security groups to be allowed to connect to the DB instance"
}

variable "egress_security_groups" {
vale21 marked this conversation as resolved.
Show resolved Hide resolved
type = list(string)
default = []
description = "List of security groups to be allowed to go in outbound from the DB instance"
vale21 marked this conversation as resolved.
Show resolved Hide resolved
}

variable "vpc_id" {
type = string
description = "VPC ID to create the cluster in (e.g. `vpc-a22222ee`)"
Expand Down Expand Up @@ -211,6 +217,12 @@ variable "allowed_cidr_blocks" {
description = "List of CIDR blocks allowed to access the cluster"
}

variable "egress_allowed_cidr_blocks" {
vale21 marked this conversation as resolved.
Show resolved Hide resolved
type = list(string)
default = ["0.0.0.0/0"]
description = "List of CIDR blocks allowed to go in outbound from the cluster"
vale21 marked this conversation as resolved.
Show resolved Hide resolved
}

variable "publicly_accessible" {
type = bool
description = "Set to true if you want your cluster to be publicly accessible (such as via QuickSight)"
Expand Down