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

com.pulumi.aws.waf.kotlin.RateBasedRuleArgs.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 6.57.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.aws.waf.kotlin

import com.pulumi.aws.waf.RateBasedRuleArgs.builder
import com.pulumi.aws.waf.kotlin.inputs.RateBasedRulePredicateArgs
import com.pulumi.aws.waf.kotlin.inputs.RateBasedRulePredicateArgsBuilder
import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.applySuspend
import kotlin.Int
import kotlin.Pair
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import kotlin.jvm.JvmName

/**
 * Provides a WAF Rate Based Rule Resource
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as aws from "@pulumi/aws";
 * const ipset = new aws.waf.IpSet("ipset", {
 *     name: "tfIPSet",
 *     ipSetDescriptors: [{
 *         type: "IPV4",
 *         value: "192.0.7.0/24",
 *     }],
 * });
 * const wafrule = new aws.waf.RateBasedRule("wafrule", {
 *     name: "tfWAFRule",
 *     metricName: "tfWAFRule",
 *     rateKey: "IP",
 *     rateLimit: 100,
 *     predicates: [{
 *         dataId: ipset.id,
 *         negated: false,
 *         type: "IPMatch",
 *     }],
 * }, {
 *     dependsOn: [ipset],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_aws as aws
 * ipset = aws.waf.IpSet("ipset",
 *     name="tfIPSet",
 *     ip_set_descriptors=[{
 *         "type": "IPV4",
 *         "value": "192.0.7.0/24",
 *     }])
 * wafrule = aws.waf.RateBasedRule("wafrule",
 *     name="tfWAFRule",
 *     metric_name="tfWAFRule",
 *     rate_key="IP",
 *     rate_limit=100,
 *     predicates=[{
 *         "data_id": ipset.id,
 *         "negated": False,
 *         "type": "IPMatch",
 *     }],
 *     opts = pulumi.ResourceOptions(depends_on=[ipset]))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Aws = Pulumi.Aws;
 * return await Deployment.RunAsync(() =>
 * {
 *     var ipset = new Aws.Waf.IpSet("ipset", new()
 *     {
 *         Name = "tfIPSet",
 *         IpSetDescriptors = new[]
 *         {
 *             new Aws.Waf.Inputs.IpSetIpSetDescriptorArgs
 *             {
 *                 Type = "IPV4",
 *                 Value = "192.0.7.0/24",
 *             },
 *         },
 *     });
 *     var wafrule = new Aws.Waf.RateBasedRule("wafrule", new()
 *     {
 *         Name = "tfWAFRule",
 *         MetricName = "tfWAFRule",
 *         RateKey = "IP",
 *         RateLimit = 100,
 *         Predicates = new[]
 *         {
 *             new Aws.Waf.Inputs.RateBasedRulePredicateArgs
 *             {
 *                 DataId = ipset.Id,
 *                 Negated = false,
 *                 Type = "IPMatch",
 *             },
 *         },
 *     }, new CustomResourceOptions
 *     {
 *         DependsOn =
 *         {
 *             ipset,
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/waf"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		ipset, err := waf.NewIpSet(ctx, "ipset", &waf.IpSetArgs{
 * 			Name: pulumi.String("tfIPSet"),
 * 			IpSetDescriptors: waf.IpSetIpSetDescriptorArray{
 * 				&waf.IpSetIpSetDescriptorArgs{
 * 					Type:  pulumi.String("IPV4"),
 * 					Value: pulumi.String("192.0.7.0/24"),
 * 				},
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = waf.NewRateBasedRule(ctx, "wafrule", &waf.RateBasedRuleArgs{
 * 			Name:       pulumi.String("tfWAFRule"),
 * 			MetricName: pulumi.String("tfWAFRule"),
 * 			RateKey:    pulumi.String("IP"),
 * 			RateLimit:  pulumi.Int(100),
 * 			Predicates: waf.RateBasedRulePredicateArray{
 * 				&waf.RateBasedRulePredicateArgs{
 * 					DataId:  ipset.ID(),
 * 					Negated: pulumi.Bool(false),
 * 					Type:    pulumi.String("IPMatch"),
 * 				},
 * 			},
 * 		}, pulumi.DependsOn([]pulumi.Resource{
 * 			ipset,
 * 		}))
 * 		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.aws.waf.IpSet;
 * import com.pulumi.aws.waf.IpSetArgs;
 * import com.pulumi.aws.waf.inputs.IpSetIpSetDescriptorArgs;
 * import com.pulumi.aws.waf.RateBasedRule;
 * import com.pulumi.aws.waf.RateBasedRuleArgs;
 * import com.pulumi.aws.waf.inputs.RateBasedRulePredicateArgs;
 * import com.pulumi.resources.CustomResourceOptions;
 * 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 ipset = new IpSet("ipset", IpSetArgs.builder()
 *             .name("tfIPSet")
 *             .ipSetDescriptors(IpSetIpSetDescriptorArgs.builder()
 *                 .type("IPV4")
 *                 .value("192.0.7.0/24")
 *                 .build())
 *             .build());
 *         var wafrule = new RateBasedRule("wafrule", RateBasedRuleArgs.builder()
 *             .name("tfWAFRule")
 *             .metricName("tfWAFRule")
 *             .rateKey("IP")
 *             .rateLimit(100)
 *             .predicates(RateBasedRulePredicateArgs.builder()
 *                 .dataId(ipset.id())
 *                 .negated(false)
 *                 .type("IPMatch")
 *                 .build())
 *             .build(), CustomResourceOptions.builder()
 *                 .dependsOn(ipset)
 *                 .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   ipset:
 *     type: aws:waf:IpSet
 *     properties:
 *       name: tfIPSet
 *       ipSetDescriptors:
 *         - type: IPV4
 *           value: 192.0.7.0/24
 *   wafrule:
 *     type: aws:waf:RateBasedRule
 *     properties:
 *       name: tfWAFRule
 *       metricName: tfWAFRule
 *       rateKey: IP
 *       rateLimit: 100
 *       predicates:
 *         - dataId: ${ipset.id}
 *           negated: false
 *           type: IPMatch
 *     options:
 *       dependson:
 *         - ${ipset}
 * ```
 * 
 * ## Import
 * Using `pulumi import`, import WAF Rated Based Rule using the id. For example:
 * ```sh
 * $ pulumi import aws:waf/rateBasedRule:RateBasedRule wafrule a1b2c3d4-d5f6-7777-8888-9999aaaabbbbcccc
 * ```
 * @property metricName The name or description for the Amazon CloudWatch metric of this rule.
 * @property name The name or description of the rule.
 * @property predicates The objects to include in a rule (documented below).
 * @property rateKey Valid value is IP.
 * @property rateLimit The maximum number of requests, which have an identical value in the field specified by the RateKey, allowed in a five-minute period. Minimum value is 100.
 * @property tags Key-value map of resource tags. .If configured with a provider `default_tags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
 */
public data class RateBasedRuleArgs(
    public val metricName: Output? = null,
    public val name: Output? = null,
    public val predicates: Output>? = null,
    public val rateKey: Output? = null,
    public val rateLimit: Output? = null,
    public val tags: Output>? = null,
) : ConvertibleToJava {
    override fun toJava(): com.pulumi.aws.waf.RateBasedRuleArgs =
        com.pulumi.aws.waf.RateBasedRuleArgs.builder()
            .metricName(metricName?.applyValue({ args0 -> args0 }))
            .name(name?.applyValue({ args0 -> args0 }))
            .predicates(
                predicates?.applyValue({ args0 ->
                    args0.map({ args0 ->
                        args0.let({ args0 ->
                            args0.toJava()
                        })
                    })
                }),
            )
            .rateKey(rateKey?.applyValue({ args0 -> args0 }))
            .rateLimit(rateLimit?.applyValue({ args0 -> args0 }))
            .tags(
                tags?.applyValue({ args0 ->
                    args0.map({ args0 ->
                        args0.key.to(args0.value)
                    }).toMap()
                }),
            ).build()
}

/**
 * Builder for [RateBasedRuleArgs].
 */
@PulumiTagMarker
public class RateBasedRuleArgsBuilder internal constructor() {
    private var metricName: Output? = null

    private var name: Output? = null

    private var predicates: Output>? = null

    private var rateKey: Output? = null

    private var rateLimit: Output? = null

    private var tags: Output>? = null

    /**
     * @param value The name or description for the Amazon CloudWatch metric of this rule.
     */
    @JvmName("xinbiwprsgurkgtf")
    public suspend fun metricName(`value`: Output) {
        this.metricName = value
    }

    /**
     * @param value The name or description of the rule.
     */
    @JvmName("xblnjqjhvlgeejvn")
    public suspend fun name(`value`: Output) {
        this.name = value
    }

    /**
     * @param value The objects to include in a rule (documented below).
     */
    @JvmName("psnyedblgffrudfc")
    public suspend fun predicates(`value`: Output>) {
        this.predicates = value
    }

    @JvmName("uxhdnksasrtpgqrj")
    public suspend fun predicates(vararg values: Output) {
        this.predicates = Output.all(values.asList())
    }

    /**
     * @param values The objects to include in a rule (documented below).
     */
    @JvmName("rvdgxghsxtwmnkam")
    public suspend fun predicates(values: List>) {
        this.predicates = Output.all(values)
    }

    /**
     * @param value Valid value is IP.
     */
    @JvmName("okjonhgrlhxcncny")
    public suspend fun rateKey(`value`: Output) {
        this.rateKey = value
    }

    /**
     * @param value The maximum number of requests, which have an identical value in the field specified by the RateKey, allowed in a five-minute period. Minimum value is 100.
     */
    @JvmName("ubyifmgdackoghmq")
    public suspend fun rateLimit(`value`: Output) {
        this.rateLimit = value
    }

    /**
     * @param value Key-value map of resource tags. .If configured with a provider `default_tags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
     */
    @JvmName("wxhgavnolkygtalw")
    public suspend fun tags(`value`: Output>) {
        this.tags = value
    }

    /**
     * @param value The name or description for the Amazon CloudWatch metric of this rule.
     */
    @JvmName("wgqmhtrvgirixmhe")
    public suspend fun metricName(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.metricName = mapped
    }

    /**
     * @param value The name or description of the rule.
     */
    @JvmName("hrgosrvujpxhdrtd")
    public suspend fun name(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.name = mapped
    }

    /**
     * @param value The objects to include in a rule (documented below).
     */
    @JvmName("osejfnjrggverjda")
    public suspend fun predicates(`value`: List?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.predicates = mapped
    }

    /**
     * @param argument The objects to include in a rule (documented below).
     */
    @JvmName("teuaqdckkjqxtgpn")
    public suspend fun predicates(argument: List Unit>) {
        val toBeMapped = argument.toList().map {
            RateBasedRulePredicateArgsBuilder().applySuspend {
                it()
            }.build()
        }
        val mapped = of(toBeMapped)
        this.predicates = mapped
    }

    /**
     * @param argument The objects to include in a rule (documented below).
     */
    @JvmName("igevsiffcjybejfd")
    public suspend fun predicates(vararg argument: suspend RateBasedRulePredicateArgsBuilder.() -> Unit) {
        val toBeMapped = argument.toList().map {
            RateBasedRulePredicateArgsBuilder().applySuspend {
                it()
            }.build()
        }
        val mapped = of(toBeMapped)
        this.predicates = mapped
    }

    /**
     * @param argument The objects to include in a rule (documented below).
     */
    @JvmName("wuqlvyneeebphyvl")
    public suspend fun predicates(argument: suspend RateBasedRulePredicateArgsBuilder.() -> Unit) {
        val toBeMapped = listOf(RateBasedRulePredicateArgsBuilder().applySuspend { argument() }.build())
        val mapped = of(toBeMapped)
        this.predicates = mapped
    }

    /**
     * @param values The objects to include in a rule (documented below).
     */
    @JvmName("nfxgcowhlnesunfm")
    public suspend fun predicates(vararg values: RateBasedRulePredicateArgs) {
        val toBeMapped = values.toList()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.predicates = mapped
    }

    /**
     * @param value Valid value is IP.
     */
    @JvmName("odtvebymhwlrwfdb")
    public suspend fun rateKey(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.rateKey = mapped
    }

    /**
     * @param value The maximum number of requests, which have an identical value in the field specified by the RateKey, allowed in a five-minute period. Minimum value is 100.
     */
    @JvmName("loeblaglntktrklv")
    public suspend fun rateLimit(`value`: Int?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.rateLimit = mapped
    }

    /**
     * @param value Key-value map of resource tags. .If configured with a provider `default_tags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
     */
    @JvmName("cjkiibitrjsblylm")
    public suspend fun tags(`value`: Map?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.tags = mapped
    }

    /**
     * @param values Key-value map of resource tags. .If configured with a provider `default_tags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
     */
    @JvmName("nsogscpxwntmistk")
    public fun tags(vararg values: Pair) {
        val toBeMapped = values.toMap()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.tags = mapped
    }

    internal fun build(): RateBasedRuleArgs = RateBasedRuleArgs(
        metricName = metricName,
        name = name,
        predicates = predicates,
        rateKey = rateKey,
        rateLimit = rateLimit,
        tags = tags,
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy