1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. compute
  5. RouterNamedSet
Viewing docs for Google Cloud v9.15.0
published on Thursday, Mar 12, 2026 by Pulumi
gcp logo
Viewing docs for Google Cloud v9.15.0
published on Thursday, Mar 12, 2026 by Pulumi

    A Named Set is a collection of IP addresses or ranges (for PREFIX type) or BGP communities (for COMMUNITY type) that can be used in route policies.

    Warning: This resource is in beta, and should be used with the terraform-provider-google-beta provider. See Provider Versions for more details on beta resources.

    To get more information about RouterNamedSet, see:

    Example Usage

    Router Named Set Route Policy

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const myNetwork = new gcp.compute.Network("my_network", {
        name: "my-network",
        autoCreateSubnetworks: false,
    });
    const myRouter = new gcp.compute.Router("my_router", {
        name: "my-router",
        network: myNetwork.name,
        region: "us-central1",
        bgp: {
            asn: 64514,
        },
    });
    const myPrefixSet = new gcp.compute.RouterNamedSet("my_prefix_set", {
        name: "prefix-set-name",
        router: myRouter.name,
        region: myRouter.region,
        description: "My example prefix named set",
        type: "NAMED_SET_TYPE_PREFIX",
        elements: [
            {
                expression: "'10.0.0.0/8'",
                title: "private-range",
            },
            {
                expression: "'172.16.0.0/12'",
            },
            {
                expression: "prefix('192.168.10.0/24').orLonger()",
                title: "or-longer-example",
            },
        ],
    });
    const myRoutePolicy = new gcp.compute.RouterRoutePolicy("my_route_policy", {
        name: "policy-name",
        router: myRouter.name,
        region: myRouter.region,
        type: "ROUTE_POLICY_TYPE_EXPORT",
        terms: [{
            priority: 1,
            match: {
                expression: pulumi.interpolate`destination.inAnyRange(prefixSets('${myPrefixSet.name}'))`,
            },
            actions: [{
                expression: "accept()",
            }],
        }],
    });
    
    import pulumi
    import pulumi_gcp as gcp
    
    my_network = gcp.compute.Network("my_network",
        name="my-network",
        auto_create_subnetworks=False)
    my_router = gcp.compute.Router("my_router",
        name="my-router",
        network=my_network.name,
        region="us-central1",
        bgp={
            "asn": 64514,
        })
    my_prefix_set = gcp.compute.RouterNamedSet("my_prefix_set",
        name="prefix-set-name",
        router=my_router.name,
        region=my_router.region,
        description="My example prefix named set",
        type="NAMED_SET_TYPE_PREFIX",
        elements=[
            {
                "expression": "'10.0.0.0/8'",
                "title": "private-range",
            },
            {
                "expression": "'172.16.0.0/12'",
            },
            {
                "expression": "prefix('192.168.10.0/24').orLonger()",
                "title": "or-longer-example",
            },
        ])
    my_route_policy = gcp.compute.RouterRoutePolicy("my_route_policy",
        name="policy-name",
        router=my_router.name,
        region=my_router.region,
        type="ROUTE_POLICY_TYPE_EXPORT",
        terms=[{
            "priority": 1,
            "match": {
                "expression": my_prefix_set.name.apply(lambda name: f"destination.inAnyRange(prefixSets('{name}'))"),
            },
            "actions": [{
                "expression": "accept()",
            }],
        }])
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		myNetwork, err := compute.NewNetwork(ctx, "my_network", &compute.NetworkArgs{
    			Name:                  pulumi.String("my-network"),
    			AutoCreateSubnetworks: pulumi.Bool(false),
    		})
    		if err != nil {
    			return err
    		}
    		myRouter, err := compute.NewRouter(ctx, "my_router", &compute.RouterArgs{
    			Name:    pulumi.String("my-router"),
    			Network: myNetwork.Name,
    			Region:  pulumi.String("us-central1"),
    			Bgp: &compute.RouterBgpArgs{
    				Asn: pulumi.Int(64514),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		myPrefixSet, err := compute.NewRouterNamedSet(ctx, "my_prefix_set", &compute.RouterNamedSetArgs{
    			Name:        pulumi.String("prefix-set-name"),
    			Router:      myRouter.Name,
    			Region:      myRouter.Region,
    			Description: pulumi.String("My example prefix named set"),
    			Type:        pulumi.String("NAMED_SET_TYPE_PREFIX"),
    			Elements: compute.RouterNamedSetElementArray{
    				&compute.RouterNamedSetElementArgs{
    					Expression: pulumi.String("'10.0.0.0/8'"),
    					Title:      pulumi.String("private-range"),
    				},
    				&compute.RouterNamedSetElementArgs{
    					Expression: pulumi.String("'172.16.0.0/12'"),
    				},
    				&compute.RouterNamedSetElementArgs{
    					Expression: pulumi.String("prefix('192.168.10.0/24').orLonger()"),
    					Title:      pulumi.String("or-longer-example"),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = compute.NewRouterRoutePolicy(ctx, "my_route_policy", &compute.RouterRoutePolicyArgs{
    			Name:   pulumi.String("policy-name"),
    			Router: myRouter.Name,
    			Region: myRouter.Region,
    			Type:   pulumi.String("ROUTE_POLICY_TYPE_EXPORT"),
    			Terms: compute.RouterRoutePolicyTermArray{
    				&compute.RouterRoutePolicyTermArgs{
    					Priority: pulumi.Int(1),
    					Match: &compute.RouterRoutePolicyTermMatchArgs{
    						Expression: myPrefixSet.Name.ApplyT(func(name string) (string, error) {
    							return fmt.Sprintf("destination.inAnyRange(prefixSets('%v'))", name), nil
    						}).(pulumi.StringOutput),
    					},
    					Actions: compute.RouterRoutePolicyTermActionArray{
    						&compute.RouterRoutePolicyTermActionArgs{
    							Expression: pulumi.String("accept()"),
    						},
    					},
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    
    return await Deployment.RunAsync(() => 
    {
        var myNetwork = new Gcp.Compute.Network("my_network", new()
        {
            Name = "my-network",
            AutoCreateSubnetworks = false,
        });
    
        var myRouter = new Gcp.Compute.Router("my_router", new()
        {
            Name = "my-router",
            Network = myNetwork.Name,
            Region = "us-central1",
            Bgp = new Gcp.Compute.Inputs.RouterBgpArgs
            {
                Asn = 64514,
            },
        });
    
        var myPrefixSet = new Gcp.Compute.RouterNamedSet("my_prefix_set", new()
        {
            Name = "prefix-set-name",
            Router = myRouter.Name,
            Region = myRouter.Region,
            Description = "My example prefix named set",
            Type = "NAMED_SET_TYPE_PREFIX",
            Elements = new[]
            {
                new Gcp.Compute.Inputs.RouterNamedSetElementArgs
                {
                    Expression = "'10.0.0.0/8'",
                    Title = "private-range",
                },
                new Gcp.Compute.Inputs.RouterNamedSetElementArgs
                {
                    Expression = "'172.16.0.0/12'",
                },
                new Gcp.Compute.Inputs.RouterNamedSetElementArgs
                {
                    Expression = "prefix('192.168.10.0/24').orLonger()",
                    Title = "or-longer-example",
                },
            },
        });
    
        var myRoutePolicy = new Gcp.Compute.RouterRoutePolicy("my_route_policy", new()
        {
            Name = "policy-name",
            Router = myRouter.Name,
            Region = myRouter.Region,
            Type = "ROUTE_POLICY_TYPE_EXPORT",
            Terms = new[]
            {
                new Gcp.Compute.Inputs.RouterRoutePolicyTermArgs
                {
                    Priority = 1,
                    Match = new Gcp.Compute.Inputs.RouterRoutePolicyTermMatchArgs
                    {
                        Expression = myPrefixSet.Name.Apply(name => $"destination.inAnyRange(prefixSets('{name}'))"),
                    },
                    Actions = new[]
                    {
                        new Gcp.Compute.Inputs.RouterRoutePolicyTermActionArgs
                        {
                            Expression = "accept()",
                        },
                    },
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.compute.Network;
    import com.pulumi.gcp.compute.NetworkArgs;
    import com.pulumi.gcp.compute.Router;
    import com.pulumi.gcp.compute.RouterArgs;
    import com.pulumi.gcp.compute.inputs.RouterBgpArgs;
    import com.pulumi.gcp.compute.RouterNamedSet;
    import com.pulumi.gcp.compute.RouterNamedSetArgs;
    import com.pulumi.gcp.compute.inputs.RouterNamedSetElementArgs;
    import com.pulumi.gcp.compute.RouterRoutePolicy;
    import com.pulumi.gcp.compute.RouterRoutePolicyArgs;
    import com.pulumi.gcp.compute.inputs.RouterRoutePolicyTermArgs;
    import com.pulumi.gcp.compute.inputs.RouterRoutePolicyTermMatchArgs;
    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 myNetwork = new Network("myNetwork", NetworkArgs.builder()
                .name("my-network")
                .autoCreateSubnetworks(false)
                .build());
    
            var myRouter = new Router("myRouter", RouterArgs.builder()
                .name("my-router")
                .network(myNetwork.name())
                .region("us-central1")
                .bgp(RouterBgpArgs.builder()
                    .asn(64514)
                    .build())
                .build());
    
            var myPrefixSet = new RouterNamedSet("myPrefixSet", RouterNamedSetArgs.builder()
                .name("prefix-set-name")
                .router(myRouter.name())
                .region(myRouter.region())
                .description("My example prefix named set")
                .type("NAMED_SET_TYPE_PREFIX")
                .elements(            
                    RouterNamedSetElementArgs.builder()
                        .expression("'10.0.0.0/8'")
                        .title("private-range")
                        .build(),
                    RouterNamedSetElementArgs.builder()
                        .expression("'172.16.0.0/12'")
                        .build(),
                    RouterNamedSetElementArgs.builder()
                        .expression("prefix('192.168.10.0/24').orLonger()")
                        .title("or-longer-example")
                        .build())
                .build());
    
            var myRoutePolicy = new RouterRoutePolicy("myRoutePolicy", RouterRoutePolicyArgs.builder()
                .name("policy-name")
                .router(myRouter.name())
                .region(myRouter.region())
                .type("ROUTE_POLICY_TYPE_EXPORT")
                .terms(RouterRoutePolicyTermArgs.builder()
                    .priority(1)
                    .match(RouterRoutePolicyTermMatchArgs.builder()
                        .expression(myPrefixSet.name().applyValue(_name -> String.format("destination.inAnyRange(prefixSets('%s'))", _name)))
                        .build())
                    .actions(RouterRoutePolicyTermActionArgs.builder()
                        .expression("accept()")
                        .build())
                    .build())
                .build());
    
        }
    }
    
    resources:
      myNetwork:
        type: gcp:compute:Network
        name: my_network
        properties:
          name: my-network
          autoCreateSubnetworks: false
      myRouter:
        type: gcp:compute:Router
        name: my_router
        properties:
          name: my-router
          network: ${myNetwork.name}
          region: us-central1
          bgp:
            asn: 64514
      myPrefixSet:
        type: gcp:compute:RouterNamedSet
        name: my_prefix_set
        properties:
          name: prefix-set-name
          router: ${myRouter.name}
          region: ${myRouter.region}
          description: My example prefix named set
          type: NAMED_SET_TYPE_PREFIX
          elements:
            - expression: '''10.0.0.0/8'''
              title: private-range
            - expression: '''172.16.0.0/12'''
            - expression: prefix('192.168.10.0/24').orLonger()
              title: or-longer-example
      myRoutePolicy:
        type: gcp:compute:RouterRoutePolicy
        name: my_route_policy
        properties:
          name: policy-name
          router: ${myRouter.name}
          region: ${myRouter.region}
          type: ROUTE_POLICY_TYPE_EXPORT
          terms:
            - priority: 1
              match:
                expression: destination.inAnyRange(prefixSets('${myPrefixSet.name}'))
              actions:
                - expression: accept()
    

    Router Named Set Prefix

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const net = new gcp.compute.Network("net", {
        name: "my-network",
        autoCreateSubnetworks: false,
    });
    const router = new gcp.compute.Router("router", {
        name: "my-router",
        network: net.name,
        region: "us-central1",
    });
    const prefixSet = new gcp.compute.RouterNamedSet("prefix_set", {
        name: "my-prefix-set",
        router: router.name,
        region: "us-central1",
        description: "A sample prefix named set",
        type: "NAMED_SET_TYPE_PREFIX",
        elements: [
            {
                expression: "'10.0.0.0/8'",
                title: "ten-slash-eight",
                description: "A sample IPv4 prefix",
            },
            {
                expression: "'172.16.0.0/12'",
                title: "seventeen-two-slash-sixteen",
            },
        ],
    });
    
    import pulumi
    import pulumi_gcp as gcp
    
    net = gcp.compute.Network("net",
        name="my-network",
        auto_create_subnetworks=False)
    router = gcp.compute.Router("router",
        name="my-router",
        network=net.name,
        region="us-central1")
    prefix_set = gcp.compute.RouterNamedSet("prefix_set",
        name="my-prefix-set",
        router=router.name,
        region="us-central1",
        description="A sample prefix named set",
        type="NAMED_SET_TYPE_PREFIX",
        elements=[
            {
                "expression": "'10.0.0.0/8'",
                "title": "ten-slash-eight",
                "description": "A sample IPv4 prefix",
            },
            {
                "expression": "'172.16.0.0/12'",
                "title": "seventeen-two-slash-sixteen",
            },
        ])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		net, err := compute.NewNetwork(ctx, "net", &compute.NetworkArgs{
    			Name:                  pulumi.String("my-network"),
    			AutoCreateSubnetworks: pulumi.Bool(false),
    		})
    		if err != nil {
    			return err
    		}
    		router, err := compute.NewRouter(ctx, "router", &compute.RouterArgs{
    			Name:    pulumi.String("my-router"),
    			Network: net.Name,
    			Region:  pulumi.String("us-central1"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = compute.NewRouterNamedSet(ctx, "prefix_set", &compute.RouterNamedSetArgs{
    			Name:        pulumi.String("my-prefix-set"),
    			Router:      router.Name,
    			Region:      pulumi.String("us-central1"),
    			Description: pulumi.String("A sample prefix named set"),
    			Type:        pulumi.String("NAMED_SET_TYPE_PREFIX"),
    			Elements: compute.RouterNamedSetElementArray{
    				&compute.RouterNamedSetElementArgs{
    					Expression:  pulumi.String("'10.0.0.0/8'"),
    					Title:       pulumi.String("ten-slash-eight"),
    					Description: pulumi.String("A sample IPv4 prefix"),
    				},
    				&compute.RouterNamedSetElementArgs{
    					Expression: pulumi.String("'172.16.0.0/12'"),
    					Title:      pulumi.String("seventeen-two-slash-sixteen"),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    
    return await Deployment.RunAsync(() => 
    {
        var net = new Gcp.Compute.Network("net", new()
        {
            Name = "my-network",
            AutoCreateSubnetworks = false,
        });
    
        var router = new Gcp.Compute.Router("router", new()
        {
            Name = "my-router",
            Network = net.Name,
            Region = "us-central1",
        });
    
        var prefixSet = new Gcp.Compute.RouterNamedSet("prefix_set", new()
        {
            Name = "my-prefix-set",
            Router = router.Name,
            Region = "us-central1",
            Description = "A sample prefix named set",
            Type = "NAMED_SET_TYPE_PREFIX",
            Elements = new[]
            {
                new Gcp.Compute.Inputs.RouterNamedSetElementArgs
                {
                    Expression = "'10.0.0.0/8'",
                    Title = "ten-slash-eight",
                    Description = "A sample IPv4 prefix",
                },
                new Gcp.Compute.Inputs.RouterNamedSetElementArgs
                {
                    Expression = "'172.16.0.0/12'",
                    Title = "seventeen-two-slash-sixteen",
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.compute.Network;
    import com.pulumi.gcp.compute.NetworkArgs;
    import com.pulumi.gcp.compute.Router;
    import com.pulumi.gcp.compute.RouterArgs;
    import com.pulumi.gcp.compute.RouterNamedSet;
    import com.pulumi.gcp.compute.RouterNamedSetArgs;
    import com.pulumi.gcp.compute.inputs.RouterNamedSetElementArgs;
    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 net = new Network("net", NetworkArgs.builder()
                .name("my-network")
                .autoCreateSubnetworks(false)
                .build());
    
            var router = new Router("router", RouterArgs.builder()
                .name("my-router")
                .network(net.name())
                .region("us-central1")
                .build());
    
            var prefixSet = new RouterNamedSet("prefixSet", RouterNamedSetArgs.builder()
                .name("my-prefix-set")
                .router(router.name())
                .region("us-central1")
                .description("A sample prefix named set")
                .type("NAMED_SET_TYPE_PREFIX")
                .elements(            
                    RouterNamedSetElementArgs.builder()
                        .expression("'10.0.0.0/8'")
                        .title("ten-slash-eight")
                        .description("A sample IPv4 prefix")
                        .build(),
                    RouterNamedSetElementArgs.builder()
                        .expression("'172.16.0.0/12'")
                        .title("seventeen-two-slash-sixteen")
                        .build())
                .build());
    
        }
    }
    
    resources:
      net:
        type: gcp:compute:Network
        properties:
          name: my-network
          autoCreateSubnetworks: false
      router:
        type: gcp:compute:Router
        properties:
          name: my-router
          network: ${net.name}
          region: us-central1
      prefixSet:
        type: gcp:compute:RouterNamedSet
        name: prefix_set
        properties:
          name: my-prefix-set
          router: ${router.name}
          region: us-central1
          description: A sample prefix named set
          type: NAMED_SET_TYPE_PREFIX
          elements:
            - expression: '''10.0.0.0/8'''
              title: ten-slash-eight
              description: A sample IPv4 prefix
            - expression: '''172.16.0.0/12'''
              title: seventeen-two-slash-sixteen
    

    Router Named Set Community

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const net = new gcp.compute.Network("net", {
        name: "my-network",
        autoCreateSubnetworks: false,
    });
    const router = new gcp.compute.Router("router", {
        name: "my-router",
        network: net.name,
        region: "us-central1",
    });
    const communitySet = new gcp.compute.RouterNamedSet("community_set", {
        name: "my-community-set",
        router: router.name,
        region: "us-central1",
        description: "A sample community named set",
        type: "NAMED_SET_TYPE_COMMUNITY",
        elements: [{
            expression: "'65512:100'",
            title: "community-one",
            description: "A sample BGP community",
        }],
    });
    
    import pulumi
    import pulumi_gcp as gcp
    
    net = gcp.compute.Network("net",
        name="my-network",
        auto_create_subnetworks=False)
    router = gcp.compute.Router("router",
        name="my-router",
        network=net.name,
        region="us-central1")
    community_set = gcp.compute.RouterNamedSet("community_set",
        name="my-community-set",
        router=router.name,
        region="us-central1",
        description="A sample community named set",
        type="NAMED_SET_TYPE_COMMUNITY",
        elements=[{
            "expression": "'65512:100'",
            "title": "community-one",
            "description": "A sample BGP community",
        }])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		net, err := compute.NewNetwork(ctx, "net", &compute.NetworkArgs{
    			Name:                  pulumi.String("my-network"),
    			AutoCreateSubnetworks: pulumi.Bool(false),
    		})
    		if err != nil {
    			return err
    		}
    		router, err := compute.NewRouter(ctx, "router", &compute.RouterArgs{
    			Name:    pulumi.String("my-router"),
    			Network: net.Name,
    			Region:  pulumi.String("us-central1"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = compute.NewRouterNamedSet(ctx, "community_set", &compute.RouterNamedSetArgs{
    			Name:        pulumi.String("my-community-set"),
    			Router:      router.Name,
    			Region:      pulumi.String("us-central1"),
    			Description: pulumi.String("A sample community named set"),
    			Type:        pulumi.String("NAMED_SET_TYPE_COMMUNITY"),
    			Elements: compute.RouterNamedSetElementArray{
    				&compute.RouterNamedSetElementArgs{
    					Expression:  pulumi.String("'65512:100'"),
    					Title:       pulumi.String("community-one"),
    					Description: pulumi.String("A sample BGP community"),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    
    return await Deployment.RunAsync(() => 
    {
        var net = new Gcp.Compute.Network("net", new()
        {
            Name = "my-network",
            AutoCreateSubnetworks = false,
        });
    
        var router = new Gcp.Compute.Router("router", new()
        {
            Name = "my-router",
            Network = net.Name,
            Region = "us-central1",
        });
    
        var communitySet = new Gcp.Compute.RouterNamedSet("community_set", new()
        {
            Name = "my-community-set",
            Router = router.Name,
            Region = "us-central1",
            Description = "A sample community named set",
            Type = "NAMED_SET_TYPE_COMMUNITY",
            Elements = new[]
            {
                new Gcp.Compute.Inputs.RouterNamedSetElementArgs
                {
                    Expression = "'65512:100'",
                    Title = "community-one",
                    Description = "A sample BGP community",
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.compute.Network;
    import com.pulumi.gcp.compute.NetworkArgs;
    import com.pulumi.gcp.compute.Router;
    import com.pulumi.gcp.compute.RouterArgs;
    import com.pulumi.gcp.compute.RouterNamedSet;
    import com.pulumi.gcp.compute.RouterNamedSetArgs;
    import com.pulumi.gcp.compute.inputs.RouterNamedSetElementArgs;
    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 net = new Network("net", NetworkArgs.builder()
                .name("my-network")
                .autoCreateSubnetworks(false)
                .build());
    
            var router = new Router("router", RouterArgs.builder()
                .name("my-router")
                .network(net.name())
                .region("us-central1")
                .build());
    
            var communitySet = new RouterNamedSet("communitySet", RouterNamedSetArgs.builder()
                .name("my-community-set")
                .router(router.name())
                .region("us-central1")
                .description("A sample community named set")
                .type("NAMED_SET_TYPE_COMMUNITY")
                .elements(RouterNamedSetElementArgs.builder()
                    .expression("'65512:100'")
                    .title("community-one")
                    .description("A sample BGP community")
                    .build())
                .build());
    
        }
    }
    
    resources:
      net:
        type: gcp:compute:Network
        properties:
          name: my-network
          autoCreateSubnetworks: false
      router:
        type: gcp:compute:Router
        properties:
          name: my-router
          network: ${net.name}
          region: us-central1
      communitySet:
        type: gcp:compute:RouterNamedSet
        name: community_set
        properties:
          name: my-community-set
          router: ${router.name}
          region: us-central1
          description: A sample community named set
          type: NAMED_SET_TYPE_COMMUNITY
          elements:
            - expression: '''65512:100'''
              title: community-one
              description: A sample BGP community
    

    Create RouterNamedSet Resource

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

    Constructor syntax

    new RouterNamedSet(name: string, args: RouterNamedSetArgs, opts?: CustomResourceOptions);
    @overload
    def RouterNamedSet(resource_name: str,
                       args: RouterNamedSetArgs,
                       opts: Optional[ResourceOptions] = None)
    
    @overload
    def RouterNamedSet(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       router: Optional[str] = None,
                       type: Optional[str] = None,
                       description: Optional[str] = None,
                       elements: Optional[Sequence[RouterNamedSetElementArgs]] = None,
                       name: Optional[str] = None,
                       project: Optional[str] = None,
                       region: Optional[str] = None)
    func NewRouterNamedSet(ctx *Context, name string, args RouterNamedSetArgs, opts ...ResourceOption) (*RouterNamedSet, error)
    public RouterNamedSet(string name, RouterNamedSetArgs args, CustomResourceOptions? opts = null)
    public RouterNamedSet(String name, RouterNamedSetArgs args)
    public RouterNamedSet(String name, RouterNamedSetArgs args, CustomResourceOptions options)
    
    type: gcp:compute:RouterNamedSet
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args RouterNamedSetArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args RouterNamedSetArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args RouterNamedSetArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args RouterNamedSetArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args RouterNamedSetArgs
    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 routerNamedSetResource = new Gcp.Compute.RouterNamedSet("routerNamedSetResource", new()
    {
        Router = "string",
        Type = "string",
        Description = "string",
        Elements = new[]
        {
            new Gcp.Compute.Inputs.RouterNamedSetElementArgs
            {
                Expression = "string",
                Description = "string",
                Location = "string",
                Title = "string",
            },
        },
        Name = "string",
        Project = "string",
        Region = "string",
    });
    
    example, err := compute.NewRouterNamedSet(ctx, "routerNamedSetResource", &compute.RouterNamedSetArgs{
    	Router:      pulumi.String("string"),
    	Type:        pulumi.String("string"),
    	Description: pulumi.String("string"),
    	Elements: compute.RouterNamedSetElementArray{
    		&compute.RouterNamedSetElementArgs{
    			Expression:  pulumi.String("string"),
    			Description: pulumi.String("string"),
    			Location:    pulumi.String("string"),
    			Title:       pulumi.String("string"),
    		},
    	},
    	Name:    pulumi.String("string"),
    	Project: pulumi.String("string"),
    	Region:  pulumi.String("string"),
    })
    
    var routerNamedSetResource = new RouterNamedSet("routerNamedSetResource", RouterNamedSetArgs.builder()
        .router("string")
        .type("string")
        .description("string")
        .elements(RouterNamedSetElementArgs.builder()
            .expression("string")
            .description("string")
            .location("string")
            .title("string")
            .build())
        .name("string")
        .project("string")
        .region("string")
        .build());
    
    router_named_set_resource = gcp.compute.RouterNamedSet("routerNamedSetResource",
        router="string",
        type="string",
        description="string",
        elements=[{
            "expression": "string",
            "description": "string",
            "location": "string",
            "title": "string",
        }],
        name="string",
        project="string",
        region="string")
    
    const routerNamedSetResource = new gcp.compute.RouterNamedSet("routerNamedSetResource", {
        router: "string",
        type: "string",
        description: "string",
        elements: [{
            expression: "string",
            description: "string",
            location: "string",
            title: "string",
        }],
        name: "string",
        project: "string",
        region: "string",
    });
    
    type: gcp:compute:RouterNamedSet
    properties:
        description: string
        elements:
            - description: string
              expression: string
              location: string
              title: string
        name: string
        project: string
        region: string
        router: string
        type: string
    

    RouterNamedSet 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 RouterNamedSet resource accepts the following input properties:

    Router string
    The name of the Cloud Router in which this Named Set will be configured.
    Type string
    The type of the Named Set. Possible values are: NAMED_SET_TYPE_PREFIX, NAMED_SET_TYPE_COMMUNITY.
    Description string
    An optional description of the Named Set.
    Elements List<RouterNamedSetElement>
    CEL expressions that are comparable to constructs of this set's type. Structure is documented below.
    Name string
    The name of the Named Set, which must be a resource ID segment and unique within all named sets owned by the Router.
    Project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    Region string
    Region where the router resides.
    Router string
    The name of the Cloud Router in which this Named Set will be configured.
    Type string
    The type of the Named Set. Possible values are: NAMED_SET_TYPE_PREFIX, NAMED_SET_TYPE_COMMUNITY.
    Description string
    An optional description of the Named Set.
    Elements []RouterNamedSetElementArgs
    CEL expressions that are comparable to constructs of this set's type. Structure is documented below.
    Name string
    The name of the Named Set, which must be a resource ID segment and unique within all named sets owned by the Router.
    Project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    Region string
    Region where the router resides.
    router String
    The name of the Cloud Router in which this Named Set will be configured.
    type String
    The type of the Named Set. Possible values are: NAMED_SET_TYPE_PREFIX, NAMED_SET_TYPE_COMMUNITY.
    description String
    An optional description of the Named Set.
    elements List<RouterNamedSetElement>
    CEL expressions that are comparable to constructs of this set's type. Structure is documented below.
    name String
    The name of the Named Set, which must be a resource ID segment and unique within all named sets owned by the Router.
    project String
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    region String
    Region where the router resides.
    router string
    The name of the Cloud Router in which this Named Set will be configured.
    type string
    The type of the Named Set. Possible values are: NAMED_SET_TYPE_PREFIX, NAMED_SET_TYPE_COMMUNITY.
    description string
    An optional description of the Named Set.
    elements RouterNamedSetElement[]
    CEL expressions that are comparable to constructs of this set's type. Structure is documented below.
    name string
    The name of the Named Set, which must be a resource ID segment and unique within all named sets owned by the Router.
    project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    region string
    Region where the router resides.
    router str
    The name of the Cloud Router in which this Named Set will be configured.
    type str
    The type of the Named Set. Possible values are: NAMED_SET_TYPE_PREFIX, NAMED_SET_TYPE_COMMUNITY.
    description str
    An optional description of the Named Set.
    elements Sequence[RouterNamedSetElementArgs]
    CEL expressions that are comparable to constructs of this set's type. Structure is documented below.
    name str
    The name of the Named Set, which must be a resource ID segment and unique within all named sets owned by the Router.
    project str
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    region str
    Region where the router resides.
    router String
    The name of the Cloud Router in which this Named Set will be configured.
    type String
    The type of the Named Set. Possible values are: NAMED_SET_TYPE_PREFIX, NAMED_SET_TYPE_COMMUNITY.
    description String
    An optional description of the Named Set.
    elements List<Property Map>
    CEL expressions that are comparable to constructs of this set's type. Structure is documented below.
    name String
    The name of the Named Set, which must be a resource ID segment and unique within all named sets owned by the Router.
    project String
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    region String
    Region where the router resides.

    Outputs

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

    Fingerprint string
    The fingerprint used for optimistic locking of this resource. Used internally during updates.
    Id string
    The provider-assigned unique ID for this managed resource.
    Fingerprint string
    The fingerprint used for optimistic locking of this resource. Used internally during updates.
    Id string
    The provider-assigned unique ID for this managed resource.
    fingerprint String
    The fingerprint used for optimistic locking of this resource. Used internally during updates.
    id String
    The provider-assigned unique ID for this managed resource.
    fingerprint string
    The fingerprint used for optimistic locking of this resource. Used internally during updates.
    id string
    The provider-assigned unique ID for this managed resource.
    fingerprint str
    The fingerprint used for optimistic locking of this resource. Used internally during updates.
    id str
    The provider-assigned unique ID for this managed resource.
    fingerprint String
    The fingerprint used for optimistic locking of this resource. Used internally during updates.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing RouterNamedSet Resource

    Get an existing RouterNamedSet 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?: RouterNamedSetState, opts?: CustomResourceOptions): RouterNamedSet
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            description: Optional[str] = None,
            elements: Optional[Sequence[RouterNamedSetElementArgs]] = None,
            fingerprint: Optional[str] = None,
            name: Optional[str] = None,
            project: Optional[str] = None,
            region: Optional[str] = None,
            router: Optional[str] = None,
            type: Optional[str] = None) -> RouterNamedSet
    func GetRouterNamedSet(ctx *Context, name string, id IDInput, state *RouterNamedSetState, opts ...ResourceOption) (*RouterNamedSet, error)
    public static RouterNamedSet Get(string name, Input<string> id, RouterNamedSetState? state, CustomResourceOptions? opts = null)
    public static RouterNamedSet get(String name, Output<String> id, RouterNamedSetState state, CustomResourceOptions options)
    resources:  _:    type: gcp:compute:RouterNamedSet    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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:
    Description string
    An optional description of the Named Set.
    Elements List<RouterNamedSetElement>
    CEL expressions that are comparable to constructs of this set's type. Structure is documented below.
    Fingerprint string
    The fingerprint used for optimistic locking of this resource. Used internally during updates.
    Name string
    The name of the Named Set, which must be a resource ID segment and unique within all named sets owned by the Router.
    Project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    Region string
    Region where the router resides.
    Router string
    The name of the Cloud Router in which this Named Set will be configured.
    Type string
    The type of the Named Set. Possible values are: NAMED_SET_TYPE_PREFIX, NAMED_SET_TYPE_COMMUNITY.
    Description string
    An optional description of the Named Set.
    Elements []RouterNamedSetElementArgs
    CEL expressions that are comparable to constructs of this set's type. Structure is documented below.
    Fingerprint string
    The fingerprint used for optimistic locking of this resource. Used internally during updates.
    Name string
    The name of the Named Set, which must be a resource ID segment and unique within all named sets owned by the Router.
    Project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    Region string
    Region where the router resides.
    Router string
    The name of the Cloud Router in which this Named Set will be configured.
    Type string
    The type of the Named Set. Possible values are: NAMED_SET_TYPE_PREFIX, NAMED_SET_TYPE_COMMUNITY.
    description String
    An optional description of the Named Set.
    elements List<RouterNamedSetElement>
    CEL expressions that are comparable to constructs of this set's type. Structure is documented below.
    fingerprint String
    The fingerprint used for optimistic locking of this resource. Used internally during updates.
    name String
    The name of the Named Set, which must be a resource ID segment and unique within all named sets owned by the Router.
    project String
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    region String
    Region where the router resides.
    router String
    The name of the Cloud Router in which this Named Set will be configured.
    type String
    The type of the Named Set. Possible values are: NAMED_SET_TYPE_PREFIX, NAMED_SET_TYPE_COMMUNITY.
    description string
    An optional description of the Named Set.
    elements RouterNamedSetElement[]
    CEL expressions that are comparable to constructs of this set's type. Structure is documented below.
    fingerprint string
    The fingerprint used for optimistic locking of this resource. Used internally during updates.
    name string
    The name of the Named Set, which must be a resource ID segment and unique within all named sets owned by the Router.
    project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    region string
    Region where the router resides.
    router string
    The name of the Cloud Router in which this Named Set will be configured.
    type string
    The type of the Named Set. Possible values are: NAMED_SET_TYPE_PREFIX, NAMED_SET_TYPE_COMMUNITY.
    description str
    An optional description of the Named Set.
    elements Sequence[RouterNamedSetElementArgs]
    CEL expressions that are comparable to constructs of this set's type. Structure is documented below.
    fingerprint str
    The fingerprint used for optimistic locking of this resource. Used internally during updates.
    name str
    The name of the Named Set, which must be a resource ID segment and unique within all named sets owned by the Router.
    project str
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    region str
    Region where the router resides.
    router str
    The name of the Cloud Router in which this Named Set will be configured.
    type str
    The type of the Named Set. Possible values are: NAMED_SET_TYPE_PREFIX, NAMED_SET_TYPE_COMMUNITY.
    description String
    An optional description of the Named Set.
    elements List<Property Map>
    CEL expressions that are comparable to constructs of this set's type. Structure is documented below.
    fingerprint String
    The fingerprint used for optimistic locking of this resource. Used internally during updates.
    name String
    The name of the Named Set, which must be a resource ID segment and unique within all named sets owned by the Router.
    project String
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    region String
    Region where the router resides.
    router String
    The name of the Cloud Router in which this Named Set will be configured.
    type String
    The type of the Named Set. Possible values are: NAMED_SET_TYPE_PREFIX, NAMED_SET_TYPE_COMMUNITY.

    Supporting Types

    RouterNamedSetElement, RouterNamedSetElementArgs

    Expression string
    Textual representation of an expression in Common Expression Language syntax.
    Description string
    Description of the expression.
    Location string
    String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
    Title string
    Title for the expression, i.e. a short string describing its purpose.
    Expression string
    Textual representation of an expression in Common Expression Language syntax.
    Description string
    Description of the expression.
    Location string
    String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
    Title string
    Title for the expression, i.e. a short string describing its purpose.
    expression String
    Textual representation of an expression in Common Expression Language syntax.
    description String
    Description of the expression.
    location String
    String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
    title String
    Title for the expression, i.e. a short string describing its purpose.
    expression string
    Textual representation of an expression in Common Expression Language syntax.
    description string
    Description of the expression.
    location string
    String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
    title string
    Title for the expression, i.e. a short string describing its purpose.
    expression str
    Textual representation of an expression in Common Expression Language syntax.
    description str
    Description of the expression.
    location str
    String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
    title str
    Title for the expression, i.e. a short string describing its purpose.
    expression String
    Textual representation of an expression in Common Expression Language syntax.
    description String
    Description of the expression.
    location String
    String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
    title String
    Title for the expression, i.e. a short string describing its purpose.

    Import

    RouterNamedSet can be imported using any of these accepted formats:

    • {{project}}/{{region}}/{{router}}/namedSets/{{name}}
    • {{project}}/{{region}}/{{router}}/{{name}}
    • {{region}}/{{router}}/{{name}}
    • {{router}}/{{name}}

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

    $ pulumi import gcp:compute/routerNamedSet:RouterNamedSet default {{project}}/{{region}}/{{router}}/namedSets/{{name}}
    $ pulumi import gcp:compute/routerNamedSet:RouterNamedSet default {{project}}/{{region}}/{{router}}/{{name}}
    $ pulumi import gcp:compute/routerNamedSet:RouterNamedSet default {{region}}/{{router}}/{{name}}
    $ pulumi import gcp:compute/routerNamedSet:RouterNamedSet default {{router}}/{{name}}
    

    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.
    gcp logo
    Viewing docs for Google Cloud v9.15.0
    published on Thursday, Mar 12, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.