Skip to content

Commit 2d06c5e

Browse files
committed
all: update nfs tf module
1 parent b5c741a commit 2d06c5e

14 files changed

+134
-43
lines changed

aws_ec2_instance/host_nfs/host_file_storage.tf

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
resource "aws_efs_file_system" "file_storage_sapmnt" {
3-
count = var.module_var_nfs_boolean_sapmnt ? 1 : 0
43
creation_token = "${var.module_var_resource_prefix}-nfs-sapmnt"
54

65
tags = {
@@ -19,20 +18,46 @@ resource "aws_efs_file_system" "file_storage_sapmnt" {
1918
}
2019

2120
resource "aws_efs_mount_target" "file_storage_attach_sapmnt" {
22-
count = var.module_var_nfs_boolean_sapmnt ? 1 : 0
23-
24-
file_system_id = aws_efs_file_system.file_storage_sapmnt[0].id
21+
file_system_id = aws_efs_file_system.file_storage_sapmnt.id
2522
subnet_id = var.module_var_aws_vpc_subnet_id
2623
security_groups = [var.module_var_host_sg_id]
2724
}
2825

29-
resource "aws_efs_access_point" "file_storage_shared_mount_point" {
30-
count = var.module_var_nfs_boolean_sapmnt ? 1 : 0
26+
resource "aws_efs_access_point" "file_storage_shared_mount_point_sapmnt" {
27+
file_system_id = aws_efs_file_system.file_storage_sapmnt.id
28+
root_directory {
29+
path = "/"
30+
}
31+
}
32+
3133

32-
file_system_id = aws_efs_file_system.file_storage_sapmnt[0].id
34+
resource "aws_efs_file_system" "file_storage_transport" {
35+
creation_token = "${var.module_var_resource_prefix}-nfs-trans"
3336

37+
tags = {
38+
Name = "${var.module_var_resource_prefix}-nfs-trans"
39+
}
40+
41+
availability_zone_name = local.target_vpc_availability_zone # One Zone storage class
42+
encrypted = true
43+
performance_mode = "generalPurpose"
44+
throughput_mode = "bursting"
45+
46+
# lifecycle_policy {
47+
# transition_to_ia = "AFTER_90_DAYS"
48+
# }
49+
50+
}
51+
52+
resource "aws_efs_mount_target" "file_storage_attach_transport" {
53+
file_system_id = aws_efs_file_system.file_storage_transport.id
54+
subnet_id = var.module_var_aws_vpc_subnet_id
55+
security_groups = [var.module_var_host_sg_id]
56+
}
57+
58+
resource "aws_efs_access_point" "file_storage_shared_mount_point_transport" {
59+
file_system_id = aws_efs_file_system.file_storage_transport.id
3460
root_directory {
3561
path = "/"
3662
}
37-
3863
}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11

2-
output "output_nfs_fqdn" {
3-
value = try(aws_efs_mount_target.file_storage_attach_sapmnt[0].mount_target_dns_name,"")
2+
output "output_nfs_fqdn_sapmnt" {
3+
value = try(aws_efs_mount_target.file_storage_attach_sapmnt.mount_target_dns_name,"")
4+
}
5+
6+
output "output_nfs_fqdn_transport" {
7+
value = try(aws_efs_mount_target.file_storage_attach_transport.mount_target_dns_name,"")
48
}

aws_ec2_instance/host_nfs/module_variables.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ variable "module_var_resource_prefix" {}
33

44
variable "module_var_aws_vpc_subnet_id" {}
55

6-
variable "module_var_nfs_boolean_sapmnt" {}
7-
86
variable "module_var_host_sg_id" {}

gcp_ce_vm/host_nfs/host_file_storage.tf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,28 @@ resource "google_filestore_instance" "file_storage_sapmnt" {
2222
}
2323

2424
}
25+
26+
27+
resource "google_filestore_instance" "file_storage_transport" {
28+
name = "${var.module_var_resource_prefix}-trans" // Letters, Numbers, Hyphens only
29+
location = var.module_var_gcp_region_zone
30+
tier = "BASIC_HDD" // "BASIC_SSD"
31+
32+
file_shares {
33+
name = "${var.module_var_resource_prefix}_trans_share" // Letters, Numbers, Underscores only
34+
capacity_gb = 2048 // 2560 // Minimum GB capacity for the Basic SSD if 2,560GB
35+
36+
nfs_export_options {
37+
ip_ranges = ["${local.target_vpc_subnet_range}"]
38+
access_mode = "READ_WRITE"
39+
squash_mode = "NO_ROOT_SQUASH"
40+
}
41+
}
42+
43+
networks {
44+
network = basename(local.target_vpc_id)
45+
modes = ["MODE_IPV4"]
46+
connect_mode = "DIRECT_PEERING" # DIRECT_PEERING or PRIVATE_SERVICE_ACCESS
47+
}
48+
49+
}

gcp_ce_vm/host_nfs/module_outputs.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11

22
# NFS Mount Point
3-
output "output_nfs_fqdn" {
3+
output "output_nfs_fqdn_sapmnt" {
44
value = "${google_filestore_instance.file_storage_sapmnt.networks[0].ip_addresses[0]}:/${google_filestore_instance.file_storage_sapmnt.file_shares[0].name}"
55
}
6+
7+
output "output_nfs_fqdn_transport" {
8+
value = "${google_filestore_instance.file_storage_transport.networks[0].ip_addresses[0]}:/${google_filestore_instance.file_storage_sapmnt.file_shares[0].name}"
9+
}

gcp_ce_vm/host_nfs/module_variables.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,3 @@ variable "module_var_resource_prefix" {}
44
variable "module_var_gcp_region_zone" {}
55

66
variable "module_var_gcp_vpc_subnet_name" {}
7-
8-
variable "module_var_nfs_boolean_sapmnt" {}
Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,43 @@
11

22
resource "ibm_is_share" "file_storage_sapmnt" {
3-
count = var.module_var_nfs_boolean_sapmnt ? 1 : 0
43
name = "${var.module_var_resource_prefix}-nfs-sapmnt"
4+
resource_group = var.module_var_resource_group_id
55

6+
access_control_mode = "vpc"
67
zone = local.target_vpc_availability_zone
7-
88
size = 2048
99
profile = "dp2"
1010

11+
lifecycle {
12+
ignore_changes = [ allowed_transit_encryption_modes ]
13+
}
1114
}
1215

1316
resource "ibm_is_share_mount_target" "file_storage_attach_sapmnt" {
14-
count = var.module_var_nfs_boolean_sapmnt ? 1 : 0
1517
name = "${var.module_var_resource_prefix}-nfs-sapmnt-attach"
1618

17-
share = ibm_is_share.file_storage_sapmnt[0].id
19+
share = ibm_is_share.file_storage_sapmnt.id
20+
vpc = local.target_vpc_id
21+
}
22+
23+
24+
resource "ibm_is_share" "file_storage_transport" {
25+
name = "${var.module_var_resource_prefix}-nfs-trans"
26+
resource_group = var.module_var_resource_group_id
27+
28+
access_control_mode = "vpc"
29+
zone = local.target_vpc_availability_zone
30+
size = 2048
31+
profile = "dp2"
32+
33+
lifecycle {
34+
ignore_changes = [ allowed_transit_encryption_modes ]
35+
}
36+
}
37+
38+
resource "ibm_is_share_mount_target" "file_storage_attach_transport" {
39+
name = "${var.module_var_resource_prefix}-nfs-trans-attach"
40+
41+
share = ibm_is_share.file_storage_transport.id
1842
vpc = local.target_vpc_id
1943
}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11

22
# Mount path
3-
output "output_nfs_fqdn" {
4-
value = try(ibm_is_share_mount_target.file_storage_attach_sapmnt[0].mount_path,"")
3+
output "output_nfs_fqdn_sapmnt" {
4+
value = try(ibm_is_share_mount_target.file_storage_attach_sapmnt.mount_path,"")
5+
}
6+
7+
output "output_nfs_fqdn_transport" {
8+
value = try(ibm_is_share_mount_target.file_storage_attach_transport.mount_path,"")
59
}

ibmcloud_vs/host_nfs/module_variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ variable "module_var_ibmcloud_vpc_subnet_name" {}
55

66
variable "module_var_host_security_group_id" {}
77

8-
variable "module_var_nfs_boolean_sapmnt" {}
8+
variable "module_var_resource_group_id" {}

msazure_vm/host_nfs/host_file_storage_azapi_secured.tf

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ data "azurerm_resource_group" "id_lookup" {
1717

1818
# https://learn.microsoft.com/en-us/azure/templates/microsoft.storage/storageaccounts?pivots=deployment-language-terraform
1919
resource "azapi_resource" "storage_account_sap" {
20-
count = var.module_var_nfs_boolean_sapmnt ? 1 : 0
21-
2220
type = "Microsoft.Storage/storageAccounts@2022-05-01"
2321
name = "${var.module_var_resource_prefix}stgacc${random_string.random_suffix.result}"
2422
location = var.module_var_az_location_region
@@ -75,11 +73,24 @@ resource "azapi_resource" "storage_account_sap" {
7573

7674
# https://learn.microsoft.com/en-us/azure/templates/microsoft.storage/storageaccounts/fileservices/shares?pivots=deployment-language-terraform
7775
resource "azapi_resource" "file_storage_sapmnt" {
78-
count = var.module_var_nfs_boolean_sapmnt ? 1 : 0
76+
type = "Microsoft.Storage/storageAccounts/fileServices/shares@2022-05-01"
77+
name = "${var.module_var_resource_prefix}nfssapmnt"
78+
parent_id = "${azapi_resource.storage_account_sap.id}/fileServices/default"
79+
body = {
80+
properties = {
81+
accessTier = "Premium"
82+
enabledProtocols = "NFS"
83+
shareQuota = 2048 // Maximum GB capacity of NFS
84+
# metadata = {}
85+
# rootSquash = "string"
86+
}
87+
}
88+
}
7989

90+
resource "azapi_resource" "file_storage_transport" {
8091
type = "Microsoft.Storage/storageAccounts/fileServices/shares@2022-05-01"
81-
name = "${var.module_var_resource_prefix}nfs"
82-
parent_id = "${azapi_resource.storage_account_sap[0].id}/fileServices/default"
92+
name = "${var.module_var_resource_prefix}nfstrans"
93+
parent_id = "${azapi_resource.storage_account_sap.id}/fileServices/default"
8394
body = {
8495
properties = {
8596
accessTier = "Premium"
@@ -102,12 +113,12 @@ resource "azapi_resource" "file_storage_sapmnt" {
102113
#data "azapi_resource" "data_storage_account_file_service" {
103114
# type = "Microsoft.Storage/storageAccounts/fileServices@2022-05-01"
104115
# name = "default"
105-
# parent_id = "${azapi_resource.storage_account_sap[0].id}"
116+
# parent_id = "${azapi_resource.storage_account_sap.id}"
106117
#}
107118

108119
#data "azapi_resource" "data_storage_account_file_service_shares" {
109120
# type = "Microsoft.Storage/storageAccounts/fileServices/shares@2022-05-01"
110121
# name = azapi_resource.file_storage_sapmnt.name
111-
# parent_id = "${azapi_resource.storage_account_sap[0].id}/fileServices/default"
122+
# parent_id = "${azapi_resource.storage_account_sap.id}/fileServices/default"
112123
#}
113124

0 commit comments

Comments
 (0)