Skip to content

Omitting private_ips variable result in terraform error. #41

Open
@riccardomassullo

Description

@riccardomassullo

Found a bug? Maybe our Slack Community can help.

Slack Community

Describe the Bug

When omitting private_ips var the execution ends whit the rollowing error:

Releasing state lock. This may take a few moments...                                                                                                                            
╷                                                                                                                                                                               
│ Error: expected private_ip to contain a valid IPv4 address, got:                                                                                                              
│                                                                                                                                                                               
│   with module.sherpa.module.ec2_instance_group[1].aws_instance.default[0],                                                                                                    
│   on ../../modules/aws/ec2_group/main.tf line 97, in resource "aws_instance" "default":                                                                                       
│   97:   private_ip                  = concat(var.private_ips, [""])[min(length(var.private_ips), count.index)]                                                                
│                                                                                                                                                                               
╵                                                                                                                                                                               
╷                                                                                                                                                                               
│ Error: expected private_ip to contain a valid IPv4 address, got:                                                                                                              
│                                                                                                                                                                               
│   with module.sherpa.module.ec2_instance_group[0].aws_instance.default[0],                                                                                                    
│   on ../../modules/aws/ec2_group/main.tf line 97, in resource "aws_instance" "default":                                                                                       
│   97:   private_ip                  = concat(var.private_ips, [""])[min(length(var.private_ips), count.index)]                                                                
│ 

Expected Behavior

As per documentation in README.md, the parameter shouldn't be mandatory.

Steps to Reproduce

Omit it in the ec2_group module declaration.

Screenshots

If applicable, add screenshots or logs to help explain your problem.

Environment (please complete the following information):

Anything that will help us triage the bug will help. Here are some ideas:

  • OS: Ubuntu
  • Version: 20.04

Additional Context

Could be easily solved by introducing a check in the aws_instance resource, in main.tf, at line 97.
e.g.: private_ip = length(var.private_ips) > 0 ? concat(var.private_ips, [""])[min(length(var.private_ips), count.index)] : null

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug🐛 An issue with the system

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions