@@ -2,6 +2,7 @@ package main
22
33import (
44 "bufio"
5+ "encoding/base64"
56 "encoding/json"
67 "fmt"
78 "io"
@@ -25,9 +26,9 @@ import (
2526// This example uses terraform as the instance plugin.
2627// It is very similar to the file instance plugin. When we
2728// provision an instance, we write a *.tf.json file in the directory
28- // and call terra apply. For describing instances, we parse the
29- // result of terra show. Destroying an instance is simply removing a
30- // tf.json file and call terra apply again.
29+ // and call terraform apply. For describing instances, we parse the
30+ // result of terraform show. Destroying an instance is simply removing a
31+ // tf.json file and call terraform apply again.
3132
3233type plugin struct {
3334 Dir string
@@ -324,7 +325,7 @@ func (p *plugin) ensureUniqueFile() string {
324325
325326func ensureUniqueFile (dir string ) string {
326327 n := fmt .Sprintf ("instance-%d" , time .Now ().Unix ())
327- // if we can open then we have to try again... the file cannot exist currently
328+ // if we can open then we have to try again... the file cannot exist currently
328329 if f , err := os .Open (filepath .Join (dir , n ) + ".tf.json" ); err == nil {
329330 f .Close ()
330331 return ensureUniqueFile (dir )
@@ -434,7 +435,7 @@ func (p *plugin) Provision(spec instance.Spec) (*instance.ID, error) {
434435 // merge the inits
435436 switch properties .Type {
436437 case "aws_instance" , "digitalocean_droplet" :
437- addUserData (properties .Value , "user_data" , spec .Init )
438+ addUserData (properties .Value , "user_data" , base64 . StdEncoding . EncodeToString ([] byte ( spec .Init )) )
438439 case "softlayer_virtual_guest" :
439440 addUserData (properties .Value , "user_metadata" , spec .Init )
440441 case "azurerm_virtual_machine" :
0 commit comments