Skip to content

Commit

Permalink
#24103 : Support sku_tier argument as part of azurerm_spring_cloud_se…
Browse files Browse the repository at this point in the history
…rvice (#24107)

* #24103 : Support sku_tier argument as part of azurerm_spring_cloud_service resource

* #24103: Add missing field managed_environment_id
  • Loading branch information
harshavmb authored Jan 4, 2024
1 parent 1d2b466 commit 9168fa4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
33 changes: 33 additions & 0 deletions internal/services/springcloud/spring_cloud_service_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}

Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/spring_cloud_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 9168fa4

Please sign in to comment.