Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

remove allowed_security_groups_count variable #39

Closed
wants to merge 4 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
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ module "db" {

replica_count = 1
allowed_security_groups = ["sg-12345678"]
allowed_security_groups_count = 1
instance_type = "db.r4.large"
storage_encrypted = true
apply_immediately = true
Expand Down Expand Up @@ -65,7 +64,6 @@ Terraform documentation is generated automatically using [pre-commit hooks](http
| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| allowed\_security\_groups | A list of Security Group ID's to allow access to. | list | `[]` | no |
| allowed\_security\_groups\_count | The number of Security Groups being added, terraform doesn't let us use length() in a count field | string | `"0"` | no |
| apply\_immediately | Determines whether or not any DB modifications are applied immediately, or during the maintenance window | string | `"false"` | no |
| auto\_minor\_version\_upgrade | Determines whether minor engine upgrades will be performed automatically in the maintenance window | string | `"true"` | no |
| backup\_retention\_period | How long to keep backups for (in days) | string | `"7"` | no |
Expand Down
3 changes: 2 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
locals {
port = "${var.port == "" ? "${var.engine == "aurora-postgresql" ? "5432" : "3306"}" : var.port}"
master_password = "${var.password == "" ? random_id.master_password.b64 : var.password}"
sg_count = "${length(var.allowed_security_groups)}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this won't always work. That's why it's implemented with allowed_security_groups_count in this module and many others. Moving the count to a local doesn't always work either.

Reference: hashicorp/terraform#12570

}

# Random string to use as master password unless one is specified
Expand Down Expand Up @@ -142,7 +143,7 @@ resource "aws_security_group" "this" {
}

resource "aws_security_group_rule" "default_ingress" {
count = "${var.allowed_security_groups_count}"
count = "${local.sg_count}"

type = "ingress"
from_port = "${aws_rds_cluster.this.port}"
Expand Down
5 changes: 0 additions & 5 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ variable "allowed_security_groups" {
default = []
}

variable "allowed_security_groups_count" {
description = "The number of Security Groups being added, terraform doesn't let us use length() in a count field"
default = 0
}

variable "vpc_id" {
description = "VPC ID"
}
Expand Down