-
-
Notifications
You must be signed in to change notification settings - Fork 575
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
Conversation
main.tf
Outdated
@@ -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)}" |
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.
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
@max-rocket-internet thanks for pointing that out. maybe we can just add ingress in aws_security_group
and remove
|
…rity_groups_count variable
Test it and if it works in the same way, sure. Note: resource "aws_security_group" "this" {
name_prefix = "${var.name}-"
ingress {
from_port = "${local.port}"
to_port = "${local.port}"
protocol = "tcp"
security_groups = ["${var.allowed_security_groups}"]
}
} |
from_port = "${local.port}" | ||
to_port = "${local.port}" | ||
protocol = "tcp" | ||
security_groups = "${var.allowed_security_groups}" |
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.
I think is is a list: security_groups = ["${var.allowed_security_groups}"]
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.
if we make it like that. it will become a list within a list since allowed_security_groups is already a list. won't it? already tested it earlier and it worked as i expected.
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.
if we make it like that. it will become a list within a list
Nope. It's just how TF works. e.g. https://github.com/terraform-aws-modules/terraform-aws-vpc/blob/master/main.tf#L44
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.
oh thanks. didn't know that. but it's still working the way i have designed it. should i change it for consistency?
I think we need to keep this as it is now because there are situations when the security groups created and used for an RDS contain not just a single ingress rule but also other rules. Using mix of inline |
We can add cidr block and even self (introduction of new variables) on the aws_security_group as far as db is concerned it will only need to allow one port from different sources, and that is from SGs, CIDR blocks and itself. as it is not recommended to always edit the module, for a more custom made security group we can add a different variable for a list of seperately created security groups that we would attach to the db cluster. which i guess is for a different pull request. |
With the changes proposed it is not possible to allow access from CIDR blocks (ipv4, ipv6), self, prefix lists. It is also not possible to mix this with other rules (created using |
i didn't mean to mix with *haven't inserted the |
Ok, try to make it work and see what happens. The scenario is to get this module to create a RDS resources and:
If you can make this to work without using |
@antonbabenko i added additional variables for sorry, i didn't notice that my changes on the use of externally created db_subnet_group was committed as well. i was thinking of doing this. but i only got to finish the db subnet group part today
|
Will redo the commits. thanks for the inputs. |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
No description provided.