Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] <Unable to execute plan successfully upon module asg.> #92

Open
Karatonev opened this issue Nov 7, 2024 · 1 comment
Open
Assignees
Labels
help wanted Extra attention is needed

Comments

@Karatonev
Copy link

Describe the bug

I am trying to use the ASG module.
The invocation of the module is as follows:

module "paloalto" {
source = "../../../terraform-aws-swfw-modules/modules/asg"
ssh_key_name = "paloalto"
interfaces = {
mgmt = {
device_index = 0
subnet_id = "subnet-xxxxxxxxxxxxxxxxxxx"
name = "mgmt"
create_public_ip = true
source_dest_check = true
security_group_ids = ["sg-xxxxxxxxxxxxxxx"]
},
public = {
device_index = 1
subnet_id = "subnet-xxxxxxxxxxxxxxxxxxx"
name = "public"
create_public_ip = true
source_dest_check = true
security_group_ids = ["sg-xxxxxxxxxxxxxxx"]
},
private = {
device_index = 2
subnet_id = "subnet-xxxxxxxxxxxxxxxxxxx"
name = "private"
create_public_ip = false
source_dest_check = true
security_group_ids = ["sg-xxxxxxxxxxxxxxx"]
}
}
global_tags = {}
region="eu-west-1"
name_prefix = "palo-alto-test"
target_group_arn = aws_lb_target_group.this.arn

}

I stumbled across the following:

default_eni_subnet_names = flatten([for k, v in var.interfaces : v.subnet_id if v.device_index == 0]) //Line 29

This is going to produce a list.

Then this:
subnet_id = values(local.default_eni_subnet_names[0])[0] // Line 72

Module Version

2.0.16

Terraform version

Terraform v1.9.7

Expected behavior

Run terraform plan successfuly.

Current behavior

│ Error: Error in function call

│ on ......\terraform-aws-swfw-modules\modules\asg\main.tf line 72, in resource "aws_launch_template" "this":
│ 72: subnet_id = values(local.default_eni_subnet_names[0])[0]
│ ├────────────────
│ │ while calling values(mapping)
│ │ local.default_eni_subnet_names[0] is "subnet-027e04xxxxxx"

│ Call to function "values" failed: values() requires a map as the first argument.

Anything else to add?

No response

@acelebanski acelebanski self-assigned this Nov 13, 2024
@acelebanski acelebanski added bug Something isn't working help wanted Extra attention is needed and removed bug Something isn't working labels Nov 13, 2024
@acelebanski
Copy link
Contributor

acelebanski commented Nov 13, 2024

Hello @Karatonev, try passing a map to subnet_id where key is availability zone name and value is subnet id.

Like this:

subnet_id = {
  "eu-west-1a" = "sg-xxxxxxxxxxxxxxx"
}

If you're deploying in multiple AZs, you can add more keys to this map.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants