terraform {
  required_version = ">= 1.15.0, < 2.0.0"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 6.0, < 7.0"
    }
  }
}

provider "aws" {
  region = "ap-south-1"
}

module "ec2_node" {
  source = "../../modules/ec2-node"

  name_prefix = "iptest"

  instances = {
    node-a = {
      name_suffix           = "node-a"
      ami_id                = "ami-057be83ec79c51287"
      instance_type         = "t3.micro"
      subnet_id             = "subnet-0a1ab504311dae1c3"
      security_group_ids    = ["sg-0a1f705f08895b7f9"]
      associate_public_ip   = false
      primary_private_ip    = "172.31.32.10"
      secondary_private_ips = ["172.31.32.11"]

      root_volume = {
        size = 8
      }
    }
  }

  tags = {
    purpose = "secondary-ip-live-attach-test"
  }
}

output "instance_ids" {
  description = "Instance IDs keyed by instance key."
  value       = module.ec2_node.instance_ids
}

output "instance_arns" {
  description = "Instance ARNs keyed by instance key."
  value       = module.ec2_node.instance_arns
}

output "primary_private_ips" {
  description = "Primary private IP addresses keyed by instance key."
  value       = module.ec2_node.primary_private_ips
}

output "secondary_private_ips" {
  description = "Secondary private IP addresses keyed by instance key."
  value       = module.ec2_node.secondary_private_ips
}

output "public_ips" {
  description = "Public IP addresses keyed by instance key. Null if not assigned."
  value       = module.ec2_node.public_ips
}

output "private_dns" {
  description = "Private DNS names keyed by instance key."
  value       = module.ec2_node.private_dns
}

output "network_interface_ids" {
  description = "Primary network interface IDs keyed by instance key."
  value       = module.ec2_node.network_interface_ids
}

output "ami_ids" {
  description = "AMI ID in use keyed by instance key."
  value       = module.ec2_node.ami_ids
}

output "key_pair_ids" {
  description = "Key pair IDs keyed by key pair key."
  value       = module.ec2_node.key_pair_ids
}

output "data_volume_ids" {
  description = "EBS data volume IDs keyed by data volume key."
  value       = module.ec2_node.data_volume_ids
}

output "data_volume_attachments" {
  description = "Attached data volume IDs keyed by data volume key."
  value       = module.ec2_node.data_volume_attachments
}
