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

Adds allowed_cidr_blocks support to RDS SG #43

Merged
merged 3 commits into from
Oct 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ module "rds_instance" {
dns_zone_id = "Z89FN1IW975KPE"
host_name = "db"
security_group_ids = ["sg-xxxxxxxx"]
allowed_cidr_blocks = ["XXX.XXX.XXX.XXX/32"]
database_name = "wordpress"
database_user = "admin"
database_password = "xxxxxxxxxxxx"
Expand Down Expand Up @@ -130,6 +131,7 @@ Available targets:
|------|-------------|:----:|:-----:|:-----:|
| allocated_storage | The allocated storage in GBs | number | - | yes |
| allow_major_version_upgrade | Allow major version upgrade | bool | `false` | no |
| allowed_cidr_blocks | The whitelisted CIDRs which to allow `ingress` traffic to the DB instance | list(string) | `<list>` | no |
| apply_immediately | Specifies whether any database modifications are applied immediately, or during the next maintenance window | bool | `false` | no |
| associate_security_group_ids | The IDs of the existing security groups to associate with the DB instance | list(string) | `<list>` | no |
| attributes | Additional attributes (e.g. `1`) | list(string) | `<list>` | no |
Expand Down
1 change: 1 addition & 0 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ usage: |-
dns_zone_id = "Z89FN1IW975KPE"
host_name = "db"
security_group_ids = ["sg-xxxxxxxx"]
allowed_cidr_blocks = ["XXX.XXX.XXX.XXX/32"]
database_name = "wordpress"
database_user = "admin"
database_password = "xxxxxxxxxxxx"
Expand Down
1 change: 1 addition & 0 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
|------|-------------|:----:|:-----:|:-----:|
| allocated_storage | The allocated storage in GBs | number | - | yes |
| allow_major_version_upgrade | Allow major version upgrade | bool | `false` | no |
| allowed_cidr_blocks | The whitelisted CIDRs which to allow `ingress` traffic to the DB instance | list(string) | `<list>` | no |
| apply_immediately | Specifies whether any database modifications are applied immediately, or during the next maintenance window | bool | `false` | no |
| associate_security_group_ids | The IDs of the existing security groups to associate with the DB instance | list(string) | `<list>` | no |
| attributes | Additional attributes (e.g. `1`) | list(string) | `<list>` | no |
Expand Down
7 changes: 7 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ resource "aws_security_group" "default" {
description = "Allow inbound traffic from the security groups"
vpc_id = var.vpc_id

ingress {
from_port = var.database_port
to_port = var.database_port
protocol = "tcp"
cidr_blocks = var.allowed_cidr_blocks
}

ingress {
from_port = var.database_port
to_port = var.database_port
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ variable "security_group_ids" {
description = "The IDs of the security groups from which to allow `ingress` traffic to the DB instance"
}

variable "allowed_cidr_blocks" {
type = list(string)
default = []
description = "The whitelisted CIDRs which to allow `ingress` traffic to the DB instance"
}

variable "associate_security_group_ids" {
type = list(string)
default = []
Expand Down