@cuemby/equinix
Version:
A Pulumi package for creating and managing equinix cloud resources.
178 lines • 9 kB
JavaScript
;
// *** 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.MetalReservedIPBlock = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* Provides a resource to create and manage blocks of reserved IP addresses in a project.
*
* When a user provisions first device in a facility, Equinix Metal API automatically allocates IPv6/56 and private IPv4/25 blocks.
* The new device then gets IPv6 and private IPv4 addresses from those block. It also gets a public IPv4/31 address.
* Every new device in the project and facility will automatically get IPv6 and private IPv4 addresses from these pre-allocated blocks.
* The IPv6 and private IPv4 blocks can't be created, only imported. With this resource, it's possible to create either public IPv4 blocks or global IPv4 blocks.
*
* Public blocks are allocated in a facility. Addresses from public blocks can only be assigned to devices in the facility. Public blocks can have mask from /24 (256 addresses) to /32 (1 address). If you create public block with this resource, you must fill the facility argument.
*
* Addresses from global blocks can be assigned in any facility. Global blocks can have mask from /30 (4 addresses), to /32 (1 address). If you create global block with this resource, you must specify type = "globalIpv4" and you must omit the facility argument.
*
* Once IP block is allocated or imported, an address from it can be assigned to device with the `equinix.MetalIPAttachment` resource.
*
* > VRF features are not generally available. The interfaces related to VRF resources may change ahead of general availability.
*
* ## Example Usage
*
* Allocate reserved IP blocks:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as equinix from "@cuemby/equinix";
*
* // Allocate /31 block of max 2 public IPv4 addresses in Silicon Valley (sv15) facility for myproject
* const twoElasticAddresses = new equinix.MetalReservedIPBlock("twoElasticAddresses", {
* projectId: local.project_id,
* facility: "sv15",
* quantity: 2,
* });
* // Allocate 1 floating IP in Sillicon Valley (sv) metro
* const testMetalReservedIPBlock = new equinix.MetalReservedIPBlock("testMetalReservedIPBlock", {
* projectId: local.project_id,
* type: "public_ipv4",
* metro: "sv",
* quantity: 1,
* });
* // Allocate 1 global floating IP, which can be assigned to device in any facility
* const testIndex_metalReservedIPBlockMetalReservedIPBlock = new equinix.MetalReservedIPBlock("testIndex/metalReservedIPBlockMetalReservedIPBlock", {
* projectId: local.project_id,
* type: "global_ipv4",
* quantity: 1,
* });
* ```
*
* Allocate a block and run a device with public IPv4 from the block
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as equinix from "@cuemby/equinix";
*
* // Allocate /31 block of max 2 public IPv4 addresses in Silicon Valley (sv15) facility
* const example = new equinix.MetalReservedIPBlock("example", {
* projectId: local.project_id,
* facility: "sv15",
* quantity: 2,
* });
* // Run a device with both public IPv4 from the block assigned
* const nodes = new equinix.MetalDevice("nodes", {
* projectId: local.project_id,
* facilities: ["sv15"],
* plan: "c3.small.x86",
* operatingSystem: "ubuntu_20_04",
* hostname: "test",
* billingCycle: "hourly",
* ipAddresses: [
* {
* type: "public_ipv4",
* cidr: 31,
* reservationIds: [example.id],
* },
* {
* type: "private_ipv4",
* },
* ],
* });
* ```
*
* ## Import
*
* This resource can be imported using an existing IP reservation ID
*
* ```sh
* $ pulumi import equinix:index/metalReservedIPBlock:MetalReservedIPBlock equinix_metal_reserved_ip_block {existing_ip_reservation_id}
* ```
*/
class MetalReservedIPBlock extends pulumi.CustomResource {
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["address"] = state ? state.address : undefined;
resourceInputs["addressFamily"] = state ? state.addressFamily : undefined;
resourceInputs["cidr"] = state ? state.cidr : undefined;
resourceInputs["cidrNotation"] = state ? state.cidrNotation : undefined;
resourceInputs["customData"] = state ? state.customData : undefined;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["facility"] = state ? state.facility : undefined;
resourceInputs["gateway"] = state ? state.gateway : undefined;
resourceInputs["global"] = state ? state.global : undefined;
resourceInputs["manageable"] = state ? state.manageable : undefined;
resourceInputs["management"] = state ? state.management : undefined;
resourceInputs["metro"] = state ? state.metro : undefined;
resourceInputs["netmask"] = state ? state.netmask : undefined;
resourceInputs["network"] = state ? state.network : undefined;
resourceInputs["projectId"] = state ? state.projectId : undefined;
resourceInputs["public"] = state ? state.public : undefined;
resourceInputs["quantity"] = state ? state.quantity : undefined;
resourceInputs["tags"] = state ? state.tags : undefined;
resourceInputs["type"] = state ? state.type : undefined;
resourceInputs["vrfId"] = state ? state.vrfId : undefined;
resourceInputs["waitForState"] = state ? state.waitForState : undefined;
}
else {
const args = argsOrState;
if ((!args || args.projectId === undefined) && !opts.urn) {
throw new Error("Missing required property 'projectId'");
}
resourceInputs["cidr"] = args ? args.cidr : undefined;
resourceInputs["customData"] = args ? args.customData : undefined;
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["facility"] = args ? args.facility : undefined;
resourceInputs["metro"] = args ? args.metro : undefined;
resourceInputs["network"] = args ? args.network : undefined;
resourceInputs["projectId"] = args ? args.projectId : undefined;
resourceInputs["quantity"] = args ? args.quantity : undefined;
resourceInputs["tags"] = args ? args.tags : undefined;
resourceInputs["type"] = args ? args.type : undefined;
resourceInputs["vrfId"] = args ? args.vrfId : undefined;
resourceInputs["waitForState"] = args ? args.waitForState : undefined;
resourceInputs["address"] = undefined /*out*/;
resourceInputs["addressFamily"] = undefined /*out*/;
resourceInputs["cidrNotation"] = undefined /*out*/;
resourceInputs["gateway"] = undefined /*out*/;
resourceInputs["global"] = undefined /*out*/;
resourceInputs["manageable"] = undefined /*out*/;
resourceInputs["management"] = undefined /*out*/;
resourceInputs["netmask"] = undefined /*out*/;
resourceInputs["public"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(MetalReservedIPBlock.__pulumiType, name, resourceInputs, opts);
}
/**
* Get an existing MetalReservedIPBlock 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 MetalReservedIPBlock(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of MetalReservedIPBlock. 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'] === MetalReservedIPBlock.__pulumiType;
}
}
exports.MetalReservedIPBlock = MetalReservedIPBlock;
/** @internal */
MetalReservedIPBlock.__pulumiType = 'equinix:index/metalReservedIPBlock:MetalReservedIPBlock';
//# sourceMappingURL=metalReservedIPBlock.js.map