UNPKG

@natzka-oss/pulumi-netbox

Version:

A Pulumi package for creating and managing Netbox cloud resources.

188 lines 8.38 kB
"use strict"; // *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.IpAddress = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * From the [official documentation](https://docs.netbox.dev/en/stable/features/ipam/#ip-addresses): * * > An IP address comprises a single host address (either IPv4 or IPv6) and its subnet mask. Its mask should match exactly how the IP address is configured on an interface in the real world. * > * > Like a prefix, an IP address can optionally be assigned to a VRF (otherwise, it will appear in the "global" table). IP addresses are automatically arranged under parent prefixes within their respective VRFs according to the IP hierarchy. * * ## Example Usage * * ### Creating an IP address that is assigned to a virtual machine interface * * Starting with provider version 3.5.0, you can use the `virtualMachineInterfaceId` attribute to assign an IP address to a virtual machine interface. * You can also use the `interfaceId` and `objectType` attributes instead. * * With `virtualMachineInterfaceId`: * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as netbox from "@natzka-oss/pulumi-netbox"; * * // Assuming a virtual machine with the id `123` exists * const _this = new netbox.virt.Interface("this", { * name: "eth0", * virtualMachineId: 123, * }); * const thisIpAddress = new netbox.ipam.IpAddress("this", { * ipAddress: "10.0.0.60/24", * status: "active", * virtualMachineInterfaceId: _this.id, * }); * ``` * * With `objectType` and `interfaceId`: * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as netbox from "@natzka-oss/pulumi-netbox"; * * // Assuming a virtual machine with the id `123` exists * const _this = new netbox.virt.Interface("this", { * name: "eth0", * virtualMachineId: 123, * }); * const thisIpAddress = new netbox.ipam.IpAddress("this", { * ipAddress: "10.0.0.60/24", * status: "active", * interfaceId: _this.id, * objectType: "virtualization.vminterface", * }); * ``` * * ### Creating an IP address that is assigned to a device interface * * Starting with provider version 3.5.0, you can use the `deviceInterfaceId` attribute to assign an IP address to a device interface. * You can also use the `interfaceId` and `objectType` attributes instead. * * With `deviceInterfaceId`: * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as netbox from "@natzka-oss/pulumi-netbox"; * * // Assuming a device with the id `123` exists * const _this = new netbox.dcim.DeviceInterface("this", { * name: "eth0", * deviceId: 123, * type: "1000base-t", * }); * const thisIpAddress = new netbox.ipam.IpAddress("this", { * ipAddress: "10.0.0.60/24", * status: "active", * deviceInterfaceId: _this.id, * }); * ``` * * With `objectType` and `interfaceId`: * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as netbox from "@natzka-oss/pulumi-netbox"; * * // Assuming a device with the id `123` exists * const _this = new netbox.dcim.DeviceInterface("this", { * name: "eth0", * deviceId: 123, * type: "1000base-t", * }); * const thisIpAddress = new netbox.ipam.IpAddress("this", { * ipAddress: "10.0.0.60/24", * status: "active", * interfaceId: _this.id, * objectType: "dcim.interface", * }); * ``` * * ### Creating an IP address that is not assigned to anything * * You can create an IP address that is not assigend to anything by omitting the attributes mentioned above. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as netbox from "@natzka-oss/pulumi-netbox"; * * const _this = new netbox.ipam.IpAddress("this", { * ipAddress: "10.0.0.50/24", * status: "reserved", * }); * ``` */ class IpAddress extends pulumi.CustomResource { /** * Get an existing IpAddress 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 IpAddress(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of IpAddress. 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'] === IpAddress.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["customFields"] = state ? state.customFields : undefined; resourceInputs["description"] = state ? state.description : undefined; resourceInputs["deviceInterfaceId"] = state ? state.deviceInterfaceId : undefined; resourceInputs["dnsName"] = state ? state.dnsName : undefined; resourceInputs["interfaceId"] = state ? state.interfaceId : undefined; resourceInputs["ipAddress"] = state ? state.ipAddress : undefined; resourceInputs["natInsideAddressId"] = state ? state.natInsideAddressId : undefined; resourceInputs["natOutsideAddresses"] = state ? state.natOutsideAddresses : undefined; resourceInputs["objectType"] = state ? state.objectType : undefined; resourceInputs["role"] = state ? state.role : undefined; resourceInputs["status"] = state ? state.status : undefined; resourceInputs["tags"] = state ? state.tags : undefined; resourceInputs["tenantId"] = state ? state.tenantId : undefined; resourceInputs["virtualMachineInterfaceId"] = state ? state.virtualMachineInterfaceId : undefined; resourceInputs["vrfId"] = state ? state.vrfId : undefined; } else { const args = argsOrState; if ((!args || args.ipAddress === undefined) && !opts.urn) { throw new Error("Missing required property 'ipAddress'"); } if ((!args || args.status === undefined) && !opts.urn) { throw new Error("Missing required property 'status'"); } resourceInputs["customFields"] = args ? args.customFields : undefined; resourceInputs["description"] = args ? args.description : undefined; resourceInputs["deviceInterfaceId"] = args ? args.deviceInterfaceId : undefined; resourceInputs["dnsName"] = args ? args.dnsName : undefined; resourceInputs["interfaceId"] = args ? args.interfaceId : undefined; resourceInputs["ipAddress"] = args ? args.ipAddress : undefined; resourceInputs["natInsideAddressId"] = args ? args.natInsideAddressId : undefined; resourceInputs["objectType"] = args ? args.objectType : undefined; resourceInputs["role"] = args ? args.role : undefined; resourceInputs["status"] = args ? args.status : undefined; resourceInputs["tags"] = args ? args.tags : undefined; resourceInputs["tenantId"] = args ? args.tenantId : undefined; resourceInputs["virtualMachineInterfaceId"] = args ? args.virtualMachineInterfaceId : undefined; resourceInputs["vrfId"] = args ? args.vrfId : undefined; resourceInputs["natOutsideAddresses"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(IpAddress.__pulumiType, name, resourceInputs, opts); } } exports.IpAddress = IpAddress; /** @internal */ IpAddress.__pulumiType = 'netbox:ipam/ipAddress:IpAddress'; //# sourceMappingURL=ipAddress.js.map