Skip to content

"Error: Invalid index" in module "security_group_splunk" v3.3.0 #152

@mmacvicar-splunk

Description

@mmacvicar-splunk

"Error: Invalid index" in module "security_group_splunk" v3.3.0

started occurring in v3.2.0 (doesn't occur in v3.1.0), using terraform v0.12 cli

Reproducible Steps

  1. terraform plan on the file below reports the following errors:
Error: Invalid index

  on .terraform/modules/security_group_splunk/main.tf line 65, in resource "aws_security_group_rule" "ingress_rules":
  65:   description      = var.rules[var.ingress_rules[count.index]][3]
    |----------------
    | count.index is 1
    | var.ingress_rules is list of string with 5 elements
    | var.rules is map of list of string with 97 elements

The given key does not identify an element in this collection value.


Error: Invalid index

  on .terraform/modules/security_group_splunk/main.tf line 67, in resource "aws_security_group_rule" "ingress_rules":
  67:   from_port = var.rules[var.ingress_rules[count.index]][0]
    |----------------
    | count.index is 1
    | var.ingress_rules is list of string with 5 elements
    | var.rules is map of list of string with 97 elements

The given key does not identify an element in this collection value.


Error: Invalid index

  on .terraform/modules/security_group_splunk/main.tf line 68, in resource "aws_security_group_rule" "ingress_rules":
  68:   to_port   = var.rules[var.ingress_rules[count.index]][1]
    |----------------
    | count.index is 1
    | var.ingress_rules is list of string with 5 elements
    | var.rules is map of list of string with 97 elements

The given key does not identify an element in this collection value.


Error: Invalid index

  on .terraform/modules/security_group_splunk/main.tf line 69, in resource "aws_security_group_rule" "ingress_rules":
  69:   protocol  = var.rules[var.ingress_rules[count.index]][2]
    |----------------
    | count.index is 1
    | var.ingress_rules is list of string with 5 elements
    | var.rules is map of list of string with 97 elements

The given key does not identify an element in this collection value.

main.tf

variable "region" {
  default = "eu-west-1"
}

provider "template" {
  version = "~> 2.1"
}

provider "aws" {
  region  = var.region
  version = "~> 2.7"
}

data "aws_vpc" "default" {
  default = true
}

# Default security group for Splunk resources
module "security_group_splunk" {
  source      = "terraform-aws-modules/security-group/aws//modules/splunk"
  version     = "3.3.0"
  name        = "splunk-default-sg"
  description = "Default Security Group for Splunk instances"

  vpc_id = data.aws_vpc.default.id

  ingress_cidr_blocks = [data.aws_vpc.default.cidr_block]
  ingress_rules       = ["all-all"]
  egress_rules        = ["all-all"]

  tags = {
    Name          = "splunk-default-sg"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions