From 9168fa4bc587018354166f988521f0e40724d934 Mon Sep 17 00:00:00 2001 From: Harshavardhan Musanalli Date: Thu, 4 Jan 2024 03:13:53 +0100 Subject: [PATCH] #24103 : Support sku_tier argument as part of azurerm_spring_cloud_service (#24107) * #24103 : Support sku_tier argument as part of azurerm_spring_cloud_service resource * #24103: Add missing field managed_environment_id --- .../spring_cloud_service_resource.go | 33 +++++++++++++++++++ .../docs/r/spring_cloud_service.html.markdown | 4 +++ 2 files changed, 37 insertions(+) diff --git a/internal/services/springcloud/spring_cloud_service_resource.go b/internal/services/springcloud/spring_cloud_service_resource.go index 10800bd4f65c..5f8e8a6d9425 100644 --- a/internal/services/springcloud/spring_cloud_service_resource.go +++ b/internal/services/springcloud/spring_cloud_service_resource.go @@ -79,6 +79,25 @@ func resourceSpringCloudService() *pluginsdk.Resource { }, false), }, + "sku_tier": { + Type: pluginsdk.TypeString, + Optional: true, + ForceNew: true, + Computed: true, + ValidateFunc: validation.StringInSlice([]string{ + "Basic", + "Enterprise", + "Standard", + "StandardGen2", + }, false), + }, + + "managed_environment_id": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: azure.ValidateResourceID, + }, + "build_agent_pool_size": { Type: pluginsdk.TypeString, Optional: true, @@ -453,6 +472,13 @@ func resourceSpringCloudServiceCreate(d *pluginsdk.ResourceData, meta interface{ } } + // we set sku_tier only when managed_environment_id is set + // otherwise we break the existing flows where sku_name is set to E0/Basic etc., + if v, ok := d.GetOk("managed_environment_id"); ok { + resource.Properties.ManagedEnvironmentID = utils.String(v.(string)) + resource.Sku.Tier = utils.String(d.Get("sku_tier").(string)) + } + gitProperty, err := expandSpringCloudConfigServerGitProperty(d.Get("config_server_git_setting").([]interface{})) if err != nil { return err @@ -752,6 +778,7 @@ func resourceSpringCloudServiceRead(d *pluginsdk.ResourceData, meta interface{}) d.Set("location", location.NormalizeNilable(resp.Location)) if resp.Sku != nil { d.Set("sku_name", resp.Sku.Name) + d.Set("sku_tier", resp.Sku.Tier) } d.Set("service_registry_enabled", serviceRegistryEnabled) @@ -799,6 +826,12 @@ func resourceSpringCloudServiceRead(d *pluginsdk.ResourceData, meta interface{}) } } + if managedEnvironmentID := props.ManagedEnvironmentID; managedEnvironmentID != nil { + if err := d.Set("managed_environment_id", utils.String(*props.ManagedEnvironmentID)); err != nil { + return fmt.Errorf("setting `managed_environment_id`: %+v", err) + } + } + d.Set("zone_redundant", props.ZoneRedundant) } diff --git a/website/docs/r/spring_cloud_service.html.markdown b/website/docs/r/spring_cloud_service.html.markdown index 63cf76073372..21085e40967b 100644 --- a/website/docs/r/spring_cloud_service.html.markdown +++ b/website/docs/r/spring_cloud_service.html.markdown @@ -72,6 +72,10 @@ The following arguments are supported: * `sku_name` - (Optional) Specifies the SKU Name for this Spring Cloud Service. Possible values are `B0`, `S0` and `E0`. Defaults to `S0`. Changing this forces a new resource to be created. +* `sku_tier` - (Optional) Specifies the SKU Tier for this Spring Cloud Service. Possible values are `Basic`, `Enterprise`, `Standard` and `StandardGen2`. The attribute is automatically computed from API response except when `managed_environment_id` is defined. + +* `managed_environment_id` - (Optional) The resource Id of the Managed Environment that the Spring Apps instance builds on. Can only be specified when `sku_tier` is set to `StandardGen2`. + * `marketplace` - (Optional) A `marketplace` block as defined below. Can only be specified when `sku` is set to `E0`. * `network` - (Optional) A `network` block as defined below. Changing this forces a new resource to be created.