From 548e1fb4b3f3ada6504aeacbcfcacca238d5ac4f Mon Sep 17 00:00:00 2001 From: Lucas Telles Date: Thu, 21 Nov 2024 11:12:39 -0300 Subject: [PATCH] [DOP-2327] Update fsx module to allow use of create/load module (#343) * Update fsx module version and add variables * Change variable names * Add fsx variables and change outputs * Add fsx variable default value * Update per_unit_storage_throughput default value * Update per_unit_storage_throughput default value * Rollback default values for fsx --- ipa.tf | 8 +++---- main.tf | 16 ++++++++++--- outputs.tf | 16 ++++++------- variables.tf | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 15 deletions(-) diff --git a/ipa.tf b/ipa.tf index 3e4eb7f8..e6885971 100644 --- a/ipa.tf +++ b/ipa.tf @@ -49,16 +49,16 @@ locals { csi: driver: fsx.csi.aws.com volumeAttributes: - dnsname: ${module.fsx-storage[0].fsx-rwx.dns_name} - mountname: ${module.fsx-storage[0].fsx-rwx.mount_name} - volumeHandle: ${module.fsx-storage[0].fsx-rwx.id} + dnsname: ${module.fsx-storage[0].fsx_rwx_dns_name} + mountname: ${module.fsx-storage[0].fsx_rwx_mount_name} + volumeHandle: ${module.fsx-storage[0].fsx_rwx_id} indicoStorageClass: enabled: true name: indico-sc provisioner: fsx.csi.aws.com parameters: securityGroupIds: ${local.security_group_id} - subnetId: ${module.fsx-storage[0].fsx-rwx.subnet_ids[0]} + subnetId: ${module.fsx-storage[0].fsx_rwx_subnet_ids[0]} EOF ] : [] storage_spec = var.include_fsx == true ? local.fsx_values : local.efs_values diff --git a/main.tf b/main.tf index 16caa8bb..4a7c71ca 100644 --- a/main.tf +++ b/main.tf @@ -286,7 +286,7 @@ module "efs-storage-local-registry" { module "fsx-storage" { count = var.include_fsx == true ? 1 : 0 source = "app.terraform.io/indico/indico-aws-fsx/mod" - version = "1.4.2" + version = "2.0.0" label = var.label additional_tags = var.additional_tags region = var.region @@ -297,7 +297,17 @@ module "fsx-storage" { api_models_bucket = module.s3-storage.api_models_s3_bucket_name kms_key = module.kms_key.key per_unit_storage_throughput = var.per_unit_storage_throughput + deployment_type = var.fsx_deployment_type include_rox = var.include_rox + fsx_type = var.fsx_type + fsx_rwx_id = var.fsx_rwx_id + fsx_rwx_subnet_ids = var.fsx_rwx_subnet_ids + fsx_rwx_security_group_ids = var.fsx_rwx_security_group_ids + fsx_rwx_dns_name = var.fsx_rwx_dns_name + fsx_rwx_mount_name = var.fsx_rwx_mount_name + fsx_rwx_arn = var.fsx_rwx_arn + fsx_rox_id = var.fsx_rox_id + fsx_rox_arn = var.fsx_rox_arn } module "cluster" { @@ -319,7 +329,7 @@ module "cluster" { cluster_node_policies = var.cluster_node_policies eks_cluster_iam_role = var.eks_cluster_iam_role eks_cluster_nodes_iam_role = "${var.label}-${var.region}-node-role" - fsx_arns = [var.include_rox ? module.fsx-storage[0].fsx-rox.arn : "", var.include_fsx == true ? module.fsx-storage[0].fsx-rwx.arn : ""] + fsx_arns = [var.include_rox ? module.fsx-storage[0].fsx_rox_arn : "", var.include_fsx == true ? module.fsx-storage[0].fsx_rwx_arn : ""] kms_key_arn = module.kms_key.key_arn az_count = var.az_count key_pair = aws_key_pair.kp.key_name @@ -468,7 +478,7 @@ module "argo-registration" { } locals { - security_group_id = var.include_fsx == true ? tolist(module.fsx-storage[0].fsx-rwx.security_group_ids)[0] : "" + security_group_id = var.include_fsx == true ? tolist(module.fsx-storage[0].fsx_rwx_security_group_ids)[0] : "" cluster_name = var.label dns_zone_name = var.dns_zone_name == "" ? lower("${var.aws_account}.${var.domain_suffix}") : var.dns_zone_name dns_name = var.domain_host == "" ? lower("${var.label}.${var.region}.${local.dns_zone_name}") : var.domain_host diff --git a/outputs.tf b/outputs.tf index bc5bd026..0348f0ad 100644 --- a/outputs.tf +++ b/outputs.tf @@ -19,14 +19,14 @@ output "efs_filesystem_id" { description = "ID of the EFS filesystem" value = var.include_efs == true ? module.efs-storage[0].efs_filesystem_id : "" } -output "fsx-rwx" { +output "fsx_rwx_id" { description = "Read write filesystem" - value = var.include_fsx == true ? module.fsx-storage[0].fsx-rwx : null + value = var.include_fsx == true ? module.fsx-storage[0].fsx_rwx_id : null } -output "fsx-rox" { +output "fsx_rox_id" { description = "Read only filesystem" - value = var.include_rox ? module.fsx-storage[0].fsx-rox : "" + value = var.include_rox ? module.fsx-storage[0].fsx_rox_id : "" } output "key_pem" { @@ -36,19 +36,19 @@ output "key_pem" { } output "fsx_storage_fsx_rwx_dns_name" { - value = var.include_fsx == true ? module.fsx-storage[0].fsx-rwx.dns_name : "" + value = var.include_fsx == true ? module.fsx-storage[0].fsx_rwx_dns_name : "" } output "fsx_storage_fsx_rwx_mount_name" { - value = var.include_fsx == true ? module.fsx-storage[0].fsx-rwx.mount_name : "" + value = var.include_fsx == true ? module.fsx-storage[0].fsx_rwx_mount_name : "" } output "fsx_storage_fsx_rwx_volume_handle" { - value = var.include_fsx == true ? module.fsx-storage[0].fsx-rwx.id : "" + value = var.include_fsx == true ? module.fsx-storage[0].fsx_rwx_id : "" } output "fsx_storage_fsx_rwx_subnet_id" { - value = var.include_fsx == true ? module.fsx-storage[0].fsx-rwx.subnet_ids[0] : "" + value = var.include_fsx == true ? module.fsx-storage[0].fsx_rwx_subnet_ids[0] : "" } output "cluster_name" { diff --git a/variables.tf b/variables.tf index c0dacb51..47d436d5 100644 --- a/variables.tf +++ b/variables.tf @@ -1051,3 +1051,66 @@ variable "instance_volume_type" { default = "gp2" description = "The type of EBS volume to attach to the cluster nodes" } + +variable "fsx_deployment_type" { + type = string + default = "PERSISTENT_1" + description = "The deployment type to launch" +} + +variable "fsx_type" { + type = string + default = "create" + validation { + condition = var.fsx_type == "create" || var.fsx_type == "load" + error_message = "${var.fsx_type} not valid. Type must be either create or load" + } +} + +variable "fsx_rwx_id" { + description = "ID of the existing FSx Lustre file system for RWX" + type = string + default = null +} + +variable "fsx_rwx_subnet_ids" { + description = "Subnet IDs for the RWX FSx Lustre file system" + type = list(string) + default = [] +} + +variable "fsx_rwx_security_group_ids" { + description = "Security group IDs for the RWX FSx Lustre file system" + type = list(string) + default = [] +} + +variable "fsx_rwx_dns_name" { + description = "DNS name for the RWX FSx Lustre file system" + type = string + default = null +} + +variable "fsx_rwx_mount_name" { + description = "Mount name for the RWX FSx Lustre file system" + type = string + default = null +} + +variable "fsx_rwx_arn" { + description = "ARN of the RWX FSx Lustre file system" + type = string + default = null +} + +variable "fsx_rox_id" { + description = "ID of the existing FSx Lustre file system for ROX" + type = string + default = null +} + +variable "fsx_rox_arn" { + description = "ARN of the ROX FSx Lustre file system" + type = string + default = null +} \ No newline at end of file