mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Fix spurious user_data diffs
This commit is contained in:
parent
93c4730de7
commit
0af10dec41
@ -2,9 +2,6 @@ package aws
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha1"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
@ -215,8 +212,7 @@ func resourceAwsSpotFleetRequest() *schema.Resource {
|
||||
StateFunc: func(v interface{}) string {
|
||||
switch v.(type) {
|
||||
case string:
|
||||
hash := sha1.Sum([]byte(v.(string)))
|
||||
return hex.EncodeToString(hash[:])
|
||||
return userDataHashSum(v.(string))
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
@ -325,8 +321,7 @@ func buildSpotFleetLaunchSpecification(d map[string]interface{}, meta interface{
|
||||
}
|
||||
|
||||
if v, ok := d["user_data"]; ok {
|
||||
opts.UserData = aws.String(
|
||||
base64Encode([]byte(v.(string))))
|
||||
opts.UserData = aws.String(base64Encode([]byte(v.(string))))
|
||||
}
|
||||
|
||||
if v, ok := d["key_name"]; ok {
|
||||
@ -771,10 +766,7 @@ func launchSpecToMap(l *ec2.SpotFleetLaunchSpecification, rootDevName *string) m
|
||||
}
|
||||
|
||||
if l.UserData != nil {
|
||||
ud_dec, err := base64.StdEncoding.DecodeString(aws.StringValue(l.UserData))
|
||||
if err == nil {
|
||||
m["user_data"] = string(ud_dec)
|
||||
}
|
||||
m["user_data"] = userDataHashSum(aws.StringValue(l.UserData))
|
||||
}
|
||||
|
||||
if l.KeyName != nil {
|
||||
@ -1013,7 +1005,6 @@ func hashLaunchSpecification(v interface{}) int {
|
||||
}
|
||||
buf.WriteString(fmt.Sprintf("%s-", m["instance_type"].(string)))
|
||||
buf.WriteString(fmt.Sprintf("%s-", m["spot_price"].(string)))
|
||||
buf.WriteString(fmt.Sprintf("%s-", m["user_data"].(string)))
|
||||
return hashcode.String(buf.String())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user