com.pulumi.cloudflare.kotlin.FirewallRule.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-cloudflare-kotlin Show documentation
Show all versions of pulumi-cloudflare-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.
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.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
/**
* Builder for [FirewallRule].
*/
@PulumiTagMarker
public class FirewallRuleResourceBuilder internal constructor() {
public var name: String? = null
public var args: FirewallRuleArgs = FirewallRuleArgs()
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 FirewallRuleArgsBuilder.() -> Unit) {
val builder = FirewallRuleArgsBuilder()
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(): FirewallRule {
val builtJavaResource = com.pulumi.cloudflare.FirewallRule(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return FirewallRule(builtJavaResource)
}
}
/**
* Define Firewall rules using filter expressions for more control over
* how traffic is matched to the rule. A filter expression permits
* selecting traffic by multiple criteria allowing greater freedom in
* rule creation.
* Filter expressions needs to be created first before using Firewall
* Rule.
* > `cloudflare.FirewallRule` is in a deprecation phase until January 15th, 2025.
* During this time period, this resource is still
* fully supported but you are strongly advised to move to the
* `cloudflare.Ruleset` resource. Full details can be found in the
* developer documentation.
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as cloudflare from "@pulumi/cloudflare";
* const wordpress = new cloudflare.Filter("wordpress", {
* zoneId: "0da42c8d2132a9ddaf714f9e7c920711",
* description: "Wordpress break-in attempts that are outside of the office",
* expression: "(http.request.uri.path ~ \".*wp-login.php\" or http.request.uri.path ~ \".*xmlrpc.php\") and ip.src ne 192.0.2.1",
* });
* const wordpressFirewallRule = new cloudflare.FirewallRule("wordpress", {
* zoneId: "0da42c8d2132a9ddaf714f9e7c920711",
* description: "Block wordpress break-in attempts",
* filterId: wordpress.id,
* action: "block",
* });
* ```
* ```python
* import pulumi
* import pulumi_cloudflare as cloudflare
* wordpress = cloudflare.Filter("wordpress",
* zone_id="0da42c8d2132a9ddaf714f9e7c920711",
* description="Wordpress break-in attempts that are outside of the office",
* expression="(http.request.uri.path ~ \".*wp-login.php\" or http.request.uri.path ~ \".*xmlrpc.php\") and ip.src ne 192.0.2.1")
* wordpress_firewall_rule = cloudflare.FirewallRule("wordpress",
* zone_id="0da42c8d2132a9ddaf714f9e7c920711",
* description="Block wordpress break-in attempts",
* filter_id=wordpress.id,
* action="block")
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Cloudflare = Pulumi.Cloudflare;
* return await Deployment.RunAsync(() =>
* {
* var wordpress = new Cloudflare.Filter("wordpress", new()
* {
* ZoneId = "0da42c8d2132a9ddaf714f9e7c920711",
* Description = "Wordpress break-in attempts that are outside of the office",
* Expression = "(http.request.uri.path ~ \".*wp-login.php\" or http.request.uri.path ~ \".*xmlrpc.php\") and ip.src ne 192.0.2.1",
* });
* var wordpressFirewallRule = new Cloudflare.FirewallRule("wordpress", new()
* {
* ZoneId = "0da42c8d2132a9ddaf714f9e7c920711",
* Description = "Block wordpress break-in attempts",
* FilterId = wordpress.Id,
* Action = "block",
* });
* });
* ```
* ```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 {
* wordpress, err := cloudflare.NewFilter(ctx, "wordpress", &cloudflare.FilterArgs{
* ZoneId: pulumi.String("0da42c8d2132a9ddaf714f9e7c920711"),
* Description: pulumi.String("Wordpress break-in attempts that are outside of the office"),
* Expression: pulumi.String("(http.request.uri.path ~ \".*wp-login.php\" or http.request.uri.path ~ \".*xmlrpc.php\") and ip.src ne 192.0.2.1"),
* })
* if err != nil {
* return err
* }
* _, err = cloudflare.NewFirewallRule(ctx, "wordpress", &cloudflare.FirewallRuleArgs{
* ZoneId: pulumi.String("0da42c8d2132a9ddaf714f9e7c920711"),
* Description: pulumi.String("Block wordpress break-in attempts"),
* FilterId: wordpress.ID(),
* Action: pulumi.String("block"),
* })
* 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.Filter;
* import com.pulumi.cloudflare.FilterArgs;
* import com.pulumi.cloudflare.FirewallRule;
* import com.pulumi.cloudflare.FirewallRuleArgs;
* 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 wordpress = new Filter("wordpress", FilterArgs.builder()
* .zoneId("0da42c8d2132a9ddaf714f9e7c920711")
* .description("Wordpress break-in attempts that are outside of the office")
* .expression("(http.request.uri.path ~ \".*wp-login.php\" or http.request.uri.path ~ \".*xmlrpc.php\") and ip.src ne 192.0.2.1")
* .build());
* var wordpressFirewallRule = new FirewallRule("wordpressFirewallRule", FirewallRuleArgs.builder()
* .zoneId("0da42c8d2132a9ddaf714f9e7c920711")
* .description("Block wordpress break-in attempts")
* .filterId(wordpress.id())
* .action("block")
* .build());
* }
* }
* ```
* ```yaml
* resources:
* wordpress:
* type: cloudflare:Filter
* properties:
* zoneId: 0da42c8d2132a9ddaf714f9e7c920711
* description: Wordpress break-in attempts that are outside of the office
* expression: (http.request.uri.path ~ ".*wp-login.php" or http.request.uri.path ~ ".*xmlrpc.php") and ip.src ne 192.0.2.1
* wordpressFirewallRule:
* type: cloudflare:FirewallRule
* name: wordpress
* properties:
* zoneId: 0da42c8d2132a9ddaf714f9e7c920711
* description: Block wordpress break-in attempts
* filterId: ${wordpress.id}
* action: block
* ```
*
* ## Import
* ```sh
* $ pulumi import cloudflare:index/firewallRule:FirewallRule example /
* ```
*/
public class FirewallRule internal constructor(
override val javaResource: com.pulumi.cloudflare.FirewallRule,
) : KotlinCustomResource(javaResource, FirewallRuleMapper) {
/**
* The action to apply to a matched request. Available values: `block`, `challenge`, `allow`, `js_challenge`, `managed_challenge`, `log`, `bypass`.
*/
public val action: Output
get() = javaResource.action().applyValue({ args0 -> args0 })
/**
* A description of the rule to help identify it.
*/
public val description: Output?
get() = javaResource.description().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* The identifier of the Filter to use for determining if the Firewall Rule should be triggered.
*/
public val filterId: Output
get() = javaResource.filterId().applyValue({ args0 -> args0 })
/**
* Whether this filter based firewall rule is currently paused.
*/
public val paused: Output?
get() = javaResource.paused().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* The priority of the rule to allow control of processing order. A lower number indicates high priority. If not provided, any rules with a priority will be sequenced before those without.
*/
public val priority: Output?
get() = javaResource.priority().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* List of products to bypass for a request when the bypass action is used. Available values: `zoneLockdown`, `uaBlock`, `bic`, `hot`, `securityLevel`, `rateLimit`, `waf`.
*/
public val products: Output>?
get() = javaResource.products().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 ->
args0
})
}).orElse(null)
})
/**
* The zone identifier to target for the resource. **Modifying this attribute will force creation of a new resource.**
*/
public val zoneId: Output
get() = javaResource.zoneId().applyValue({ args0 -> args0 })
}
public object FirewallRuleMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.cloudflare.FirewallRule::class == javaResource::class
override fun map(javaResource: Resource): FirewallRule = FirewallRule(
javaResource as
com.pulumi.cloudflare.FirewallRule,
)
}
/**
* @see [FirewallRule].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [FirewallRule].
*/
public suspend fun firewallRule(
name: String,
block: suspend FirewallRuleResourceBuilder.() -> Unit,
): FirewallRule {
val builder = FirewallRuleResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [FirewallRule].
* @param name The _unique_ name of the resulting resource.
*/
public fun firewallRule(name: String): FirewallRule {
val builder = FirewallRuleResourceBuilder()
builder.name(name)
return builder.build()
}