antonbabenko / modules.tf-lambda

Infrastructure as code generator - from visual diagrams created with Cloudcraft.co to Terraform
https://www.cloudcraft.co/
MIT License
351 stars 56 forks source link

multiple ec2s getting "var.subnet_ids is empty list of string" #53

Open kataqatsi opened 4 years ago

kataqatsi commented 4 years ago

Describe the bug

Receiving this error on multiple ec2s before the build fails:

Error: Error in function call

  on main.tf line 12, in resource "aws_instance" "this":
  12:   subnet_id = length(var.network_interface) > 0 ? null : element(
  13:     distinct(compact(concat([var.subnet_id], var.subnet_ids))),
  14:     count.index,
  15:   )
    |----------------
    | count.index is 0
    | var.subnet_id is ""
    | var.subnet_ids is empty list of string

Call to function "element" failed: cannot use element function with an empty
list.

Releasing state lock. This may take a few moments...

-----BEGIN PGP MESSAGE----- Version: Keybase OpenPGP v2.1.13 Comment: https://keybase.io/crypto

wcFMAxWeMqYOPYuBAQ//biL5BcqYVj+IirR88sspCQNnCBT3ImaQ55Vo6dtf/96c yYc3JNnFtOEtTmrcf8ZpGvPe6ITtRIpuRLtDL9Yd/1zfBgX4tw2YZPny+QVHKvt2 CLLFLasS8MZNvQzv13NXPVo99t9tsGCvKFssZHHxXDy7VBjW0qhdU1pNIalwkv6x svbTsoJrLyu1wbNy691ZkmjvxXSdFeA01gys4x2qJi7v1NcMqJgO6WN4KVJigWm/ zWqfvJfW2gRJzOH/KOEQZletApOAqq/JtDT14f82JlDwxh6MmwKDO+8mc3wsjR6p 8dkNMklMOGeBtZGD69jaEX4U3ogmL6YNsJs4v+lQkMJfCDTGCmxAW/We2Wp1NgyD iLdkxMANRA17JnaqRNKl4IjUJ0JsqfgcROKlV3LfvoXDoyCnMibWpGsVdyzKKJMY JSaLBXyEwtnt5Cou1ZzM7wMSLXCeik6a8XeW/fCbQb/OkKRbA7FgxzTgcxJ+80AB 8xHbLVYW/J6ZOW6nJXyBBl6YL5tPZw8Ox8lD8366s8xOLkWcEdPQG3FMAAekUo+5 gd9qolZ0AzJtK6Nb+V4ryeqWPjnbEUDNLwN7gFNR0/lZ2po1PHcxcP8hqtGLBEGd Qj2ILX83S+uysN5beyHaWkSqOMOv8v8LDMVdAyB5DfudIKNHI9NdeLxlpHwH+LTS mgEUATjwkT3bqgL0KdgAy3nL4Xjx9RZC4Ur7/Gkuu6on4XM8vnbyu7FXG9IpkGdr FJzfEEeXmnkSPDeTC02JknyPVUx0R5Wob1ECHNJUJuvS1gDqK38kpYrj9EuEio9L 9DErJP6u0SPtksmlzJaQuw7khZ93+3dssGAmFb/POpCvhIc+3KXC5iT/0hZMZngf Omb1BkXHx9yfi8w= =AMYJ -----END PGP MESSAGE-----

Expected behavior

After exporting my project to tf and installing dependencies, expected a successful build

Actual behavior

Build failure

antonbabenko commented 4 years ago

Thanks for opening this issue. Subnets are available in cloudcraft but not yet exported into terraform configurations by modules.tf, so you will have to specify subnet_id or subnet_ids arguments in ec2-instance layers.

I will keep this open as a reminder for myself when working on this project.