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

Subnet Output Values Format Issue #691

Closed
fitchtech opened this issue Sep 22, 2021 · 4 comments
Closed

Subnet Output Values Format Issue #691

fitchtech opened this issue Sep 22, 2021 · 4 comments

Comments

@fitchtech
Copy link

value = aws_subnet.private.*.id

This is an issue with all subnet outputs. That there should be outputs for each of the subnet resources themselves, instead of or in addition to having an output for that's a list of an attribute for all the subnets of that type.

The reason why this is an issue is that based on the current outputs available I cannot determine which subnet are created in which of the AZ IDs I've specified. The use of the splat expression to output each value separately is the issue. If you were to just output the value = aws_subnet.private it could then be grouped by AZ or any other value of each subnet.

However, since that is missing the only way to determine this is to pass the output subnet IDs to a data source which if the subnets haven't previously been created results in an error that Terraform cannot be determined until apply.

output "private_subnets" {
  description = "List of IDs of private subnets"
  value       = aws_subnet.private.*.id # Using splat expressions to output each value separately is the issue
}

This is how I recommend it should be, output the subnet resource for private, public, intra, database, and redshift:

output "private_subnets" {
  description = "List of IDs of private subnets"
  value       = aws_subnet.private
}

output "private_subnets_ids" {
  description = "List of IDs of private subnets"
  value       = aws_subnet.private.*.id
}

output "public_subnets" {
  description = "List of IDs of publicsubnets"
  value       = aws_subnet.public
}

output "public_subnets_ids" {
  description = "List of IDs of public subnets"
  value       = aws_subnet.public.*.id
}
# Etc, etc, etc...

So that I can do this:

output "subnet_zones" {
  value = { for id, subnet in module.vpc.private_subnets : subnet.availability_zone_id => subnet... }
  description = "Subnets grouped by AZ ID"
}
@antonbabenko
Copy link
Member

This can be a potential workaround until we have proper support for maps instead of lists in subnets (#403).

The downside of the approach you are recommending here is the amount of unnecessary information each aws_subnet resource contains which is rather large to be included in outputs.

@github-actions
Copy link

This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days

@github-actions github-actions bot added the stale label Jan 11, 2022
@github-actions
Copy link

This issue was automatically closed because of stale in 10 days

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants