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 (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/sha1"
|
|
||||||
"encoding/base64"
|
|
||||||
"encoding/hex"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -215,8 +212,7 @@ func resourceAwsSpotFleetRequest() *schema.Resource {
|
|||||||
StateFunc: func(v interface{}) string {
|
StateFunc: func(v interface{}) string {
|
||||||
switch v.(type) {
|
switch v.(type) {
|
||||||
case string:
|
case string:
|
||||||
hash := sha1.Sum([]byte(v.(string)))
|
return userDataHashSum(v.(string))
|
||||||
return hex.EncodeToString(hash[:])
|
|
||||||
default:
|
default:
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@ -325,8 +321,7 @@ func buildSpotFleetLaunchSpecification(d map[string]interface{}, meta interface{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if v, ok := d["user_data"]; ok {
|
if v, ok := d["user_data"]; ok {
|
||||||
opts.UserData = aws.String(
|
opts.UserData = aws.String(base64Encode([]byte(v.(string))))
|
||||||
base64Encode([]byte(v.(string))))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if v, ok := d["key_name"]; ok {
|
if v, ok := d["key_name"]; ok {
|
||||||
@ -771,10 +766,7 @@ func launchSpecToMap(l *ec2.SpotFleetLaunchSpecification, rootDevName *string) m
|
|||||||
}
|
}
|
||||||
|
|
||||||
if l.UserData != nil {
|
if l.UserData != nil {
|
||||||
ud_dec, err := base64.StdEncoding.DecodeString(aws.StringValue(l.UserData))
|
m["user_data"] = userDataHashSum(aws.StringValue(l.UserData))
|
||||||
if err == nil {
|
|
||||||
m["user_data"] = string(ud_dec)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if l.KeyName != nil {
|
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["instance_type"].(string)))
|
||||||
buf.WriteString(fmt.Sprintf("%s-", m["spot_price"].(string)))
|
buf.WriteString(fmt.Sprintf("%s-", m["spot_price"].(string)))
|
||||||
buf.WriteString(fmt.Sprintf("%s-", m["user_data"].(string)))
|
|
||||||
return hashcode.String(buf.String())
|
return hashcode.String(buf.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user