F5Networks / terraform-aws-bigip-module

Terraform module for Deploying BIG-IP in AWS
Apache License 2.0
10 stars 21 forks source link

Security Group ID List String Type Error: given index is greater than or equal to the length of the collection #10

Closed jdj333 closed 2 years ago

jdj333 commented 2 years ago
module "bigip" {
  source                      = "F5Networks/bigip-module/aws"
  count                       = var.instance_count
  prefix                      = var.prefix
  ec2_key_name                = var.ec2_key_name
  mgmt_subnet_ids             = var.mgmt_subnet_ids
  external_subnet_ids         = var.external_subnet_ids
  internal_subnet_ids         = var.internal_subnet_ids

  mgmt_securitygroup_ids      = ["sg-00000000000000001"] #var.mgmt_securitygroup_ids
  external_securitygroup_ids  = ["sg-00000000000000002"] #var.external_securitygroup_ids
  internal_securitygroup_ids  = ["sg-00000000000000003"] #var.internal_securitygroup_ids

  f5_username                 = var.f5_username
  f5_password                 = var.f5_password
}

When supplying a string list of security group IDs from either variables or supplying the string list within the module definition I get the following error.

Am I formatting the security group IDs incorrectly? What data type are the securitygroup_ids expecting? NOTE: I replaced the security group IDs with fake strings for security.

 Error: Invalid index
│ 
│   on .terraform/modules/bigip/locals.tf line 21, in locals:
│   21:     for i in local.mgmt_public_index : local.bigip_map["mgmt_securitygroup_ids"][i]
│     ├────────────────
│     │ local.bigip_map["mgmt_securitygroup_ids"] is list of string with 1 element
│ 
│ The given key does not identify an element in this collection value: the
│ given index is greater than or equal to the length of the collection.
╵
╷
│ Error: Invalid index
│ 
│   on .terraform/modules/bigip/locals.tf line 21, in locals:
│   21:     for i in local.mgmt_public_index : local.bigip_map["mgmt_securitygroup_ids"][i]
│     ├────────────────
│     │ local.bigip_map["mgmt_securitygroup_ids"] is list of string with 1 element
│ 
│ The given key does not identify an element in this collection value: the
│ given index is greater than or equal to the length of the collection.
╵
╷
│ Error: Invalid index
│ 
│   on .terraform/modules/bigip/locals.tf line 47, in locals:
│   47:     for i in local.external_public_index : local.bigip_map["external_securitygroup_ids"][i]
│     ├────────────────
│     │ local.bigip_map["external_securitygroup_ids"] is list of string with 1 element
│ 
│ The given key does not identify an element in this collection value: the
│ given index is greater than or equal to the length of the collection.
╵
╷
│ Error: Invalid index
│ 
│   on .terraform/modules/bigip/locals.tf line 47, in locals:
│   47:     for i in local.external_public_index : local.bigip_map["external_securitygroup_ids"][i]
│     ├────────────────
│     │ local.bigip_map["external_securitygroup_ids"] is list of string with 1 element
│ 
│ The given key does not identify an element in this collection value: the
│ given index is greater than or equal to the length of the collection.
╵
╷
│ Error: Invalid index
│ 
│   on .terraform/modules/bigip/locals.tf line 73, in locals:
│   73:     for i in local.internal_public_index : local.bigip_map["internal_securitygroup_ids"][i]
│     ├────────────────
│     │ local.bigip_map["internal_securitygroup_ids"] is list of string with 1 element
│ 
│ The given key does not identify an element in this collection value: the
│ given index is greater than or equal to the length of the collection.
╵
╷
│ Error: Invalid index
│ 
│   on .terraform/modules/bigip/locals.tf line 73, in locals:
│   73:     for i in local.internal_public_index : local.bigip_map["internal_securitygroup_ids"][i]
│     ├────────────────
│     │ local.bigip_map["internal_securitygroup_ids"] is list of string with 1 element
│ 
│ The given key does not identify an element in this collection value: the
│ given index is greater than or equal to the length of the collection.
trinaths commented 2 years ago

Created [INFRAANO-726] for internal tracking.

jdj333 commented 2 years ago

Created [INFRAANO-726] for internal tracking.

I found out the issue. I had 2 subnets and only 1 security group. I got past the error by assigning 2 security groups so there is a 1 to 1 mapping as specified in the NOTE on this page: https://registry.terraform.io/modules/F5Networks/bigip-module/aws/latest

Closing the ticket.