UNPKG

@pulumi/linode

Version:

A Pulumi package for creating and managing linode cloud resources.

252 lines • 8.31 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Interface = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * Provides a Linode Interface resource that can be used to create, modify, and delete network interfaces for Linode instances. Interfaces allow you to configure public, VLAN, and VPC networking for your Linode instances. * * This resource is specifically for Linode interfaces. If you are interested in deploying a Linode instance with a legacy config interface, please refer to the `linode.InstanceConfig` resource documentation for details. * * This resource is designed to work with explicitly defined disk and config resources for the Linode instance. See the Complete Example with Linode section below for details. * * For more information, see the [Linode APIv4 docs](https://techdocs.akamai.com/linode-api/reference/post-linode-instance-interface). * * ## Example Usage * * ### Public Interface Example * * The following example shows how to create a public interface with specific IPv4 and IPv6 configurations. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as linode from "@pulumi/linode"; * * const _public = new linode.Interface("public", { * linodeId: my_instance.id, * "public": { * ipv4: { * addresses: [{ * address: "auto", * primary: true, * }], * }, * ipv6: { * ranges: [{ * range: "/64", * }], * }, * }, * }); * ``` * * ### IPv6-Only Public Interface Example * * The following example shows how to create an IPv6-only public interface. Note that you must explicitly set `addresses = []` to prevent the automatic creation of an IPv4 address. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as linode from "@pulumi/linode"; * * const ipv6Only = new linode.Interface("ipv6_only", { * linodeId: my_instance.id, * "public": { * ipv4: { * addresses: [], * }, * ipv6: { * ranges: [{ * range: "/64", * }], * }, * }, * }); * ``` * * ### VPC Interface Example * * The following example shows how to create a VPC interface with custom IPv4 configuration and 1:1 NAT. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as linode from "@pulumi/linode"; * * const vpc = new linode.Interface("vpc", { * linodeId: my_instance.id, * vpc: { * subnetId: 240213, * ipv4: { * addresses: [{ * address: "auto", * }], * ranges: [{ * range: "/32", * }], * }, * }, * }); * ``` * * ### VPC (IPv6) Interface Example * * The following example shows how to create a public VPC interface with a custom IPv6 configuration. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as linode from "@pulumi/linode"; * * const vpc = new linode.Interface("vpc", { * linodeId: my_instance.id, * vpc: { * subnetId: 12345, * ipv6: { * isPublic: true, * slaacs: [{ * range: "auto", * }], * ranges: [{ * range: "auto", * }], * }, * }, * }); * ``` * * ### VLAN Interface Example * * The following example shows how to create a VLAN interface. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as linode from "@pulumi/linode"; * * const vlan = new linode.Interface("vlan", { * linodeId: web.id, * vlan: { * vlanLabel: "web-vlan", * ipamAddress: "192.168.200.5/24", * }, * }); * ``` * * ### Complete Example with Linode * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as linode from "@pulumi/linode"; * * const my_instance = new linode.Instance("my-instance", { * label: "my-instance", * region: "us-mia", * type: "g6-standard-1", * interfaceGeneration: "linode", * }); * const boot = new linode.InstanceDisk("boot", { * label: "boot", * linodeId: my_instance.id, * size: my_instance.specs.apply(specs => specs[0].disk), * image: "linode/debian12", * rootPass: "this-is-NOT-a-safe-password", * }); * const _public = new linode.Interface("public", { * linodeId: my_instance.id, * "public": { * ipv4: { * addresses: [{ * address: "auto", * primary: true, * }], * }, * ipv6: { * ranges: [{ * range: "/64", * }], * }, * }, * }); * const my_config = new linode.InstanceConfig("my-config", { * linodeId: my_instance.id, * label: "my-config", * devices: [{ * deviceName: "sda", * diskId: boot.id, * }], * booted: true, * }, { * dependsOn: [_public], * }); * ``` * * ## Notes * * * Each Linode instance can have up to 3 network interfaces. * * VLAN interfaces cannot be updated after creation and require recreation. * * VPC subnet IDs cannot be changed after interface creation. * * Firewall IDs are only supported for public and VPC interfaces, not for VLAN interfaces. * * When configuring multiple interfaces, use the `defaultRoute` setting to specify which interface should handle default routing. * * ## Import * * Interfaces can be imported using a Linode ID followed by an Interface ID, separated by a comma, e.g. * * ```sh * $ pulumi import linode:index/interface:Interface example 12345,67890 * ``` */ class Interface extends pulumi.CustomResource { /** * Get an existing Interface resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new Interface(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of Interface. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === Interface.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["defaultRoute"] = state?.defaultRoute; resourceInputs["firewallId"] = state?.firewallId; resourceInputs["linodeId"] = state?.linodeId; resourceInputs["public"] = state?.public; resourceInputs["vlan"] = state?.vlan; resourceInputs["vpc"] = state?.vpc; } else { const args = argsOrState; if (args?.linodeId === undefined && !opts.urn) { throw new Error("Missing required property 'linodeId'"); } resourceInputs["defaultRoute"] = args?.defaultRoute; resourceInputs["firewallId"] = args?.firewallId; resourceInputs["linodeId"] = args?.linodeId; resourceInputs["public"] = args?.public; resourceInputs["vlan"] = args?.vlan; resourceInputs["vpc"] = args?.vpc; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Interface.__pulumiType, name, resourceInputs, opts); } } exports.Interface = Interface; /** @internal */ Interface.__pulumiType = 'linode:index/interface:Interface'; //# sourceMappingURL=interface.js.map