Skip to content

Commit 92b220f

Browse files
authored
Merge pull request #149 from NetApp/update_terraform_fsxn
Some minor, mostly cosmetic updates.
2 parents b269cc5 + 0631f32 commit 92b220f

File tree

5 files changed

+47
-51
lines changed

5 files changed

+47
-51
lines changed

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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ module "fsxontap" {
133133
primarysub = "<YOUR-PRIMARY-SUBNET>"
134134
secondarysub = "<YOUR-SECONDAY-SUBNET>"
135135
}
136-
create_sg = <true / false> // true to create Security Group for the Fs / false otherwise
136+
create_sg = true // true to create Security Group for the Fs / false otherwise
137137
cidr_for_sg = "<YOUR-CIDR-BLOCK>"
138-
fsx_admin_password = "<YOUR_PASSWORD>"
138+
fsx_secret_name = "<YOUR_SECRET>" // The name of a secret in AWS Secrets Manager that contains the FSxN admin password.
139139
tags = {
140140
Terraform = "true"
141141
Environment = "dev"
@@ -147,7 +147,7 @@ module "fsxontap" {
147147
> To Override default values assigned to other variables in this module, add them to this source block as well. The above source block includes the minimum requirements only.
148148
149149
> [!NOTE]
150-
> The default deployment type is: MULTI_AZ_1. For SINGLE AZ deployment, override the `fsx_deploy_type` variable in the module block, and make sure to only provide one subnet as `primarysub`
150+
> The default deployment type is: MULTI_AZ_1. For SINGLE AZ deployment, set the `fsx_deploy_type` variable to SINGLE_AZ_1 in the module block.
151151
152152
Please read the vriables descriptions in `variables.tf` file for more information regarding the variables passed to the module block.
153153

@@ -166,31 +166,29 @@ terraform {
166166
}
167167
168168
provider "aws" {
169-
shared_config_files = ["$HOME/.aws/conf"]
170-
shared_credentials_files = ["$HOME/.aws/credentials"]
171169
region = "us-west-2"
172170
}
173171
174172
175173
module "fsxontap" {
176174
source = "github.com/Netapp/FSx-ONTAP-samples-scripts/Terraform/deploy-fsx-ontap/module"
177175
176+
name = "fsxontap"
177+
178178
vpc_id = "vpc-111111111"
179179
fsx_subnets = {
180180
"primarysub" = "subnet-11111111"
181181
"secondarysub" = "subnet-2222222"
182182
}
183183
create_sg = true
184184
cidr_for_sg = "10.0.0.0/8"
185-
fsx_admin_password = "yourpassword"
185+
fsx_secret_name = "fsx_secret"
186186
route_table_ids = ["rtb-111111"]
187187
tags = {
188188
Terraform = "true"
189189
Environment = "dev"
190190
}
191191
}
192-
193-
194192
```
195193

196194
### Install the module
@@ -240,7 +238,7 @@ Ensure that the proposed changes match what you expected before you apply the ch
240238
241239
Once confirmed, run the `terraform apply` command followed by `yes` to execute the Terrafom code and apply the changes proposed in the `plan` step:
242240
```shell
243-
terraform apply -y
241+
terraform apply
244242
```
245243
246244
<!-- BEGIN_TF_DOCS -->
@@ -259,25 +257,26 @@ terraform apply -y
259257
|------|-------------|------|---------|:--------:|
260258
| backup_retention_days | The number of days to retain automatic backups. Setting this to 0 disables automatic backups. You can retain automatic backups for a maximum of 90 days. | `number` | `0` | no |
261259
| cidr_for_sg | cidr block to be used for the created security ingress rules. | `string` | `"10.0.0.0/8"` | no |
262-
| create_sg | Determines whether the SG should be deployed as part of this execution or not | `bool` | `true` | no |
260+
| create_sg | Determines whether the SG should be deployed as part of this deployment or not. | `bool` | `true` | no |
263261
| daily_backup_start_time | A recurring daily time, in the format HH:MM. HH is the zero-padded hour of the day (0-23), and MM is the zero-padded minute of the hour. Requires automatic_backup_retention_days to be set. | `string` | `"00:00"` | no |
264262
| disk_iops_configuration | The SSD IOPS configuration for the file system. Valid modes are 'AUTOMATIC' (3 iops per GB provided) or 'USER_PROVISIONED'. NOTE: Due to a bug in the AWS FSx provider, if you want AUTOMATIC, then leave this variable empty. If you want USER_PROVIDEDED, then add a 'mode=USER_PROVISIONED' (with USER_PROVISIONED enclosed in doube quotes) and 'iops=number' where number is between 1 and 160000. | `map(any)` | `{}` | no |
265263
| fsx_capacity_size_gb | The storage capacity (GiB) of the FSxN file system. Valid values between 1024 and 196608 | `number` | `1024` | no |
266264
| fsx_deploy_type | The filesystem deployment type. Supports MULTI_AZ_1 and SINGLE_AZ_1 | `string` | `"MULTI_AZ_1"` | no |
267265
| fsx_maintenance_start_time | The preferred start time (in d:HH:MM format) to perform weekly maintenance, in the UTC time zone. | `string` | `"1:00:00"` | no |
268-
| fsx_secret_name | The name of the secure where the FSxN passwood is stored | `string` | `""` | no |
266+
| fsx_name | The name to assigne to the FSxN file system. | `string` | `"fsx1"` | no |
267+
| fsx_secret_name | The name of the secure where the FSxN passwood is stored. | `string` | `""` | no |
269268
| fsx_subnets | The subnets from where the file system will be accessible from. For MULTI_AZ_1 deployment type, provide both primvary and secondary subnets. For SINGLE_AZ_1 deployment type, only the primary subnet is used. | `map(string)` | <pre>{<br> "primarysub": "subnet-111111111",<br> "secondarysub": "subnet-222222222"<br>}</pre> | no |
270269
| fsx_tput_in_MBps | The throughput capacity (in MBps) for the file system. Valid values are 128, 256, 512, 1024, 2048, and 4096. | `number` | `128` | no |
271270
| kms_key_id | ARN for the KMS Key to encrypt the file system at rest, Defaults to an AWS managed KMS Key. | `string` | `null` | no |
272271
| root_vol_sec_style | Specifies the root volume security style, Valid values are UNIX, NTFS, and MIXED (although MIXED is not recommended). All volumes created under this SVM will inherit the root security style unless the security style is specified on the volume. | `string` | `"UNIX"` | no |
273272
| route_table_ids | Specifies the VPC route tables in which your file system's endpoints will be created. You should specify all VPC route tables associated with the subnets in which your clients are located. By default, Amazon FSx selects your VPC's default route table. Note, this variable is only used for MULTI_AZ_1 type deployments. | `list(any)` | `null` | no |
274-
| security_group_id | If you are not creating the SG, provide the ID of the SG to be used | `string` | `""` | no |
273+
| security_group_id | If you are not creating the security group, provide the ID of the security group to be used. | `string` | `""` | no |
275274
| source_security_group_id | The ID of the security group to allow access to the FSxN file system. | `string` | `""` | no |
276-
| svm_name | The name of the Storage Virtual Machine | `string` | `"first_svm"` | no |
277-
| tags | Tags to be applied to the resources | `map(any)` | <pre>{<br> "Name": "terraform-fsxn"<br>}</pre> | no |
278-
| vol_info | Details for the volume creation | `map(any)` | <pre>{<br> "bypass_sl_retention": false,<br> "cooling_period": 31,<br> "copy_tags_to_backups": false,<br> "efficiency": true,<br> "junction_path": "/vol1",<br> "sec_style": "UNIX",<br> "size_mg": 1024,<br> "skip_final_backup": false,<br> "tier_policy_name": "AUTO",<br> "vol_name": "vol1",<br> "vol_type": "RW"<br>}</pre> | no |
275+
| svm_name | The name of the Storage Virtual Machine, (a.k.a. vserver). | `string` | `"first_svm"` | no |
276+
| tags | Tags to be applied to the FSxN file system. | `map(any)` | `{}` | no |
277+
| vol_info | Details for the volume creation | `map(any)` | <pre>{<br> "cooling_period": 31,<br> "copy_tags_to_backups": false,<br> "efficiency": true,<br> "junction_path": "/vol1",<br> "sec_style": "UNIX",<br> "size_mg": 1024,<br> "skip_final_backup": false,<br> "snapshot_policy": "default",<br> "tier_policy_name": "AUTO",<br> "vol_name": "vol1",<br> "vol_type": "RW"<br>}</pre> | no |
279278
| vol_snapshot_policy | Specifies the snapshot policy for the volume | `map(any)` | `null` | no |
280-
| vpc_id | The ID of the VPC in which the FSxN fikesystem should be deployed | `string` | `""` | no |
279+
| vpc_id | The ID of the VPC in where the security group will be created. | `string` | `""` | no |
281280
282281
### Outputs
283282

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ resource "aws_fsx_ontap_file_system" "terraform-fsxn" {
2828
daily_automatic_backup_start_time = var.daily_backup_start_time
2929
fsx_admin_password = data.aws_secretsmanager_secret_version.fsx_password.secret_string
3030
route_table_ids = (var.fsx_deploy_type == "MULTI_AZ_1" ? var.route_table_ids : null)
31-
tags = var.tags
31+
tags = merge(var.tags, {Name = var.fsx_name })
3232
dynamic "disk_iops_configuration" {
3333
for_each = length(var.disk_iops_configuration) > 0 ? [var.disk_iops_configuration] : []
3434

@@ -57,7 +57,6 @@ resource "aws_fsx_ontap_storage_virtual_machine" "mysvm" {
5757

5858
// OPTIONAL PARAMETERS
5959
root_volume_security_style = var.root_vol_sec_style
60-
# active_directory_configuration {}
6160
}
6261

6362
resource "aws_fsx_ontap_volume" "myvol" {
@@ -74,12 +73,10 @@ resource "aws_fsx_ontap_volume" "myvol" {
7473
name = var.vol_info["tier_policy_name"]
7574
cooling_period = var.vol_info["cooling_period"]
7675
}
77-
bypass_snaplock_enterprise_retention = var.vol_info["bypass_sl_retention"]
78-
copy_tags_to_backups = var.vol_info["copy_tags_to_backups"]
79-
security_style = var.vol_info["sec_style"]
80-
skip_final_backup = var.vol_info["skip_final_backup"]
81-
# snaplock_configuration {}
82-
# snapshot_policy {}
76+
copy_tags_to_backups = var.vol_info["copy_tags_to_backups"]
77+
security_style = var.vol_info["sec_style"]
78+
skip_final_backup = var.vol_info["skip_final_backup"]
79+
snapshot_policy = var.vol_info["snapshot_policy"]
8380
}
8481
#
8582
# The next two data blocks retrieve the secret from Secrets Manager.

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

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
/*
2-
* If you want to set the nam eof your FSxN file system, you must set a "Name"
3-
* tag equal to the desired name. Feel free to add additional tags as needed.
4-
*/
51
variable "tags" {
6-
description = "Tags to be applied to the resources"
2+
description = "Tags to be applied to the FSxN file system."
73
type = map(any)
8-
default = {
9-
"Name" = "terraform-fsxn"
10-
}
4+
default = {}
5+
}
6+
7+
variable "fsx_name" {
8+
description = "The name to assigne to the FSxN file system."
9+
type = string
10+
default = "fsx1"
1111
}
1212

1313
variable "create_sg" {
14-
description = "Determines whether the SG should be deployed as part of this execution or not"
14+
description = "Determines whether the SG should be deployed as part of this deployment or not."
1515
type = bool
1616
default = true
1717
}
1818

1919
variable "security_group_id" {
20-
description = "If you are not creating the SG, provide the ID of the SG to be used"
20+
description = "If you are not creating the security group, provide the ID of the security group to be used."
2121
type = string
2222
default = ""
2323
}
@@ -41,20 +41,16 @@ variable "source_security_group_id" {
4141
}
4242

4343
variable "vpc_id" {
44-
description = "The ID of the VPC in which the FSxN fikesystem should be deployed"
44+
description = "The ID of the VPC in where the security group will be created."
4545
type = string
4646
default = ""
47-
validation {
48-
condition = var.vpc_id != ""
49-
error_message = "You must provide the ID of the VPC in which the FSxN file system should be deployed."
50-
}
5147
}
5248

5349
variable "fsx_subnets" {
5450
description = "The subnets from where the file system will be accessible from. For MULTI_AZ_1 deployment type, provide both primvary and secondary subnets. For SINGLE_AZ_1 deployment type, only the primary subnet is used."
5551
type = map(string)
5652
default = {
57-
"primarysub" = "subnet-111111111"
53+
"primarysub" = "subnet-111111111"
5854
"secondarysub" = "subnet-222222222"
5955
}
6056
}
@@ -105,6 +101,10 @@ variable "backup_retention_days" {
105101
description = "The number of days to retain automatic backups. Setting this to 0 disables automatic backups. You can retain automatic backups for a maximum of 90 days."
106102
type = number
107103
default = 0
104+
validation {
105+
condition = var.backup_retention_days >= 0 && var.backup_retention_days <= 90
106+
error_message = "Invalid backup retention days. Valid values are between 0 and 90."
107+
}
108108
}
109109

110110
variable "daily_backup_start_time" {
@@ -120,7 +120,7 @@ variable "disk_iops_configuration" {
120120
}
121121

122122
variable "fsx_secret_name" {
123-
description = "The name of the secure where the FSxN passwood is stored"
123+
description = "The name of the secure where the FSxN passwood is stored."
124124
type = string
125125
default = ""
126126
validation {
@@ -136,7 +136,7 @@ variable "route_table_ids" {
136136
}
137137

138138
variable "svm_name" {
139-
description = "The name of the Storage Virtual Machine"
139+
description = "The name of the Storage Virtual Machine, (a.k.a. vserver)."
140140
type = string
141141
default = "first_svm"
142142
}
@@ -151,17 +151,17 @@ variable "vol_info" {
151151
description = "Details for the volume creation"
152152
type = map(any)
153153
default = {
154-
"vol_name" = "vol1"
155-
"junction_path" = "/vol1"
156-
"size_mg" = 1024
157-
"efficiency" = true
158-
"tier_policy_name" = "AUTO"
159-
"cooling_period" = 31
154+
"vol_name" = "vol1"
155+
"junction_path" = "/vol1"
156+
"size_mg" = 1024
157+
"efficiency" = true
158+
"tier_policy_name" = "AUTO"
159+
"cooling_period" = 31
160160
"vol_type" = "RW"
161-
"bypass_sl_retention" = false
162161
"copy_tags_to_backups" = false
163162
"sec_style" = "UNIX"
164163
"skip_final_backup" = false
164+
"snapshot_policy" = "default"
165165
}
166166
}
167167

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ terraform apply
199199
| fsx_tput_in_MBps | The throughput capacity (in MBps) for the file system. Valid values are 128, 256, 512, 1024, 2048, and 4096. | `number` | `128` | no |
200200
| svm_name | The name of the Storage Virtual Machine | `string` | `"first_svm"` | no |
201201
| vol_info | Details for the volume creation | `map(any)` | <pre>{<br> "cooling_period": 31,<br> "efficiency": true,<br> "junction_path": "/vol1",<br> "size_mg": 1024,<br> "tier_policy_name": "AUTO",<br> "vol_name": "vol1"<br>}</pre> | no |
202-
| vpc_id | The ID of the VPC in which the FSxN fikesystem should be deployed | `string` | `"vpc-11111111"` | no |
202+
| vpc_id | The ID of the VPC in which the security group will be created. | `string` | `"vpc-11111111"` | no |
203203
204204
### Outputs
205205

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ variable "vol_info" {
8181
}
8282

8383
variable "vpc_id" {
84-
description = "The ID of the VPC in which the FSxN fikesystem should be deployed"
84+
description = "The ID of the VPC in which the security group will be created."
8585
type = string
8686
default = "vpc-11111111"
8787
}

0 commit comments

Comments
 (0)