2016-06-17 10 views
3

In der Terraform-Dokumentation wird gezeigt, wie eine Vorlage verwendet wird. Gibt es eine Möglichkeit, diese gerenderte Ausgabe der Konsole zu protokollieren?Drucken Terraform Vorlage gerendert Ausgabe im Terminal?

https://www.terraform.io/docs/configuration/interpolation.html#templates

resource "template_file" "example" { 
    template = "${hello} ${world}!" 
    vars { 
    hello = "goodnight" 
    world = "moon" 
    } 
} 

output "rendered" { 
    value = "${template_file.example.rendered}" 
} 

Antwort

2

Sie benötigen terraform apply dann terraform output rendered

$ terraform apply 
template_file.example: Creating... 
    rendered: "" => "<computed>" 
    template: "" => "${hello} ${world}!" 
    vars.#:  "" => "2" 
    vars.hello: "" => "goodnight" 
    vars.world: "" => "moon" 
template_file.example: Creation complete 

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

The state of your infrastructure has been saved to the path 
below. This state is required to modify and destroy your 
infrastructure, so keep it safe. To inspect the complete state 
use the `terraform show` command. 

State path: terraform.tfstate 

Outputs: 

    rendered = goodnight moon! 
$ terraform output rendered 
goodnight moon! 
+2

Beachten Sie, dass 'terraform refresh' ausreichend ist; Sie müssen nicht "Terraform anwenden". –

0

Ist dieser Code vielleicht Teil eines Moduls laufen? Wenn es Teil eines Moduls ist, wird es nicht angezeigt. Sie müssen die Ausgabe des Moduls dort platzieren, wo das Modul aufgerufen wird.