All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.azure.desktopvirtualization.kotlin.ScalingPlan.kt Maven / Gradle / Ivy

@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.azure.desktopvirtualization.kotlin

import com.pulumi.azure.desktopvirtualization.kotlin.outputs.ScalingPlanHostPool
import com.pulumi.azure.desktopvirtualization.kotlin.outputs.ScalingPlanSchedule
import com.pulumi.core.Output
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import com.pulumi.azure.desktopvirtualization.kotlin.outputs.ScalingPlanHostPool.Companion.toKotlin as scalingPlanHostPoolToKotlin
import com.pulumi.azure.desktopvirtualization.kotlin.outputs.ScalingPlanSchedule.Companion.toKotlin as scalingPlanScheduleToKotlin

/**
 * Builder for [ScalingPlan].
 */
@PulumiTagMarker
public class ScalingPlanResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: ScalingPlanArgs = ScalingPlanArgs()

    public var opts: CustomResourceOptions = CustomResourceOptions()

    /**
     * @param name The _unique_ name of the resulting resource.
     */
    public fun name(`value`: String) {
        this.name = value
    }

    /**
     * @param block The arguments to use to populate this resource's properties.
     */
    public suspend fun args(block: suspend ScalingPlanArgsBuilder.() -> Unit) {
        val builder = ScalingPlanArgsBuilder()
        block(builder)
        this.args = builder.build()
    }

    /**
     * @param block A bag of options that control this resource's behavior.
     */
    public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
        this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
    }

    internal fun build(): ScalingPlan {
        val builtJavaResource =
            com.pulumi.azure.desktopvirtualization.ScalingPlan(
                this.name,
                this.args.toJava(),
                this.opts.toJava(),
            )
        return ScalingPlan(builtJavaResource)
    }
}

/**
 * Manages a Virtual Desktop Scaling Plan.
 * ## Disclaimers
 * > **Note** Scaling Plans are currently in preview and are only supported in a limited number of regions. Both the Scaling Plan and any referenced Host Pools must be deployed in a supported region. [Autoscale (preview) for Azure Virtual Desktop host pools](https://docs.microsoft.com/azure/virtual-desktop/autoscale-scaling-plan).
 * > **Note** Scaling Plans require specific permissions to be granted to the Windows Virtual Desktop application before a 'host_pool' can be configured. [Required Permissions for Scaling Plans](https://docs.microsoft.com/azure/virtual-desktop/autoscale-scaling-plan#create-a-custom-rbac-role).
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * import * as azuread from "@pulumi/azuread";
 * import * as random from "@pulumi/random";
 * const exampleRandomUuid = new random.RandomUuid("example", {});
 * const exampleResourceGroup = new azure.core.ResourceGroup("example", {
 *     name: "example-resources",
 *     location: "West Europe",
 * });
 * const exampleRoleDefinition = new azure.authorization.RoleDefinition("example", {
 *     name: "AVD-AutoScale",
 *     scope: exampleResourceGroup.id,
 *     description: "AVD AutoScale Role",
 *     permissions: [{
 *         actions: [
 *             "Microsoft.Insights/eventtypes/values/read",
 *             "Microsoft.Compute/virtualMachines/deallocate/action",
 *             "Microsoft.Compute/virtualMachines/restart/action",
 *             "Microsoft.Compute/virtualMachines/powerOff/action",
 *             "Microsoft.Compute/virtualMachines/start/action",
 *             "Microsoft.Compute/virtualMachines/read",
 *             "Microsoft.DesktopVirtualization/hostpools/read",
 *             "Microsoft.DesktopVirtualization/hostpools/write",
 *             "Microsoft.DesktopVirtualization/hostpools/sessionhosts/read",
 *             "Microsoft.DesktopVirtualization/hostpools/sessionhosts/write",
 *             "Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/delete",
 *             "Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/read",
 *             "Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/sendMessage/action",
 *             "Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/read",
 *         ],
 *         notActions: [],
 *     }],
 *     assignableScopes: [exampleResourceGroup.id],
 * });
 * const example = azuread.getServicePrincipal({
 *     displayName: "Azure Virtual Desktop",
 * });
 * const exampleAssignment = new azure.authorization.Assignment("example", {
 *     name: exampleRandomUuid.result,
 *     scope: exampleResourceGroup.id,
 *     roleDefinitionId: exampleRoleDefinition.roleDefinitionResourceId,
 *     principalId: example.then(example => example.id),
 *     skipServicePrincipalAadCheck: true,
 * });
 * const exampleHostPool = new azure.desktopvirtualization.HostPool("example", {
 *     name: "example-hostpool",
 *     location: exampleResourceGroup.location,
 *     resourceGroupName: exampleResourceGroup.name,
 *     type: "Pooled",
 *     validateEnvironment: true,
 *     loadBalancerType: "BreadthFirst",
 * });
 * const exampleScalingPlan = new azure.desktopvirtualization.ScalingPlan("example", {
 *     name: "example-scaling-plan",
 *     location: exampleResourceGroup.location,
 *     resourceGroupName: exampleResourceGroup.name,
 *     friendlyName: "Scaling Plan Example",
 *     description: "Example Scaling Plan",
 *     timeZone: "GMT Standard Time",
 *     schedules: [{
 *         name: "Weekdays",
 *         daysOfWeeks: [
 *             "Monday",
 *             "Tuesday",
 *             "Wednesday",
 *             "Thursday",
 *             "Friday",
 *         ],
 *         rampUpStartTime: "05:00",
 *         rampUpLoadBalancingAlgorithm: "BreadthFirst",
 *         rampUpMinimumHostsPercent: 20,
 *         rampUpCapacityThresholdPercent: 10,
 *         peakStartTime: "09:00",
 *         peakLoadBalancingAlgorithm: "BreadthFirst",
 *         rampDownStartTime: "19:00",
 *         rampDownLoadBalancingAlgorithm: "DepthFirst",
 *         rampDownMinimumHostsPercent: 10,
 *         rampDownForceLogoffUsers: false,
 *         rampDownWaitTimeMinutes: 45,
 *         rampDownNotificationMessage: "Please log off in the next 45 minutes...",
 *         rampDownCapacityThresholdPercent: 5,
 *         rampDownStopHostsWhen: "ZeroSessions",
 *         offPeakStartTime: "22:00",
 *         offPeakLoadBalancingAlgorithm: "DepthFirst",
 *     }],
 *     hostPools: [{
 *         hostpoolId: exampleHostPool.id,
 *         scalingPlanEnabled: true,
 *     }],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * import pulumi_azuread as azuread
 * import pulumi_random as random
 * example_random_uuid = random.RandomUuid("example")
 * example_resource_group = azure.core.ResourceGroup("example",
 *     name="example-resources",
 *     location="West Europe")
 * example_role_definition = azure.authorization.RoleDefinition("example",
 *     name="AVD-AutoScale",
 *     scope=example_resource_group.id,
 *     description="AVD AutoScale Role",
 *     permissions=[{
 *         "actions": [
 *             "Microsoft.Insights/eventtypes/values/read",
 *             "Microsoft.Compute/virtualMachines/deallocate/action",
 *             "Microsoft.Compute/virtualMachines/restart/action",
 *             "Microsoft.Compute/virtualMachines/powerOff/action",
 *             "Microsoft.Compute/virtualMachines/start/action",
 *             "Microsoft.Compute/virtualMachines/read",
 *             "Microsoft.DesktopVirtualization/hostpools/read",
 *             "Microsoft.DesktopVirtualization/hostpools/write",
 *             "Microsoft.DesktopVirtualization/hostpools/sessionhosts/read",
 *             "Microsoft.DesktopVirtualization/hostpools/sessionhosts/write",
 *             "Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/delete",
 *             "Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/read",
 *             "Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/sendMessage/action",
 *             "Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/read",
 *         ],
 *         "not_actions": [],
 *     }],
 *     assignable_scopes=[example_resource_group.id])
 * example = azuread.get_service_principal(display_name="Azure Virtual Desktop")
 * example_assignment = azure.authorization.Assignment("example",
 *     name=example_random_uuid.result,
 *     scope=example_resource_group.id,
 *     role_definition_id=example_role_definition.role_definition_resource_id,
 *     principal_id=example.id,
 *     skip_service_principal_aad_check=True)
 * example_host_pool = azure.desktopvirtualization.HostPool("example",
 *     name="example-hostpool",
 *     location=example_resource_group.location,
 *     resource_group_name=example_resource_group.name,
 *     type="Pooled",
 *     validate_environment=True,
 *     load_balancer_type="BreadthFirst")
 * example_scaling_plan = azure.desktopvirtualization.ScalingPlan("example",
 *     name="example-scaling-plan",
 *     location=example_resource_group.location,
 *     resource_group_name=example_resource_group.name,
 *     friendly_name="Scaling Plan Example",
 *     description="Example Scaling Plan",
 *     time_zone="GMT Standard Time",
 *     schedules=[{
 *         "name": "Weekdays",
 *         "days_of_weeks": [
 *             "Monday",
 *             "Tuesday",
 *             "Wednesday",
 *             "Thursday",
 *             "Friday",
 *         ],
 *         "ramp_up_start_time": "05:00",
 *         "ramp_up_load_balancing_algorithm": "BreadthFirst",
 *         "ramp_up_minimum_hosts_percent": 20,
 *         "ramp_up_capacity_threshold_percent": 10,
 *         "peak_start_time": "09:00",
 *         "peak_load_balancing_algorithm": "BreadthFirst",
 *         "ramp_down_start_time": "19:00",
 *         "ramp_down_load_balancing_algorithm": "DepthFirst",
 *         "ramp_down_minimum_hosts_percent": 10,
 *         "ramp_down_force_logoff_users": False,
 *         "ramp_down_wait_time_minutes": 45,
 *         "ramp_down_notification_message": "Please log off in the next 45 minutes...",
 *         "ramp_down_capacity_threshold_percent": 5,
 *         "ramp_down_stop_hosts_when": "ZeroSessions",
 *         "off_peak_start_time": "22:00",
 *         "off_peak_load_balancing_algorithm": "DepthFirst",
 *     }],
 *     host_pools=[{
 *         "hostpool_id": example_host_pool.id,
 *         "scaling_plan_enabled": True,
 *     }])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * using AzureAD = Pulumi.AzureAD;
 * using Random = Pulumi.Random;
 * return await Deployment.RunAsync(() =>
 * {
 *     var exampleRandomUuid = new Random.RandomUuid("example");
 *     var exampleResourceGroup = new Azure.Core.ResourceGroup("example", new()
 *     {
 *         Name = "example-resources",
 *         Location = "West Europe",
 *     });
 *     var exampleRoleDefinition = new Azure.Authorization.RoleDefinition("example", new()
 *     {
 *         Name = "AVD-AutoScale",
 *         Scope = exampleResourceGroup.Id,
 *         Description = "AVD AutoScale Role",
 *         Permissions = new[]
 *         {
 *             new Azure.Authorization.Inputs.RoleDefinitionPermissionArgs
 *             {
 *                 Actions = new[]
 *                 {
 *                     "Microsoft.Insights/eventtypes/values/read",
 *                     "Microsoft.Compute/virtualMachines/deallocate/action",
 *                     "Microsoft.Compute/virtualMachines/restart/action",
 *                     "Microsoft.Compute/virtualMachines/powerOff/action",
 *                     "Microsoft.Compute/virtualMachines/start/action",
 *                     "Microsoft.Compute/virtualMachines/read",
 *                     "Microsoft.DesktopVirtualization/hostpools/read",
 *                     "Microsoft.DesktopVirtualization/hostpools/write",
 *                     "Microsoft.DesktopVirtualization/hostpools/sessionhosts/read",
 *                     "Microsoft.DesktopVirtualization/hostpools/sessionhosts/write",
 *                     "Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/delete",
 *                     "Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/read",
 *                     "Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/sendMessage/action",
 *                     "Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/read",
 *                 },
 *                 NotActions = new() { },
 *             },
 *         },
 *         AssignableScopes = new[]
 *         {
 *             exampleResourceGroup.Id,
 *         },
 *     });
 *     var example = AzureAD.GetServicePrincipal.Invoke(new()
 *     {
 *         DisplayName = "Azure Virtual Desktop",
 *     });
 *     var exampleAssignment = new Azure.Authorization.Assignment("example", new()
 *     {
 *         Name = exampleRandomUuid.Result,
 *         Scope = exampleResourceGroup.Id,
 *         RoleDefinitionId = exampleRoleDefinition.RoleDefinitionResourceId,
 *         PrincipalId = example.Apply(getServicePrincipalResult => getServicePrincipalResult.Id),
 *         SkipServicePrincipalAadCheck = true,
 *     });
 *     var exampleHostPool = new Azure.DesktopVirtualization.HostPool("example", new()
 *     {
 *         Name = "example-hostpool",
 *         Location = exampleResourceGroup.Location,
 *         ResourceGroupName = exampleResourceGroup.Name,
 *         Type = "Pooled",
 *         ValidateEnvironment = true,
 *         LoadBalancerType = "BreadthFirst",
 *     });
 *     var exampleScalingPlan = new Azure.DesktopVirtualization.ScalingPlan("example", new()
 *     {
 *         Name = "example-scaling-plan",
 *         Location = exampleResourceGroup.Location,
 *         ResourceGroupName = exampleResourceGroup.Name,
 *         FriendlyName = "Scaling Plan Example",
 *         Description = "Example Scaling Plan",
 *         TimeZone = "GMT Standard Time",
 *         Schedules = new[]
 *         {
 *             new Azure.DesktopVirtualization.Inputs.ScalingPlanScheduleArgs
 *             {
 *                 Name = "Weekdays",
 *                 DaysOfWeeks = new[]
 *                 {
 *                     "Monday",
 *                     "Tuesday",
 *                     "Wednesday",
 *                     "Thursday",
 *                     "Friday",
 *                 },
 *                 RampUpStartTime = "05:00",
 *                 RampUpLoadBalancingAlgorithm = "BreadthFirst",
 *                 RampUpMinimumHostsPercent = 20,
 *                 RampUpCapacityThresholdPercent = 10,
 *                 PeakStartTime = "09:00",
 *                 PeakLoadBalancingAlgorithm = "BreadthFirst",
 *                 RampDownStartTime = "19:00",
 *                 RampDownLoadBalancingAlgorithm = "DepthFirst",
 *                 RampDownMinimumHostsPercent = 10,
 *                 RampDownForceLogoffUsers = false,
 *                 RampDownWaitTimeMinutes = 45,
 *                 RampDownNotificationMessage = "Please log off in the next 45 minutes...",
 *                 RampDownCapacityThresholdPercent = 5,
 *                 RampDownStopHostsWhen = "ZeroSessions",
 *                 OffPeakStartTime = "22:00",
 *                 OffPeakLoadBalancingAlgorithm = "DepthFirst",
 *             },
 *         },
 *         HostPools = new[]
 *         {
 *             new Azure.DesktopVirtualization.Inputs.ScalingPlanHostPoolArgs
 *             {
 *                 HostpoolId = exampleHostPool.Id,
 *                 ScalingPlanEnabled = true,
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/authorization"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/desktopvirtualization"
 * 	"github.com/pulumi/pulumi-azuread/sdk/v5/go/azuread"
 * 	"github.com/pulumi/pulumi-random/sdk/v4/go/random"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		exampleRandomUuid, err := random.NewRandomUuid(ctx, "example", nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleResourceGroup, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
 * 			Name:     pulumi.String("example-resources"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleRoleDefinition, err := authorization.NewRoleDefinition(ctx, "example", &authorization.RoleDefinitionArgs{
 * 			Name:        pulumi.String("AVD-AutoScale"),
 * 			Scope:       exampleResourceGroup.ID(),
 * 			Description: pulumi.String("AVD AutoScale Role"),
 * 			Permissions: authorization.RoleDefinitionPermissionArray{
 * 				&authorization.RoleDefinitionPermissionArgs{
 * 					Actions: pulumi.StringArray{
 * 						pulumi.String("Microsoft.Insights/eventtypes/values/read"),
 * 						pulumi.String("Microsoft.Compute/virtualMachines/deallocate/action"),
 * 						pulumi.String("Microsoft.Compute/virtualMachines/restart/action"),
 * 						pulumi.String("Microsoft.Compute/virtualMachines/powerOff/action"),
 * 						pulumi.String("Microsoft.Compute/virtualMachines/start/action"),
 * 						pulumi.String("Microsoft.Compute/virtualMachines/read"),
 * 						pulumi.String("Microsoft.DesktopVirtualization/hostpools/read"),
 * 						pulumi.String("Microsoft.DesktopVirtualization/hostpools/write"),
 * 						pulumi.String("Microsoft.DesktopVirtualization/hostpools/sessionhosts/read"),
 * 						pulumi.String("Microsoft.DesktopVirtualization/hostpools/sessionhosts/write"),
 * 						pulumi.String("Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/delete"),
 * 						pulumi.String("Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/read"),
 * 						pulumi.String("Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/sendMessage/action"),
 * 						pulumi.String("Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/read"),
 * 					},
 * 					NotActions: pulumi.StringArray{},
 * 				},
 * 			},
 * 			AssignableScopes: pulumi.StringArray{
 * 				exampleResourceGroup.ID(),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		example, err := azuread.LookupServicePrincipal(ctx, &azuread.LookupServicePrincipalArgs{
 * 			DisplayName: pulumi.StringRef("Azure Virtual Desktop"),
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = authorization.NewAssignment(ctx, "example", &authorization.AssignmentArgs{
 * 			Name:                         exampleRandomUuid.Result,
 * 			Scope:                        exampleResourceGroup.ID(),
 * 			RoleDefinitionId:             exampleRoleDefinition.RoleDefinitionResourceId,
 * 			PrincipalId:                  pulumi.String(example.Id),
 * 			SkipServicePrincipalAadCheck: pulumi.Bool(true),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleHostPool, err := desktopvirtualization.NewHostPool(ctx, "example", &desktopvirtualization.HostPoolArgs{
 * 			Name:                pulumi.String("example-hostpool"),
 * 			Location:            exampleResourceGroup.Location,
 * 			ResourceGroupName:   exampleResourceGroup.Name,
 * 			Type:                pulumi.String("Pooled"),
 * 			ValidateEnvironment: pulumi.Bool(true),
 * 			LoadBalancerType:    pulumi.String("BreadthFirst"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = desktopvirtualization.NewScalingPlan(ctx, "example", &desktopvirtualization.ScalingPlanArgs{
 * 			Name:              pulumi.String("example-scaling-plan"),
 * 			Location:          exampleResourceGroup.Location,
 * 			ResourceGroupName: exampleResourceGroup.Name,
 * 			FriendlyName:      pulumi.String("Scaling Plan Example"),
 * 			Description:       pulumi.String("Example Scaling Plan"),
 * 			TimeZone:          pulumi.String("GMT Standard Time"),
 * 			Schedules: desktopvirtualization.ScalingPlanScheduleArray{
 * 				&desktopvirtualization.ScalingPlanScheduleArgs{
 * 					Name: pulumi.String("Weekdays"),
 * 					DaysOfWeeks: pulumi.StringArray{
 * 						pulumi.String("Monday"),
 * 						pulumi.String("Tuesday"),
 * 						pulumi.String("Wednesday"),
 * 						pulumi.String("Thursday"),
 * 						pulumi.String("Friday"),
 * 					},
 * 					RampUpStartTime:                  pulumi.String("05:00"),
 * 					RampUpLoadBalancingAlgorithm:     pulumi.String("BreadthFirst"),
 * 					RampUpMinimumHostsPercent:        pulumi.Int(20),
 * 					RampUpCapacityThresholdPercent:   pulumi.Int(10),
 * 					PeakStartTime:                    pulumi.String("09:00"),
 * 					PeakLoadBalancingAlgorithm:       pulumi.String("BreadthFirst"),
 * 					RampDownStartTime:                pulumi.String("19:00"),
 * 					RampDownLoadBalancingAlgorithm:   pulumi.String("DepthFirst"),
 * 					RampDownMinimumHostsPercent:      pulumi.Int(10),
 * 					RampDownForceLogoffUsers:         pulumi.Bool(false),
 * 					RampDownWaitTimeMinutes:          pulumi.Int(45),
 * 					RampDownNotificationMessage:      pulumi.String("Please log off in the next 45 minutes..."),
 * 					RampDownCapacityThresholdPercent: pulumi.Int(5),
 * 					RampDownStopHostsWhen:            pulumi.String("ZeroSessions"),
 * 					OffPeakStartTime:                 pulumi.String("22:00"),
 * 					OffPeakLoadBalancingAlgorithm:    pulumi.String("DepthFirst"),
 * 				},
 * 			},
 * 			HostPools: desktopvirtualization.ScalingPlanHostPoolArray{
 * 				&desktopvirtualization.ScalingPlanHostPoolArgs{
 * 					HostpoolId:         exampleHostPool.ID(),
 * 					ScalingPlanEnabled: pulumi.Bool(true),
 * 				},
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.random.RandomUuid;
 * import com.pulumi.azure.core.ResourceGroup;
 * import com.pulumi.azure.core.ResourceGroupArgs;
 * import com.pulumi.azure.authorization.RoleDefinition;
 * import com.pulumi.azure.authorization.RoleDefinitionArgs;
 * import com.pulumi.azure.authorization.inputs.RoleDefinitionPermissionArgs;
 * import com.pulumi.azuread.AzureadFunctions;
 * import com.pulumi.azuread.inputs.GetServicePrincipalArgs;
 * import com.pulumi.azure.authorization.Assignment;
 * import com.pulumi.azure.authorization.AssignmentArgs;
 * import com.pulumi.azure.desktopvirtualization.HostPool;
 * import com.pulumi.azure.desktopvirtualization.HostPoolArgs;
 * import com.pulumi.azure.desktopvirtualization.ScalingPlan;
 * import com.pulumi.azure.desktopvirtualization.ScalingPlanArgs;
 * import com.pulumi.azure.desktopvirtualization.inputs.ScalingPlanScheduleArgs;
 * import com.pulumi.azure.desktopvirtualization.inputs.ScalingPlanHostPoolArgs;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 *     public static void stack(Context ctx) {
 *         var exampleRandomUuid = new RandomUuid("exampleRandomUuid");
 *         var exampleResourceGroup = new ResourceGroup("exampleResourceGroup", ResourceGroupArgs.builder()
 *             .name("example-resources")
 *             .location("West Europe")
 *             .build());
 *         var exampleRoleDefinition = new RoleDefinition("exampleRoleDefinition", RoleDefinitionArgs.builder()
 *             .name("AVD-AutoScale")
 *             .scope(exampleResourceGroup.id())
 *             .description("AVD AutoScale Role")
 *             .permissions(RoleDefinitionPermissionArgs.builder()
 *                 .actions(
 *                     "Microsoft.Insights/eventtypes/values/read",
 *                     "Microsoft.Compute/virtualMachines/deallocate/action",
 *                     "Microsoft.Compute/virtualMachines/restart/action",
 *                     "Microsoft.Compute/virtualMachines/powerOff/action",
 *                     "Microsoft.Compute/virtualMachines/start/action",
 *                     "Microsoft.Compute/virtualMachines/read",
 *                     "Microsoft.DesktopVirtualization/hostpools/read",
 *                     "Microsoft.DesktopVirtualization/hostpools/write",
 *                     "Microsoft.DesktopVirtualization/hostpools/sessionhosts/read",
 *                     "Microsoft.DesktopVirtualization/hostpools/sessionhosts/write",
 *                     "Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/delete",
 *                     "Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/read",
 *                     "Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/sendMessage/action",
 *                     "Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/read")
 *                 .notActions()
 *                 .build())
 *             .assignableScopes(exampleResourceGroup.id())
 *             .build());
 *         final var example = AzureadFunctions.getServicePrincipal(GetServicePrincipalArgs.builder()
 *             .displayName("Azure Virtual Desktop")
 *             .build());
 *         var exampleAssignment = new Assignment("exampleAssignment", AssignmentArgs.builder()
 *             .name(exampleRandomUuid.result())
 *             .scope(exampleResourceGroup.id())
 *             .roleDefinitionId(exampleRoleDefinition.roleDefinitionResourceId())
 *             .principalId(example.applyValue(getServicePrincipalResult -> getServicePrincipalResult.id()))
 *             .skipServicePrincipalAadCheck(true)
 *             .build());
 *         var exampleHostPool = new HostPool("exampleHostPool", HostPoolArgs.builder()
 *             .name("example-hostpool")
 *             .location(exampleResourceGroup.location())
 *             .resourceGroupName(exampleResourceGroup.name())
 *             .type("Pooled")
 *             .validateEnvironment(true)
 *             .loadBalancerType("BreadthFirst")
 *             .build());
 *         var exampleScalingPlan = new ScalingPlan("exampleScalingPlan", ScalingPlanArgs.builder()
 *             .name("example-scaling-plan")
 *             .location(exampleResourceGroup.location())
 *             .resourceGroupName(exampleResourceGroup.name())
 *             .friendlyName("Scaling Plan Example")
 *             .description("Example Scaling Plan")
 *             .timeZone("GMT Standard Time")
 *             .schedules(ScalingPlanScheduleArgs.builder()
 *                 .name("Weekdays")
 *                 .daysOfWeeks(
 *                     "Monday",
 *                     "Tuesday",
 *                     "Wednesday",
 *                     "Thursday",
 *                     "Friday")
 *                 .rampUpStartTime("05:00")
 *                 .rampUpLoadBalancingAlgorithm("BreadthFirst")
 *                 .rampUpMinimumHostsPercent(20)
 *                 .rampUpCapacityThresholdPercent(10)
 *                 .peakStartTime("09:00")
 *                 .peakLoadBalancingAlgorithm("BreadthFirst")
 *                 .rampDownStartTime("19:00")
 *                 .rampDownLoadBalancingAlgorithm("DepthFirst")
 *                 .rampDownMinimumHostsPercent(10)
 *                 .rampDownForceLogoffUsers(false)
 *                 .rampDownWaitTimeMinutes(45)
 *                 .rampDownNotificationMessage("Please log off in the next 45 minutes...")
 *                 .rampDownCapacityThresholdPercent(5)
 *                 .rampDownStopHostsWhen("ZeroSessions")
 *                 .offPeakStartTime("22:00")
 *                 .offPeakLoadBalancingAlgorithm("DepthFirst")
 *                 .build())
 *             .hostPools(ScalingPlanHostPoolArgs.builder()
 *                 .hostpoolId(exampleHostPool.id())
 *                 .scalingPlanEnabled(true)
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   exampleRandomUuid:
 *     type: random:RandomUuid
 *     name: example
 *   exampleResourceGroup:
 *     type: azure:core:ResourceGroup
 *     name: example
 *     properties:
 *       name: example-resources
 *       location: West Europe
 *   exampleRoleDefinition:
 *     type: azure:authorization:RoleDefinition
 *     name: example
 *     properties:
 *       name: AVD-AutoScale
 *       scope: ${exampleResourceGroup.id}
 *       description: AVD AutoScale Role
 *       permissions:
 *         - actions:
 *             - Microsoft.Insights/eventtypes/values/read
 *             - Microsoft.Compute/virtualMachines/deallocate/action
 *             - Microsoft.Compute/virtualMachines/restart/action
 *             - Microsoft.Compute/virtualMachines/powerOff/action
 *             - Microsoft.Compute/virtualMachines/start/action
 *             - Microsoft.Compute/virtualMachines/read
 *             - Microsoft.DesktopVirtualization/hostpools/read
 *             - Microsoft.DesktopVirtualization/hostpools/write
 *             - Microsoft.DesktopVirtualization/hostpools/sessionhosts/read
 *             - Microsoft.DesktopVirtualization/hostpools/sessionhosts/write
 *             - Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/delete
 *             - Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/read
 *             - Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/sendMessage/action
 *             - Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/read
 *           notActions: []
 *       assignableScopes:
 *         - ${exampleResourceGroup.id}
 *   exampleAssignment:
 *     type: azure:authorization:Assignment
 *     name: example
 *     properties:
 *       name: ${exampleRandomUuid.result}
 *       scope: ${exampleResourceGroup.id}
 *       roleDefinitionId: ${exampleRoleDefinition.roleDefinitionResourceId}
 *       principalId: ${example.id}
 *       skipServicePrincipalAadCheck: true
 *   exampleHostPool:
 *     type: azure:desktopvirtualization:HostPool
 *     name: example
 *     properties:
 *       name: example-hostpool
 *       location: ${exampleResourceGroup.location}
 *       resourceGroupName: ${exampleResourceGroup.name}
 *       type: Pooled
 *       validateEnvironment: true
 *       loadBalancerType: BreadthFirst
 *   exampleScalingPlan:
 *     type: azure:desktopvirtualization:ScalingPlan
 *     name: example
 *     properties:
 *       name: example-scaling-plan
 *       location: ${exampleResourceGroup.location}
 *       resourceGroupName: ${exampleResourceGroup.name}
 *       friendlyName: Scaling Plan Example
 *       description: Example Scaling Plan
 *       timeZone: GMT Standard Time
 *       schedules:
 *         - name: Weekdays
 *           daysOfWeeks:
 *             - Monday
 *             - Tuesday
 *             - Wednesday
 *             - Thursday
 *             - Friday
 *           rampUpStartTime: 05:00
 *           rampUpLoadBalancingAlgorithm: BreadthFirst
 *           rampUpMinimumHostsPercent: 20
 *           rampUpCapacityThresholdPercent: 10
 *           peakStartTime: 09:00
 *           peakLoadBalancingAlgorithm: BreadthFirst
 *           rampDownStartTime: 19:00
 *           rampDownLoadBalancingAlgorithm: DepthFirst
 *           rampDownMinimumHostsPercent: 10
 *           rampDownForceLogoffUsers: false
 *           rampDownWaitTimeMinutes: 45
 *           rampDownNotificationMessage: Please log off in the next 45 minutes...
 *           rampDownCapacityThresholdPercent: 5
 *           rampDownStopHostsWhen: ZeroSessions
 *           offPeakStartTime: 22:00
 *           offPeakLoadBalancingAlgorithm: DepthFirst
 *       hostPools:
 *         - hostpoolId: ${exampleHostPool.id}
 *           scalingPlanEnabled: true
 * variables:
 *   example:
 *     fn::invoke:
 *       Function: azuread:getServicePrincipal
 *       Arguments:
 *         displayName: Azure Virtual Desktop
 * ```
 * 
 * ## Import
 * Virtual Desktop Scaling Plans can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:desktopvirtualization/scalingPlan:ScalingPlan example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DesktopVirtualization/scalingPlans/plan1
 * ```
 */
public class ScalingPlan internal constructor(
    override val javaResource: com.pulumi.azure.desktopvirtualization.ScalingPlan,
) : KotlinCustomResource(javaResource, ScalingPlanMapper) {
    /**
     * A description of the Scaling Plan.
     */
    public val description: Output?
        get() = javaResource.description().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The name of the tag associated with the VMs you want to exclude from autoscaling.
     */
    public val exclusionTag: Output?
        get() = javaResource.exclusionTag().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Friendly name of the Scaling Plan.
     */
    public val friendlyName: Output?
        get() = javaResource.friendlyName().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * One or more `host_pool` blocks as defined below.
     */
    public val hostPools: Output>
        get() = javaResource.hostPools().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    scalingPlanHostPoolToKotlin(args0)
                })
            })
        })

    /**
     * The Azure Region where the Virtual Desktop Scaling Plan should exist. Changing this forces a new Virtual Desktop Scaling Plan to be created.
     */
    public val location: Output
        get() = javaResource.location().applyValue({ args0 -> args0 })

    /**
     * The name which should be used for this Virtual Desktop Scaling Plan . Changing this forces a new Virtual Desktop Scaling Plan to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The name of the Resource Group where the Virtual Desktop Scaling Plan should exist. Changing this forces a new Virtual Desktop Scaling Plan to be created.
     */
    public val resourceGroupName: Output
        get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })

    /**
     * One or more `schedule` blocks as defined below.
     */
    public val schedules: Output>
        get() = javaResource.schedules().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    scalingPlanScheduleToKotlin(args0)
                })
            })
        })

    /**
     * A mapping of tags which should be assigned to the Virtual Desktop Scaling Plan .
     */
    public val tags: Output>?
        get() = javaResource.tags().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * Specifies the Time Zone which should be used by the Scaling Plan for time based events, [the possible values are defined here](https://jackstromberg.com/2017/01/list-of-time-zones-consumed-by-azure/).
     */
    public val timeZone: Output
        get() = javaResource.timeZone().applyValue({ args0 -> args0 })
}

public object ScalingPlanMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.desktopvirtualization.ScalingPlan::class == javaResource::class

    override fun map(javaResource: Resource): ScalingPlan = ScalingPlan(
        javaResource as
            com.pulumi.azure.desktopvirtualization.ScalingPlan,
    )
}

/**
 * @see [ScalingPlan].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [ScalingPlan].
 */
public suspend fun scalingPlan(name: String, block: suspend ScalingPlanResourceBuilder.() -> Unit): ScalingPlan {
    val builder = ScalingPlanResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [ScalingPlan].
 * @param name The _unique_ name of the resulting resource.
 */
public fun scalingPlan(name: String): ScalingPlan {
    val builder = ScalingPlanResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy