@ -214,6 +214,7 @@ func legacyDiffComparisonString(changes *plans.Changes) string {
}
byModule := map [ string ] map [ string ] * ResourceChanges { }
resourceKeys := map [ string ] [ ] string { }
requiresReplace := map [ string ] [ ] string { }
var moduleKeys [ ] string
for _ , rc := range changes . Resources {
if rc . Action == plans . NoOp {
@ -239,6 +240,12 @@ func legacyDiffComparisonString(changes *plans.Changes) string {
} else {
byModule [ moduleKey ] [ resourceKey ] . Deposed [ rc . DeposedKey ] = rc
}
rr := [ ] string { }
for _ , p := range rc . RequiredReplace . List ( ) {
rr = append ( rr , hcl2shim . FlatmapKeyFromPath ( p ) )
}
requiresReplace [ resourceKey ] = rr
}
sort . Strings ( moduleKeys )
for _ , ks := range resourceKeys {
@ -254,6 +261,8 @@ func legacyDiffComparisonString(changes *plans.Changes) string {
for _ , resourceKey := range resourceKeys [ moduleKey ] {
rc := rcs [ resourceKey ]
forceNewAttrs := requiresReplace [ resourceKey ]
crud := "UPDATE"
if rc . Current != nil {
switch rc . Current . Action {
@ -341,7 +350,17 @@ func legacyDiffComparisonString(changes *plans.Changes) string {
// at the core layer.
updateMsg := ""
// TODO: Mark " (forces new resource)" in updateMsg when appropriate.
// This may not be as precise as in the old diff, as it matches
// everything under the attribute that was originally marked as
// ForceNew, but should help make it easier to determine what
// caused replacement here.
for _ , k := range forceNewAttrs {
if strings . HasPrefix ( attrK , k ) {
updateMsg = " (forces new resource)"
break
}
}
fmt . Fprintf (
& mBuf , " %s:%s %#v => %#v%s\n" ,