mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-20 11:48:24 -06:00
Adds a diff suppress function for the `engine_version` attribute of the `db_instance` AWS resource. The function only supresses the state diff, if the attribute key `auto_minor_version_upgrade` is set, and if the returned `engine_version` from the running RDS instance shares the same prefix as the configured `engine_version`. ``` $ make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSDBInstance_MinorVersion' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2017/01/23 17:59:14 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSDBInstance_MinorVersion -timeout 120m === RUN TestAccAWSDBInstance_MinorVersion --- PASS: TestAccAWSDBInstance_MinorVersion (503.48s) PASS ok github.com/hashicorp/terraform/builtin/providers/aws 503.518s ```
34 lines
813 B
Go
34 lines
813 B
Go
package aws
|
|
|
|
import (
|
|
"log"
|
|
"strings"
|
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
"github.com/jen20/awspolicyequivalence"
|
|
)
|
|
|
|
func suppressEquivalentAwsPolicyDiffs(k, old, new string, d *schema.ResourceData) bool {
|
|
equivalent, err := awspolicy.PoliciesAreEquivalent(old, new)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
|
|
return equivalent
|
|
}
|
|
|
|
// Suppresses minor version changes to the db_instance engine_version attribute
|
|
func suppressAwsDbEngineVersionDiffs(k, old, new string, d *schema.ResourceData) bool {
|
|
if d.Get("auto_minor_version_upgrade").(bool) {
|
|
// If we're set to auto upgrade minor versions
|
|
// ignore a minor version diff between versions
|
|
if strings.HasPrefix(old, new) {
|
|
log.Printf("[DEBUG] Ignoring minor version diff")
|
|
return true
|
|
}
|
|
}
|
|
|
|
// Throw a diff by default
|
|
return false
|
|
}
|