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

com.pulumi.cloudflare.kotlin.MagicFirewallRuleset.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.

The newest version!
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.cloudflare.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
import kotlin.collections.List
import kotlin.collections.Map

/**
 * Builder for [MagicFirewallRuleset].
 */
@PulumiTagMarker
public class MagicFirewallRulesetResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: MagicFirewallRulesetArgs = MagicFirewallRulesetArgs()

    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 MagicFirewallRulesetArgsBuilder.() -> Unit) {
        val builder = MagicFirewallRulesetArgsBuilder()
        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(): MagicFirewallRuleset {
        val builtJavaResource = com.pulumi.cloudflare.MagicFirewallRuleset(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return MagicFirewallRuleset(builtJavaResource)
    }
}

/**
 * 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
 * ```
 */
public class MagicFirewallRuleset internal constructor(
    override val javaResource: com.pulumi.cloudflare.MagicFirewallRuleset,
) : KotlinCustomResource(javaResource, MagicFirewallRulesetMapper) {
    /**
     * The ID of the account where the ruleset is being created.
     */
    public val accountId: Output
        get() = javaResource.accountId().applyValue({ args0 -> args0 })

    /**
     * A note that can be used to annotate the rule.
     */
    public val description: Output?
        get() = javaResource.description().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The name of the ruleset.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    public val rules: Output>>?
        get() = javaResource.rules().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.map({ args0 -> args0.key.to(args0.value) }).toMap()
                })
            }).orElse(null)
        })
}

public object MagicFirewallRulesetMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.cloudflare.MagicFirewallRuleset::class == javaResource::class

    override fun map(javaResource: Resource): MagicFirewallRuleset = MagicFirewallRuleset(
        javaResource
            as com.pulumi.cloudflare.MagicFirewallRuleset,
    )
}

/**
 * @see [MagicFirewallRuleset].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [MagicFirewallRuleset].
 */
public suspend fun magicFirewallRuleset(
    name: String,
    block: suspend MagicFirewallRulesetResourceBuilder.() -> Unit,
): MagicFirewallRuleset {
    val builder = MagicFirewallRulesetResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [MagicFirewallRuleset].
 * @param name The _unique_ name of the resulting resource.
 */
public fun magicFirewallRuleset(name: String): MagicFirewallRuleset {
    val builder = MagicFirewallRulesetResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy