@@ -2,9 +2,6 @@ package aws
22
33import (
44 "bytes"
5- "crypto/sha1"
6- "encoding/base64"
7- "encoding/hex"
85 "fmt"
96 "log"
107 "strconv"
@@ -215,8 +212,7 @@ func resourceAwsSpotFleetRequest() *schema.Resource {
215212 StateFunc : func (v interface {}) string {
216213 switch v .(type ) {
217214 case string :
218- hash := sha1 .Sum ([]byte (v .(string )))
219- return hex .EncodeToString (hash [:])
215+ return userDataHashSum (v .(string ))
220216 default :
221217 return ""
222218 }
@@ -325,8 +321,7 @@ func buildSpotFleetLaunchSpecification(d map[string]interface{}, meta interface{
325321 }
326322
327323 if v , ok := d ["user_data" ]; ok {
328- opts .UserData = aws .String (
329- base64Encode ([]byte (v .(string ))))
324+ opts .UserData = aws .String (base64Encode ([]byte (v .(string ))))
330325 }
331326
332327 if v , ok := d ["key_name" ]; ok {
@@ -771,10 +766,7 @@ func launchSpecToMap(l *ec2.SpotFleetLaunchSpecification, rootDevName *string) m
771766 }
772767
773768 if l .UserData != nil {
774- ud_dec , err := base64 .StdEncoding .DecodeString (aws .StringValue (l .UserData ))
775- if err == nil {
776- m ["user_data" ] = string (ud_dec )
777- }
769+ m ["user_data" ] = userDataHashSum (aws .StringValue (l .UserData ))
778770 }
779771
780772 if l .KeyName != nil {
@@ -1013,7 +1005,6 @@ func hashLaunchSpecification(v interface{}) int {
10131005 }
10141006 buf .WriteString (fmt .Sprintf ("%s-" , m ["instance_type" ].(string )))
10151007 buf .WriteString (fmt .Sprintf ("%s-" , m ["spot_price" ].(string )))
1016- buf .WriteString (fmt .Sprintf ("%s-" , m ["user_data" ].(string )))
10171008 return hashcode .String (buf .String ())
10181009}
10191010
0 commit comments