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

More complex, formatted, outputs with splats #8105

Closed
ghost opened this issue Aug 10, 2016 · 4 comments
Closed

More complex, formatted, outputs with splats #8105

ghost opened this issue Aug 10, 2016 · 4 comments

Comments

@ghost
Copy link

ghost commented Aug 10, 2016

Terraform Version

Terraform v0.7.0

Terraform Configuration Files

Assuming a base config as in issue #2821 and this output definition:

output "int_subnets" {
  value = ["Subnet with CIDR ${aws_subnet.int.*.cidr_block} is in availability zone ${aws_subnet.int.*.availability_zone}"]
}

Expected Behavior

I'd expect this to render as:

int_subnets = [
    Subnet with CIDR 10.0.0.0/24 is in availability zone eu-west-1a,
    Subnet with CIDR 10.0.1.0/24 is in availability zone eu-west-1b   
]

(this kind of thing can already be done in an output where splats/lists are not involved)

Actual Behavior

Nothing is output at all.

@phinze
Copy link
Contributor

phinze commented Aug 11, 2016

Hi @RodoM - the formatlist() interpolation function should do what you want here.

An example:

resource "aws_vpc" "main" {
  cidr_block = "10.0.0.0/16"
}
resource "aws_subnet" "int" {
  count      = 3
  vpc_id     = "${aws_vpc.main.id}"
  cidr_block = "10.0.${count.index}.0/24"
}
output "list" {
  value = "${
    formatlist(
      "Subnet with CIDR %s is in availability zone %s",
      aws_subnet.int.*.cidr_block,
      aws_subnet.int.*.availability_zone
    )}"
}
Outputs:

list = [
    Subnet with CIDR 10.0.0.0/24 is in availability zone us-west-2b,
    Subnet with CIDR 10.0.1.0/24 is in availability zone us-west-2a,
    Subnet with CIDR 10.0.2.0/24 is in availability zone us-west-2a
]

@phinze phinze closed this as completed Aug 11, 2016
@ghost
Copy link
Author

ghost commented Aug 12, 2016

Thanks @phinze that works. It's still not what I'd have expected to be consistent with the non-list case, but it works. As an aside, outputs should not silently fail when there's something wrong with them - is that being addressed?

@ghost
Copy link
Author

ghost commented Aug 12, 2016

I'll answer my own question :-) #5334.

@ghost
Copy link

ghost commented Apr 23, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants