1. Packages
  2. Equinix
  3. API Docs
  4. metal
  5. BgpSession
Equinix v0.13.0 published on Monday, Jul 22, 2024 by Equinix

equinix.metal.BgpSession

Explore with Pulumi AI

equinix logo
Equinix v0.13.0 published on Monday, Jul 22, 2024 by Equinix

    Provides a resource to manage BGP sessions in Equinix Metal Host. Refer to Equinix Metal BGP documentation for more details.

    You need to have BGP config enabled in your project.

    BGP session must be linked to a device running BIRD or other BGP routing daemon which will control route advertisements via the session to Equinix Metal’s upstream routers.

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Equinix = Pulumi.Equinix;
    using Null = Pulumi.Null;
    
    return await Deployment.RunAsync(() => 
    {
        var bgpPassword = "955dB0b81Ef";
    
        var projectId = "<UUID_of_your_project>";
    
        var addr = new Equinix.Metal.ReservedIpBlock("addr", new()
        {
            ProjectId = projectId,
            Metro = "ny",
            Quantity = 1,
        });
    
        var interfaceLo0 = Output.Tuple(addr.Address, addr.Netmask).Apply(values =>
        {
            var address = values.Item1;
            var netmask = values.Item2;
            return @$"auto lo:0
    iface lo:0 inet static
       address {address}
       netmask {netmask}
    ";
        });
    
        var test = new Equinix.Metal.Device("test", new()
        {
            Hostname = "terraform-test-bgp-sesh",
            Plan = Equinix.Metal.Plan.C3SmallX86,
            Metro = "ny",
            OperatingSystem = Equinix.Metal.OperatingSystem.Ubuntu20_04,
            BillingCycle = Equinix.Metal.BillingCycle.Hourly,
            ProjectId = projectId,
        });
    
        var birdConf = Output.Tuple(addr.Address, addr.Cidr, test.Network, test.Network).Apply(values =>
        {
            var address = values.Item1;
            var cidr = values.Item2;
            var testNetwork = values.Item3;
            var testNetwork1 = values.Item4;
            return @$"filter equinix_metal_bgp {{
        if net = {address}/{cidr} then accept;
    }}
    router id {testNetwork[2].Address};
    protocol direct {{
        interface ""lo"";
    }}
    protocol kernel {{
        scan time 10;
        persist;
        import all;
        export all;
    }}
    protocol device {{
        scan time 10;
    }}
    protocol bgp {{
        export filter equinix_metal_bgp;
        local as 65000;
        neighbor {testNetwork1[2].Gateway} as 65530;
        password ""{bgpPassword}"";
    }}
    ";
        });
    
        var testBgpSession = new Equinix.Metal.BgpSession("testBgpSession", new()
        {
            DeviceId = test.Id,
            AddressFamily = "ipv4",
        });
    
        var configureBird = new Null.Resource("configureBird", new()
        {
            Triggers = 
            {
                { "bird_conf", birdConf },
                { "interface", interfaceLo0 },
            },
        });
    
    });
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/equinix/pulumi-equinix/sdk/go/equinix/metal"
    	"github.com/pulumi/pulumi-null/sdk/go/null"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		bgpPassword := "955dB0b81Ef"
    		projectId := "<UUID_of_your_project>"
    		addr, err := metal.NewReservedIpBlock(ctx, "addr", &metal.ReservedIpBlockArgs{
    			ProjectId: pulumi.String(projectId),
    			Metro:     pulumi.String("ny"),
    			Quantity:  pulumi.Int(1),
    		})
    		if err != nil {
    			return err
    		}
    		interfaceLo0 := pulumi.All(addr.Address, addr.Netmask).ApplyT(func(_args []interface{}) (string, error) {
    			address := _args[0].(string)
    			netmask := _args[1].(string)
    			return fmt.Sprintf("auto lo:0\niface lo:0 inet static\n   address %v\n   netmask %v\n", address, netmask), nil
    		}).(pulumi.StringOutput)
    		test, err := metal.NewDevice(ctx, "test", &metal.DeviceArgs{
    			Hostname:        pulumi.String("terraform-test-bgp-sesh"),
    			Plan:            pulumi.String(metal.PlanC3SmallX86),
    			Metro:           pulumi.String("ny"),
    			OperatingSystem: pulumi.String(metal.OperatingSystem_Ubuntu20_04),
    			BillingCycle:    pulumi.String(metal.BillingCycleHourly),
    			ProjectId:       pulumi.String(projectId),
    		})
    		if err != nil {
    			return err
    		}
    		birdConf := pulumi.All(addr.Address, addr.Cidr, test.Network, test.Network).ApplyT(func(_args []interface{}) (string, error) {
    			address := _args[0].(string)
    			cidr := _args[1].(int)
    			testNetwork := _args[2].([]metal.DeviceNetwork)
    			testNetwork1 := _args[3].([]metal.DeviceNetwork)
    			return fmt.Sprintf(`filter equinix_metal_bgp {
        if net = %v/%v then accept;
    }
    router id %v;
    protocol direct {
        interface "lo";
    }
    protocol kernel {
        scan time 10;
        persist;
        import all;
        export all;
    }
    protocol device {
        scan time 10;
    }
    protocol bgp {
        export filter equinix_metal_bgp;
        local as 65000;
        neighbor %v as 65530;
        password "%v";
    }
    `, address, cidr, testNetwork[2].Address, testNetwork1[2].Gateway, bgpPassword), nil
    		}).(pulumi.StringOutput)
    		_, err = metal.NewBgpSession(ctx, "testBgpSession", &metal.BgpSessionArgs{
    			DeviceId:      test.ID(),
    			AddressFamily: pulumi.String("ipv4"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = null.NewResource(ctx, "configureBird", &null.ResourceArgs{
    			Triggers: pulumi.StringMap{
    				"bird_conf": pulumi.String(birdConf),
    				"interface": pulumi.String(interfaceLo0),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.equinix.metal.ReservedIpBlock;
    import com.pulumi.equinix.metal.ReservedIpBlockArgs;
    import com.pulumi.equinix.metal.Device;
    import com.pulumi.equinix.metal.DeviceArgs;
    import com.pulumi.equinix.metal.BgpSession;
    import com.pulumi.equinix.metal.BgpSessionArgs;
    import com.pulumi.null.Resource;
    import com.pulumi.null.ResourceArgs;
    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) {
            final var bgpPassword = "955dB0b81Ef";
    
            final var projectId = "<UUID_of_your_project>";
    
            var addr = new ReservedIpBlock("addr", ReservedIpBlockArgs.builder()
                .projectId(projectId)
                .metro("ny")
                .quantity(1)
                .build());
    
            final var interfaceLo0 = Output.tuple(addr.address(), addr.netmask()).applyValue(values -> {
                var address = values.t1;
                var netmask = values.t2;
                return """
    auto lo:0
    iface lo:0 inet static
       address %s
       netmask %s
    ", address,netmask);
            });
    
            var test = new Device("test", DeviceArgs.builder()
                .hostname("terraform-test-bgp-sesh")
                .plan("c3.small.x86")
                .metro("ny")
                .operatingSystem("ubuntu_20_04")
                .billingCycle("hourly")
                .projectId(projectId)
                .build());
    
            final var birdConf = Output.tuple(addr.address(), addr.cidr(), test.network(), test.network()).applyValue(values -> {
                var address = values.t1;
                var cidr = values.t2;
                var testNetwork = values.t3;
                var testNetwork1 = values.t4;
                return """
    filter equinix_metal_bgp {
        if net = %s/%s then accept;
    }
    router id %s;
    protocol direct {
        interface "lo";
    }
    protocol kernel {
        scan time 10;
        persist;
        import all;
        export all;
    }
    protocol device {
        scan time 10;
    }
    protocol bgp {
        export filter equinix_metal_bgp;
        local as 65000;
        neighbor %s as 65530;
        password "%s";
    }
    ", address,cidr,testNetwork[2].address(),testNetwork1[2].gateway(),bgpPassword);
            });
    
            var testBgpSession = new BgpSession("testBgpSession", BgpSessionArgs.builder()
                .deviceId(test.id())
                .addressFamily("ipv4")
                .build());
    
            var configureBird = new Resource("configureBird", ResourceArgs.builder()
                .triggers(Map.ofEntries(
                    Map.entry("bird_conf", birdConf),
                    Map.entry("interface", interfaceLo0)
                ))
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_equinix as equinix
    import pulumi_null as null
    
    bgp_password = "955dB0b81Ef"
    project_id = "<UUID_of_your_project>"
    addr = equinix.metal.ReservedIpBlock("addr",
        project_id=project_id,
        metro="ny",
        quantity=1)
    interface_lo0 = pulumi.Output.all(addr.address, addr.netmask).apply(lambda address, netmask: f"""auto lo:0
    iface lo:0 inet static
       address {address}
       netmask {netmask}
    """)
    test = equinix.metal.Device("test",
        hostname="terraform-test-bgp-sesh",
        plan=equinix.metal.Plan.C3_SMALL_X86,
        metro="ny",
        operating_system=equinix.metal.OperatingSystem.UBUNTU20_04,
        billing_cycle=equinix.metal.BillingCycle.HOURLY,
        project_id=project_id)
    bird_conf = pulumi.Output.all(addr.address, addr.cidr, test.network, test.network).apply(lambda address, cidr, testNetwork, testNetwork1: f"""filter equinix_metal_bgp {{
        if net = {address}/{cidr} then accept;
    }}
    router id {test_network[2].address};
    protocol direct {{
        interface "lo";
    }}
    protocol kernel {{
        scan time 10;
        persist;
        import all;
        export all;
    }}
    protocol device {{
        scan time 10;
    }}
    protocol bgp {{
        export filter equinix_metal_bgp;
        local as 65000;
        neighbor {test_network1[2].gateway} as 65530;
        password "{bgp_password}";
    }}
    """)
    test_bgp_session = equinix.metal.BgpSession("testBgpSession",
        device_id=test.id,
        address_family="ipv4")
    configure_bird = null.Resource("configureBird", triggers={
        "bird_conf": bird_conf,
        "interface": interface_lo0,
    })
    
    import * as pulumi from "@pulumi/pulumi";
    import * as _null from "@pulumi/null";
    import * as equinix from "@equinix-labs/pulumi-equinix";
    
    const bgpPassword = "955dB0b81Ef";
    const projectId = "<UUID_of_your_project>";
    const addr = new equinix.metal.ReservedIpBlock("addr", {
        projectId: projectId,
        metro: "ny",
        quantity: 1,
    });
    const interfaceLo0 = pulumi.interpolate`auto lo:0
    iface lo:0 inet static
       address ${addr.address}
       netmask ${addr.netmask}
    `;
    const test = new equinix.metal.Device("test", {
        hostname: "terraform-test-bgp-sesh",
        plan: equinix.metal.Plan.C3SmallX86,
        metro: "ny",
        operatingSystem: equinix.metal.OperatingSystem.Ubuntu20_04,
        billingCycle: equinix.metal.BillingCycle.Hourly,
        projectId: projectId,
    });
    const birdConf = pulumi.all([addr.address, addr.cidr, test.network, test.network]).apply(([address, cidr, testNetwork, testNetwork1]) => `filter equinix_metal_bgp {
        if net = ${address}/${cidr} then accept;
    }
    router id ${testNetwork[2].address};
    protocol direct {
        interface "lo";
    }
    protocol kernel {
        scan time 10;
        persist;
        import all;
        export all;
    }
    protocol device {
        scan time 10;
    }
    protocol bgp {
        export filter equinix_metal_bgp;
        local as 65000;
        neighbor ${testNetwork1[2].gateway} as 65530;
        password "${bgpPassword}";
    }
    `);
    const testBgpSession = new equinix.metal.BgpSession("testBgpSession", {
        deviceId: test.id,
        addressFamily: "ipv4",
    });
    const configureBird = new _null.Resource("configureBird", {triggers: {
        bird_conf: birdConf,
        "interface": interfaceLo0,
    }});
    
      # you need to enable BGP config for the project. If you decide to create new
      # project, you can use the bgp_config section to enable BGP.
      # resource "equinix_metal_project" "test" {
      #   name = "testpro"
      #   bgp_config {
      #      deployment_type = "local"
      #      md5 = local.bgp_password
      #      asn = 65000
      #   }
      # }
      addr:
        type: equinix:metal:ReservedIpBlock
        properties:
          projectId: ${projectId}
          metro: ny
          quantity: 1
      test:
        type: equinix:metal:Device
        properties:
          hostname: terraform-test-bgp-sesh
          plan: c3.small.x86
          metro: ny
          operatingSystem: ubuntu_20_04
          billingCycle: hourly
          projectId: ${projectId}
      testBgpSession:
        type: equinix:metal:BgpSession
        name: test
        properties:
          deviceId: ${test.id}
          addressFamily: ipv4
      configureBird:
        type: null:Resource
        name: configure_bird
        properties:
          triggers:
            bird_conf: ${birdConf}
            interface: ${interfaceLo0}
    variables:
      bgpPassword: 955dB0b81Ef
      projectId: <UUID_of_your_project>
      interfaceLo0: |
        auto lo:0
        iface lo:0 inet static
           address ${addr.address}
           netmask ${addr.netmask}    
      birdConf: |
        filter equinix_metal_bgp {
            if net = ${addr.address}/${addr.cidr} then accept;
        }
        router id ${test.network[2].address};
        protocol direct {
            interface "lo";
        }
        protocol kernel {
            scan time 10;
            persist;
            import all;
            export all;
        }
        protocol device {
            scan time 10;
        }
        protocol bgp {
            export filter equinix_metal_bgp;
            local as 65000;
            neighbor ${test.network[2].gateway} as 65530;
            password "${bgpPassword}";
        }    
    

    Create BgpSession Resource

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

    Constructor syntax

    new BgpSession(name: string, args: BgpSessionArgs, opts?: CustomResourceOptions);
    @overload
    def BgpSession(resource_name: str,
                   args: BgpSessionArgs,
                   opts: Optional[ResourceOptions] = None)
    
    @overload
    def BgpSession(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   address_family: Optional[str] = None,
                   device_id: Optional[str] = None,
                   default_route: Optional[bool] = None)
    func NewBgpSession(ctx *Context, name string, args BgpSessionArgs, opts ...ResourceOption) (*BgpSession, error)
    public BgpSession(string name, BgpSessionArgs args, CustomResourceOptions? opts = null)
    public BgpSession(String name, BgpSessionArgs args)
    public BgpSession(String name, BgpSessionArgs args, CustomResourceOptions options)
    
    type: equinix:metal:BgpSession
    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 BgpSessionArgs
    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 BgpSessionArgs
    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 BgpSessionArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args BgpSessionArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args BgpSessionArgs
    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 bgpSessionResource = new Equinix.Metal.BgpSession("bgpSessionResource", new()
    {
        AddressFamily = "string",
        DeviceId = "string",
        DefaultRoute = false,
    });
    
    example, err := metal.NewBgpSession(ctx, "bgpSessionResource", &metal.BgpSessionArgs{
    	AddressFamily: pulumi.String("string"),
    	DeviceId:      pulumi.String("string"),
    	DefaultRoute:  pulumi.Bool(false),
    })
    
    var bgpSessionResource = new BgpSession("bgpSessionResource", BgpSessionArgs.builder()
        .addressFamily("string")
        .deviceId("string")
        .defaultRoute(false)
        .build());
    
    bgp_session_resource = equinix.metal.BgpSession("bgpSessionResource",
        address_family="string",
        device_id="string",
        default_route=False)
    
    const bgpSessionResource = new equinix.metal.BgpSession("bgpSessionResource", {
        addressFamily: "string",
        deviceId: "string",
        defaultRoute: false,
    });
    
    type: equinix:metal:BgpSession
    properties:
        addressFamily: string
        defaultRoute: false
        deviceId: string
    

    BgpSession Resource Properties

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

    Inputs

    The BgpSession resource accepts the following input properties:

    AddressFamily string
    ipv4 or ipv6.
    DeviceId string
    ID of device.
    DefaultRoute bool
    Boolean flag to set the default route policy. False by default.
    AddressFamily string
    ipv4 or ipv6.
    DeviceId string
    ID of device.
    DefaultRoute bool
    Boolean flag to set the default route policy. False by default.
    addressFamily String
    ipv4 or ipv6.
    deviceId String
    ID of device.
    defaultRoute Boolean
    Boolean flag to set the default route policy. False by default.
    addressFamily string
    ipv4 or ipv6.
    deviceId string
    ID of device.
    defaultRoute boolean
    Boolean flag to set the default route policy. False by default.
    address_family str
    ipv4 or ipv6.
    device_id str
    ID of device.
    default_route bool
    Boolean flag to set the default route policy. False by default.
    addressFamily String
    ipv4 or ipv6.
    deviceId String
    ID of device.
    defaultRoute Boolean
    Boolean flag to set the default route policy. False by default.

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    Status string
    Status of the session - up or down
    Id string
    The provider-assigned unique ID for this managed resource.
    Status string
    Status of the session - up or down
    id String
    The provider-assigned unique ID for this managed resource.
    status String
    Status of the session - up or down
    id string
    The provider-assigned unique ID for this managed resource.
    status string
    Status of the session - up or down
    id str
    The provider-assigned unique ID for this managed resource.
    status str
    Status of the session - up or down
    id String
    The provider-assigned unique ID for this managed resource.
    status String
    Status of the session - up or down

    Look up Existing BgpSession Resource

    Get an existing BgpSession 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?: BgpSessionState, opts?: CustomResourceOptions): BgpSession
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            address_family: Optional[str] = None,
            default_route: Optional[bool] = None,
            device_id: Optional[str] = None,
            status: Optional[str] = None) -> BgpSession
    func GetBgpSession(ctx *Context, name string, id IDInput, state *BgpSessionState, opts ...ResourceOption) (*BgpSession, error)
    public static BgpSession Get(string name, Input<string> id, BgpSessionState? state, CustomResourceOptions? opts = null)
    public static BgpSession get(String name, Output<String> id, BgpSessionState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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:
    AddressFamily string
    ipv4 or ipv6.
    DefaultRoute bool
    Boolean flag to set the default route policy. False by default.
    DeviceId string
    ID of device.
    Status string
    Status of the session - up or down
    AddressFamily string
    ipv4 or ipv6.
    DefaultRoute bool
    Boolean flag to set the default route policy. False by default.
    DeviceId string
    ID of device.
    Status string
    Status of the session - up or down
    addressFamily String
    ipv4 or ipv6.
    defaultRoute Boolean
    Boolean flag to set the default route policy. False by default.
    deviceId String
    ID of device.
    status String
    Status of the session - up or down
    addressFamily string
    ipv4 or ipv6.
    defaultRoute boolean
    Boolean flag to set the default route policy. False by default.
    deviceId string
    ID of device.
    status string
    Status of the session - up or down
    address_family str
    ipv4 or ipv6.
    default_route bool
    Boolean flag to set the default route policy. False by default.
    device_id str
    ID of device.
    status str
    Status of the session - up or down
    addressFamily String
    ipv4 or ipv6.
    defaultRoute Boolean
    Boolean flag to set the default route policy. False by default.
    deviceId String
    ID of device.
    status String
    Status of the session - up or down

    Package Details

    Repository
    equinix equinix/pulumi-equinix
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the equinix Terraform Provider.
    equinix logo
    Equinix v0.13.0 published on Monday, Jul 22, 2024 by Equinix