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

com.pulumi.aws.wafregional.kotlin.RuleArgs.kt Maven / Gradle / Ivy

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

package com.pulumi.aws.wafregional.kotlin

import com.pulumi.aws.wafregional.RuleArgs.builder
import com.pulumi.aws.wafregional.kotlin.inputs.RulePredicateArgs
import com.pulumi.aws.wafregional.kotlin.inputs.RulePredicateArgsBuilder
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.Pair
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import kotlin.jvm.JvmName

/**
 * Provides an WAF Regional Rule Resource for use with Application Load Balancer.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as aws from "@pulumi/aws";
 * const ipset = new aws.wafregional.IpSet("ipset", {
 *     name: "tfIPSet",
 *     ipSetDescriptors: [{
 *         type: "IPV4",
 *         value: "192.0.7.0/24",
 *     }],
 * });
 * const wafrule = new aws.wafregional.Rule("wafrule", {
 *     name: "tfWAFRule",
 *     metricName: "tfWAFRule",
 *     predicates: [{
 *         type: "IPMatch",
 *         dataId: ipset.id,
 *         negated: false,
 *     }],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_aws as aws
 * ipset = aws.wafregional.IpSet("ipset",
 *     name="tfIPSet",
 *     ip_set_descriptors=[{
 *         "type": "IPV4",
 *         "value": "192.0.7.0/24",
 *     }])
 * wafrule = aws.wafregional.Rule("wafrule",
 *     name="tfWAFRule",
 *     metric_name="tfWAFRule",
 *     predicates=[{
 *         "type": "IPMatch",
 *         "data_id": ipset.id,
 *         "negated": False,
 *     }])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Aws = Pulumi.Aws;
 * return await Deployment.RunAsync(() =>
 * {
 *     var ipset = new Aws.WafRegional.IpSet("ipset", new()
 *     {
 *         Name = "tfIPSet",
 *         IpSetDescriptors = new[]
 *         {
 *             new Aws.WafRegional.Inputs.IpSetIpSetDescriptorArgs
 *             {
 *                 Type = "IPV4",
 *                 Value = "192.0.7.0/24",
 *             },
 *         },
 *     });
 *     var wafrule = new Aws.WafRegional.Rule("wafrule", new()
 *     {
 *         Name = "tfWAFRule",
 *         MetricName = "tfWAFRule",
 *         Predicates = new[]
 *         {
 *             new Aws.WafRegional.Inputs.RulePredicateArgs
 *             {
 *                 Type = "IPMatch",
 *                 DataId = ipset.Id,
 *                 Negated = false,
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/wafregional"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		ipset, err := wafregional.NewIpSet(ctx, "ipset", &wafregional.IpSetArgs{
 * 			Name: pulumi.String("tfIPSet"),
 * 			IpSetDescriptors: wafregional.IpSetIpSetDescriptorArray{
 * 				&wafregional.IpSetIpSetDescriptorArgs{
 * 					Type:  pulumi.String("IPV4"),
 * 					Value: pulumi.String("192.0.7.0/24"),
 * 				},
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = wafregional.NewRule(ctx, "wafrule", &wafregional.RuleArgs{
 * 			Name:       pulumi.String("tfWAFRule"),
 * 			MetricName: pulumi.String("tfWAFRule"),
 * 			Predicates: wafregional.RulePredicateArray{
 * 				&wafregional.RulePredicateArgs{
 * 					Type:    pulumi.String("IPMatch"),
 * 					DataId:  ipset.ID(),
 * 					Negated: pulumi.Bool(false),
 * 				},
 * 			},
 * 		})
 * 		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.wafregional.IpSet;
 * import com.pulumi.aws.wafregional.IpSetArgs;
 * import com.pulumi.aws.wafregional.inputs.IpSetIpSetDescriptorArgs;
 * import com.pulumi.aws.wafregional.Rule;
 * import com.pulumi.aws.wafregional.RuleArgs;
 * import com.pulumi.aws.wafregional.inputs.RulePredicateArgs;
 * 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 Rule("wafrule", RuleArgs.builder()
 *             .name("tfWAFRule")
 *             .metricName("tfWAFRule")
 *             .predicates(RulePredicateArgs.builder()
 *                 .type("IPMatch")
 *                 .dataId(ipset.id())
 *                 .negated(false)
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   ipset:
 *     type: aws:wafregional:IpSet
 *     properties:
 *       name: tfIPSet
 *       ipSetDescriptors:
 *         - type: IPV4
 *           value: 192.0.7.0/24
 *   wafrule:
 *     type: aws:wafregional:Rule
 *     properties:
 *       name: tfWAFRule
 *       metricName: tfWAFRule
 *       predicates:
 *         - type: IPMatch
 *           dataId: ${ipset.id}
 *           negated: false
 * ```
 * 
 * ## Nested Fields
 * ### `predicate`
 * See the [WAF Documentation](https://docs.aws.amazon.com/waf/latest/APIReference/API_Predicate.html) for more information.
 * #### Arguments
 * * `type` - (Required) The type of predicate in a rule. Valid values: `ByteMatch`, `GeoMatch`, `IPMatch`, `RegexMatch`, `SizeConstraint`, `SqlInjectionMatch`, or `XssMatch`
 * * `data_id` - (Required) The unique identifier of a predicate, such as the ID of a `ByteMatchSet` or `IPSet`.
 * * `negated` - (Required) Whether to use the settings or the negated settings that you specified in the objects.
 * ## Import
 * Using `pulumi import`, import WAF Regional Rule using the id. For example:
 * ```sh
 * $ pulumi import aws:wafregional/rule:Rule 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 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 RuleArgs(
    public val metricName: Output? = null,
    public val name: Output? = null,
    public val predicates: Output>? = null,
    public val tags: Output>? = null,
) : ConvertibleToJava {
    override fun toJava(): com.pulumi.aws.wafregional.RuleArgs =
        com.pulumi.aws.wafregional.RuleArgs.builder()
            .metricName(metricName?.applyValue({ args0 -> args0 }))
            .name(name?.applyValue({ args0 -> args0 }))
            .predicates(
                predicates?.applyValue({ args0 ->
                    args0.map({ args0 ->
                        args0.let({ args0 ->
                            args0.toJava()
                        })
                    })
                }),
            )
            .tags(
                tags?.applyValue({ args0 ->
                    args0.map({ args0 ->
                        args0.key.to(args0.value)
                    }).toMap()
                }),
            ).build()
}

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

    private var name: Output? = null

    private var predicates: Output>? = null

    private var tags: Output>? = null

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

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

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

    @JvmName("cpsxodexronwkvxy")
    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("fuihdpwmwsifwmnd")
    public suspend fun predicates(values: List>) {
        this.predicates = Output.all(values)
    }

    /**
     * @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("syjsplscwemcpnxy")
    public suspend fun tags(`value`: Output>) {
        this.tags = value
    }

    /**
     * @param value The name or description for the Amazon CloudWatch metric of this rule.
     */
    @JvmName("ddtuttrtjbrededc")
    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("dwxkmaashomycenu")
    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("fcjgdrvhmtvfyvbn")
    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("srkdefvcbtyxfujo")
    public suspend fun predicates(argument: List Unit>) {
        val toBeMapped = argument.toList().map {
            RulePredicateArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.predicates = mapped
    }

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

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

    /**
     * @param values The objects to include in a rule (documented below).
     */
    @JvmName("exjrcflpdvnbddee")
    public suspend fun predicates(vararg values: RulePredicateArgs) {
        val toBeMapped = values.toList()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.predicates = 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("fhhgvtjtedbmdecw")
    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("lpecuevoojtjlawp")
    public fun tags(vararg values: Pair) {
        val toBeMapped = values.toMap()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.tags = mapped
    }

    internal fun build(): RuleArgs = RuleArgs(
        metricName = metricName,
        name = name,
        predicates = predicates,
        tags = tags,
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy