From 27fc5f62d55370aade397360dc76ea9be7ad71c7 Mon Sep 17 00:00:00 2001 From: nichollri Date: Thu, 10 Oct 2024 13:52:11 -0500 Subject: [PATCH] used ONTAP provider to add volume to DR system after DR FSxN was created by Terraform --- Terraform/fsxn-replicate/main.tf | 15 +++++++++---- Terraform/fsxn-replicate/security_groups.tf | 8 +++---- Terraform/fsxn-replicate/variables.tf | 25 ++++++++------------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Terraform/fsxn-replicate/main.tf b/Terraform/fsxn-replicate/main.tf index 628270a..3c67dc9 100644 --- a/Terraform/fsxn-replicate/main.tf +++ b/Terraform/fsxn-replicate/main.tf @@ -41,6 +41,13 @@ provider "netapp-ontap" { username = jsondecode(data.aws_secretsmanager_secret_version.ontap_prime_username_pass.secret_string)["username"] password = jsondecode(data.aws_secretsmanager_secret_version.ontap_prime_username_pass.secret_string)["password"] validate_certs = var.validate_certs + }, + { + name = "dr_clus" + hostname = join("", aws_fsx_ontap_file_system.terraform-fsxn.endpoints[0].management[0].ip_addresses) + username = jsondecode(data.aws_secretsmanager_secret_version.ontap_prime_username_pass.secret_string)["username"] + password = jsondecode(data.aws_secretsmanager_secret_version.ontap_prime_username_pass.secret_string)["password"] + validate_certs = var.validate_certs } ] @@ -51,7 +58,7 @@ resource "aws_fsx_ontap_file_system" "terraform-fsxn" { preferred_subnet_id = var.dr_fsx_subnets["primarysub"] storage_capacity = var.dr_fsx_capacity_size_gb - security_group_ids = var.create_sg ? [element(aws_security_group.fsx_sg[*].id, 0)] : var.security_group_ids + security_group_ids = var.dr_create_sg ? [element(aws_security_group.fsx_sg[*].id, 0)] : var.dr_security_group_ids deployment_type = var.dr_fsx_deploy_type throughput_capacity_per_ha_pair = var.dr_fsx_tput_in_MBps ha_pairs = var.dr_ha_pairs @@ -88,10 +95,10 @@ data "netapp-ontap_storage_volume_data_source" "my_vol" { name = each.value } - resource "netapp-ontap_storage_volume_resource" "example" { - cx_profile_name = "primary_clus" + resource "netapp-ontap_storage_volume_resource" "example2" { + cx_profile_name = "dr_clus" name = "rvwn_vol1_tf" - svm_name = var.prime_svm + svm_name = aws_fsx_ontap_storage_virtual_machine.mysvm.name aggregates = [ { name = "aggr1" diff --git a/Terraform/fsxn-replicate/security_groups.tf b/Terraform/fsxn-replicate/security_groups.tf index 0c882f6..3de9588 100644 --- a/Terraform/fsxn-replicate/security_groups.tf +++ b/Terraform/fsxn-replicate/security_groups.tf @@ -12,15 +12,15 @@ */ locals { - mycount = var.create_sg ? 1 : 0 - my_ref_sec_group_id = (var.source_sg_id != "" ? var.source_sg_id : null) - my_cidr = (var.cidr_for_sg != "" ? var.cidr_for_sg : null) + mycount = var.dr_create_sg ? 1 : 0 + my_ref_sec_group_id = (var.dr_source_sg_id != "" ? var.dr_source_sg_id : null) + my_cidr = (var.dr_cidr_for_sg != "" ? var.dr_cidr_for_sg : null) } resource "aws_security_group" "fsx_sg" { description = "Allow FSx ONTAP required ports" count = local.mycount - name_prefix = var.security_group_name_prefix + name_prefix = var.dr_security_group_name_prefix vpc_id = var.dr_vpc_id } diff --git a/Terraform/fsxn-replicate/variables.tf b/Terraform/fsxn-replicate/variables.tf index 534aea8..3c6029f 100644 --- a/Terraform/fsxn-replicate/variables.tf +++ b/Terraform/fsxn-replicate/variables.tf @@ -20,7 +20,7 @@ variable "prime_aws_region" { variable "dr_aws_region" { description = "AWS regionfor the Secondary(DR) ONTAP FSxN" type = string - default = "us-east-2" + default = "us-west-2" } variable "username_pass_secrets_id" { @@ -55,7 +55,7 @@ variable "dr_fsx_subnets" { description = "The primary subnet ID, and secondary subnet ID if you are deploying in a Multi AZ environment, file system will be accessible from. For MULTI_AZ deployment types both subnets are required. For SINGLE_AZ deployment type, only the primary subnet is used." type = map(any) default = { - "primarysub" = "subnet-0a64530a9c7afc84c" + "primarysub" = "subnet-8fba81f8" "secondarysub" = "subnet-33333333" } } @@ -168,40 +168,40 @@ variable "dr_root_vol_sec_style" { * the ID of the security group that you want to use. * */ -variable "create_sg" { +variable "dr_create_sg" { description = "Determines whether the Security Group should be created as part of this deployment or not." type = bool default = true } -variable "security_group_ids" { +variable "dr_security_group_ids" { description = "If you are not creating the security group, provide a list of IDs of security groups to be used." type = list(string) default = [] } -variable "security_group_name_prefix" { +variable "dr_security_group_name_prefix" { description = "The prefix to the security group name that will be created." type = string default = "fsxn-sg" } -variable "cidr_for_sg" { +variable "dr_cidr_for_sg" { description = "The cidr block to be used for the created security ingress rules. Set to an empty string if you want to use the source_sg_id as the source." type = string default = "10.0.0.0/8" } -variable "source_sg_id" { +variable "dr_source_sg_id" { description = "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." type = string default = "" } variable "dr_vpc_id" { - description = "The VPC ID where the security group will be created." + description = "The VPC ID where the DR FSxN and security group will be created." type = string - default = "vpc-0684c5d22c4b48dd4" + default = "vpc-445d4f21" } variable "dr_username_pass_secrets_id" { @@ -210,13 +210,6 @@ variable "dr_username_pass_secrets_id" { default = "rvwn_replicate_ontap_creds" } -variable "dr_hostname" { - description = "Hostname or IP address of disaster recovery cluster." - type = string -# Prod DR FSxN - default = "198.19.254.83" -} - variable "validate_certs" { description = "Do we validate the cluster certs (true or false)" type = string