From dc7234aba6bedfeef6b9f0caba20ec6651716095 Mon Sep 17 00:00:00 2001 From: kohei3110 Date: Tue, 18 May 2021 17:59:01 +0900 Subject: [PATCH 1/4] modified wrong server resources --- website/docs/r/mssql_database.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/r/mssql_database.html.markdown b/website/docs/r/mssql_database.html.markdown index cdad2ff91b5e..bcddb7e773bc 100644 --- a/website/docs/r/mssql_database.html.markdown +++ b/website/docs/r/mssql_database.html.markdown @@ -32,7 +32,7 @@ resource "azurerm_storage_account" "example" { account_replication_type = "LRS" } -resource "azurerm_sql_server" "example" { +resource "azurerm_mssql_server" "example" { name = "example-sqlserver" resource_group_name = azurerm_resource_group.example.name location = azurerm_resource_group.example.location @@ -43,7 +43,7 @@ resource "azurerm_sql_server" "example" { resource "azurerm_mssql_database" "test" { name = "acctest-db-d" - server_id = azurerm_sql_server.example.id + server_id = msazurerm_mssql_server.example.id collation = "SQL_Latin1_General_CP1_CI_AS" license_type = "LicenseIncluded" max_size_gb = 4 From 1ec855cc1348e670e227a76840636696b4bcfd22 Mon Sep 17 00:00:00 2001 From: kohei3110 Date: Thu, 27 May 2021 22:39:29 +0900 Subject: [PATCH 2/4] fix azurerm_spatial_anchors_account tags argument always forces replacement of spatial_anchors_account resource #11037 --- .../spatial_anchors_account_resource.go | 34 +++---------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/azurerm/internal/services/mixedreality/spatial_anchors_account_resource.go b/azurerm/internal/services/mixedreality/spatial_anchors_account_resource.go index 5c5e4501c684..bb1351c2b11b 100644 --- a/azurerm/internal/services/mixedreality/spatial_anchors_account_resource.go +++ b/azurerm/internal/services/mixedreality/spatial_anchors_account_resource.go @@ -20,21 +20,20 @@ import ( func resourceSpatialAnchorsAccount() *schema.Resource { return &schema.Resource{ - Create: resourceSpatialAnchorsAccountCreate, + Create: resourceSpatialAnchorsAccountCreateUpdate, Read: resourceSpatialAnchorsAccountRead, + Update: resourceSpatialAnchorsAccountCreateUpdate, Delete: resourceSpatialAnchorsAccountDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { _, err := parse.SpatialAnchorsAccountID(id) return err }), - Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(30 * time.Minute), Read: schema.DefaultTimeout(5 * time.Minute), Update: schema.DefaultTimeout(30 * time.Minute), Delete: schema.DefaultTimeout(30 * time.Minute), }, - Schema: map[string]*schema.Schema{ "name": { Type: schema.TypeString, @@ -45,26 +44,20 @@ func resourceSpatialAnchorsAccount() *schema.Resource { "Spatial Anchors Account name must be 1 - 90 characters long, contain only word characters and underscores.", ), }, - - "location": azure.SchemaLocation(), - + "location": azure.SchemaLocation(), "resource_group_name": azure.SchemaResourceGroupName(), - - "tags": tags.ForceNewSchema(), + "tags": tags.Schema(), }, } } - -func resourceSpatialAnchorsAccountCreate(d *schema.ResourceData, meta interface{}) error { +func resourceSpatialAnchorsAccountCreateUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*clients.Client).MixedReality.SpatialAnchorsAccountClient ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - name := d.Get("name").(string) location := azure.NormalizeLocation(d.Get("location").(string)) resourceGroup := d.Get("resource_group_name").(string) t := d.Get("tags").(map[string]interface{}) - if d.IsNewResource() { existing, err := client.Get(ctx, resourceGroup, name) if err != nil { @@ -72,80 +65,63 @@ func resourceSpatialAnchorsAccountCreate(d *schema.ResourceData, meta interface{ return fmt.Errorf("checking for presence of existing Spatial Anchors Account %q (Resource Group %q): %s", name, resourceGroup, err) } } - if existing.ID != nil && *existing.ID != "" { return tf.ImportAsExistsError("azurerm_spatial_anchors_account", *existing.ID) } } - account := mixedreality.SpatialAnchorsAccount{ Location: &location, Tags: tags.Expand(t), } - if _, err := client.Create(ctx, resourceGroup, name, account); err != nil { return fmt.Errorf("creating/updating Spatial Anchors Account %q (Resource Group %q): %+v", name, resourceGroup, err) } - resp, err := client.Get(ctx, resourceGroup, name) if err != nil { return fmt.Errorf("retrieving Spatial Anchors Account %q (Resource Group %q): %+v", name, resourceGroup, err) } - if resp.ID == nil { return fmt.Errorf("cannot read Spatial Anchors Account %q (Resource Group %q) ID", name, resourceGroup) } - d.SetId(*resp.ID) - return resourceSpatialAnchorsAccountRead(d, meta) } - func resourceSpatialAnchorsAccountRead(d *schema.ResourceData, meta interface{}) error { client := meta.(*clients.Client).MixedReality.SpatialAnchorsAccountClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SpatialAnchorsAccountID(d.Id()) if err != nil { return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.Name) if err != nil { if utils.ResponseWasNotFound(resp.Response) { d.SetId("") return nil } - return fmt.Errorf("retrieving Spatial Anchors Account %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) } - d.Set("name", resp.Name) d.Set("resource_group_name", id.ResourceGroup) if location := resp.Location; location != nil { d.Set("location", azure.NormalizeLocation(*location)) } - return tags.FlattenAndSet(d, resp.Tags) } - func resourceSpatialAnchorsAccountDelete(d *schema.ResourceData, meta interface{}) error { client := meta.(*clients.Client).MixedReality.SpatialAnchorsAccountClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SpatialAnchorsAccountID(d.Id()) if err != nil { return err } - response, err := client.Delete(ctx, id.ResourceGroup, id.Name) if err != nil { if !utils.ResponseWasNotFound(response) { return fmt.Errorf("deleting Spatial Anchors Account %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) } } - return nil } From 693fe0cbbb452dae2128f59a9cf2fbd141b68d95 Mon Sep 17 00:00:00 2001 From: kohei3110 Date: Sun, 20 Jun 2021 21:35:44 +0900 Subject: [PATCH 3/4] reverted all the white space removal --- .../spatial_anchors_account_resource.go | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/azurerm/internal/services/mixedreality/spatial_anchors_account_resource.go b/azurerm/internal/services/mixedreality/spatial_anchors_account_resource.go index bb1351c2b11b..fa7e8da4337e 100644 --- a/azurerm/internal/services/mixedreality/spatial_anchors_account_resource.go +++ b/azurerm/internal/services/mixedreality/spatial_anchors_account_resource.go @@ -28,12 +28,14 @@ func resourceSpatialAnchorsAccount() *schema.Resource { _, err := parse.SpatialAnchorsAccountID(id) return err }), + Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(30 * time.Minute), Read: schema.DefaultTimeout(5 * time.Minute), Update: schema.DefaultTimeout(30 * time.Minute), Delete: schema.DefaultTimeout(30 * time.Minute), }, + Schema: map[string]*schema.Schema{ "name": { Type: schema.TypeString, @@ -44,20 +46,26 @@ func resourceSpatialAnchorsAccount() *schema.Resource { "Spatial Anchors Account name must be 1 - 90 characters long, contain only word characters and underscores.", ), }, - "location": azure.SchemaLocation(), + + "location": azure.SchemaLocation(), + "resource_group_name": azure.SchemaResourceGroupName(), - "tags": tags.Schema(), + + "tags": tags.Schema(), }, } } + func resourceSpatialAnchorsAccountCreateUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*clients.Client).MixedReality.SpatialAnchorsAccountClient ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() + name := d.Get("name").(string) location := azure.NormalizeLocation(d.Get("location").(string)) resourceGroup := d.Get("resource_group_name").(string) t := d.Get("tags").(map[string]interface{}) + if d.IsNewResource() { existing, err := client.Get(ctx, resourceGroup, name) if err != nil { @@ -65,63 +73,80 @@ func resourceSpatialAnchorsAccountCreateUpdate(d *schema.ResourceData, meta inte return fmt.Errorf("checking for presence of existing Spatial Anchors Account %q (Resource Group %q): %s", name, resourceGroup, err) } } + if existing.ID != nil && *existing.ID != "" { return tf.ImportAsExistsError("azurerm_spatial_anchors_account", *existing.ID) } } + account := mixedreality.SpatialAnchorsAccount{ Location: &location, Tags: tags.Expand(t), } + if _, err := client.Create(ctx, resourceGroup, name, account); err != nil { return fmt.Errorf("creating/updating Spatial Anchors Account %q (Resource Group %q): %+v", name, resourceGroup, err) } + resp, err := client.Get(ctx, resourceGroup, name) if err != nil { return fmt.Errorf("retrieving Spatial Anchors Account %q (Resource Group %q): %+v", name, resourceGroup, err) } + if resp.ID == nil { return fmt.Errorf("cannot read Spatial Anchors Account %q (Resource Group %q) ID", name, resourceGroup) } + d.SetId(*resp.ID) + return resourceSpatialAnchorsAccountRead(d, meta) } + func resourceSpatialAnchorsAccountRead(d *schema.ResourceData, meta interface{}) error { client := meta.(*clients.Client).MixedReality.SpatialAnchorsAccountClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() + id, err := parse.SpatialAnchorsAccountID(d.Id()) if err != nil { return err } + resp, err := client.Get(ctx, id.ResourceGroup, id.Name) if err != nil { if utils.ResponseWasNotFound(resp.Response) { d.SetId("") return nil } + return fmt.Errorf("retrieving Spatial Anchors Account %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) } + d.Set("name", resp.Name) d.Set("resource_group_name", id.ResourceGroup) if location := resp.Location; location != nil { d.Set("location", azure.NormalizeLocation(*location)) } + return tags.FlattenAndSet(d, resp.Tags) } + func resourceSpatialAnchorsAccountDelete(d *schema.ResourceData, meta interface{}) error { client := meta.(*clients.Client).MixedReality.SpatialAnchorsAccountClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() + id, err := parse.SpatialAnchorsAccountID(d.Id()) if err != nil { return err } + response, err := client.Delete(ctx, id.ResourceGroup, id.Name) if err != nil { if !utils.ResponseWasNotFound(response) { return fmt.Errorf("deleting Spatial Anchors Account %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) } } + return nil } From 0cf35f2269bb047bcfa9a19a502314dfb45b39f6 Mon Sep 17 00:00:00 2001 From: kohei3110 Date: Sun, 27 Jun 2021 00:04:12 +0900 Subject: [PATCH 4/4] fix typo --- .../services/mixedreality/spatial_anchors_account_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/internal/services/mixedreality/spatial_anchors_account_resource.go b/azurerm/internal/services/mixedreality/spatial_anchors_account_resource.go index 164d3636e206..129a9f95dd46 100644 --- a/azurerm/internal/services/mixedreality/spatial_anchors_account_resource.go +++ b/azurerm/internal/services/mixedreality/spatial_anchors_account_resource.go @@ -65,7 +65,7 @@ func resourceSpatialAnchorsAccount() *pluginsdk.Resource { } } -func resourceSpatialAnchorsAccountCreateUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceSpatialAnchorsAccountCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).MixedReality.SpatialAnchorsAccountClient ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel()