amazon builder: always base64 encode ec2 user data

This commit is contained in:
Florian Noeding 2015-07-31 16:34:33 +02:00
parent 207b81c86b
commit 62c39888b4
1 changed files with 5 additions and 6 deletions

View File

@ -54,14 +54,13 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
return multistep.ActionHalt return multistep.ActionHalt
} }
// Test if it is encoded already, and if not, encode it
if _, err := base64.StdEncoding.DecodeString(string(contents)); err != nil {
log.Printf("[DEBUG] base64 encoding user data...")
contents = []byte(base64.StdEncoding.EncodeToString(contents))
}
userData = string(contents) userData = string(contents)
}
// Test if it is encoded already, and if not, encode it
if _, err := base64.StdEncoding.DecodeString(userData); err != nil {
log.Printf("[DEBUG] base64 encoding user data...")
userData = base64.StdEncoding.EncodeToString([]byte(userData))
} }
ui.Say("Launching a source AWS instance...") ui.Say("Launching a source AWS instance...")