@@ -2,6 +2,7 @@ package main
2
2
3
3
import (
4
4
"bufio"
5
+ "encoding/base64"
5
6
"encoding/json"
6
7
"fmt"
7
8
"io"
@@ -25,9 +26,9 @@ import (
25
26
// This example uses terraform as the instance plugin.
26
27
// It is very similar to the file instance plugin. When we
27
28
// 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.
31
32
32
33
type plugin struct {
33
34
Dir string
@@ -324,7 +325,7 @@ func (p *plugin) ensureUniqueFile() string {
324
325
325
326
func ensureUniqueFile (dir string ) string {
326
327
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
328
329
if f , err := os .Open (filepath .Join (dir , n ) + ".tf.json" ); err == nil {
329
330
f .Close ()
330
331
return ensureUniqueFile (dir )
@@ -434,7 +435,7 @@ func (p *plugin) Provision(spec instance.Spec) (*instance.ID, error) {
434
435
// merge the inits
435
436
switch properties .Type {
436
437
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 )) )
438
439
case "softlayer_virtual_guest" :
439
440
addUserData (properties .Value , "user_metadata" , spec .Init )
440
441
case "azurerm_virtual_machine" :
0 commit comments