From c54b2cdec39e213fad8cdc4e4e2d31d55745c0a5 Mon Sep 17 00:00:00 2001 From: Patrick Decat Date: Mon, 17 Jun 2019 16:39:32 +0200 Subject: [PATCH] Sort IAM policy bindings by their role name to get simpler diffs as it's what the API does --- google/data_source_google_iam_policy.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/google/data_source_google_iam_policy.go b/google/data_source_google_iam_policy.go index 3a8bac5ed1a..ce78fee81df 100644 --- a/google/data_source_google_iam_policy.go +++ b/google/data_source_google_iam_policy.go @@ -2,6 +2,7 @@ package google import ( "encoding/json" + "sort" "strconv" "github.com/hashicorp/terraform/helper/hashcode" @@ -103,6 +104,11 @@ func dataSourceGoogleIamPolicyRead(d *schema.ResourceData, meta interface{}) err } } + // Sort bindings by their role name to get simpler diffs as it's what the API does + sort.Slice(bindings, func(i, j int) bool { + return bindings[i].Role < bindings[j].Role + }) + // Convert each audit_config into a cloudresourcemanager.AuditConfig policy.AuditConfigs = expandAuditConfig(aset)