Terraform Error: Extraneous label for module when running terraform init

5.7k views Asked by At

I am getting this error when I run terraform init:

Error: Extraneous label for module

  on rds.tf line 22, in module "rds" "app":
  22: module "rds" "app" {

Only 1 labels (name) are expected for module blocks.

I have a two modules created "rds" and "app" which I am both referencing when creating a db instance:

# PostgreSQL RDS App Instance
module "rds" "app" {

How doI fix this error?

1

There are 1 answers

0
Steven Viljoen On

If using TF 0.13, another option would be to use a single module with a count set to 2 and then a count.index to fetch the specific name for that iteration from a predefined list [] variable.

https://blog.ktz.me/terraform-0-13-count-modules/