From 82cc9d3e560dfedc8f5a67517a6122978cfa6b3c Mon Sep 17 00:00:00 2001 From: Andreas Kyrris Date: Tue, 27 Sep 2016 17:15:02 +0100 Subject: [PATCH] Supress diffs for differences in resource_group_name capitalisation. --- builtin/providers/azurerm/provider.go | 6 ++++++ builtin/providers/azurerm/resource_arm_storage_account.go | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/builtin/providers/azurerm/provider.go b/builtin/providers/azurerm/provider.go index 4a3b3ac35..352897dd2 100644 --- a/builtin/providers/azurerm/provider.go +++ b/builtin/providers/azurerm/provider.go @@ -236,3 +236,9 @@ func azureStateRefreshFunc(resourceURI string, client *ArmClient, command rivier panic(fmt.Errorf("azureStateRefreshFunc called on structure %T with no mapstructure:provisioningState tag. This is a bug", res.Parsed)) } } + +// Resource group names can be capitalised, but we store them in lowercase. +// Use a custom diff function to avoid creation of new resources. +func resourceAzurermResourceGroupNameDiffSuppress(k, old, new string, d *schema.ResourceData) bool { + return strings.ToLower(old) == strings.ToLower(new) +} diff --git a/builtin/providers/azurerm/resource_arm_storage_account.go b/builtin/providers/azurerm/resource_arm_storage_account.go index 47789b15b..6f485169e 100644 --- a/builtin/providers/azurerm/resource_arm_storage_account.go +++ b/builtin/providers/azurerm/resource_arm_storage_account.go @@ -33,9 +33,10 @@ func resourceArmStorageAccount() *schema.Resource { }, "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: resourceAzurermResourceGroupNameDiffSuppress, }, "location": {