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

com.pulumi.cloudflare.kotlin.MagicFirewallRulesetArgs.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: 5.40.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.cloudflare.kotlin

import com.pulumi.cloudflare.MagicFirewallRulesetArgs.builder
import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import kotlin.String
import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.Map
import kotlin.jvm.JvmName

/**
 * Magic Firewall is a network-level firewall to protect networks that are onboarded to Cloudflare's Magic Transit. This resource
 * creates a root ruleset on the account level and contains one or more rules. Rules can be crafted in Wireshark syntax and
 * are evaluated in order, with the first rule having the highest priority.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as cloudflare from "@pulumi/cloudflare";
 * const example = new cloudflare.MagicFirewallRuleset("example", {
 *     accountId: "d41d8cd98f00b204e9800998ecf8427e",
 *     name: "Magic Transit Ruleset",
 *     description: "Global mitigations",
 *     rules: [
 *         {
 *             action: "allow",
 *             expression: "tcp.dstport in { 32768..65535 }",
 *             description: "Allow TCP Ephemeral Ports",
 *             enabled: "true",
 *         },
 *         {
 *             action: "block",
 *             expression: "ip.len >= 0",
 *             description: "Block all",
 *             enabled: "true",
 *         },
 *     ],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_cloudflare as cloudflare
 * example = cloudflare.MagicFirewallRuleset("example",
 *     account_id="d41d8cd98f00b204e9800998ecf8427e",
 *     name="Magic Transit Ruleset",
 *     description="Global mitigations",
 *     rules=[
 *         {
 *             "action": "allow",
 *             "expression": "tcp.dstport in { 32768..65535 }",
 *             "description": "Allow TCP Ephemeral Ports",
 *             "enabled": "true",
 *         },
 *         {
 *             "action": "block",
 *             "expression": "ip.len >= 0",
 *             "description": "Block all",
 *             "enabled": "true",
 *         },
 *     ])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Cloudflare = Pulumi.Cloudflare;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Cloudflare.MagicFirewallRuleset("example", new()
 *     {
 *         AccountId = "d41d8cd98f00b204e9800998ecf8427e",
 *         Name = "Magic Transit Ruleset",
 *         Description = "Global mitigations",
 *         Rules = new[]
 *         {
 *             {
 *                 { "action", "allow" },
 *                 { "expression", "tcp.dstport in { 32768..65535 }" },
 *                 { "description", "Allow TCP Ephemeral Ports" },
 *                 { "enabled", "true" },
 *             },
 *             {
 *                 { "action", "block" },
 *                 { "expression", "ip.len >= 0" },
 *                 { "description", "Block all" },
 *                 { "enabled", "true" },
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-cloudflare/sdk/v5/go/cloudflare"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := cloudflare.NewMagicFirewallRuleset(ctx, "example", &cloudflare.MagicFirewallRulesetArgs{
 * 			AccountId:   pulumi.String("d41d8cd98f00b204e9800998ecf8427e"),
 * 			Name:        pulumi.String("Magic Transit Ruleset"),
 * 			Description: pulumi.String("Global mitigations"),
 * 			Rules: pulumi.StringMapArray{
 * 				pulumi.StringMap{
 * 					"action":      pulumi.String("allow"),
 * 					"expression":  pulumi.String("tcp.dstport in { 32768..65535 }"),
 * 					"description": pulumi.String("Allow TCP Ephemeral Ports"),
 * 					"enabled":     pulumi.String("true"),
 * 				},
 * 				pulumi.StringMap{
 * 					"action":      pulumi.String("block"),
 * 					"expression":  pulumi.String("ip.len >= 0"),
 * 					"description": pulumi.String("Block all"),
 * 					"enabled":     pulumi.String("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.cloudflare.MagicFirewallRuleset;
 * import com.pulumi.cloudflare.MagicFirewallRulesetArgs;
 * 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 example = new MagicFirewallRuleset("example", MagicFirewallRulesetArgs.builder()
 *             .accountId("d41d8cd98f00b204e9800998ecf8427e")
 *             .name("Magic Transit Ruleset")
 *             .description("Global mitigations")
 *             .rules(
 *                 Map.ofEntries(
 *                     Map.entry("action", "allow"),
 *                     Map.entry("expression", "tcp.dstport in { 32768..65535 }"),
 *                     Map.entry("description", "Allow TCP Ephemeral Ports"),
 *                     Map.entry("enabled", "true")
 *                 ),
 *                 Map.ofEntries(
 *                     Map.entry("action", "block"),
 *                     Map.entry("expression", "ip.len >= 0"),
 *                     Map.entry("description", "Block all"),
 *                     Map.entry("enabled", "true")
 *                 ))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: cloudflare:MagicFirewallRuleset
 *     properties:
 *       accountId: d41d8cd98f00b204e9800998ecf8427e
 *       name: Magic Transit Ruleset
 *       description: Global mitigations
 *       rules:
 *         - action: allow
 *           expression: tcp.dstport in { 32768..65535 }
 *           description: Allow TCP Ephemeral Ports
 *           enabled: 'true'
 *         - action: block
 *           expression: ip.len >= 0
 *           description: Block all
 *           enabled: 'true'
 * ```
 * 
 * ## Import
 * An existing Magic Firewall Ruleset can be imported using the account ID and ruleset ID
 * ```sh
 * $ pulumi import cloudflare:index/magicFirewallRuleset:MagicFirewallRuleset example d41d8cd98f00b204e9800998ecf8427e/cb029e245cfdd66dc8d2e570d5dd3322
 * ```
 * @property accountId The ID of the account where the ruleset is being created.
 * @property description A note that can be used to annotate the rule.
 * @property name The name of the ruleset.
 * @property rules
 */
public data class MagicFirewallRulesetArgs(
    public val accountId: Output? = null,
    public val description: Output? = null,
    public val name: Output? = null,
    public val rules: Output>>? = null,
) : ConvertibleToJava {
    override fun toJava(): com.pulumi.cloudflare.MagicFirewallRulesetArgs =
        com.pulumi.cloudflare.MagicFirewallRulesetArgs.builder()
            .accountId(accountId?.applyValue({ args0 -> args0 }))
            .description(description?.applyValue({ args0 -> args0 }))
            .name(name?.applyValue({ args0 -> args0 }))
            .rules(
                rules?.applyValue({ args0 ->
                    args0.map({ args0 ->
                        args0.map({ args0 ->
                            args0.key.to(args0.value)
                        }).toMap()
                    })
                }),
            ).build()
}

/**
 * Builder for [MagicFirewallRulesetArgs].
 */
@PulumiTagMarker
public class MagicFirewallRulesetArgsBuilder internal constructor() {
    private var accountId: Output? = null

    private var description: Output? = null

    private var name: Output? = null

    private var rules: Output>>? = null

    /**
     * @param value The ID of the account where the ruleset is being created.
     */
    @JvmName("pyimpvgahdhycsfq")
    public suspend fun accountId(`value`: Output) {
        this.accountId = value
    }

    /**
     * @param value A note that can be used to annotate the rule.
     */
    @JvmName("rmmtgmmvbilmkqqe")
    public suspend fun description(`value`: Output) {
        this.description = value
    }

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

    /**
     * @param value
     */
    @JvmName("vopsryocxkhsaeux")
    public suspend fun rules(`value`: Output>>) {
        this.rules = value
    }

    @JvmName("fxlfedkxuojbydsx")
    public suspend fun rules(vararg values: Output>) {
        this.rules = Output.all(values.asList())
    }

    /**
     * @param values
     */
    @JvmName("pxrjhigbtjeqacdj")
    public suspend fun rules(values: List>>) {
        this.rules = Output.all(values)
    }

    /**
     * @param value The ID of the account where the ruleset is being created.
     */
    @JvmName("kklatrirxeepirkw")
    public suspend fun accountId(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.accountId = mapped
    }

    /**
     * @param value A note that can be used to annotate the rule.
     */
    @JvmName("ukiiwnnsxpccvxeg")
    public suspend fun description(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.description = mapped
    }

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

    /**
     * @param value
     */
    @JvmName("pevhgcgphlocnstq")
    public suspend fun rules(`value`: List>?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.rules = mapped
    }

    /**
     * @param values
     */
    @JvmName("gtdovkbphvpqkjmy")
    public suspend fun rules(vararg values: Map) {
        val toBeMapped = values.toList()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.rules = mapped
    }

    internal fun build(): MagicFirewallRulesetArgs = MagicFirewallRulesetArgs(
        accountId = accountId,
        description = description,
        name = name,
        rules = rules,
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy