1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. compute
  5. NetworkFirewallPolicyAssociation
Google Cloud v8.14.0 published on Wednesday, Jan 15, 2025 by Pulumi

gcp.compute.NetworkFirewallPolicyAssociation

Explore with Pulumi AI

The Compute NetworkFirewallPolicyAssociation resource

To get more information about NetworkFirewallPolicyAssociation, see:

Example Usage

Network Firewall Policy Association

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

const policy = new gcp.compute.NetworkFirewallPolicy("policy", {
    name: "my-policy",
    project: "my-project-name",
    description: "Sample global network firewall policy",
});
const network = new gcp.compute.Network("network", {
    name: "my-network",
    autoCreateSubnetworks: false,
});
const _default = new gcp.compute.NetworkFirewallPolicyAssociation("default", {
    name: "my-association",
    project: "my-project-name",
    attachmentTarget: network.id,
    firewallPolicy: policy.id,
});
Copy
import pulumi
import pulumi_gcp as gcp

policy = gcp.compute.NetworkFirewallPolicy("policy",
    name="my-policy",
    project="my-project-name",
    description="Sample global network firewall policy")
network = gcp.compute.Network("network",
    name="my-network",
    auto_create_subnetworks=False)
default = gcp.compute.NetworkFirewallPolicyAssociation("default",
    name="my-association",
    project="my-project-name",
    attachment_target=network.id,
    firewall_policy=policy.id)
Copy
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/compute"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		policy, err := compute.NewNetworkFirewallPolicy(ctx, "policy", &compute.NetworkFirewallPolicyArgs{
			Name:        pulumi.String("my-policy"),
			Project:     pulumi.String("my-project-name"),
			Description: pulumi.String("Sample global network firewall policy"),
		})
		if err != nil {
			return err
		}
		network, err := compute.NewNetwork(ctx, "network", &compute.NetworkArgs{
			Name:                  pulumi.String("my-network"),
			AutoCreateSubnetworks: pulumi.Bool(false),
		})
		if err != nil {
			return err
		}
		_, err = compute.NewNetworkFirewallPolicyAssociation(ctx, "default", &compute.NetworkFirewallPolicyAssociationArgs{
			Name:             pulumi.String("my-association"),
			Project:          pulumi.String("my-project-name"),
			AttachmentTarget: network.ID(),
			FirewallPolicy:   policy.ID(),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var policy = new Gcp.Compute.NetworkFirewallPolicy("policy", new()
    {
        Name = "my-policy",
        Project = "my-project-name",
        Description = "Sample global network firewall policy",
    });

    var network = new Gcp.Compute.Network("network", new()
    {
        Name = "my-network",
        AutoCreateSubnetworks = false,
    });

    var @default = new Gcp.Compute.NetworkFirewallPolicyAssociation("default", new()
    {
        Name = "my-association",
        Project = "my-project-name",
        AttachmentTarget = network.Id,
        FirewallPolicy = policy.Id,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.NetworkFirewallPolicy;
import com.pulumi.gcp.compute.NetworkFirewallPolicyArgs;
import com.pulumi.gcp.compute.Network;
import com.pulumi.gcp.compute.NetworkArgs;
import com.pulumi.gcp.compute.NetworkFirewallPolicyAssociation;
import com.pulumi.gcp.compute.NetworkFirewallPolicyAssociationArgs;
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 policy = new NetworkFirewallPolicy("policy", NetworkFirewallPolicyArgs.builder()
            .name("my-policy")
            .project("my-project-name")
            .description("Sample global network firewall policy")
            .build());

        var network = new Network("network", NetworkArgs.builder()
            .name("my-network")
            .autoCreateSubnetworks(false)
            .build());

        var default_ = new NetworkFirewallPolicyAssociation("default", NetworkFirewallPolicyAssociationArgs.builder()
            .name("my-association")
            .project("my-project-name")
            .attachmentTarget(network.id())
            .firewallPolicy(policy.id())
            .build());

    }
}
Copy
resources:
  policy:
    type: gcp:compute:NetworkFirewallPolicy
    properties:
      name: my-policy
      project: my-project-name
      description: Sample global network firewall policy
  network:
    type: gcp:compute:Network
    properties:
      name: my-network
      autoCreateSubnetworks: false
  default:
    type: gcp:compute:NetworkFirewallPolicyAssociation
    properties:
      name: my-association
      project: my-project-name
      attachmentTarget: ${network.id}
      firewallPolicy: ${policy.id}
Copy

Create NetworkFirewallPolicyAssociation Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new NetworkFirewallPolicyAssociation(name: string, args: NetworkFirewallPolicyAssociationArgs, opts?: CustomResourceOptions);
@overload
def NetworkFirewallPolicyAssociation(resource_name: str,
                                     args: NetworkFirewallPolicyAssociationArgs,
                                     opts: Optional[ResourceOptions] = None)

@overload
def NetworkFirewallPolicyAssociation(resource_name: str,
                                     opts: Optional[ResourceOptions] = None,
                                     attachment_target: Optional[str] = None,
                                     firewall_policy: Optional[str] = None,
                                     name: Optional[str] = None,
                                     project: Optional[str] = None)
func NewNetworkFirewallPolicyAssociation(ctx *Context, name string, args NetworkFirewallPolicyAssociationArgs, opts ...ResourceOption) (*NetworkFirewallPolicyAssociation, error)
public NetworkFirewallPolicyAssociation(string name, NetworkFirewallPolicyAssociationArgs args, CustomResourceOptions? opts = null)
public NetworkFirewallPolicyAssociation(String name, NetworkFirewallPolicyAssociationArgs args)
public NetworkFirewallPolicyAssociation(String name, NetworkFirewallPolicyAssociationArgs args, CustomResourceOptions options)
type: gcp:compute:NetworkFirewallPolicyAssociation
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. NetworkFirewallPolicyAssociationArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. NetworkFirewallPolicyAssociationArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. NetworkFirewallPolicyAssociationArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. NetworkFirewallPolicyAssociationArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. NetworkFirewallPolicyAssociationArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var networkFirewallPolicyAssociationResource = new Gcp.Compute.NetworkFirewallPolicyAssociation("networkFirewallPolicyAssociationResource", new()
{
    AttachmentTarget = "string",
    FirewallPolicy = "string",
    Name = "string",
    Project = "string",
});
Copy
example, err := compute.NewNetworkFirewallPolicyAssociation(ctx, "networkFirewallPolicyAssociationResource", &compute.NetworkFirewallPolicyAssociationArgs{
	AttachmentTarget: pulumi.String("string"),
	FirewallPolicy:   pulumi.String("string"),
	Name:             pulumi.String("string"),
	Project:          pulumi.String("string"),
})
Copy
var networkFirewallPolicyAssociationResource = new NetworkFirewallPolicyAssociation("networkFirewallPolicyAssociationResource", NetworkFirewallPolicyAssociationArgs.builder()
    .attachmentTarget("string")
    .firewallPolicy("string")
    .name("string")
    .project("string")
    .build());
Copy
network_firewall_policy_association_resource = gcp.compute.NetworkFirewallPolicyAssociation("networkFirewallPolicyAssociationResource",
    attachment_target="string",
    firewall_policy="string",
    name="string",
    project="string")
Copy
const networkFirewallPolicyAssociationResource = new gcp.compute.NetworkFirewallPolicyAssociation("networkFirewallPolicyAssociationResource", {
    attachmentTarget: "string",
    firewallPolicy: "string",
    name: "string",
    project: "string",
});
Copy
type: gcp:compute:NetworkFirewallPolicyAssociation
properties:
    attachmentTarget: string
    firewallPolicy: string
    name: string
    project: string
Copy

NetworkFirewallPolicyAssociation Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The NetworkFirewallPolicyAssociation resource accepts the following input properties:

AttachmentTarget
This property is required.
Changes to this property will trigger replacement.
string
The target that the firewall policy is attached to.
FirewallPolicy
This property is required.
Changes to this property will trigger replacement.
string
The firewall policy of the resource.


Name Changes to this property will trigger replacement. string
The name for an association.
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
AttachmentTarget
This property is required.
Changes to this property will trigger replacement.
string
The target that the firewall policy is attached to.
FirewallPolicy
This property is required.
Changes to this property will trigger replacement.
string
The firewall policy of the resource.


Name Changes to this property will trigger replacement. string
The name for an association.
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
attachmentTarget
This property is required.
Changes to this property will trigger replacement.
String
The target that the firewall policy is attached to.
firewallPolicy
This property is required.
Changes to this property will trigger replacement.
String
The firewall policy of the resource.


name Changes to this property will trigger replacement. String
The name for an association.
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
attachmentTarget
This property is required.
Changes to this property will trigger replacement.
string
The target that the firewall policy is attached to.
firewallPolicy
This property is required.
Changes to this property will trigger replacement.
string
The firewall policy of the resource.


name Changes to this property will trigger replacement. string
The name for an association.
project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
attachment_target
This property is required.
Changes to this property will trigger replacement.
str
The target that the firewall policy is attached to.
firewall_policy
This property is required.
Changes to this property will trigger replacement.
str
The firewall policy of the resource.


name Changes to this property will trigger replacement. str
The name for an association.
project Changes to this property will trigger replacement. str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
attachmentTarget
This property is required.
Changes to this property will trigger replacement.
String
The target that the firewall policy is attached to.
firewallPolicy
This property is required.
Changes to this property will trigger replacement.
String
The firewall policy of the resource.


name Changes to this property will trigger replacement. String
The name for an association.
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Outputs

All input properties are implicitly available as output properties. Additionally, the NetworkFirewallPolicyAssociation resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
ShortName string
The short name of the firewall policy of the association.
Id string
The provider-assigned unique ID for this managed resource.
ShortName string
The short name of the firewall policy of the association.
id String
The provider-assigned unique ID for this managed resource.
shortName String
The short name of the firewall policy of the association.
id string
The provider-assigned unique ID for this managed resource.
shortName string
The short name of the firewall policy of the association.
id str
The provider-assigned unique ID for this managed resource.
short_name str
The short name of the firewall policy of the association.
id String
The provider-assigned unique ID for this managed resource.
shortName String
The short name of the firewall policy of the association.

Look up Existing NetworkFirewallPolicyAssociation Resource

Get an existing NetworkFirewallPolicyAssociation resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: NetworkFirewallPolicyAssociationState, opts?: CustomResourceOptions): NetworkFirewallPolicyAssociation
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        attachment_target: Optional[str] = None,
        firewall_policy: Optional[str] = None,
        name: Optional[str] = None,
        project: Optional[str] = None,
        short_name: Optional[str] = None) -> NetworkFirewallPolicyAssociation
func GetNetworkFirewallPolicyAssociation(ctx *Context, name string, id IDInput, state *NetworkFirewallPolicyAssociationState, opts ...ResourceOption) (*NetworkFirewallPolicyAssociation, error)
public static NetworkFirewallPolicyAssociation Get(string name, Input<string> id, NetworkFirewallPolicyAssociationState? state, CustomResourceOptions? opts = null)
public static NetworkFirewallPolicyAssociation get(String name, Output<String> id, NetworkFirewallPolicyAssociationState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
AttachmentTarget Changes to this property will trigger replacement. string
The target that the firewall policy is attached to.
FirewallPolicy Changes to this property will trigger replacement. string
The firewall policy of the resource.


Name Changes to this property will trigger replacement. string
The name for an association.
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
ShortName string
The short name of the firewall policy of the association.
AttachmentTarget Changes to this property will trigger replacement. string
The target that the firewall policy is attached to.
FirewallPolicy Changes to this property will trigger replacement. string
The firewall policy of the resource.


Name Changes to this property will trigger replacement. string
The name for an association.
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
ShortName string
The short name of the firewall policy of the association.
attachmentTarget Changes to this property will trigger replacement. String
The target that the firewall policy is attached to.
firewallPolicy Changes to this property will trigger replacement. String
The firewall policy of the resource.


name Changes to this property will trigger replacement. String
The name for an association.
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
shortName String
The short name of the firewall policy of the association.
attachmentTarget Changes to this property will trigger replacement. string
The target that the firewall policy is attached to.
firewallPolicy Changes to this property will trigger replacement. string
The firewall policy of the resource.


name Changes to this property will trigger replacement. string
The name for an association.
project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
shortName string
The short name of the firewall policy of the association.
attachment_target Changes to this property will trigger replacement. str
The target that the firewall policy is attached to.
firewall_policy Changes to this property will trigger replacement. str
The firewall policy of the resource.


name Changes to this property will trigger replacement. str
The name for an association.
project Changes to this property will trigger replacement. str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
short_name str
The short name of the firewall policy of the association.
attachmentTarget Changes to this property will trigger replacement. String
The target that the firewall policy is attached to.
firewallPolicy Changes to this property will trigger replacement. String
The firewall policy of the resource.


name Changes to this property will trigger replacement. String
The name for an association.
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
shortName String
The short name of the firewall policy of the association.

Import

NetworkFirewallPolicyAssociation can be imported using any of these accepted formats:

  • projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/associations/{{name}}

  • {{project}}/{{firewall_policy}}/{{name}}

  • {{firewall_policy}}/{{name}}

When using the pulumi import command, NetworkFirewallPolicyAssociation can be imported using one of the formats above. For example:

$ pulumi import gcp:compute/networkFirewallPolicyAssociation:NetworkFirewallPolicyAssociation default projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/associations/{{name}}
Copy
$ pulumi import gcp:compute/networkFirewallPolicyAssociation:NetworkFirewallPolicyAssociation default {{project}}/{{firewall_policy}}/{{name}}
Copy
$ pulumi import gcp:compute/networkFirewallPolicyAssociation:NetworkFirewallPolicyAssociation default {{firewall_policy}}/{{name}}
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
Google Cloud (GCP) Classic pulumi/pulumi-gcp
License
Apache-2.0
Notes
This Pulumi package is based on the google-beta Terraform Provider.