1. Packages
  2. Scaleway
  3. API Docs
  4. getVpcPublicGatewayDhcpReservation
Scaleway v1.15.0 published on Tuesday, Jul 30, 2024 by pulumiverse

scaleway.getVpcPublicGatewayDhcpReservation

Explore with Pulumi AI

scaleway logo
Scaleway v1.15.0 published on Tuesday, Jul 30, 2024 by pulumiverse

    Gets information about a DHCP entry. For further information, please see the API documentation/

    Example Dynamic

    import * as pulumi from "@pulumi/pulumi";
    import * as scaleway from "@pulumi/scaleway";
    import * as scaleway from "@pulumiverse/scaleway";
    
    const mainVpcPrivateNetwork = new scaleway.VpcPrivateNetwork("mainVpcPrivateNetwork", {});
    const mainInstanceServer = new scaleway.InstanceServer("mainInstanceServer", {
        image: "ubuntu_jammy",
        type: "DEV1-S",
        zone: "fr-par-1",
    });
    const mainInstancePrivateNic = new scaleway.InstancePrivateNic("mainInstancePrivateNic", {
        serverId: mainInstanceServer.id,
        privateNetworkId: mainVpcPrivateNetwork.id,
    });
    const mainVpcPublicGatewayIp = new scaleway.VpcPublicGatewayIp("mainVpcPublicGatewayIp", {});
    const mainVpcPublicGatewayDhcp = new scaleway.VpcPublicGatewayDhcp("mainVpcPublicGatewayDhcp", {subnet: "192.168.1.0/24"});
    const mainVpcPublicGateway = new scaleway.VpcPublicGateway("mainVpcPublicGateway", {
        type: "VPC-GW-S",
        ipId: mainVpcPublicGatewayIp.id,
    });
    const mainVpcGatewayNetwork = new scaleway.VpcGatewayNetwork("mainVpcGatewayNetwork", {
        gatewayId: mainVpcPublicGateway.id,
        privateNetworkId: mainVpcPrivateNetwork.id,
        dhcpId: mainVpcPublicGatewayDhcp.id,
        cleanupDhcp: true,
        enableMasquerade: true,
    });
    //# Retrieve the dynamic entries generated by mac address & gateway network
    const byMacAddressAndGwNetwork = scaleway.getVpcPublicGatewayDhcpReservationOutput({
        macAddress: mainInstancePrivateNic.macAddress,
        gatewayNetworkId: mainVpcGatewayNetwork.id,
    });
    
    import pulumi
    import pulumi_scaleway as scaleway
    import pulumiverse_scaleway as scaleway
    
    main_vpc_private_network = scaleway.VpcPrivateNetwork("mainVpcPrivateNetwork")
    main_instance_server = scaleway.InstanceServer("mainInstanceServer",
        image="ubuntu_jammy",
        type="DEV1-S",
        zone="fr-par-1")
    main_instance_private_nic = scaleway.InstancePrivateNic("mainInstancePrivateNic",
        server_id=main_instance_server.id,
        private_network_id=main_vpc_private_network.id)
    main_vpc_public_gateway_ip = scaleway.VpcPublicGatewayIp("mainVpcPublicGatewayIp")
    main_vpc_public_gateway_dhcp = scaleway.VpcPublicGatewayDhcp("mainVpcPublicGatewayDhcp", subnet="192.168.1.0/24")
    main_vpc_public_gateway = scaleway.VpcPublicGateway("mainVpcPublicGateway",
        type="VPC-GW-S",
        ip_id=main_vpc_public_gateway_ip.id)
    main_vpc_gateway_network = scaleway.VpcGatewayNetwork("mainVpcGatewayNetwork",
        gateway_id=main_vpc_public_gateway.id,
        private_network_id=main_vpc_private_network.id,
        dhcp_id=main_vpc_public_gateway_dhcp.id,
        cleanup_dhcp=True,
        enable_masquerade=True)
    ## Retrieve the dynamic entries generated by mac address & gateway network
    by_mac_address_and_gw_network = scaleway.get_vpc_public_gateway_dhcp_reservation_output(mac_address=main_instance_private_nic.mac_address,
        gateway_network_id=main_vpc_gateway_network.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumiverse/pulumi-scaleway/sdk/go/scaleway"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		mainVpcPrivateNetwork, err := scaleway.NewVpcPrivateNetwork(ctx, "mainVpcPrivateNetwork", nil)
    		if err != nil {
    			return err
    		}
    		mainInstanceServer, err := scaleway.NewInstanceServer(ctx, "mainInstanceServer", &scaleway.InstanceServerArgs{
    			Image: pulumi.String("ubuntu_jammy"),
    			Type:  pulumi.String("DEV1-S"),
    			Zone:  pulumi.String("fr-par-1"),
    		})
    		if err != nil {
    			return err
    		}
    		mainInstancePrivateNic, err := scaleway.NewInstancePrivateNic(ctx, "mainInstancePrivateNic", &scaleway.InstancePrivateNicArgs{
    			ServerId:         mainInstanceServer.ID(),
    			PrivateNetworkId: mainVpcPrivateNetwork.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		mainVpcPublicGatewayIp, err := scaleway.NewVpcPublicGatewayIp(ctx, "mainVpcPublicGatewayIp", nil)
    		if err != nil {
    			return err
    		}
    		mainVpcPublicGatewayDhcp, err := scaleway.NewVpcPublicGatewayDhcp(ctx, "mainVpcPublicGatewayDhcp", &scaleway.VpcPublicGatewayDhcpArgs{
    			Subnet: pulumi.String("192.168.1.0/24"),
    		})
    		if err != nil {
    			return err
    		}
    		mainVpcPublicGateway, err := scaleway.NewVpcPublicGateway(ctx, "mainVpcPublicGateway", &scaleway.VpcPublicGatewayArgs{
    			Type: pulumi.String("VPC-GW-S"),
    			IpId: mainVpcPublicGatewayIp.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		mainVpcGatewayNetwork, err := scaleway.NewVpcGatewayNetwork(ctx, "mainVpcGatewayNetwork", &scaleway.VpcGatewayNetworkArgs{
    			GatewayId:        mainVpcPublicGateway.ID(),
    			PrivateNetworkId: mainVpcPrivateNetwork.ID(),
    			DhcpId:           mainVpcPublicGatewayDhcp.ID(),
    			CleanupDhcp:      pulumi.Bool(true),
    			EnableMasquerade: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		_ = scaleway.LookupVpcPublicGatewayDhcpReservationOutput(ctx, scaleway.GetVpcPublicGatewayDhcpReservationOutputArgs{
    			MacAddress:       mainInstancePrivateNic.MacAddress,
    			GatewayNetworkId: mainVpcGatewayNetwork.ID(),
    		}, nil)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Scaleway = Pulumi.Scaleway;
    using Scaleway = Pulumiverse.Scaleway;
    
    return await Deployment.RunAsync(() => 
    {
        var mainVpcPrivateNetwork = new Scaleway.VpcPrivateNetwork("mainVpcPrivateNetwork");
    
        var mainInstanceServer = new Scaleway.InstanceServer("mainInstanceServer", new()
        {
            Image = "ubuntu_jammy",
            Type = "DEV1-S",
            Zone = "fr-par-1",
        });
    
        var mainInstancePrivateNic = new Scaleway.InstancePrivateNic("mainInstancePrivateNic", new()
        {
            ServerId = mainInstanceServer.Id,
            PrivateNetworkId = mainVpcPrivateNetwork.Id,
        });
    
        var mainVpcPublicGatewayIp = new Scaleway.VpcPublicGatewayIp("mainVpcPublicGatewayIp");
    
        var mainVpcPublicGatewayDhcp = new Scaleway.VpcPublicGatewayDhcp("mainVpcPublicGatewayDhcp", new()
        {
            Subnet = "192.168.1.0/24",
        });
    
        var mainVpcPublicGateway = new Scaleway.VpcPublicGateway("mainVpcPublicGateway", new()
        {
            Type = "VPC-GW-S",
            IpId = mainVpcPublicGatewayIp.Id,
        });
    
        var mainVpcGatewayNetwork = new Scaleway.VpcGatewayNetwork("mainVpcGatewayNetwork", new()
        {
            GatewayId = mainVpcPublicGateway.Id,
            PrivateNetworkId = mainVpcPrivateNetwork.Id,
            DhcpId = mainVpcPublicGatewayDhcp.Id,
            CleanupDhcp = true,
            EnableMasquerade = true,
        });
    
        //# Retrieve the dynamic entries generated by mac address & gateway network
        var byMacAddressAndGwNetwork = Scaleway.GetVpcPublicGatewayDhcpReservation.Invoke(new()
        {
            MacAddress = mainInstancePrivateNic.MacAddress,
            GatewayNetworkId = mainVpcGatewayNetwork.Id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.scaleway.VpcPrivateNetwork;
    import com.pulumi.scaleway.InstanceServer;
    import com.pulumi.scaleway.InstanceServerArgs;
    import com.pulumi.scaleway.InstancePrivateNic;
    import com.pulumi.scaleway.InstancePrivateNicArgs;
    import com.pulumi.scaleway.VpcPublicGatewayIp;
    import com.pulumi.scaleway.VpcPublicGatewayDhcp;
    import com.pulumi.scaleway.VpcPublicGatewayDhcpArgs;
    import com.pulumi.scaleway.VpcPublicGateway;
    import com.pulumi.scaleway.VpcPublicGatewayArgs;
    import com.pulumi.scaleway.VpcGatewayNetwork;
    import com.pulumi.scaleway.VpcGatewayNetworkArgs;
    import com.pulumi.scaleway.ScalewayFunctions;
    import com.pulumi.scaleway.inputs.GetVpcPublicGatewayDhcpReservationArgs;
    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 mainVpcPrivateNetwork = new VpcPrivateNetwork("mainVpcPrivateNetwork");
    
            var mainInstanceServer = new InstanceServer("mainInstanceServer", InstanceServerArgs.builder()
                .image("ubuntu_jammy")
                .type("DEV1-S")
                .zone("fr-par-1")
                .build());
    
            var mainInstancePrivateNic = new InstancePrivateNic("mainInstancePrivateNic", InstancePrivateNicArgs.builder()
                .serverId(mainInstanceServer.id())
                .privateNetworkId(mainVpcPrivateNetwork.id())
                .build());
    
            var mainVpcPublicGatewayIp = new VpcPublicGatewayIp("mainVpcPublicGatewayIp");
    
            var mainVpcPublicGatewayDhcp = new VpcPublicGatewayDhcp("mainVpcPublicGatewayDhcp", VpcPublicGatewayDhcpArgs.builder()
                .subnet("192.168.1.0/24")
                .build());
    
            var mainVpcPublicGateway = new VpcPublicGateway("mainVpcPublicGateway", VpcPublicGatewayArgs.builder()
                .type("VPC-GW-S")
                .ipId(mainVpcPublicGatewayIp.id())
                .build());
    
            var mainVpcGatewayNetwork = new VpcGatewayNetwork("mainVpcGatewayNetwork", VpcGatewayNetworkArgs.builder()
                .gatewayId(mainVpcPublicGateway.id())
                .privateNetworkId(mainVpcPrivateNetwork.id())
                .dhcpId(mainVpcPublicGatewayDhcp.id())
                .cleanupDhcp(true)
                .enableMasquerade(true)
                .build());
    
            //# Retrieve the dynamic entries generated by mac address & gateway network
            final var byMacAddressAndGwNetwork = ScalewayFunctions.getVpcPublicGatewayDhcpReservation(GetVpcPublicGatewayDhcpReservationArgs.builder()
                .macAddress(mainInstancePrivateNic.macAddress())
                .gatewayNetworkId(mainVpcGatewayNetwork.id())
                .build());
    
        }
    }
    
    resources:
      mainVpcPrivateNetwork:
        type: scaleway:VpcPrivateNetwork
      mainInstanceServer:
        type: scaleway:InstanceServer
        properties:
          image: ubuntu_jammy
          type: DEV1-S
          zone: fr-par-1
      mainInstancePrivateNic:
        type: scaleway:InstancePrivateNic
        properties:
          serverId: ${mainInstanceServer.id}
          privateNetworkId: ${mainVpcPrivateNetwork.id}
      mainVpcPublicGatewayIp:
        type: scaleway:VpcPublicGatewayIp
      mainVpcPublicGatewayDhcp:
        type: scaleway:VpcPublicGatewayDhcp
        properties:
          subnet: 192.168.1.0/24
      mainVpcPublicGateway:
        type: scaleway:VpcPublicGateway
        properties:
          type: VPC-GW-S
          ipId: ${mainVpcPublicGatewayIp.id}
      mainVpcGatewayNetwork: ## Retrieve the dynamic entries generated by mac address & gateway network
        type: scaleway:VpcGatewayNetwork
        properties:
          gatewayId: ${mainVpcPublicGateway.id}
          privateNetworkId: ${mainVpcPrivateNetwork.id}
          dhcpId: ${mainVpcPublicGatewayDhcp.id}
          cleanupDhcp: true
          enableMasquerade: true
    variables:
      byMacAddressAndGwNetwork:
        fn::invoke:
          Function: scaleway:getVpcPublicGatewayDhcpReservation
          Arguments:
            macAddress: ${mainInstancePrivateNic.macAddress}
            gatewayNetworkId: ${mainVpcGatewayNetwork.id}
    

    Example Static and PAT Rule

    import * as pulumi from "@pulumi/pulumi";
    import * as scaleway from "@pulumi/scaleway";
    import * as scaleway from "@pulumiverse/scaleway";
    
    const mainVpcPrivateNetwork = new scaleway.VpcPrivateNetwork("mainVpcPrivateNetwork", {});
    const mainInstanceSecurityGroup = new scaleway.InstanceSecurityGroup("mainInstanceSecurityGroup", {
        inboundDefaultPolicy: "drop",
        outboundDefaultPolicy: "accept",
        inboundRules: [{
            action: "accept",
            port: 22,
        }],
    });
    const mainInstanceServer = new scaleway.InstanceServer("mainInstanceServer", {
        image: "ubuntu_jammy",
        type: "DEV1-S",
        zone: "fr-par-1",
        securityGroupId: mainInstanceSecurityGroup.id,
    });
    const mainInstancePrivateNic = new scaleway.InstancePrivateNic("mainInstancePrivateNic", {
        serverId: mainInstanceServer.id,
        privateNetworkId: mainVpcPrivateNetwork.id,
    });
    const mainVpcPublicGatewayIp = new scaleway.VpcPublicGatewayIp("mainVpcPublicGatewayIp", {});
    const mainVpcPublicGatewayDhcp = new scaleway.VpcPublicGatewayDhcp("mainVpcPublicGatewayDhcp", {subnet: "192.168.1.0/24"});
    const mainVpcPublicGateway = new scaleway.VpcPublicGateway("mainVpcPublicGateway", {
        type: "VPC-GW-S",
        ipId: mainVpcPublicGatewayIp.id,
    });
    const mainVpcGatewayNetwork = new scaleway.VpcGatewayNetwork("mainVpcGatewayNetwork", {
        gatewayId: mainVpcPublicGateway.id,
        privateNetworkId: mainVpcPrivateNetwork.id,
        dhcpId: mainVpcPublicGatewayDhcp.id,
        cleanupDhcp: true,
        enableMasquerade: true,
    });
    const mainVpcPublicGatewayDhcpReservation = new scaleway.VpcPublicGatewayDhcpReservation("mainVpcPublicGatewayDhcpReservation", {
        gatewayNetworkId: mainVpcGatewayNetwork.id,
        macAddress: mainInstancePrivateNic.macAddress,
        ipAddress: "192.168.1.4",
    });
    //## VPC PAT RULE
    const mainVpcPublicGatewayPatRule = new scaleway.VpcPublicGatewayPatRule("mainVpcPublicGatewayPatRule", {
        gatewayId: mainVpcPublicGateway.id,
        privateIp: mainVpcPublicGatewayDhcpReservation.ipAddress,
        privatePort: 22,
        publicPort: 2222,
        protocol: "tcp",
    });
    const byId = scaleway.getVpcPublicGatewayDhcpReservationOutput({
        reservationId: mainVpcPublicGatewayDhcpReservation.id,
    });
    
    import pulumi
    import pulumi_scaleway as scaleway
    import pulumiverse_scaleway as scaleway
    
    main_vpc_private_network = scaleway.VpcPrivateNetwork("mainVpcPrivateNetwork")
    main_instance_security_group = scaleway.InstanceSecurityGroup("mainInstanceSecurityGroup",
        inbound_default_policy="drop",
        outbound_default_policy="accept",
        inbound_rules=[scaleway.InstanceSecurityGroupInboundRuleArgs(
            action="accept",
            port=22,
        )])
    main_instance_server = scaleway.InstanceServer("mainInstanceServer",
        image="ubuntu_jammy",
        type="DEV1-S",
        zone="fr-par-1",
        security_group_id=main_instance_security_group.id)
    main_instance_private_nic = scaleway.InstancePrivateNic("mainInstancePrivateNic",
        server_id=main_instance_server.id,
        private_network_id=main_vpc_private_network.id)
    main_vpc_public_gateway_ip = scaleway.VpcPublicGatewayIp("mainVpcPublicGatewayIp")
    main_vpc_public_gateway_dhcp = scaleway.VpcPublicGatewayDhcp("mainVpcPublicGatewayDhcp", subnet="192.168.1.0/24")
    main_vpc_public_gateway = scaleway.VpcPublicGateway("mainVpcPublicGateway",
        type="VPC-GW-S",
        ip_id=main_vpc_public_gateway_ip.id)
    main_vpc_gateway_network = scaleway.VpcGatewayNetwork("mainVpcGatewayNetwork",
        gateway_id=main_vpc_public_gateway.id,
        private_network_id=main_vpc_private_network.id,
        dhcp_id=main_vpc_public_gateway_dhcp.id,
        cleanup_dhcp=True,
        enable_masquerade=True)
    main_vpc_public_gateway_dhcp_reservation = scaleway.VpcPublicGatewayDhcpReservation("mainVpcPublicGatewayDhcpReservation",
        gateway_network_id=main_vpc_gateway_network.id,
        mac_address=main_instance_private_nic.mac_address,
        ip_address="192.168.1.4")
    ### VPC PAT RULE
    main_vpc_public_gateway_pat_rule = scaleway.VpcPublicGatewayPatRule("mainVpcPublicGatewayPatRule",
        gateway_id=main_vpc_public_gateway.id,
        private_ip=main_vpc_public_gateway_dhcp_reservation.ip_address,
        private_port=22,
        public_port=2222,
        protocol="tcp")
    by_id = scaleway.get_vpc_public_gateway_dhcp_reservation_output(reservation_id=main_vpc_public_gateway_dhcp_reservation.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumiverse/pulumi-scaleway/sdk/go/scaleway"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		mainVpcPrivateNetwork, err := scaleway.NewVpcPrivateNetwork(ctx, "mainVpcPrivateNetwork", nil)
    		if err != nil {
    			return err
    		}
    		mainInstanceSecurityGroup, err := scaleway.NewInstanceSecurityGroup(ctx, "mainInstanceSecurityGroup", &scaleway.InstanceSecurityGroupArgs{
    			InboundDefaultPolicy:  pulumi.String("drop"),
    			OutboundDefaultPolicy: pulumi.String("accept"),
    			InboundRules: scaleway.InstanceSecurityGroupInboundRuleArray{
    				&scaleway.InstanceSecurityGroupInboundRuleArgs{
    					Action: pulumi.String("accept"),
    					Port:   pulumi.Int(22),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		mainInstanceServer, err := scaleway.NewInstanceServer(ctx, "mainInstanceServer", &scaleway.InstanceServerArgs{
    			Image:           pulumi.String("ubuntu_jammy"),
    			Type:            pulumi.String("DEV1-S"),
    			Zone:            pulumi.String("fr-par-1"),
    			SecurityGroupId: mainInstanceSecurityGroup.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		mainInstancePrivateNic, err := scaleway.NewInstancePrivateNic(ctx, "mainInstancePrivateNic", &scaleway.InstancePrivateNicArgs{
    			ServerId:         mainInstanceServer.ID(),
    			PrivateNetworkId: mainVpcPrivateNetwork.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		mainVpcPublicGatewayIp, err := scaleway.NewVpcPublicGatewayIp(ctx, "mainVpcPublicGatewayIp", nil)
    		if err != nil {
    			return err
    		}
    		mainVpcPublicGatewayDhcp, err := scaleway.NewVpcPublicGatewayDhcp(ctx, "mainVpcPublicGatewayDhcp", &scaleway.VpcPublicGatewayDhcpArgs{
    			Subnet: pulumi.String("192.168.1.0/24"),
    		})
    		if err != nil {
    			return err
    		}
    		mainVpcPublicGateway, err := scaleway.NewVpcPublicGateway(ctx, "mainVpcPublicGateway", &scaleway.VpcPublicGatewayArgs{
    			Type: pulumi.String("VPC-GW-S"),
    			IpId: mainVpcPublicGatewayIp.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		mainVpcGatewayNetwork, err := scaleway.NewVpcGatewayNetwork(ctx, "mainVpcGatewayNetwork", &scaleway.VpcGatewayNetworkArgs{
    			GatewayId:        mainVpcPublicGateway.ID(),
    			PrivateNetworkId: mainVpcPrivateNetwork.ID(),
    			DhcpId:           mainVpcPublicGatewayDhcp.ID(),
    			CleanupDhcp:      pulumi.Bool(true),
    			EnableMasquerade: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		mainVpcPublicGatewayDhcpReservation, err := scaleway.NewVpcPublicGatewayDhcpReservation(ctx, "mainVpcPublicGatewayDhcpReservation", &scaleway.VpcPublicGatewayDhcpReservationArgs{
    			GatewayNetworkId: mainVpcGatewayNetwork.ID(),
    			MacAddress:       mainInstancePrivateNic.MacAddress,
    			IpAddress:        pulumi.String("192.168.1.4"),
    		})
    		if err != nil {
    			return err
    		}
    		// ## VPC PAT RULE
    		_, err = scaleway.NewVpcPublicGatewayPatRule(ctx, "mainVpcPublicGatewayPatRule", &scaleway.VpcPublicGatewayPatRuleArgs{
    			GatewayId:   mainVpcPublicGateway.ID(),
    			PrivateIp:   mainVpcPublicGatewayDhcpReservation.IpAddress,
    			PrivatePort: pulumi.Int(22),
    			PublicPort:  pulumi.Int(2222),
    			Protocol:    pulumi.String("tcp"),
    		})
    		if err != nil {
    			return err
    		}
    		_ = scaleway.LookupVpcPublicGatewayDhcpReservationOutput(ctx, scaleway.GetVpcPublicGatewayDhcpReservationOutputArgs{
    			ReservationId: mainVpcPublicGatewayDhcpReservation.ID(),
    		}, nil)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Scaleway = Pulumi.Scaleway;
    using Scaleway = Pulumiverse.Scaleway;
    
    return await Deployment.RunAsync(() => 
    {
        var mainVpcPrivateNetwork = new Scaleway.VpcPrivateNetwork("mainVpcPrivateNetwork");
    
        var mainInstanceSecurityGroup = new Scaleway.InstanceSecurityGroup("mainInstanceSecurityGroup", new()
        {
            InboundDefaultPolicy = "drop",
            OutboundDefaultPolicy = "accept",
            InboundRules = new[]
            {
                new Scaleway.Inputs.InstanceSecurityGroupInboundRuleArgs
                {
                    Action = "accept",
                    Port = 22,
                },
            },
        });
    
        var mainInstanceServer = new Scaleway.InstanceServer("mainInstanceServer", new()
        {
            Image = "ubuntu_jammy",
            Type = "DEV1-S",
            Zone = "fr-par-1",
            SecurityGroupId = mainInstanceSecurityGroup.Id,
        });
    
        var mainInstancePrivateNic = new Scaleway.InstancePrivateNic("mainInstancePrivateNic", new()
        {
            ServerId = mainInstanceServer.Id,
            PrivateNetworkId = mainVpcPrivateNetwork.Id,
        });
    
        var mainVpcPublicGatewayIp = new Scaleway.VpcPublicGatewayIp("mainVpcPublicGatewayIp");
    
        var mainVpcPublicGatewayDhcp = new Scaleway.VpcPublicGatewayDhcp("mainVpcPublicGatewayDhcp", new()
        {
            Subnet = "192.168.1.0/24",
        });
    
        var mainVpcPublicGateway = new Scaleway.VpcPublicGateway("mainVpcPublicGateway", new()
        {
            Type = "VPC-GW-S",
            IpId = mainVpcPublicGatewayIp.Id,
        });
    
        var mainVpcGatewayNetwork = new Scaleway.VpcGatewayNetwork("mainVpcGatewayNetwork", new()
        {
            GatewayId = mainVpcPublicGateway.Id,
            PrivateNetworkId = mainVpcPrivateNetwork.Id,
            DhcpId = mainVpcPublicGatewayDhcp.Id,
            CleanupDhcp = true,
            EnableMasquerade = true,
        });
    
        var mainVpcPublicGatewayDhcpReservation = new Scaleway.VpcPublicGatewayDhcpReservation("mainVpcPublicGatewayDhcpReservation", new()
        {
            GatewayNetworkId = mainVpcGatewayNetwork.Id,
            MacAddress = mainInstancePrivateNic.MacAddress,
            IpAddress = "192.168.1.4",
        });
    
        //## VPC PAT RULE
        var mainVpcPublicGatewayPatRule = new Scaleway.VpcPublicGatewayPatRule("mainVpcPublicGatewayPatRule", new()
        {
            GatewayId = mainVpcPublicGateway.Id,
            PrivateIp = mainVpcPublicGatewayDhcpReservation.IpAddress,
            PrivatePort = 22,
            PublicPort = 2222,
            Protocol = "tcp",
        });
    
        var byId = Scaleway.GetVpcPublicGatewayDhcpReservation.Invoke(new()
        {
            ReservationId = mainVpcPublicGatewayDhcpReservation.Id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.scaleway.VpcPrivateNetwork;
    import com.pulumi.scaleway.InstanceSecurityGroup;
    import com.pulumi.scaleway.InstanceSecurityGroupArgs;
    import com.pulumi.scaleway.inputs.InstanceSecurityGroupInboundRuleArgs;
    import com.pulumi.scaleway.InstanceServer;
    import com.pulumi.scaleway.InstanceServerArgs;
    import com.pulumi.scaleway.InstancePrivateNic;
    import com.pulumi.scaleway.InstancePrivateNicArgs;
    import com.pulumi.scaleway.VpcPublicGatewayIp;
    import com.pulumi.scaleway.VpcPublicGatewayDhcp;
    import com.pulumi.scaleway.VpcPublicGatewayDhcpArgs;
    import com.pulumi.scaleway.VpcPublicGateway;
    import com.pulumi.scaleway.VpcPublicGatewayArgs;
    import com.pulumi.scaleway.VpcGatewayNetwork;
    import com.pulumi.scaleway.VpcGatewayNetworkArgs;
    import com.pulumi.scaleway.VpcPublicGatewayDhcpReservation;
    import com.pulumi.scaleway.VpcPublicGatewayDhcpReservationArgs;
    import com.pulumi.scaleway.VpcPublicGatewayPatRule;
    import com.pulumi.scaleway.VpcPublicGatewayPatRuleArgs;
    import com.pulumi.scaleway.ScalewayFunctions;
    import com.pulumi.scaleway.inputs.GetVpcPublicGatewayDhcpReservationArgs;
    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 mainVpcPrivateNetwork = new VpcPrivateNetwork("mainVpcPrivateNetwork");
    
            var mainInstanceSecurityGroup = new InstanceSecurityGroup("mainInstanceSecurityGroup", InstanceSecurityGroupArgs.builder()
                .inboundDefaultPolicy("drop")
                .outboundDefaultPolicy("accept")
                .inboundRules(InstanceSecurityGroupInboundRuleArgs.builder()
                    .action("accept")
                    .port("22")
                    .build())
                .build());
    
            var mainInstanceServer = new InstanceServer("mainInstanceServer", InstanceServerArgs.builder()
                .image("ubuntu_jammy")
                .type("DEV1-S")
                .zone("fr-par-1")
                .securityGroupId(mainInstanceSecurityGroup.id())
                .build());
    
            var mainInstancePrivateNic = new InstancePrivateNic("mainInstancePrivateNic", InstancePrivateNicArgs.builder()
                .serverId(mainInstanceServer.id())
                .privateNetworkId(mainVpcPrivateNetwork.id())
                .build());
    
            var mainVpcPublicGatewayIp = new VpcPublicGatewayIp("mainVpcPublicGatewayIp");
    
            var mainVpcPublicGatewayDhcp = new VpcPublicGatewayDhcp("mainVpcPublicGatewayDhcp", VpcPublicGatewayDhcpArgs.builder()
                .subnet("192.168.1.0/24")
                .build());
    
            var mainVpcPublicGateway = new VpcPublicGateway("mainVpcPublicGateway", VpcPublicGatewayArgs.builder()
                .type("VPC-GW-S")
                .ipId(mainVpcPublicGatewayIp.id())
                .build());
    
            var mainVpcGatewayNetwork = new VpcGatewayNetwork("mainVpcGatewayNetwork", VpcGatewayNetworkArgs.builder()
                .gatewayId(mainVpcPublicGateway.id())
                .privateNetworkId(mainVpcPrivateNetwork.id())
                .dhcpId(mainVpcPublicGatewayDhcp.id())
                .cleanupDhcp(true)
                .enableMasquerade(true)
                .build());
    
            var mainVpcPublicGatewayDhcpReservation = new VpcPublicGatewayDhcpReservation("mainVpcPublicGatewayDhcpReservation", VpcPublicGatewayDhcpReservationArgs.builder()
                .gatewayNetworkId(mainVpcGatewayNetwork.id())
                .macAddress(mainInstancePrivateNic.macAddress())
                .ipAddress("192.168.1.4")
                .build());
    
            //## VPC PAT RULE
            var mainVpcPublicGatewayPatRule = new VpcPublicGatewayPatRule("mainVpcPublicGatewayPatRule", VpcPublicGatewayPatRuleArgs.builder()
                .gatewayId(mainVpcPublicGateway.id())
                .privateIp(mainVpcPublicGatewayDhcpReservation.ipAddress())
                .privatePort(22)
                .publicPort(2222)
                .protocol("tcp")
                .build());
    
            final var byId = ScalewayFunctions.getVpcPublicGatewayDhcpReservation(GetVpcPublicGatewayDhcpReservationArgs.builder()
                .reservationId(mainVpcPublicGatewayDhcpReservation.id())
                .build());
    
        }
    }
    
    resources:
      mainVpcPrivateNetwork:
        type: scaleway:VpcPrivateNetwork
      mainInstanceSecurityGroup:
        type: scaleway:InstanceSecurityGroup
        properties:
          inboundDefaultPolicy: drop
          outboundDefaultPolicy: accept
          inboundRules:
            - action: accept
              port: '22'
      mainInstanceServer:
        type: scaleway:InstanceServer
        properties:
          image: ubuntu_jammy
          type: DEV1-S
          zone: fr-par-1
          securityGroupId: ${mainInstanceSecurityGroup.id}
      mainInstancePrivateNic:
        type: scaleway:InstancePrivateNic
        properties:
          serverId: ${mainInstanceServer.id}
          privateNetworkId: ${mainVpcPrivateNetwork.id}
      mainVpcPublicGatewayIp:
        type: scaleway:VpcPublicGatewayIp
      mainVpcPublicGatewayDhcp:
        type: scaleway:VpcPublicGatewayDhcp
        properties:
          subnet: 192.168.1.0/24
      mainVpcPublicGateway:
        type: scaleway:VpcPublicGateway
        properties:
          type: VPC-GW-S
          ipId: ${mainVpcPublicGatewayIp.id}
      mainVpcGatewayNetwork:
        type: scaleway:VpcGatewayNetwork
        properties:
          gatewayId: ${mainVpcPublicGateway.id}
          privateNetworkId: ${mainVpcPrivateNetwork.id}
          dhcpId: ${mainVpcPublicGatewayDhcp.id}
          cleanupDhcp: true
          enableMasquerade: true
      mainVpcPublicGatewayDhcpReservation:
        type: scaleway:VpcPublicGatewayDhcpReservation
        properties:
          gatewayNetworkId: ${mainVpcGatewayNetwork.id}
          macAddress: ${mainInstancePrivateNic.macAddress}
          ipAddress: 192.168.1.4
      ### VPC PAT RULE
      mainVpcPublicGatewayPatRule:
        type: scaleway:VpcPublicGatewayPatRule
        properties:
          gatewayId: ${mainVpcPublicGateway.id}
          privateIp: ${mainVpcPublicGatewayDhcpReservation.ipAddress}
          privatePort: 22
          publicPort: 2222
          protocol: tcp
    variables:
      byId:
        fn::invoke:
          Function: scaleway:getVpcPublicGatewayDhcpReservation
          Arguments:
            reservationId: ${mainVpcPublicGatewayDhcpReservation.id}
    

    Using getVpcPublicGatewayDhcpReservation

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getVpcPublicGatewayDhcpReservation(args: GetVpcPublicGatewayDhcpReservationArgs, opts?: InvokeOptions): Promise<GetVpcPublicGatewayDhcpReservationResult>
    function getVpcPublicGatewayDhcpReservationOutput(args: GetVpcPublicGatewayDhcpReservationOutputArgs, opts?: InvokeOptions): Output<GetVpcPublicGatewayDhcpReservationResult>
    def get_vpc_public_gateway_dhcp_reservation(gateway_network_id: Optional[str] = None,
                                                mac_address: Optional[str] = None,
                                                reservation_id: Optional[str] = None,
                                                wait_for_dhcp: Optional[bool] = None,
                                                zone: Optional[str] = None,
                                                opts: Optional[InvokeOptions] = None) -> GetVpcPublicGatewayDhcpReservationResult
    def get_vpc_public_gateway_dhcp_reservation_output(gateway_network_id: Optional[pulumi.Input[str]] = None,
                                                mac_address: Optional[pulumi.Input[str]] = None,
                                                reservation_id: Optional[pulumi.Input[str]] = None,
                                                wait_for_dhcp: Optional[pulumi.Input[bool]] = None,
                                                zone: Optional[pulumi.Input[str]] = None,
                                                opts: Optional[InvokeOptions] = None) -> Output[GetVpcPublicGatewayDhcpReservationResult]
    func LookupVpcPublicGatewayDhcpReservation(ctx *Context, args *LookupVpcPublicGatewayDhcpReservationArgs, opts ...InvokeOption) (*LookupVpcPublicGatewayDhcpReservationResult, error)
    func LookupVpcPublicGatewayDhcpReservationOutput(ctx *Context, args *LookupVpcPublicGatewayDhcpReservationOutputArgs, opts ...InvokeOption) LookupVpcPublicGatewayDhcpReservationResultOutput

    > Note: This function is named LookupVpcPublicGatewayDhcpReservation in the Go SDK.

    public static class GetVpcPublicGatewayDhcpReservation 
    {
        public static Task<GetVpcPublicGatewayDhcpReservationResult> InvokeAsync(GetVpcPublicGatewayDhcpReservationArgs args, InvokeOptions? opts = null)
        public static Output<GetVpcPublicGatewayDhcpReservationResult> Invoke(GetVpcPublicGatewayDhcpReservationInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetVpcPublicGatewayDhcpReservationResult> getVpcPublicGatewayDhcpReservation(GetVpcPublicGatewayDhcpReservationArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: scaleway:index/getVpcPublicGatewayDhcpReservation:getVpcPublicGatewayDhcpReservation
      arguments:
        # arguments dictionary

    The following arguments are supported:

    GatewayNetworkId string

    The ID of the owning GatewayNetwork.

    Only one of reservation_id or mac_address with gateway_network_id should be specified.

    MacAddress string
    The MAC address of the reservation to retrieve.
    ReservationId string
    The ID of the reservation (DHCP entry) to retrieve.
    WaitForDhcp bool
    Whether to wait for mac_address to exist in DHCP.
    Zone string
    zone). The zone in which the reservation exists.
    GatewayNetworkId string

    The ID of the owning GatewayNetwork.

    Only one of reservation_id or mac_address with gateway_network_id should be specified.

    MacAddress string
    The MAC address of the reservation to retrieve.
    ReservationId string
    The ID of the reservation (DHCP entry) to retrieve.
    WaitForDhcp bool
    Whether to wait for mac_address to exist in DHCP.
    Zone string
    zone). The zone in which the reservation exists.
    gatewayNetworkId String

    The ID of the owning GatewayNetwork.

    Only one of reservation_id or mac_address with gateway_network_id should be specified.

    macAddress String
    The MAC address of the reservation to retrieve.
    reservationId String
    The ID of the reservation (DHCP entry) to retrieve.
    waitForDhcp Boolean
    Whether to wait for mac_address to exist in DHCP.
    zone String
    zone). The zone in which the reservation exists.
    gatewayNetworkId string

    The ID of the owning GatewayNetwork.

    Only one of reservation_id or mac_address with gateway_network_id should be specified.

    macAddress string
    The MAC address of the reservation to retrieve.
    reservationId string
    The ID of the reservation (DHCP entry) to retrieve.
    waitForDhcp boolean
    Whether to wait for mac_address to exist in DHCP.
    zone string
    zone). The zone in which the reservation exists.
    gateway_network_id str

    The ID of the owning GatewayNetwork.

    Only one of reservation_id or mac_address with gateway_network_id should be specified.

    mac_address str
    The MAC address of the reservation to retrieve.
    reservation_id str
    The ID of the reservation (DHCP entry) to retrieve.
    wait_for_dhcp bool
    Whether to wait for mac_address to exist in DHCP.
    zone str
    zone). The zone in which the reservation exists.
    gatewayNetworkId String

    The ID of the owning GatewayNetwork.

    Only one of reservation_id or mac_address with gateway_network_id should be specified.

    macAddress String
    The MAC address of the reservation to retrieve.
    reservationId String
    The ID of the reservation (DHCP entry) to retrieve.
    waitForDhcp Boolean
    Whether to wait for mac_address to exist in DHCP.
    zone String
    zone). The zone in which the reservation exists.

    getVpcPublicGatewayDhcpReservation Result

    The following output properties are available:

    CreatedAt string
    Hostname string
    Id string
    The provider-assigned unique ID for this managed resource.
    IpAddress string
    Type string
    UpdatedAt string
    GatewayNetworkId string
    MacAddress string
    ReservationId string
    WaitForDhcp bool
    Zone string
    CreatedAt string
    Hostname string
    Id string
    The provider-assigned unique ID for this managed resource.
    IpAddress string
    Type string
    UpdatedAt string
    GatewayNetworkId string
    MacAddress string
    ReservationId string
    WaitForDhcp bool
    Zone string
    createdAt String
    hostname String
    id String
    The provider-assigned unique ID for this managed resource.
    ipAddress String
    type String
    updatedAt String
    gatewayNetworkId String
    macAddress String
    reservationId String
    waitForDhcp Boolean
    zone String
    createdAt string
    hostname string
    id string
    The provider-assigned unique ID for this managed resource.
    ipAddress string
    type string
    updatedAt string
    gatewayNetworkId string
    macAddress string
    reservationId string
    waitForDhcp boolean
    zone string
    created_at str
    hostname str
    id str
    The provider-assigned unique ID for this managed resource.
    ip_address str
    type str
    updated_at str
    gateway_network_id str
    mac_address str
    reservation_id str
    wait_for_dhcp bool
    zone str
    createdAt String
    hostname String
    id String
    The provider-assigned unique ID for this managed resource.
    ipAddress String
    type String
    updatedAt String
    gatewayNetworkId String
    macAddress String
    reservationId String
    waitForDhcp Boolean
    zone String

    Package Details

    Repository
    scaleway pulumiverse/pulumi-scaleway
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the scaleway Terraform Provider.
    scaleway logo
    Scaleway v1.15.0 published on Tuesday, Jul 30, 2024 by pulumiverse