Terraform: Unable to use output with space in identifier

Created on 5 Dec 2017  ยท  3Comments  ยท  Source: hashicorp/terraform

Terraform Version

Terraform v0.11.1

  • provider.openstack v1.0.0

Terraform Configuration Files

From third-party code:

output "router id" {
  value = "${openstack_networking_router_v2.bosh_router.id}"
}

From my own code (multiple examples, not comprehensive):

output "net_id" {
  value = "${module.bosh-init-tf.network id}"
}
output "net_id" {
  value = "${module.bosh-init-tf."network id"}"
}



md5-d5b633427fd39419de506b62fe3154e3



output "net_id" {
  value = "${module.bosh-init-tf.network\ id}"
}



md5-ea9aa1a48738d1ecc9d439aaaafd8d07



terraform init
terraform apply

Perceived erroneous behavior

It seems to me that there should be some way to escape a space in an output identifier or that spaces should be illegal characters in output identifiers; having neither be true makes the language syntactically incomplete and/or incoherent in some situations.

bug config

Most helpful comment

Hi @dhaines! Sorry for this strange behavior.

It is indeed supposed to be forbidden to use a space in an output. Looks like there's some missing validation here.

All 3 comments

Hi @dhaines! Sorry for this strange behavior.

It is indeed supposed to be forbidden to use a space in an output. Looks like there's some missing validation here.

Hi again @dhaines! Sorry for the long silence.

I've just confirmed that the output block name is now validated correctly in v0.12.0-alpha1, and that fix will be included in the forthcoming v0.12.0 release.

Error: Invalid output name

  on output-name-validation.tf line 1, in output "router id":
   1: output "router id" {

A name must start with a letter and may contain only letters, digits,
underscores, and dashes.

This means that the third-party configuration you mentioned will produce an error after upgrading to Terraform 0.12. If you are able to reach the developers of that module, I'd suggest letting them know about this so that they might address it. As you saw, there was previously no way to actually use an output whose name contained a space so hopefully the developer of that module can rename the output to router_id instead.

Thanks for reporting this! Since it's now fixed in master, I'm going to close out this issue.

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.

Was this page helpful?
0 / 5 - 0 ratings