com.pulumi.gcp.compute.kotlin.SecurityPolicyRule.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-gcp-kotlin Show documentation
Show all versions of pulumi-gcp-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.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.compute.kotlin
import com.pulumi.core.Output
import com.pulumi.gcp.compute.kotlin.outputs.SecurityPolicyRuleMatch
import com.pulumi.gcp.compute.kotlin.outputs.SecurityPolicyRulePreconfiguredWafConfig
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 com.pulumi.gcp.compute.kotlin.outputs.SecurityPolicyRuleMatch.Companion.toKotlin as securityPolicyRuleMatchToKotlin
import com.pulumi.gcp.compute.kotlin.outputs.SecurityPolicyRulePreconfiguredWafConfig.Companion.toKotlin as securityPolicyRulePreconfiguredWafConfigToKotlin
/**
* Builder for [SecurityPolicyRule].
*/
@PulumiTagMarker
public class SecurityPolicyRuleResourceBuilder internal constructor() {
public var name: String? = null
public var args: SecurityPolicyRuleArgs = SecurityPolicyRuleArgs()
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 SecurityPolicyRuleArgsBuilder.() -> Unit) {
val builder = SecurityPolicyRuleArgsBuilder()
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(): SecurityPolicyRule {
val builtJavaResource = com.pulumi.gcp.compute.SecurityPolicyRule(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return SecurityPolicyRule(builtJavaResource)
}
}
/**
* A rule for the SecurityPolicy.
* To get more information about SecurityPolicyRule, see:
* * [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/securityPolicies/addRule)
* * How-to Guides
* * [Creating global security policy rules](https://cloud.google.com/armor/docs/configure-security-policies)
* ## Example Usage
* ### Security Policy Rule Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const _default = new gcp.compute.SecurityPolicy("default", {
* name: "policyruletest",
* description: "basic global security policy",
* type: "CLOUD_ARMOR",
* });
* const policyRule = new gcp.compute.SecurityPolicyRule("policy_rule", {
* securityPolicy: _default.name,
* description: "new rule",
* priority: 100,
* match: {
* versionedExpr: "SRC_IPS_V1",
* config: {
* srcIpRanges: ["10.10.0.0/16"],
* },
* },
* action: "allow",
* preview: true,
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* default = gcp.compute.SecurityPolicy("default",
* name="policyruletest",
* description="basic global security policy",
* type="CLOUD_ARMOR")
* policy_rule = gcp.compute.SecurityPolicyRule("policy_rule",
* security_policy=default.name,
* description="new rule",
* priority=100,
* match=gcp.compute.SecurityPolicyRuleMatchArgs(
* versioned_expr="SRC_IPS_V1",
* config=gcp.compute.SecurityPolicyRuleMatchConfigArgs(
* src_ip_ranges=["10.10.0.0/16"],
* ),
* ),
* action="allow",
* preview=True)
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var @default = new Gcp.Compute.SecurityPolicy("default", new()
* {
* Name = "policyruletest",
* Description = "basic global security policy",
* Type = "CLOUD_ARMOR",
* });
* var policyRule = new Gcp.Compute.SecurityPolicyRule("policy_rule", new()
* {
* SecurityPolicy = @default.Name,
* Description = "new rule",
* Priority = 100,
* Match = new Gcp.Compute.Inputs.SecurityPolicyRuleMatchArgs
* {
* VersionedExpr = "SRC_IPS_V1",
* Config = new Gcp.Compute.Inputs.SecurityPolicyRuleMatchConfigArgs
* {
* SrcIpRanges = new[]
* {
* "10.10.0.0/16",
* },
* },
* },
* Action = "allow",
* Preview = true,
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := compute.NewSecurityPolicy(ctx, "default", &compute.SecurityPolicyArgs{
* Name: pulumi.String("policyruletest"),
* Description: pulumi.String("basic global security policy"),
* Type: pulumi.String("CLOUD_ARMOR"),
* })
* if err != nil {
* return err
* }
* _, err = compute.NewSecurityPolicyRule(ctx, "policy_rule", &compute.SecurityPolicyRuleArgs{
* SecurityPolicy: _default.Name,
* Description: pulumi.String("new rule"),
* Priority: pulumi.Int(100),
* Match: &compute.SecurityPolicyRuleMatchArgs{
* VersionedExpr: pulumi.String("SRC_IPS_V1"),
* Config: &compute.SecurityPolicyRuleMatchConfigArgs{
* SrcIpRanges: pulumi.StringArray{
* pulumi.String("10.10.0.0/16"),
* },
* },
* },
* Action: pulumi.String("allow"),
* Preview: pulumi.Bool(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.gcp.compute.SecurityPolicy;
* import com.pulumi.gcp.compute.SecurityPolicyArgs;
* import com.pulumi.gcp.compute.SecurityPolicyRule;
* import com.pulumi.gcp.compute.SecurityPolicyRuleArgs;
* import com.pulumi.gcp.compute.inputs.SecurityPolicyRuleMatchArgs;
* import com.pulumi.gcp.compute.inputs.SecurityPolicyRuleMatchConfigArgs;
* 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 default_ = new SecurityPolicy("default", SecurityPolicyArgs.builder()
* .name("policyruletest")
* .description("basic global security policy")
* .type("CLOUD_ARMOR")
* .build());
* var policyRule = new SecurityPolicyRule("policyRule", SecurityPolicyRuleArgs.builder()
* .securityPolicy(default_.name())
* .description("new rule")
* .priority(100)
* .match(SecurityPolicyRuleMatchArgs.builder()
* .versionedExpr("SRC_IPS_V1")
* .config(SecurityPolicyRuleMatchConfigArgs.builder()
* .srcIpRanges("10.10.0.0/16")
* .build())
* .build())
* .action("allow")
* .preview(true)
* .build());
* }
* }
* ```
* ```yaml
* resources:
* default:
* type: gcp:compute:SecurityPolicy
* properties:
* name: policyruletest
* description: basic global security policy
* type: CLOUD_ARMOR
* policyRule:
* type: gcp:compute:SecurityPolicyRule
* name: policy_rule
* properties:
* securityPolicy: ${default.name}
* description: new rule
* priority: 100
* match:
* versionedExpr: SRC_IPS_V1
* config:
* srcIpRanges:
* - 10.10.0.0/16
* action: allow
* preview: true
* ```
*
* ### Security Policy Rule Default Rule
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const _default = new gcp.compute.SecurityPolicy("default", {
* name: "policyruletest",
* description: "basic global security policy",
* type: "CLOUD_ARMOR",
* });
* // A default rule is generated when creating the security_policy resource, import is needed to patch it
* // import {
* // id = "projects//global/securityPolicies/policyruletest/priority/2147483647"
* // to = google_compute_security_policy_rule.default_rule
* // }
* const defaultRule = new gcp.compute.SecurityPolicyRule("default_rule", {
* securityPolicy: _default.name,
* description: "default rule",
* action: "allow",
* priority: 2147483647,
* match: {
* versionedExpr: "SRC_IPS_V1",
* config: {
* srcIpRanges: ["*"],
* },
* },
* });
* const policyRule = new gcp.compute.SecurityPolicyRule("policy_rule", {
* securityPolicy: _default.name,
* description: "new rule",
* priority: 100,
* match: {
* versionedExpr: "SRC_IPS_V1",
* config: {
* srcIpRanges: ["10.10.0.0/16"],
* },
* },
* action: "allow",
* preview: true,
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* default = gcp.compute.SecurityPolicy("default",
* name="policyruletest",
* description="basic global security policy",
* type="CLOUD_ARMOR")
* # A default rule is generated when creating the security_policy resource, import is needed to patch it
* # import {
* # id = "projects//global/securityPolicies/policyruletest/priority/2147483647"
* # to = google_compute_security_policy_rule.default_rule
* # }
* default_rule = gcp.compute.SecurityPolicyRule("default_rule",
* security_policy=default.name,
* description="default rule",
* action="allow",
* priority=2147483647,
* match=gcp.compute.SecurityPolicyRuleMatchArgs(
* versioned_expr="SRC_IPS_V1",
* config=gcp.compute.SecurityPolicyRuleMatchConfigArgs(
* src_ip_ranges=["*"],
* ),
* ))
* policy_rule = gcp.compute.SecurityPolicyRule("policy_rule",
* security_policy=default.name,
* description="new rule",
* priority=100,
* match=gcp.compute.SecurityPolicyRuleMatchArgs(
* versioned_expr="SRC_IPS_V1",
* config=gcp.compute.SecurityPolicyRuleMatchConfigArgs(
* src_ip_ranges=["10.10.0.0/16"],
* ),
* ),
* action="allow",
* preview=True)
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var @default = new Gcp.Compute.SecurityPolicy("default", new()
* {
* Name = "policyruletest",
* Description = "basic global security policy",
* Type = "CLOUD_ARMOR",
* });
* // A default rule is generated when creating the security_policy resource, import is needed to patch it
* // import {
* // id = "projects//global/securityPolicies/policyruletest/priority/2147483647"
* // to = google_compute_security_policy_rule.default_rule
* // }
* var defaultRule = new Gcp.Compute.SecurityPolicyRule("default_rule", new()
* {
* SecurityPolicy = @default.Name,
* Description = "default rule",
* Action = "allow",
* Priority = 2147483647,
* Match = new Gcp.Compute.Inputs.SecurityPolicyRuleMatchArgs
* {
* VersionedExpr = "SRC_IPS_V1",
* Config = new Gcp.Compute.Inputs.SecurityPolicyRuleMatchConfigArgs
* {
* SrcIpRanges = new[]
* {
* "*",
* },
* },
* },
* });
* var policyRule = new Gcp.Compute.SecurityPolicyRule("policy_rule", new()
* {
* SecurityPolicy = @default.Name,
* Description = "new rule",
* Priority = 100,
* Match = new Gcp.Compute.Inputs.SecurityPolicyRuleMatchArgs
* {
* VersionedExpr = "SRC_IPS_V1",
* Config = new Gcp.Compute.Inputs.SecurityPolicyRuleMatchConfigArgs
* {
* SrcIpRanges = new[]
* {
* "10.10.0.0/16",
* },
* },
* },
* Action = "allow",
* Preview = true,
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := compute.NewSecurityPolicy(ctx, "default", &compute.SecurityPolicyArgs{
* Name: pulumi.String("policyruletest"),
* Description: pulumi.String("basic global security policy"),
* Type: pulumi.String("CLOUD_ARMOR"),
* })
* if err != nil {
* return err
* }
* // A default rule is generated when creating the security_policy resource, import is needed to patch it
* //
* // import {
* // id = "projects//global/securityPolicies/policyruletest/priority/2147483647"
* // to = google_compute_security_policy_rule.default_rule
* // }
* _, err = compute.NewSecurityPolicyRule(ctx, "default_rule", &compute.SecurityPolicyRuleArgs{
* SecurityPolicy: _default.Name,
* Description: pulumi.String("default rule"),
* Action: pulumi.String("allow"),
* Priority: pulumi.Int(2147483647),
* Match: &compute.SecurityPolicyRuleMatchArgs{
* VersionedExpr: pulumi.String("SRC_IPS_V1"),
* Config: &compute.SecurityPolicyRuleMatchConfigArgs{
* SrcIpRanges: pulumi.StringArray{
* pulumi.String("*"),
* },
* },
* },
* })
* if err != nil {
* return err
* }
* _, err = compute.NewSecurityPolicyRule(ctx, "policy_rule", &compute.SecurityPolicyRuleArgs{
* SecurityPolicy: _default.Name,
* Description: pulumi.String("new rule"),
* Priority: pulumi.Int(100),
* Match: &compute.SecurityPolicyRuleMatchArgs{
* VersionedExpr: pulumi.String("SRC_IPS_V1"),
* Config: &compute.SecurityPolicyRuleMatchConfigArgs{
* SrcIpRanges: pulumi.StringArray{
* pulumi.String("10.10.0.0/16"),
* },
* },
* },
* Action: pulumi.String("allow"),
* Preview: pulumi.Bool(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.gcp.compute.SecurityPolicy;
* import com.pulumi.gcp.compute.SecurityPolicyArgs;
* import com.pulumi.gcp.compute.SecurityPolicyRule;
* import com.pulumi.gcp.compute.SecurityPolicyRuleArgs;
* import com.pulumi.gcp.compute.inputs.SecurityPolicyRuleMatchArgs;
* import com.pulumi.gcp.compute.inputs.SecurityPolicyRuleMatchConfigArgs;
* 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 default_ = new SecurityPolicy("default", SecurityPolicyArgs.builder()
* .name("policyruletest")
* .description("basic global security policy")
* .type("CLOUD_ARMOR")
* .build());
* // A default rule is generated when creating the security_policy resource, import is needed to patch it
* // import {
* // id = "projects//global/securityPolicies/policyruletest/priority/2147483647"
* // to = google_compute_security_policy_rule.default_rule
* // }
* var defaultRule = new SecurityPolicyRule("defaultRule", SecurityPolicyRuleArgs.builder()
* .securityPolicy(default_.name())
* .description("default rule")
* .action("allow")
* .priority("2147483647")
* .match(SecurityPolicyRuleMatchArgs.builder()
* .versionedExpr("SRC_IPS_V1")
* .config(SecurityPolicyRuleMatchConfigArgs.builder()
* .srcIpRanges("*")
* .build())
* .build())
* .build());
* var policyRule = new SecurityPolicyRule("policyRule", SecurityPolicyRuleArgs.builder()
* .securityPolicy(default_.name())
* .description("new rule")
* .priority(100)
* .match(SecurityPolicyRuleMatchArgs.builder()
* .versionedExpr("SRC_IPS_V1")
* .config(SecurityPolicyRuleMatchConfigArgs.builder()
* .srcIpRanges("10.10.0.0/16")
* .build())
* .build())
* .action("allow")
* .preview(true)
* .build());
* }
* }
* ```
* ```yaml
* resources:
* default:
* type: gcp:compute:SecurityPolicy
* properties:
* name: policyruletest
* description: basic global security policy
* type: CLOUD_ARMOR
* # A default rule is generated when creating the security_policy resource, import is needed to patch it
* # import {
* # id = "projects//global/securityPolicies/policyruletest/priority/2147483647"
* # to = google_compute_security_policy_rule.default_rule
* # }
* defaultRule:
* type: gcp:compute:SecurityPolicyRule
* name: default_rule
* properties:
* securityPolicy: ${default.name}
* description: default rule
* action: allow
* priority: '2147483647'
* match:
* versionedExpr: SRC_IPS_V1
* config:
* srcIpRanges:
* - '*'
* policyRule:
* type: gcp:compute:SecurityPolicyRule
* name: policy_rule
* properties:
* securityPolicy: ${default.name}
* description: new rule
* priority: 100
* match:
* versionedExpr: SRC_IPS_V1
* config:
* srcIpRanges:
* - 10.10.0.0/16
* action: allow
* preview: true
* ```
*
* ### Security Policy Rule Multiple Rules
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const _default = new gcp.compute.SecurityPolicy("default", {
* name: "policywithmultiplerules",
* description: "basic global security policy",
* type: "CLOUD_ARMOR",
* });
* const policyRuleOne = new gcp.compute.SecurityPolicyRule("policy_rule_one", {
* securityPolicy: _default.name,
* description: "new rule one",
* priority: 100,
* match: {
* versionedExpr: "SRC_IPS_V1",
* config: {
* srcIpRanges: ["10.10.0.0/16"],
* },
* },
* action: "allow",
* preview: true,
* });
* const policyRuleTwo = new gcp.compute.SecurityPolicyRule("policy_rule_two", {
* securityPolicy: _default.name,
* description: "new rule two",
* priority: 101,
* match: {
* versionedExpr: "SRC_IPS_V1",
* config: {
* srcIpRanges: [
* "192.168.0.0/16",
* "10.0.0.0/8",
* ],
* },
* },
* action: "allow",
* preview: true,
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* default = gcp.compute.SecurityPolicy("default",
* name="policywithmultiplerules",
* description="basic global security policy",
* type="CLOUD_ARMOR")
* policy_rule_one = gcp.compute.SecurityPolicyRule("policy_rule_one",
* security_policy=default.name,
* description="new rule one",
* priority=100,
* match=gcp.compute.SecurityPolicyRuleMatchArgs(
* versioned_expr="SRC_IPS_V1",
* config=gcp.compute.SecurityPolicyRuleMatchConfigArgs(
* src_ip_ranges=["10.10.0.0/16"],
* ),
* ),
* action="allow",
* preview=True)
* policy_rule_two = gcp.compute.SecurityPolicyRule("policy_rule_two",
* security_policy=default.name,
* description="new rule two",
* priority=101,
* match=gcp.compute.SecurityPolicyRuleMatchArgs(
* versioned_expr="SRC_IPS_V1",
* config=gcp.compute.SecurityPolicyRuleMatchConfigArgs(
* src_ip_ranges=[
* "192.168.0.0/16",
* "10.0.0.0/8",
* ],
* ),
* ),
* action="allow",
* preview=True)
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var @default = new Gcp.Compute.SecurityPolicy("default", new()
* {
* Name = "policywithmultiplerules",
* Description = "basic global security policy",
* Type = "CLOUD_ARMOR",
* });
* var policyRuleOne = new Gcp.Compute.SecurityPolicyRule("policy_rule_one", new()
* {
* SecurityPolicy = @default.Name,
* Description = "new rule one",
* Priority = 100,
* Match = new Gcp.Compute.Inputs.SecurityPolicyRuleMatchArgs
* {
* VersionedExpr = "SRC_IPS_V1",
* Config = new Gcp.Compute.Inputs.SecurityPolicyRuleMatchConfigArgs
* {
* SrcIpRanges = new[]
* {
* "10.10.0.0/16",
* },
* },
* },
* Action = "allow",
* Preview = true,
* });
* var policyRuleTwo = new Gcp.Compute.SecurityPolicyRule("policy_rule_two", new()
* {
* SecurityPolicy = @default.Name,
* Description = "new rule two",
* Priority = 101,
* Match = new Gcp.Compute.Inputs.SecurityPolicyRuleMatchArgs
* {
* VersionedExpr = "SRC_IPS_V1",
* Config = new Gcp.Compute.Inputs.SecurityPolicyRuleMatchConfigArgs
* {
* SrcIpRanges = new[]
* {
* "192.168.0.0/16",
* "10.0.0.0/8",
* },
* },
* },
* Action = "allow",
* Preview = true,
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := compute.NewSecurityPolicy(ctx, "default", &compute.SecurityPolicyArgs{
* Name: pulumi.String("policywithmultiplerules"),
* Description: pulumi.String("basic global security policy"),
* Type: pulumi.String("CLOUD_ARMOR"),
* })
* if err != nil {
* return err
* }
* _, err = compute.NewSecurityPolicyRule(ctx, "policy_rule_one", &compute.SecurityPolicyRuleArgs{
* SecurityPolicy: _default.Name,
* Description: pulumi.String("new rule one"),
* Priority: pulumi.Int(100),
* Match: &compute.SecurityPolicyRuleMatchArgs{
* VersionedExpr: pulumi.String("SRC_IPS_V1"),
* Config: &compute.SecurityPolicyRuleMatchConfigArgs{
* SrcIpRanges: pulumi.StringArray{
* pulumi.String("10.10.0.0/16"),
* },
* },
* },
* Action: pulumi.String("allow"),
* Preview: pulumi.Bool(true),
* })
* if err != nil {
* return err
* }
* _, err = compute.NewSecurityPolicyRule(ctx, "policy_rule_two", &compute.SecurityPolicyRuleArgs{
* SecurityPolicy: _default.Name,
* Description: pulumi.String("new rule two"),
* Priority: pulumi.Int(101),
* Match: &compute.SecurityPolicyRuleMatchArgs{
* VersionedExpr: pulumi.String("SRC_IPS_V1"),
* Config: &compute.SecurityPolicyRuleMatchConfigArgs{
* SrcIpRanges: pulumi.StringArray{
* pulumi.String("192.168.0.0/16"),
* pulumi.String("10.0.0.0/8"),
* },
* },
* },
* Action: pulumi.String("allow"),
* Preview: pulumi.Bool(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.gcp.compute.SecurityPolicy;
* import com.pulumi.gcp.compute.SecurityPolicyArgs;
* import com.pulumi.gcp.compute.SecurityPolicyRule;
* import com.pulumi.gcp.compute.SecurityPolicyRuleArgs;
* import com.pulumi.gcp.compute.inputs.SecurityPolicyRuleMatchArgs;
* import com.pulumi.gcp.compute.inputs.SecurityPolicyRuleMatchConfigArgs;
* 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 default_ = new SecurityPolicy("default", SecurityPolicyArgs.builder()
* .name("policywithmultiplerules")
* .description("basic global security policy")
* .type("CLOUD_ARMOR")
* .build());
* var policyRuleOne = new SecurityPolicyRule("policyRuleOne", SecurityPolicyRuleArgs.builder()
* .securityPolicy(default_.name())
* .description("new rule one")
* .priority(100)
* .match(SecurityPolicyRuleMatchArgs.builder()
* .versionedExpr("SRC_IPS_V1")
* .config(SecurityPolicyRuleMatchConfigArgs.builder()
* .srcIpRanges("10.10.0.0/16")
* .build())
* .build())
* .action("allow")
* .preview(true)
* .build());
* var policyRuleTwo = new SecurityPolicyRule("policyRuleTwo", SecurityPolicyRuleArgs.builder()
* .securityPolicy(default_.name())
* .description("new rule two")
* .priority(101)
* .match(SecurityPolicyRuleMatchArgs.builder()
* .versionedExpr("SRC_IPS_V1")
* .config(SecurityPolicyRuleMatchConfigArgs.builder()
* .srcIpRanges(
* "192.168.0.0/16",
* "10.0.0.0/8")
* .build())
* .build())
* .action("allow")
* .preview(true)
* .build());
* }
* }
* ```
* ```yaml
* resources:
* default:
* type: gcp:compute:SecurityPolicy
* properties:
* name: policywithmultiplerules
* description: basic global security policy
* type: CLOUD_ARMOR
* policyRuleOne:
* type: gcp:compute:SecurityPolicyRule
* name: policy_rule_one
* properties:
* securityPolicy: ${default.name}
* description: new rule one
* priority: 100
* match:
* versionedExpr: SRC_IPS_V1
* config:
* srcIpRanges:
* - 10.10.0.0/16
* action: allow
* preview: true
* policyRuleTwo:
* type: gcp:compute:SecurityPolicyRule
* name: policy_rule_two
* properties:
* securityPolicy: ${default.name}
* description: new rule two
* priority: 101
* match:
* versionedExpr: SRC_IPS_V1
* config:
* srcIpRanges:
* - 192.168.0.0/16
* - 10.0.0.0/8
* action: allow
* preview: true
* ```
*
* ## Import
* SecurityPolicyRule can be imported using any of these accepted formats:
* * `projects/{{project}}/global/securityPolicies/{{security_policy}}/priority/{{priority}}`
* * `{{project}}/{{security_policy}}/{{priority}}`
* * `{{security_policy}}/{{priority}}`
* When using the `pulumi import` command, SecurityPolicyRule can be imported using one of the formats above. For example:
* ```sh
* $ pulumi import gcp:compute/securityPolicyRule:SecurityPolicyRule default projects/{{project}}/global/securityPolicies/{{security_policy}}/priority/{{priority}}
* ```
* ```sh
* $ pulumi import gcp:compute/securityPolicyRule:SecurityPolicyRule default {{project}}/{{security_policy}}/{{priority}}
* ```
* ```sh
* $ pulumi import gcp:compute/securityPolicyRule:SecurityPolicyRule default {{security_policy}}/{{priority}}
* ```
*/
public class SecurityPolicyRule internal constructor(
override val javaResource: com.pulumi.gcp.compute.SecurityPolicyRule,
) : KotlinCustomResource(javaResource, SecurityPolicyRuleMapper) {
/**
* The Action to perform when the rule is matched. The following are the valid actions:
* * allow: allow access to target.
* * deny(STATUS): deny access to target, returns the HTTP response code specified. Valid values for STATUS are 403, 404, and 502.
* * rate_based_ban: limit client traffic to the configured threshold and ban the client if the traffic exceeds the threshold. Configure parameters for this action in RateLimitOptions. Requires rateLimitOptions to be set.
* * redirect: redirect to a different target. This can either be an internal reCAPTCHA redirect, or an external URL-based redirect via a 302 response. Parameters for this action can be configured via redirectOptions. This action is only supported in Global Security Policies of type CLOUD_ARMOR.
* * throttle: limit client traffic to the configured threshold. Configure parameters for this action in rateLimitOptions. Requires rateLimitOptions to be set for this.
*/
public val action: Output
get() = javaResource.action().applyValue({ args0 -> args0 })
/**
* An optional description of this resource. Provide this property when you create the resource.
*/
public val description: Output?
get() = javaResource.description().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* A match condition that incoming traffic is evaluated against.
* If it evaluates to true, the corresponding 'action' is enforced.
* Structure is documented below.
*/
public val match: Output?
get() = javaResource.match().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
securityPolicyRuleMatchToKotlin(args0)
})
}).orElse(null)
})
/**
* Preconfigured WAF configuration to be applied for the rule.
* If the rule does not evaluate preconfigured WAF rules, i.e., if evaluatePreconfiguredWaf() is not used, this field will have no effect.
* Structure is documented below.
*/
public val preconfiguredWafConfig: Output?
get() = javaResource.preconfiguredWafConfig().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
securityPolicyRulePreconfiguredWafConfigToKotlin(args0)
})
}).orElse(null)
})
/**
* If set to true, the specified action is not enforced.
*/
public val preview: Output?
get() = javaResource.preview().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* An integer indicating the priority of a rule in the list.
* The priority must be a positive value between 0 and 2147483647.
* Rules are evaluated from highest to lowest priority where 0 is the highest priority and 2147483647 is the lowest priority.
*/
public val priority: Output
get() = javaResource.priority().applyValue({ args0 -> args0 })
/**
* The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
public val project: Output
get() = javaResource.project().applyValue({ args0 -> args0 })
/**
* The name of the security policy this rule belongs to.
* - - -
*/
public val securityPolicy: Output
get() = javaResource.securityPolicy().applyValue({ args0 -> args0 })
}
public object SecurityPolicyRuleMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.gcp.compute.SecurityPolicyRule::class == javaResource::class
override fun map(javaResource: Resource): SecurityPolicyRule = SecurityPolicyRule(
javaResource as
com.pulumi.gcp.compute.SecurityPolicyRule,
)
}
/**
* @see [SecurityPolicyRule].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [SecurityPolicyRule].
*/
public suspend fun securityPolicyRule(
name: String,
block: suspend SecurityPolicyRuleResourceBuilder.() -> Unit,
): SecurityPolicyRule {
val builder = SecurityPolicyRuleResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [SecurityPolicyRule].
* @param name The _unique_ name of the resulting resource.
*/
public fun securityPolicyRule(name: String): SecurityPolicyRule {
val builder = SecurityPolicyRuleResourceBuilder()
builder.name(name)
return builder.build()
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy