Skip to content

Commit f34fc47

Browse files
authored
Merge pull request #183 from NetApp/rvwn_sg_list
Changed to support a list of security groups instead of just one security group
2 parents 2482172 + 2b9a784 commit f34fc47

File tree

4 files changed

+36
-36
lines changed

4 files changed

+36
-36
lines changed

Terraform/deploy-fsx-ontap/standalone-module/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* [License](#license)
1111

1212
## Introduction
13-
This sample demonstrates how to deploy an FSx for NetApp ONTAP file system, including an SVM and a FlexVolume in that file system, using AWS Terraform provider in a standalone Terraform module.
13+
This sample demonstrates how to deploy an FSx for NetApp ONTAP file system, including an SVM and a FlexVolume in that file system, using AWS Terraform provider in a standalone Terraform module.
1414
Follow the instructions below to use this sample in your own environment.
1515
### Repository Overview
1616
This is a standalone Terraform configuration repository that contains the following files:
@@ -43,7 +43,7 @@ Running this terraform sample will result the following:
4343
* A new FSx for Netapp ONTAP file-system. Much of the configuration is defined in the `variables.tf` file, but the following are the default values:
4444
* 1024Gb of storage capacity
4545
* Generation 1 Multi AZ deployment type
46-
* 128Mbps of throughput capacity
46+
* 128Mbps of throughput capacity
4747
* 1 HA pair
4848
* 1 Storage Virtual Machine (SVM)
4949
* 1 FlexVol volume with the following configuration parameters:
@@ -52,7 +52,7 @@ Running this terraform sample will result the following:
5252
* Security style of UNIX
5353
* Storage efficiencies enabled
5454
* Auto tiering policy with 31 cooling days
55-
* post-delete backup disabled
55+
* post-delete backup disabled
5656

5757
## Prerequisites
5858

@@ -107,7 +107,7 @@ value was retrieved, and the configuration variable name.
107107
### 1. Clone the repository
108108
In your server's terminal, navigate to the location where you wish to store this Terraform repository, and clone the repository using your preferred authentication type. In this example we are using HTTPS clone:
109109

110-
```shell
110+
```shell
111111
git clone https://github.com/NetApp/FSx-ONTAP-samples-scripts.git
112112
```
113113

@@ -211,7 +211,7 @@ terraform apply
211211
| route_table_ids | An array of routing table IDs that will be modified to allow access to the FSxN file system. This is only used for Multi AZ deployment types and must be left as null for Single AZ deployment types. | `list(string)` | `null` | no |
212212
| secret_name_prefix | The prefix to the secret names created that will contain the FSxN passwords (system, and SVM). | `string` | `"fsxn-secret"` | no |
213213
| secret_region | The AWS region where the secrets for the FSxN file system and SVM will be deployed. | `string` | `"us-west-2"` | no |
214-
| security_group_id | If you are not creating the security group, provide the ID of the security group to be used. | `string` | `""` | no |
214+
| security_group_ids | If you are not creating the security group, provide a list of IDs of security groups to be used. | `list(string)` | `[]` | no |
215215
| security_group_name_prefix | The prefix to the security group name that will be created. | `string` | `"fsxn-sg"` | no |
216216
| source_sg_id | The ID of the security group to allow access to the FSxN file system. Set to an empty string if you want to use the cidr_for_sg as the source. | `string` | `""` | no |
217217
| svm_name | The name of the Storage Virtual Machine | `string` | `"fsx"` | no |

Terraform/deploy-fsx-ontap/standalone-module/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ module "fsxn_rotate_secret" {
3232
}
3333

3434
/*
35-
* The following resources are for deploying a complete FSx ONTAP file system.
35+
* The following resources are for deploying a complete FSx ONTAP file system.
3636
* The code below deploys the following resources in this order:
37-
* 1. A file system
37+
* 1. A file system
3838
* 2. A storage virtual machine
3939
* 3. A volume within the storage virtual machine
4040
*/
@@ -43,7 +43,7 @@ resource "aws_fsx_ontap_file_system" "terraform-fsxn" {
4343
preferred_subnet_id = var.fsx_subnets["primarysub"]
4444

4545
storage_capacity = var.fsx_capacity_size_gb
46-
security_group_ids = var.create_sg ? [element(aws_security_group.fsx_sg[*].id, 0)] : [var.security_group_id]
46+
security_group_ids = var.create_sg ? [element(aws_security_group.fsx_sg[*].id, 0)] : var.security_group_ids
4747
deployment_type = var.fsx_deploy_type
4848
throughput_capacity_per_ha_pair = var.fsx_tput_in_MBps
4949
ha_pairs = var.ha_pairs

Terraform/deploy-fsx-ontap/standalone-module/security_groups.tf

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* The following defines a Security Group for FSx ONTAP that allows the required ports for NFS, CIFS,
33
* Kerberos, and iSCSI as well as SnapMirror.
44
*
@@ -23,7 +23,7 @@ resource "aws_vpc_security_group_ingress_rule" "all_icmp" {
2323
count = var.create_sg ? 1 : 0
2424
security_group_id = aws_security_group.fsx_sg[count.index].id
2525
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
26-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
26+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
2727
from_port = -1
2828
to_port = -1
2929
ip_protocol = "icmp"
@@ -34,7 +34,7 @@ resource "aws_vpc_security_group_ingress_rule" "nfs_tcp" {
3434
count = var.create_sg ? 1 : 0
3535
security_group_id = aws_security_group.fsx_sg[count.index].id
3636
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
37-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
37+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
3838
from_port = 111
3939
to_port = 111
4040
ip_protocol = "tcp"
@@ -45,7 +45,7 @@ resource "aws_vpc_security_group_ingress_rule" "nfs_udp" {
4545
count = var.create_sg ? 1 : 0
4646
security_group_id = aws_security_group.fsx_sg[count.index].id
4747
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
48-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
48+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
4949
from_port = 111
5050
to_port = 111
5151
ip_protocol = "udp"
@@ -56,7 +56,7 @@ resource "aws_vpc_security_group_ingress_rule" "cifs" {
5656
count = var.create_sg ? 1 : 0
5757
security_group_id = aws_security_group.fsx_sg[count.index].id
5858
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
59-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
59+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
6060
from_port = 139
6161
to_port = 139
6262
ip_protocol = "tcp"
@@ -67,7 +67,7 @@ resource "aws_vpc_security_group_ingress_rule" "snmp_tcp" {
6767
count = var.create_sg ? 1 : 0
6868
security_group_id = aws_security_group.fsx_sg[count.index].id
6969
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
70-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
70+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
7171
from_port = 161
7272
to_port = 162
7373
ip_protocol = "tcp"
@@ -78,7 +78,7 @@ resource "aws_vpc_security_group_ingress_rule" "snmp_udp" {
7878
count = var.create_sg ? 1 : 0
7979
security_group_id = aws_security_group.fsx_sg[count.index].id
8080
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
81-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
81+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
8282
from_port = 161
8383
to_port = 162
8484
ip_protocol = "udp"
@@ -89,7 +89,7 @@ resource "aws_vpc_security_group_ingress_rule" "smb_cifs" {
8989
count = var.create_sg ? 1 : 0
9090
security_group_id = aws_security_group.fsx_sg[count.index].id
9191
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
92-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
92+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
9393
from_port = 445
9494
to_port = 445
9595
ip_protocol = "tcp"
@@ -100,7 +100,7 @@ resource "aws_vpc_security_group_ingress_rule" "nfs_mount_tcp" {
100100
count = var.create_sg ? 1 : 0
101101
security_group_id = aws_security_group.fsx_sg[count.index].id
102102
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
103-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
103+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
104104
from_port = 635
105105
to_port = 635
106106
ip_protocol = "tcp"
@@ -111,7 +111,7 @@ resource "aws_vpc_security_group_ingress_rule" "kerberos" {
111111
count = var.create_sg ? 1 : 0
112112
security_group_id = aws_security_group.fsx_sg[count.index].id
113113
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
114-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
114+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
115115
from_port = 749
116116
to_port = 749
117117
ip_protocol = "tcp"
@@ -122,7 +122,7 @@ resource "aws_vpc_security_group_ingress_rule" "nfs_server_daemon" {
122122
count = var.create_sg ? 1 : 0
123123
security_group_id = aws_security_group.fsx_sg[count.index].id
124124
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
125-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
125+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
126126
from_port = 2049
127127
to_port = 2049
128128
ip_protocol = "tcp"
@@ -133,7 +133,7 @@ resource "aws_vpc_security_group_ingress_rule" "nfs_server_daemon_udp" {
133133
count = var.create_sg ? 1 : 0
134134
security_group_id = aws_security_group.fsx_sg[count.index].id
135135
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
136-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
136+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
137137
from_port = 2049
138138
to_port = 2049
139139
ip_protocol = "udp"
@@ -144,7 +144,7 @@ resource "aws_vpc_security_group_ingress_rule" "nfs_lock_daemon" {
144144
count = var.create_sg ? 1 : 0
145145
security_group_id = aws_security_group.fsx_sg[count.index].id
146146
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
147-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
147+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
148148
from_port = 4045
149149
to_port = 4045
150150
ip_protocol = "tcp"
@@ -155,7 +155,7 @@ resource "aws_vpc_security_group_ingress_rule" "nfs_lock_daemon_udp" {
155155
count = var.create_sg ? 1 : 0
156156
security_group_id = aws_security_group.fsx_sg[count.index].id
157157
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
158-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
158+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
159159
from_port = 4045
160160
to_port = 4045
161161
ip_protocol = "udp"
@@ -166,7 +166,7 @@ resource "aws_vpc_security_group_ingress_rule" "nfs_status_monitor" {
166166
count = var.create_sg ? 1 : 0
167167
security_group_id = aws_security_group.fsx_sg[count.index].id
168168
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
169-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
169+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
170170
from_port = 4046
171171
to_port = 4046
172172
ip_protocol = "tcp"
@@ -177,7 +177,7 @@ resource "aws_vpc_security_group_ingress_rule" "nfs_status_monitor_udp" {
177177
count = var.create_sg ? 1 : 0
178178
security_group_id = aws_security_group.fsx_sg[count.index].id
179179
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
180-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
180+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
181181
from_port = 4046
182182
to_port = 4046
183183
ip_protocol = "udp"
@@ -188,7 +188,7 @@ resource "aws_vpc_security_group_ingress_rule" "nfs_rquotad" {
188188
count = var.create_sg ? 1 : 0
189189
security_group_id = aws_security_group.fsx_sg[count.index].id
190190
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
191-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
191+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
192192
from_port = 4049
193193
to_port = 4049
194194
ip_protocol = "udp"
@@ -199,7 +199,7 @@ resource "aws_vpc_security_group_ingress_rule" "iscsi_tcp" {
199199
count = var.create_sg ? 1 : 0
200200
security_group_id = aws_security_group.fsx_sg[count.index].id
201201
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
202-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
202+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
203203
from_port = 3260
204204
to_port = 3260
205205
ip_protocol = "tcp"
@@ -210,7 +210,7 @@ resource "aws_vpc_security_group_ingress_rule" "Snapmirror_Intercluster_communic
210210
count = var.create_sg ? 1 : 0
211211
security_group_id = aws_security_group.fsx_sg[count.index].id
212212
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
213-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
213+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
214214
from_port = 11104
215215
to_port = 11104
216216
ip_protocol = "tcp"
@@ -221,7 +221,7 @@ resource "aws_vpc_security_group_ingress_rule" "Snapmirror_data_transfer" {
221221
count = var.create_sg ? 1 : 0
222222
security_group_id = aws_security_group.fsx_sg[count.index].id
223223
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
224-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
224+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
225225
from_port = 11105
226226
to_port = 11105
227227
ip_protocol = "tcp"
@@ -232,7 +232,7 @@ resource "aws_vpc_security_group_ingress_rule" "nfs_mount_udp" {
232232
count = var.create_sg ? 1 : 0
233233
security_group_id = aws_security_group.fsx_sg[count.index].id
234234
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
235-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
235+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
236236
from_port = 635
237237
to_port = 635
238238
ip_protocol = "udp"
@@ -243,7 +243,7 @@ resource "aws_vpc_security_group_ingress_rule" "ssh" {
243243
count = var.create_sg ? 1 : 0
244244
security_group_id = aws_security_group.fsx_sg[count.index].id
245245
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
246-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
246+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
247247
from_port = 22
248248
to_port = 22
249249
ip_protocol = "tcp"
@@ -254,7 +254,7 @@ resource "aws_vpc_security_group_ingress_rule" "s3_and_api" {
254254
count = var.create_sg ? 1 : 0
255255
security_group_id = aws_security_group.fsx_sg[count.index].id
256256
cidr_ipv4 = (var.cidr_for_sg != "" ? var.cidr_for_sg : null)
257-
referenced_security_group_id = (var.security_group_id != "" ? var.security_group_id : null)
257+
referenced_security_group_id = (var.source_sg_id != "" ? var.source_sg_id : null)
258258
from_port = 443
259259
to_port = 443
260260
ip_protocol = "tcp"

Terraform/deploy-fsx-ontap/standalone-module/variables.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ variable "fsx_name" {
66

77
variable "fsx_deploy_type" {
88
description = "The file system deployment type. Supported values are 'MULTI_AZ_1', 'SINGLE_AZ_1', 'MULTI_AZ_2', and 'SINGLE_AZ_2'. MULTI_AZ_1 and SINGLE_AZ_1 are Gen 1. MULTI_AZ_2 and SINGLE_AZ_2 are Gen 2."
9-
type = string
9+
type = string
1010
default = "MULTI_AZ_1"
1111
validation {
1212
condition = contains(["MULTI_AZ_1", "SINGLE_AZ_1", "MULTI_AZ_2", "SINGLE_AZ_2"], var.fsx_deploy_type)
@@ -186,10 +186,10 @@ variable "create_sg" {
186186
default = true
187187
}
188188

189-
variable "security_group_id" {
190-
description = "If you are not creating the security group, provide the ID of the security group to be used."
191-
type = string
192-
default = ""
189+
variable "security_group_ids" {
190+
description = "If you are not creating the security group, provide a list of IDs of security groups to be used."
191+
type = list(string)
192+
default = []
193193
}
194194

195195
variable "security_group_name_prefix" {

0 commit comments

Comments
 (0)