com.pulumi.gcp.dataproc.kotlin.AutoscalingPolicy.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-gcp-kotlin Show documentation
Show all versions of pulumi-gcp-kotlin Show documentation
Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.dataproc.kotlin
import com.pulumi.core.Output
import com.pulumi.gcp.dataproc.kotlin.outputs.AutoscalingPolicyBasicAlgorithm
import com.pulumi.gcp.dataproc.kotlin.outputs.AutoscalingPolicySecondaryWorkerConfig
import com.pulumi.gcp.dataproc.kotlin.outputs.AutoscalingPolicyWorkerConfig
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 com.pulumi.gcp.dataproc.kotlin.outputs.AutoscalingPolicyBasicAlgorithm.Companion.toKotlin as autoscalingPolicyBasicAlgorithmToKotlin
import com.pulumi.gcp.dataproc.kotlin.outputs.AutoscalingPolicySecondaryWorkerConfig.Companion.toKotlin as autoscalingPolicySecondaryWorkerConfigToKotlin
import com.pulumi.gcp.dataproc.kotlin.outputs.AutoscalingPolicyWorkerConfig.Companion.toKotlin as autoscalingPolicyWorkerConfigToKotlin
/**
* Builder for [AutoscalingPolicy].
*/
@PulumiTagMarker
public class AutoscalingPolicyResourceBuilder internal constructor() {
public var name: String? = null
public var args: AutoscalingPolicyArgs = AutoscalingPolicyArgs()
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 AutoscalingPolicyArgsBuilder.() -> Unit) {
val builder = AutoscalingPolicyArgsBuilder()
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(): AutoscalingPolicy {
val builtJavaResource = com.pulumi.gcp.dataproc.AutoscalingPolicy(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return AutoscalingPolicy(builtJavaResource)
}
}
/**
* Describes an autoscaling policy for Dataproc cluster autoscaler.
* ## Example Usage
* ### Dataproc Autoscaling Policy
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const asp = new gcp.dataproc.AutoscalingPolicy("asp", {
* policyId: "dataproc-policy",
* location: "us-central1",
* workerConfig: {
* maxInstances: 3,
* },
* basicAlgorithm: {
* yarnConfig: {
* gracefulDecommissionTimeout: "30s",
* scaleUpFactor: 0.5,
* scaleDownFactor: 0.5,
* },
* },
* });
* const basic = new gcp.dataproc.Cluster("basic", {
* name: "dataproc-policy",
* region: "us-central1",
* clusterConfig: {
* autoscalingConfig: {
* policyUri: asp.name,
* },
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* asp = gcp.dataproc.AutoscalingPolicy("asp",
* policy_id="dataproc-policy",
* location="us-central1",
* worker_config=gcp.dataproc.AutoscalingPolicyWorkerConfigArgs(
* max_instances=3,
* ),
* basic_algorithm=gcp.dataproc.AutoscalingPolicyBasicAlgorithmArgs(
* yarn_config=gcp.dataproc.AutoscalingPolicyBasicAlgorithmYarnConfigArgs(
* graceful_decommission_timeout="30s",
* scale_up_factor=0.5,
* scale_down_factor=0.5,
* ),
* ))
* basic = gcp.dataproc.Cluster("basic",
* name="dataproc-policy",
* region="us-central1",
* cluster_config=gcp.dataproc.ClusterClusterConfigArgs(
* autoscaling_config=gcp.dataproc.ClusterClusterConfigAutoscalingConfigArgs(
* policy_uri=asp.name,
* ),
* ))
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var asp = new Gcp.Dataproc.AutoscalingPolicy("asp", new()
* {
* PolicyId = "dataproc-policy",
* Location = "us-central1",
* WorkerConfig = new Gcp.Dataproc.Inputs.AutoscalingPolicyWorkerConfigArgs
* {
* MaxInstances = 3,
* },
* BasicAlgorithm = new Gcp.Dataproc.Inputs.AutoscalingPolicyBasicAlgorithmArgs
* {
* YarnConfig = new Gcp.Dataproc.Inputs.AutoscalingPolicyBasicAlgorithmYarnConfigArgs
* {
* GracefulDecommissionTimeout = "30s",
* ScaleUpFactor = 0.5,
* ScaleDownFactor = 0.5,
* },
* },
* });
* var basic = new Gcp.Dataproc.Cluster("basic", new()
* {
* Name = "dataproc-policy",
* Region = "us-central1",
* ClusterConfig = new Gcp.Dataproc.Inputs.ClusterClusterConfigArgs
* {
* AutoscalingConfig = new Gcp.Dataproc.Inputs.ClusterClusterConfigAutoscalingConfigArgs
* {
* PolicyUri = asp.Name,
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/dataproc"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* asp, err := dataproc.NewAutoscalingPolicy(ctx, "asp", &dataproc.AutoscalingPolicyArgs{
* PolicyId: pulumi.String("dataproc-policy"),
* Location: pulumi.String("us-central1"),
* WorkerConfig: &dataproc.AutoscalingPolicyWorkerConfigArgs{
* MaxInstances: pulumi.Int(3),
* },
* BasicAlgorithm: &dataproc.AutoscalingPolicyBasicAlgorithmArgs{
* YarnConfig: &dataproc.AutoscalingPolicyBasicAlgorithmYarnConfigArgs{
* GracefulDecommissionTimeout: pulumi.String("30s"),
* ScaleUpFactor: pulumi.Float64(0.5),
* ScaleDownFactor: pulumi.Float64(0.5),
* },
* },
* })
* if err != nil {
* return err
* }
* _, err = dataproc.NewCluster(ctx, "basic", &dataproc.ClusterArgs{
* Name: pulumi.String("dataproc-policy"),
* Region: pulumi.String("us-central1"),
* ClusterConfig: &dataproc.ClusterClusterConfigArgs{
* AutoscalingConfig: &dataproc.ClusterClusterConfigAutoscalingConfigArgs{
* PolicyUri: asp.Name,
* },
* },
* })
* 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.gcp.dataproc.AutoscalingPolicy;
* import com.pulumi.gcp.dataproc.AutoscalingPolicyArgs;
* import com.pulumi.gcp.dataproc.inputs.AutoscalingPolicyWorkerConfigArgs;
* import com.pulumi.gcp.dataproc.inputs.AutoscalingPolicyBasicAlgorithmArgs;
* import com.pulumi.gcp.dataproc.inputs.AutoscalingPolicyBasicAlgorithmYarnConfigArgs;
* import com.pulumi.gcp.dataproc.Cluster;
* import com.pulumi.gcp.dataproc.ClusterArgs;
* import com.pulumi.gcp.dataproc.inputs.ClusterClusterConfigArgs;
* import com.pulumi.gcp.dataproc.inputs.ClusterClusterConfigAutoscalingConfigArgs;
* 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 asp = new AutoscalingPolicy("asp", AutoscalingPolicyArgs.builder()
* .policyId("dataproc-policy")
* .location("us-central1")
* .workerConfig(AutoscalingPolicyWorkerConfigArgs.builder()
* .maxInstances(3)
* .build())
* .basicAlgorithm(AutoscalingPolicyBasicAlgorithmArgs.builder()
* .yarnConfig(AutoscalingPolicyBasicAlgorithmYarnConfigArgs.builder()
* .gracefulDecommissionTimeout("30s")
* .scaleUpFactor(0.5)
* .scaleDownFactor(0.5)
* .build())
* .build())
* .build());
* var basic = new Cluster("basic", ClusterArgs.builder()
* .name("dataproc-policy")
* .region("us-central1")
* .clusterConfig(ClusterClusterConfigArgs.builder()
* .autoscalingConfig(ClusterClusterConfigAutoscalingConfigArgs.builder()
* .policyUri(asp.name())
* .build())
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* basic:
* type: gcp:dataproc:Cluster
* properties:
* name: dataproc-policy
* region: us-central1
* clusterConfig:
* autoscalingConfig:
* policyUri: ${asp.name}
* asp:
* type: gcp:dataproc:AutoscalingPolicy
* properties:
* policyId: dataproc-policy
* location: us-central1
* workerConfig:
* maxInstances: 3
* basicAlgorithm:
* yarnConfig:
* gracefulDecommissionTimeout: 30s
* scaleUpFactor: 0.5
* scaleDownFactor: 0.5
* ```
*
* ## Import
* AutoscalingPolicy can be imported using any of these accepted formats:
* * `projects/{{project}}/locations/{{location}}/autoscalingPolicies/{{policy_id}}`
* * `{{project}}/{{location}}/{{policy_id}}`
* * `{{location}}/{{policy_id}}`
* When using the `pulumi import` command, AutoscalingPolicy can be imported using one of the formats above. For example:
* ```sh
* $ pulumi import gcp:dataproc/autoscalingPolicy:AutoscalingPolicy default projects/{{project}}/locations/{{location}}/autoscalingPolicies/{{policy_id}}
* ```
* ```sh
* $ pulumi import gcp:dataproc/autoscalingPolicy:AutoscalingPolicy default {{project}}/{{location}}/{{policy_id}}
* ```
* ```sh
* $ pulumi import gcp:dataproc/autoscalingPolicy:AutoscalingPolicy default {{location}}/{{policy_id}}
* ```
*/
public class AutoscalingPolicy internal constructor(
override val javaResource: com.pulumi.gcp.dataproc.AutoscalingPolicy,
) : KotlinCustomResource(javaResource, AutoscalingPolicyMapper) {
/**
* Basic algorithm for autoscaling.
* Structure is documented below.
*/
public val basicAlgorithm: Output?
get() = javaResource.basicAlgorithm().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> autoscalingPolicyBasicAlgorithmToKotlin(args0) })
}).orElse(null)
})
/**
* The location where the autoscaling policy should reside.
* The default value is `global`.
*/
public val location: Output?
get() = javaResource.location().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* The "resource name" of the autoscaling policy.
*/
public val name: Output
get() = javaResource.name().applyValue({ args0 -> args0 })
/**
* The policy id. The id must contain only letters (a-z, A-Z), numbers (0-9), underscores (_),
* and hyphens (-). Cannot begin or end with underscore or hyphen. Must consist of between
* 3 and 50 characters.
* - - -
*/
public val policyId: Output
get() = javaResource.policyId().applyValue({ args0 -> args0 })
/**
* The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
public val project: Output
get() = javaResource.project().applyValue({ args0 -> args0 })
/**
* Describes how the autoscaler will operate for secondary workers.
* Structure is documented below.
*/
public val secondaryWorkerConfig: Output?
get() = javaResource.secondaryWorkerConfig().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> autoscalingPolicySecondaryWorkerConfigToKotlin(args0) })
}).orElse(null)
})
/**
* Describes how the autoscaler will operate for primary workers.
* Structure is documented below.
*/
public val workerConfig: Output?
get() = javaResource.workerConfig().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
autoscalingPolicyWorkerConfigToKotlin(args0)
})
}).orElse(null)
})
}
public object AutoscalingPolicyMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.gcp.dataproc.AutoscalingPolicy::class == javaResource::class
override fun map(javaResource: Resource): AutoscalingPolicy = AutoscalingPolicy(
javaResource as
com.pulumi.gcp.dataproc.AutoscalingPolicy,
)
}
/**
* @see [AutoscalingPolicy].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [AutoscalingPolicy].
*/
public suspend fun autoscalingPolicy(
name: String,
block: suspend AutoscalingPolicyResourceBuilder.() -> Unit,
): AutoscalingPolicy {
val builder = AutoscalingPolicyResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [AutoscalingPolicy].
* @param name The _unique_ name of the resulting resource.
*/
public fun autoscalingPolicy(name: String): AutoscalingPolicy {
val builder = AutoscalingPolicyResourceBuilder()
builder.name(name)
return builder.build()
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy