Skip to content

Commit

Permalink
used ONTAP provider to add volume to DR system after DR FSxN was crea…
Browse files Browse the repository at this point in the history
…ted by Terraform
  • Loading branch information
nichollri committed Oct 10, 2024
1 parent 09d6779 commit 27fc5f6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
15 changes: 11 additions & 4 deletions Terraform/fsxn-replicate/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

]
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions Terraform/fsxn-replicate/security_groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
25 changes: 9 additions & 16 deletions Terraform/fsxn-replicate/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -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"
}
}
Expand Down Expand Up @@ -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" {
Expand All @@ -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
Expand Down

0 comments on commit 27fc5f6

Please sign in to comment.