Inappropriate value for attribute "subnet_ids": element 0: string required

Hi,

I’m using Registry Module (Git Link : https://github.com/tmknom/terraform-aws-elasticache-redis) to create elasticache_redis with two cluster. I’m passing Subnet Ids from Registry Module (Registry Link : https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws/2.9.0/Git Link : https://github.com/terraform-aws-modules/terraform-aws-vpc).

I’m getting following error, When I’m passing output from VPC Module Subnetids to Elasticache module. Please note that both VPC & Subnet Id are of list types, I’m not getting error for VPC but for Subnetids I’m getting error.

What do you think, I’m doing wrong here?

aws_subnet.elasticache.*.id

Error: Incorrect attribute value type

on .terraform/modules/elasticache_redis/main.tf line 105, in resource “aws_elasticache_subnet_group” “default”:
105: subnet_ids = ["${var.subnet_ids}"]

Inappropriate value for attribute “subnet_ids”: element 0: string required.

Error: Incorrect attribute value type

on .terraform/modules/elasticache_redis/main.tf line 126, in resource “aws_security_group_rule” “ingress”:
126: cidr_blocks = ["${var.ingress_cidr_blocks}"]

Inappropriate value for attribute “cidr_blocks”: element 0: string required.

ubuntu@ip-172-31-45-128:~/downloads/.terraform/modules/vpc/terraform-aws-modules-terraform-aws-vpc-271b6a7/examples/complete-vpc$

Hi @Kalyan-Alamuru,

Unfortunately it seems that this module is using a backward-compatibility form that is no longer valid in Terraform 0.12.

If this module were under your control then you could make it work by running terraform 0.12upgrade on it, or (for a more localized solution) removing the redundant brackets around the value that make it appear to Terraform 0.12 as being a list of lists, rather than a list of strings.

However, it sounds like you’re using a third-party module from the registry here, in which case this is harder to work around. You could potentially fork the module and run the upgrade steps on it yourself, or perhaps the module maintainer would accept an issue or PR for updating the existing module to support Terraform 0.12.

hi @apparentlymart ,

Thank you very much detailed response. Yes it is not my module I’ve forked it and made changes as described to below resource modules in third party code and it worked fine.

How can we raise issue to be resolved by module creator? So that someone wants to use in future doesn’t have to go through this?

Following are the changes I’ve done :slightly_frowning_face:

https://www.terraform.io/docs/providers/aws/r/elasticache_subnet_group.html

resource “aws_elasticache_subnet_group” “default” {
name = “{var.name}" subnet_ids = "{var.subnet_ids}”
description = “${var.description}”

I’ve removed extra “SQUARE Brackets” from Subnet id. Samthing has been applied for CIDR_BLOCKS variable also below .

https://www.terraform.io/docs/providers/aws/r/security_group_rule.html

resource “aws_security_group_rule” “ingress” {
type = “ingress”
from_port = “{var.port}" to_port = "{var.port}”
protocol = “tcp”
cidr_blocks = “{var.ingress_cidr_blocks}" security_group_id = "{aws_security_group.default.id}”

It seems from your question that you already identified the GitHub repository for this, so if you have already made the changes in a fork maybe the best path here is to propose your changes in a pull request.

Note that most of the modules in the Terraform Registry are not maintained by HashiCorp, but are rather maintained by community members, so the maintainer of this module may have some reservations about just upgrading to 0.12 syntax, but opening a PR would be a good way to start the conversation.