Skip to content

Commit 9e20db8

Browse files
author
Steven Nemetz
committed
Add setting security group ingress by cidr. Add name output
1 parent 3902b37 commit 9e20db8

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

main.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ resource "aws_security_group_rule" "ingress" {
6161
security_group_id = "${aws_security_group.default.id}"
6262
}
6363

64+
resource "aws_security_group_rule" "ingress_cidr" {
65+
count = "${module.enabled.value && length(compact(var.ingress_cidr)) > 0 ? 1 : 0}"
66+
type = "ingress"
67+
from_port = "2049"
68+
to_port = "2049"
69+
protocol = "tcp"
70+
cidr_blocks = ["${var.ingress_cidr}"]
71+
security_group_id = "${aws_security_group.default.id}"
72+
}
73+
6474
resource "aws_security_group_rule" "egress" {
6575
count = "${module.enabled.value}"
6676
type = "egress"

outputs.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// EFS File System outputs
22
output "dns_name" {
3-
description = ""
3+
description = "FQDN of the EFS volume"
44
value = "${element(concat(aws_efs_file_system.default.*.dns_name, list("")),0)}"
55
}
66

@@ -14,6 +14,11 @@ output "kms_key_id" {
1414
value = "${element(concat(aws_efs_file_system.default.*.kms_key_id, list("")),0)}"
1515
}
1616

17+
output "name" {
18+
description = "Service name that was passed in. This is to make creating mount points easier"
19+
value = "${module.label.name}"
20+
}
21+
1722
// EFS Mount Target outputs
1823
/*
1924
# Same as EFS mount_target_dns_names

test/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module "efs" {
99
zone_id = "ZURF67XJUWC5A" # one
1010

1111
security_groups = []
12+
ingress_cidr = ["10.0.0.0/8"]
1213
subnets = ["subnet-857efce3", "subnet-0852f140", "subnet-6395c038"]
1314
vpc_id = "vpc-417c0027" # one
1415

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ variable "encrypted" {
6868
default = "false"
6969
}
7070

71+
variable "ingress_cidr" {
72+
description = "List of CIDR to allow access to EFS"
73+
type = "list"
74+
default = []
75+
}
76+
7177
variable "kms_key_id" {
7278
description = "ARN for the KMS encryption key. When specifying kms_key_id, encrypted needs to be set to true"
7379
type = "string"

0 commit comments

Comments
 (0)