@pulumi/linode
Version:
A Pulumi package for creating and managing linode cloud resources.
141 lines • 5.7 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.InstanceSharedIps = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* Manages IPs shared to a Linode instance.
* For more information, see the [Linode APIv4 docs](https://techdocs.akamai.com/linode-api/reference/post-share-ips).
*
* > **Beta Notice** IPv6 sharing is currently available through early access.
* To use early access resources, the `apiVersion` provider argument must be set to `v4beta`.
* To learn more, see the early access documentation.
*
* > **Notice** This resource should only be defined once per-instance and should not be used alongside the `sharedIpv4` field in `linode.Instance`.
*
* ## Example Usage
*
* Share in IPv4 address between two instances:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as linode from "@pulumi/linode";
*
* // Create a single primary node
* const primaryInstance = new linode.Instance("primary", {
* label: "node-primary",
* type: "g6-nanode-1",
* region: "eu-central",
* });
* // Allocate an IP under the primary node
* const primary = new linode.InstanceIp("primary", {linodeId: primaryInstance.id});
* // Create a secondary node
* const secondary = new linode.Instance("secondary", {
* label: "node-secondary",
* type: "g6-nanode-1",
* region: "eu-central",
* });
* // Share the IP with the secondary node
* const share_primary = new linode.InstanceSharedIps("share-primary", {
* linodeId: secondary.id,
* addresses: [primary.address],
* });
* ```
*
* Share an IPv6 address among a primary node and its replicas:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as linode from "@pulumi/linode";
*
* // Create a single primary node
* const primary = new linode.Instance("primary", {
* label: "node-primary",
* type: "g6-nanode-1",
* region: "eu-central",
* });
* // Allocate an IPv6 range pointing at the primary node
* const rangeIpv6Range = new linode.Ipv6Range("range", {
* prefixLength: 64,
* linodeId: primary.id,
* });
* // Share with primary node
* const share_primary = new linode.InstanceSharedIps("share-primary", {
* linodeId: primary.id,
* addresses: [rangeIpv6Range.range],
* });
* const config = new pulumi.Config();
* const numberReplicas = config.getNumber("numberReplicas") || 2;
* // Create two secondary nodes
* const secondary: linode.Instance[] = [];
* for (const range = {value: 0}; range.value < numberReplicas; range.value++) {
* secondary.push(new linode.Instance(`secondary-${range.value}`, {
* label: `node-secondary-${range.value}`,
* type: "g6-nanode-1",
* region: "eu-central",
* }));
* }
* // Share with secondary nodes
* const share_secondary: linode.InstanceSharedIps[] = [];
* for (const range = {value: 0}; range.value < numberReplicas; range.value++) {
* share_secondary.push(new linode.InstanceSharedIps(`share-secondary-${range.value}`, {
* linodeId: secondary[range.value].id,
* addresses: [rangeIpv6Range.range],
* }, {
* dependsOn: [share_primary],
* }));
* }
* ```
*/
class InstanceSharedIps extends pulumi.CustomResource {
/**
* Get an existing InstanceSharedIps 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 InstanceSharedIps(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of InstanceSharedIps. 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'] === InstanceSharedIps.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["addresses"] = state ? state.addresses : undefined;
resourceInputs["linodeId"] = state ? state.linodeId : undefined;
}
else {
const args = argsOrState;
if ((!args || args.addresses === undefined) && !opts.urn) {
throw new Error("Missing required property 'addresses'");
}
if ((!args || args.linodeId === undefined) && !opts.urn) {
throw new Error("Missing required property 'linodeId'");
}
resourceInputs["addresses"] = args ? args.addresses : undefined;
resourceInputs["linodeId"] = args ? args.linodeId : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(InstanceSharedIps.__pulumiType, name, resourceInputs, opts);
}
}
exports.InstanceSharedIps = InstanceSharedIps;
/** @internal */
InstanceSharedIps.__pulumiType = 'linode:index/instanceSharedIps:InstanceSharedIps';
//# sourceMappingURL=instanceSharedIps.js.map
;