FirewallRule class

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:

Example Usage

App Engine Firewall Rule Basic

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
import * as time from "@pulumiverse/time";

const myProject = new gcp.organizations.Project("my_project", {
    name: "tf-test-project",
    projectId: "ae-project",
    orgId: "123456789",
    billingAccount: "000000-0000000-0000000-000000",
    deletionPolicy: "DELETE",
});
const app = new gcp.appengine.Application("app", {
    project: myProject.projectId,
    locationId: "us-central",
});
// Wait for 5 minutes seconds to ensure IAM permission propagation completes
const wait300Seconds = new time.Sleep("wait_300_seconds", {createDuration: "300s"}, {
    dependsOn: [app],
});
const rule = new gcp.appengine.FirewallRule("rule", {
    project: app.project,
    priority: 1000,
    action: "ALLOW",
    sourceRange: "*",
}, {
    dependsOn: [wait300Seconds],
});
import pulumi
import pulumi_gcp as gcp
import pulumiverse_time as time

my_project = gcp.organizations.Project("my_project",
    name="tf-test-project",
    project_id="ae-project",
    org_id="123456789",
    billing_account="000000-0000000-0000000-000000",
    deletion_policy="DELETE")
app = gcp.appengine.Application("app",
    project=my_project.project_id,
    location_id="us-central")
# Wait for 5 minutes seconds to ensure IAM permission propagation completes
wait300_seconds = time.Sleep("wait_300_seconds", create_duration="300s",
opts = pulumi.ResourceOptions(depends_on=[app]))
rule = gcp.appengine.FirewallRule("rule",
    project=app.project,
    priority=1000,
    action="ALLOW",
    source_range="*",
    opts = pulumi.ResourceOptions(depends_on=[wait300_seconds]))
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
using Time = Pulumiverse.Time;

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",
        DeletionPolicy = "DELETE",
    });

    var app = new Gcp.AppEngine.Application("app", new()
    {
        Project = myProject.ProjectId,
        LocationId = "us-central",
    });

    // Wait for 5 minutes seconds to ensure IAM permission propagation completes
    var wait300Seconds = new Time.Sleep("wait_300_seconds", new()
    {
        CreateDuration = "300s",
    }, new CustomResourceOptions
    {
        DependsOn =
        {
            app,
        },
    });

    var rule = new Gcp.AppEngine.FirewallRule("rule", new()
    {
        Project = app.Project,
        Priority = 1000,
        Action = "ALLOW",
        SourceRange = "*",
    }, new CustomResourceOptions
    {
        DependsOn =
        {
            wait300Seconds,
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/appengine"
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/organizations"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
	"github.com/pulumiverse/pulumi-time/sdk/go/time"
)

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"),
			DeletionPolicy: pulumi.String("DELETE"),
		})
		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
		}
		// Wait for 5 minutes seconds to ensure IAM permission propagation completes
		wait300Seconds, err := time.NewSleep(ctx, "wait_300_seconds", &time.SleepArgs{
			CreateDuration: pulumi.String("300s"),
		}, pulumi.DependsOn([]pulumi.Resource{
			app,
		}))
		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("*"),
		}, pulumi.DependsOn([]pulumi.Resource{
			wait300Seconds,
		}))
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    gcp = {
      source = "pulumi/gcp"
    }
    time = {
      source = "pulumi/time"
    }
  }
}

resource "gcp_organizations_project" "my_project" {
  name            = "tf-test-project"
  project_id      = "ae-project"
  org_id          = "123456789"
  billing_account = "000000-0000000-0000000-000000"
  deletion_policy = "DELETE"
}
resource "gcp_appengine_application" "app" {
  project     = gcp_organizations_project.my_project.project_id
  location_id = "us-central"
}
# Wait for 5 minutes seconds to ensure IAM permission propagation completes
resource "time_sleep" "wait_300_seconds" {
  depends_on      = [gcp_appengine_application.app]
  create_duration = "300s"
}
resource "gcp_appengine_firewallrule" "rule" {
  depends_on   = [time_sleep.wait_300_seconds]
  project      = gcp_appengine_application.app.project
  priority     = 1000
  action       = "ALLOW"
  source_range = "*"
}
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.pulumiverse.time.Sleep;
import com.pulumiverse.time.SleepArgs;
import com.pulumi.gcp.appengine.FirewallRule;
import com.pulumi.gcp.appengine.FirewallRuleArgs;
import com.pulumi.resources.CustomResourceOptions;
import java.util.ArrayList;
import java.util.Arrays;
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")
            .deletionPolicy("DELETE")
            .build());

        var app = new Application("app", ApplicationArgs.builder()
            .project(myProject.projectId())
            .locationId("us-central")
            .build());

        // Wait for 5 minutes seconds to ensure IAM permission propagation completes
        var wait300Seconds = new Sleep("wait300Seconds", SleepArgs.builder()
            .createDuration("300s")
            .build(), CustomResourceOptions.builder()
                .dependsOn(app)
                .build());

        var rule = new FirewallRule("rule", FirewallRuleArgs.builder()
            .project(app.project())
            .priority(1000)
            .action("ALLOW")
            .sourceRange("*")
            .build(), CustomResourceOptions.builder()
                .dependsOn(wait300Seconds)
                .build());

    }
}
resources:
  myProject:
    type: gcp:organizations:Project
    name: my_project
    properties:
      name: tf-test-project
      projectId: ae-project
      orgId: '123456789'
      billingAccount: 000000-0000000-0000000-000000
      deletionPolicy: DELETE
  app:
    type: gcp:appengine:Application
    properties:
      project: ${myProject.projectId}
      locationId: us-central
  # Wait for 5 minutes seconds to ensure IAM permission propagation completes
  wait300Seconds:
    type: time:Sleep
    name: wait_300_seconds
    properties:
      createDuration: 300s
    options:
      dependsOn:
        - ${app}
  rule:
    type: gcp:appengine:FirewallRule
    properties:
      project: ${app.project}
      priority: 1000
      action: ALLOW
      sourceRange: '*'
    options:
      dependsOn:
        - ${wait300Seconds}

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:

$ pulumi import gcp:appengine/firewallRule:FirewallRule default apps/{{project}}/firewall/ingressRules/{{priority}}
$ pulumi import gcp:appengine/firewallRule:FirewallRule default {{project}}/{{priority}}
$ pulumi import gcp:appengine/firewallRule:FirewallRule default {{priority}}

Constructors

FirewallRule(String name, {FirewallRuleArgs? args, CustomResourceOptions? options})
Creates a new FirewallRule. name The Pulumi resource name. args Arguments used to configure this FirewallRule. The set of arguments for FirewallRule. options Resource options controlling this resource's behavior.
FirewallRule.reference(String urn)
Creates a typed reference to an existing FirewallRule resource.

Properties

action ↔ Output<String>
The action to take if this rule matches. Possible values are: UNSPECIFIED_ACTION, ALLOW, DENY.
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
deletionPolicy ↔ Output<String>
Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. When a 'terraform destroy' or 'pulumi up' would delete the resource, the command will fail if this field is set to "PREVENT" in Terraform state. When set to "ABANDON", the command will remove the resource from Terraform management without updating or deleting the resource in the API. When set to "DELETE", deleting the resource is allowed.
latefinal
description ↔ Output<String?>
An optional string description of this rule.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
priority ↔ Output<int?>
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.
latefinal
project ↔ Output<String>
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sourceRange ↔ Output<String>
IP address or range, defined using CIDR notation, of requests that this rule applies to.
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {FirewallRuleState? state, CustomResourceOptions? options}) → FirewallRule
Gets an existing FirewallRule resource's state with the given name and id.