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

com.pulumi.gcp.appengine.kotlin.FirewallRule.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: 8.10.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.appengine.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

/**
 * 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.gcp.appengine.FirewallRule(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return FirewallRule(builtJavaResource)
    }
}

/**
 * A single firewall rule that is evaluated against incoming traffic
 * and provides an action to take on matched requests.
 * To get more information about FirewallRule, see:
 * * [API documentation](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.firewall.ingressRules)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/appengine/docs/standard/python/creating-firewalls#creating_firewall_rules)
 * ## Example Usage
 * ### App Engine Firewall Rule Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const myProject = new gcp.organizations.Project("my_project", {
 *     name: "tf-test-project",
 *     projectId: "ae-project",
 *     orgId: "123456789",
 *     billingAccount: "000000-0000000-0000000-000000",
 * });
 * const app = new gcp.appengine.Application("app", {
 *     project: myProject.projectId,
 *     locationId: "us-central",
 * });
 * const rule = new gcp.appengine.FirewallRule("rule", {
 *     project: app.project,
 *     priority: 1000,
 *     action: "ALLOW",
 *     sourceRange: "*",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * my_project = gcp.organizations.Project("my_project",
 *     name="tf-test-project",
 *     project_id="ae-project",
 *     org_id="123456789",
 *     billing_account="000000-0000000-0000000-000000")
 * app = gcp.appengine.Application("app",
 *     project=my_project.project_id,
 *     location_id="us-central")
 * rule = gcp.appengine.FirewallRule("rule",
 *     project=app.project,
 *     priority=1000,
 *     action="ALLOW",
 *     source_range="*")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var myProject = new Gcp.Organizations.Project("my_project", new()
 *     {
 *         Name = "tf-test-project",
 *         ProjectId = "ae-project",
 *         OrgId = "123456789",
 *         BillingAccount = "000000-0000000-0000000-000000",
 *     });
 *     var app = new Gcp.AppEngine.Application("app", new()
 *     {
 *         Project = myProject.ProjectId,
 *         LocationId = "us-central",
 *     });
 *     var rule = new Gcp.AppEngine.FirewallRule("rule", new()
 *     {
 *         Project = app.Project,
 *         Priority = 1000,
 *         Action = "ALLOW",
 *         SourceRange = "*",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/appengine"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		myProject, err := organizations.NewProject(ctx, "my_project", &organizations.ProjectArgs{
 * 			Name:           pulumi.String("tf-test-project"),
 * 			ProjectId:      pulumi.String("ae-project"),
 * 			OrgId:          pulumi.String("123456789"),
 * 			BillingAccount: pulumi.String("000000-0000000-0000000-000000"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		app, err := appengine.NewApplication(ctx, "app", &appengine.ApplicationArgs{
 * 			Project:    myProject.ProjectId,
 * 			LocationId: pulumi.String("us-central"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = appengine.NewFirewallRule(ctx, "rule", &appengine.FirewallRuleArgs{
 * 			Project:     app.Project,
 * 			Priority:    pulumi.Int(1000),
 * 			Action:      pulumi.String("ALLOW"),
 * 			SourceRange: pulumi.String("*"),
 * 		})
 * 		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.organizations.Project;
 * import com.pulumi.gcp.organizations.ProjectArgs;
 * import com.pulumi.gcp.appengine.Application;
 * import com.pulumi.gcp.appengine.ApplicationArgs;
 * import com.pulumi.gcp.appengine.FirewallRule;
 * import com.pulumi.gcp.appengine.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 myProject = new Project("myProject", ProjectArgs.builder()
 *             .name("tf-test-project")
 *             .projectId("ae-project")
 *             .orgId("123456789")
 *             .billingAccount("000000-0000000-0000000-000000")
 *             .build());
 *         var app = new Application("app", ApplicationArgs.builder()
 *             .project(myProject.projectId())
 *             .locationId("us-central")
 *             .build());
 *         var rule = new FirewallRule("rule", FirewallRuleArgs.builder()
 *             .project(app.project())
 *             .priority(1000)
 *             .action("ALLOW")
 *             .sourceRange("*")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   myProject:
 *     type: gcp:organizations:Project
 *     name: my_project
 *     properties:
 *       name: tf-test-project
 *       projectId: ae-project
 *       orgId: '123456789'
 *       billingAccount: 000000-0000000-0000000-000000
 *   app:
 *     type: gcp:appengine:Application
 *     properties:
 *       project: ${myProject.projectId}
 *       locationId: us-central
 *   rule:
 *     type: gcp:appengine:FirewallRule
 *     properties:
 *       project: ${app.project}
 *       priority: 1000
 *       action: ALLOW
 *       sourceRange: '*'
 * ```
 * 
 * ## Import
 * FirewallRule can be imported using any of these accepted formats:
 * * `apps/{{project}}/firewall/ingressRules/{{priority}}`
 * * `{{project}}/{{priority}}`
 * * `{{priority}}`
 * When using the `pulumi import` command, FirewallRule can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:appengine/firewallRule:FirewallRule default apps/{{project}}/firewall/ingressRules/{{priority}}
 * ```
 * ```sh
 * $ pulumi import gcp:appengine/firewallRule:FirewallRule default {{project}}/{{priority}}
 * ```
 * ```sh
 * $ pulumi import gcp:appengine/firewallRule:FirewallRule default {{priority}}
 * ```
 */
public class FirewallRule internal constructor(
    override val javaResource: com.pulumi.gcp.appengine.FirewallRule,
) : KotlinCustomResource(javaResource, FirewallRuleMapper) {
    /**
     * The action to take if this rule matches.
     * Possible values are: `UNSPECIFIED_ACTION`, `ALLOW`, `DENY`.
     * - - -
     */
    public val action: Output
        get() = javaResource.action().applyValue({ args0 -> args0 })

    /**
     * An optional string description of this rule.
     */
    public val description: Output?
        get() = javaResource.description().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * A positive integer that defines the order of rule evaluation.
     * Rules with the lowest priority are evaluated first.
     * A default rule at priority Int32.MaxValue matches all IPv4 and
     * IPv6 traffic when no previous rule matches. Only the action of
     * this rule can be modified by the user.
     */
    public val priority: Output?
        get() = javaResource.priority().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * 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 })

    /**
     * IP address or range, defined using CIDR notation, of requests that this rule applies to.
     */
    public val sourceRange: Output
        get() = javaResource.sourceRange().applyValue({ args0 -> args0 })
}

public object FirewallRuleMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.appengine.FirewallRule::class == javaResource::class

    override fun map(javaResource: Resource): FirewallRule = FirewallRule(
        javaResource as
            com.pulumi.gcp.appengine.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()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy