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

output not working with Terraform 10 #16317

Closed
jegadeshhike opened this issue Oct 12, 2017 · 4 comments
Closed

output not working with Terraform 10 #16317

jegadeshhike opened this issue Oct 12, 2017 · 4 comments

Comments

@jegadeshhike
Copy link

jegadeshhike commented Oct 12, 2017

Terraform v0.9.11

Code:

resource "google_compute_instance" "nomad" {
 count = 1 
    zone  = "asia-southeast1-a"

 name = "nomad-${count.index}"
 machine_type = "n1-standard-2"
 disk {
    image = "ubuntu-1404-trusty-v20170918"
 }
 network_interface {
   network = "default"
   access_config {
   }
 }
}

output "masterip" {
 value = "${google_compute_instance.nomad.*.network_interface.0.address}"
}
output "externalip" {
 value = "${google_compute_instance.nomad.*.network_interface.0.access_config.0.assigned_nat_ip}"
}

Result : 

Outputs:

externalip = [
    3*.*.236.242
]
masterip = [
    10.*.*.2
]

"Terraform '0.10.7'"

resource "google_compute_disk" "nomad-disk" {
    name  = "nomad-disk1"
    zone  = "asia-southeast1-a"
    type  = "pd-ssd"
    image = "ubuntu-1404-trusty-v20170918"
    size = 10
}

resource "google_compute_instance" "nomad" {
 count = 1
    zone  = "asia-southeast1-a"

 name = "nomad-${count.index}"
 machine_type = "n1-standard-2"
 boot_disk {
       source = "${google_compute_disk.nomad-disk.id}"
 }
 network_interface {
   network = "default"
   access_config {
   }
 }
}

output "masterip" {
 value = "${google_compute_instance.nomad.*.network_interface.0.address}"
}
output "externalip" {
 value = "${google_compute_instance.nomad.*.network_interface.0.access_config.0.assigned_nat_ip}"
}


Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

externalip = [
]
masterip = [
]
@jegadeshhike
Copy link
Author

Workaround : Downgraded to Terraform v0.9.11

@hashibot
Copy link
Contributor

This issue has been automatically migrated to hashicorp/terraform-provider-google#595 because it looks like an issue with that provider. If you believe this is not an issue with the provider, please reply to this issue and let us know.

@pavelsmejkal
Copy link

Terraform v0.10.7
Terraform v0.10.8

├── module
│   └── module.tf
├── state.tf
├── terraform.tfstate
└── terraform.tfstate.backup

cat state.tf

module "mod" {
   source = "./module"
   key="key2"
}

cat module/module.tf

variable "key" { }
output "key" {
   value = "value-${var.key}"
}

Steps

  • terraform apply
  • change key="key2" => key="key3"
  • terraform apply -target=module.mod
  • terraform output -module=mod

Expected

key = value-key3

Actual

key = value-key2

i have to "terraform apply" to get output variable updated

@ghost
Copy link

ghost commented Apr 6, 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 6, 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

4 participants