com.pulumi.alicloud.dcdn.kotlin.WafPolicy.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-alicloud-kotlin Show documentation
Show all versions of pulumi-alicloud-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.alicloud.dcdn.kotlin
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
/**
* Builder for [WafPolicy].
*/
@PulumiTagMarker
public class WafPolicyResourceBuilder internal constructor() {
public var name: String? = null
public var args: WafPolicyArgs = WafPolicyArgs()
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 WafPolicyArgsBuilder.() -> Unit) {
val builder = WafPolicyArgsBuilder()
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(): WafPolicy {
val builtJavaResource = com.pulumi.alicloud.dcdn.WafPolicy(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return WafPolicy(builtJavaResource)
}
}
/**
* Provides a DCDN Waf Policy resource.
* For information about DCDN Waf Policy and how to use it, see [What is Waf Policy](https://www.alibabacloud.com/help/en/dcdn/developer-reference/api-dcdn-2018-01-15-createdcdnwafpolicy).
* > **NOTE:** Available since v1.184.0.
* ## Example Usage
* Basic Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as alicloud from "@pulumi/alicloud";
* import * as random from "@pulumi/random";
* const config = new pulumi.Config();
* const name = config.get("name") || "tf_example";
* const _default = new random.index.Integer("default", {
* min: 10000,
* max: 99999,
* });
* const example = new alicloud.dcdn.WafPolicy("example", {
* defenseScene: "waf_group",
* policyName: `${name}_${_default.result}`,
* policyType: "custom",
* status: "on",
* });
* ```
* ```python
* import pulumi
* import pulumi_alicloud as alicloud
* import pulumi_random as random
* config = pulumi.Config()
* name = config.get("name")
* if name is None:
* name = "tf_example"
* default = random.index.Integer("default",
* min=10000,
* max=99999)
* example = alicloud.dcdn.WafPolicy("example",
* defense_scene="waf_group",
* policy_name=f"{name}_{default['result']}",
* policy_type="custom",
* status="on")
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using AliCloud = Pulumi.AliCloud;
* using Random = Pulumi.Random;
* return await Deployment.RunAsync(() =>
* {
* var config = new Config();
* var name = config.Get("name") ?? "tf_example";
* var @default = new Random.Index.Integer("default", new()
* {
* Min = 10000,
* Max = 99999,
* });
* var example = new AliCloud.Dcdn.WafPolicy("example", new()
* {
* DefenseScene = "waf_group",
* PolicyName = $"{name}_{@default.Result}",
* PolicyType = "custom",
* Status = "on",
* });
* });
* ```
* ```go
* package main
* import (
* "fmt"
* "github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/dcdn"
* "github.com/pulumi/pulumi-random/sdk/v4/go/random"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* cfg := config.New(ctx, "")
* name := "tf_example"
* if param := cfg.Get("name"); param != "" {
* name = param
* }
* _, err := random.NewInteger(ctx, "default", &random.IntegerArgs{
* Min: 10000,
* Max: 99999,
* })
* if err != nil {
* return err
* }
* _, err = dcdn.NewWafPolicy(ctx, "example", &dcdn.WafPolicyArgs{
* DefenseScene: pulumi.String("waf_group"),
* PolicyName: pulumi.Sprintf("%v_%v", name, _default.Result),
* PolicyType: pulumi.String("custom"),
* Status: pulumi.String("on"),
* })
* 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.integer;
* import com.pulumi.random.IntegerArgs;
* import com.pulumi.alicloud.dcdn.WafPolicy;
* import com.pulumi.alicloud.dcdn.WafPolicyArgs;
* 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) {
* final var config = ctx.config();
* final var name = config.get("name").orElse("tf_example");
* var default_ = new Integer("default", IntegerArgs.builder()
* .min(10000)
* .max(99999)
* .build());
* var example = new WafPolicy("example", WafPolicyArgs.builder()
* .defenseScene("waf_group")
* .policyName(String.format("%s_%s", name,default_.result()))
* .policyType("custom")
* .status("on")
* .build());
* }
* }
* ```
* ```yaml
* configuration:
* name:
* type: string
* default: tf_example
* resources:
* default:
* type: random:integer
* properties:
* min: 10000
* max: 99999
* example:
* type: alicloud:dcdn:WafPolicy
* properties:
* defenseScene: waf_group
* policyName: ${name}_${default.result}
* policyType: custom
* status: on
* ```
*
* ## Import
* DCDN Waf Policy can be imported using the id, e.g.
* ```sh
* $ pulumi import alicloud:dcdn/wafPolicy:WafPolicy example
* ```
*/
public class WafPolicy internal constructor(
override val javaResource: com.pulumi.alicloud.dcdn.WafPolicy,
) : KotlinCustomResource(javaResource, WafPolicyMapper) {
/**
* The type of protection policy. Valid values: `waf_group`, `custom_acl`, `whitelist`, `ip_blacklist`, `region_block`.
*/
public val defenseScene: Output
get() = javaResource.defenseScene().applyValue({ args0 -> args0 })
/**
* The name of the protection policy. The name must be 1 to 64 characters in length, and can contain letters, digits,and underscores (_).
*/
public val policyName: Output
get() = javaResource.policyName().applyValue({ args0 -> args0 })
/**
* The type of the protection policy. Valid values: `default`, `custom`.
*/
public val policyType: Output
get() = javaResource.policyType().applyValue({ args0 -> args0 })
/**
* The status of the resource. Valid values: `on`, `off`.
*/
public val status: Output
get() = javaResource.status().applyValue({ args0 -> args0 })
}
public object WafPolicyMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.alicloud.dcdn.WafPolicy::class == javaResource::class
override fun map(javaResource: Resource): WafPolicy = WafPolicy(
javaResource as
com.pulumi.alicloud.dcdn.WafPolicy,
)
}
/**
* @see [WafPolicy].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [WafPolicy].
*/
public suspend fun wafPolicy(name: String, block: suspend WafPolicyResourceBuilder.() -> Unit): WafPolicy {
val builder = WafPolicyResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [WafPolicy].
* @param name The _unique_ name of the resulting resource.
*/
public fun wafPolicy(name: String): WafPolicy {
val builder = WafPolicyResourceBuilder()
builder.name(name)
return builder.build()
}