github.com/simonswine/terraform@v0.9.0-beta2/builtin/providers/aws/diff_suppress_funcs.go (about)

     1  package aws
     2  
     3  import (
     4  	"log"
     5  	"strings"
     6  
     7  	"github.com/hashicorp/terraform/helper/schema"
     8  	"github.com/jen20/awspolicyequivalence"
     9  )
    10  
    11  func suppressEquivalentAwsPolicyDiffs(k, old, new string, d *schema.ResourceData) bool {
    12  	equivalent, err := awspolicy.PoliciesAreEquivalent(old, new)
    13  	if err != nil {
    14  		return false
    15  	}
    16  
    17  	return equivalent
    18  }
    19  
    20  // Suppresses minor version changes to the db_instance engine_version attribute
    21  func suppressAwsDbEngineVersionDiffs(k, old, new string, d *schema.ResourceData) bool {
    22  	// First check if the old/new values are nil.
    23  	// If both are nil, we have no state to compare the values with, so register a diff.
    24  	// This populates the attribute field during a plan/apply with fresh state, allowing
    25  	// the attribute to still be used in future resources.
    26  	// See https://github.com/hashicorp/terraform/issues/11881
    27  	if old == "" && new == "" {
    28  		return false
    29  	}
    30  
    31  	if v, ok := d.GetOk("auto_minor_version_upgrade"); ok {
    32  		if v.(bool) {
    33  			// If we're set to auto upgrade minor versions
    34  			// ignore a minor version diff between versions
    35  			if strings.HasPrefix(old, new) {
    36  				log.Printf("[DEBUG] Ignoring minor version diff")
    37  				return true
    38  			}
    39  		}
    40  	}
    41  
    42  	// Throw a diff by default
    43  	return false
    44  }