UNPKG

@lbrlabs/pulumi-scaleway

Version:

A Pulumi package for creating and managing scaleway cloud resources.

649 lines (648 loc) 25.2 kB
import * as pulumi from "@pulumi/pulumi"; import * as inputs from "./types/input"; import * as outputs from "./types/output"; /** * Creates and manages Scaleway Compute Instance servers. For more information, see [the documentation](https://developers.scaleway.com/en/products/instance/api/#servers-8bf7d7). * * Please check our [FAQ - Instances](https://www.scaleway.com/en/docs/faq/instances). * * ## Examples * * ### Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@lbrlabs/pulumi-scaleway"; * * const publicIp = new scaleway.InstanceIp("publicIp", {}); * const web = new scaleway.InstanceServer("web", { * type: "DEV1-S", * image: "ubuntu_jammy", * ipId: publicIp.id, * }); * ``` * * ### With additional volumes and tags * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@lbrlabs/pulumi-scaleway"; * * const data = new scaleway.InstanceVolume("data", { * sizeInGb: 100, * type: "b_ssd", * }); * const web = new scaleway.InstanceServer("web", { * type: "DEV1-S", * image: "ubuntu_jammy", * tags: [ * "hello", * "public", * ], * rootVolume: { * deleteOnTermination: false, * }, * additionalVolumeIds: [data.id], * }); * ``` * * ### With a reserved IP * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@lbrlabs/pulumi-scaleway"; * * const ip = new scaleway.InstanceIp("ip", {}); * const web = new scaleway.InstanceServer("web", { * type: "DEV1-S", * image: "f974feac-abae-4365-b988-8ec7d1cec10d", * tags: [ * "hello", * "public", * ], * ipId: ip.id, * }); * ``` * * ### With security group * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@lbrlabs/pulumi-scaleway"; * * const www = new scaleway.InstanceSecurityGroup("www", { * inboundDefaultPolicy: "drop", * outboundDefaultPolicy: "accept", * inboundRules: [ * { * action: "accept", * port: 22, * ip: "212.47.225.64", * }, * { * action: "accept", * port: 80, * }, * { * action: "accept", * port: 443, * }, * ], * outboundRules: [{ * action: "drop", * ipRange: "10.20.0.0/24", * }], * }); * const web = new scaleway.InstanceServer("web", { * type: "DEV1-S", * image: "ubuntu_jammy", * securityGroupId: www.id, * }); * ``` * * ### With user data and cloud-init * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as fs from "fs"; * import * as scaleway from "@lbrlabs/pulumi-scaleway"; * * const web = new scaleway.InstanceServer("web", { * type: "DEV1-S", * image: "ubuntu_jammy", * userData: { * foo: "bar", * "cloud-init": fs.readFileSync(`${path.module}/cloud-init.yml`), * }, * }); * ``` * * ### With private network * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@lbrlabs/pulumi-scaleway"; * * const pn01 = new scaleway.VpcPrivateNetwork("pn01", {}); * const base = new scaleway.InstanceServer("base", { * image: "ubuntu_jammy", * type: "DEV1-S", * privateNetworks: [{ * pnId: pn01.id, * }], * }); * ``` * * ### Root volume configuration * * #### Resized block volume with installed image * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@lbrlabs/pulumi-scaleway"; * * const image = new scaleway.InstanceServer("image", { * image: "ubuntu_jammy", * rootVolume: { * sizeInGb: 100, * volumeType: "b_ssd", * }, * type: "PRO2-XXS", * }); * ``` * * #### From snapshot * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@lbrlabs/pulumi-scaleway"; * import * as scaleway from "@pulumi/scaleway"; * * const snapshot = scaleway.getInstanceSnapshot({ * name: "my_snapshot", * }); * const fromSnapshotInstanceVolume = new scaleway.InstanceVolume("fromSnapshotInstanceVolume", { * fromSnapshotId: snapshot.then(snapshot => snapshot.id), * type: "b_ssd", * }); * const fromSnapshotInstanceServer = new scaleway.InstanceServer("fromSnapshotInstanceServer", { * type: "PRO2-XXS", * rootVolume: { * volumeId: fromSnapshotInstanceVolume.id, * }, * }); * ``` * * ## Private Network * * > **Important:** Updates to `privateNetwork` will recreate a new private network interface. * * - `pnId` - (Required) The private network ID where to connect. * - `macAddress` The private NIC MAC address. * - `status` The private NIC state. * - `zone` - (Defaults to provider `zone`) The zone in which the server must be created. * * > **Important:** * * - You can only attach an instance in the same zone as a private network. * - Instance supports maximum 8 different private networks. * * ## Import * * Instance servers can be imported using the `{zone}/{id}`, e.g. bash * * ```sh * $ pulumi import scaleway:index/instanceServer:InstanceServer web fr-par-1/11111111-1111-1111-1111-111111111111 * ``` */ export declare class InstanceServer extends pulumi.CustomResource { /** * Get an existing InstanceServer 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: string, id: pulumi.Input<pulumi.ID>, state?: InstanceServerState, opts?: pulumi.CustomResourceOptions): InstanceServer; /** * Returns true if the given object is an instance of InstanceServer. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is InstanceServer; /** * The [additional volumes](https://developers.scaleway.com/en/products/instance/api/#volumes-7e8a39) * attached to the server. Updates to this field will trigger a stop/start of the server. * * > **Important:** If this field contains local volumes, the `state` must be set to `stopped`, otherwise it will fail. * * > **Important:** If this field contains local volumes, you have to first detach them, in one apply, and then delete the volume in another apply. */ readonly additionalVolumeIds: pulumi.Output<string[] | undefined>; /** * The boot Type of the server. Possible values are: `local`, `bootscript` or `rescue`. */ readonly bootType: pulumi.Output<string | undefined>; /** * The ID of the bootscript to use (set bootType to `bootscript`). */ readonly bootscriptId: pulumi.Output<string>; /** * The cloud init script associated with this server */ readonly cloudInit: pulumi.Output<string>; /** * If true a dynamic IP will be attached to the server. */ readonly enableDynamicIp: pulumi.Output<boolean | undefined>; /** * Determines if IPv6 is enabled for the server. */ readonly enableIpv6: pulumi.Output<boolean | undefined>; /** * The UUID or the label of the base image used by the server. You can use [this endpoint](https://api-marketplace.scaleway.com/images?page=1&per_page=100) * to find either the right `label` or the right local image `ID` for a given `type`. Optional when creating an instance with an existing root volume. * * You can check the available labels with our [CLI](https://www.scaleway.com/en/docs/compute/instances/api-cli/creating-managing-instances-with-cliv2/). ```scw marketplace image list``` * * To retrieve more information by label please use: ```scw marketplace image get label=<LABEL>``` */ readonly image: pulumi.Output<string | undefined>; /** * The ID of the reserved IP that is attached to the server. */ readonly ipId: pulumi.Output<string | undefined>; /** * List of ID of reserved IPs that are attached to the server. Cannot be used with `ipId`. */ readonly ipIds: pulumi.Output<string[] | undefined>; /** * The default ipv6 address routed to the server. ( Only set when enableIpv6 is set to true ) */ readonly ipv6Address: pulumi.Output<string>; /** * The ipv6 gateway address. ( Only set when enableIpv6 is set to true ) */ readonly ipv6Gateway: pulumi.Output<string>; /** * The prefix length of the ipv6 subnet routed to the server. ( Only set when enableIpv6 is set to true ) */ readonly ipv6PrefixLength: pulumi.Output<number>; /** * The name of the server. */ readonly name: pulumi.Output<string>; /** * The organization ID the server is associated with. */ readonly organizationId: pulumi.Output<string>; /** * The [placement group](https://developers.scaleway.com/en/products/instance/api/#placement-groups-d8f653) the server is attached to. * * * > **Important:** When updating `placementGroupId` the `state` must be set to `stopped`, otherwise it will fail. */ readonly placementGroupId: pulumi.Output<string | undefined>; /** * True when the placement group policy is respected. */ readonly placementGroupPolicyRespected: pulumi.Output<boolean>; /** * The Scaleway internal IP address of the server. */ readonly privateIp: pulumi.Output<string>; /** * The private network associated with the server. * Use the `pnId` key to attach a [privateNetwork](https://developers.scaleway.com/en/products/instance/api/#private-nics-a42eea) on your instance. */ readonly privateNetworks: pulumi.Output<outputs.InstanceServerPrivateNetwork[] | undefined>; /** * `projectId`) The ID of the project the server is associated with. */ readonly projectId: pulumi.Output<string>; /** * The public IP address of the server. */ readonly publicIp: pulumi.Output<string>; /** * The list of public IPs of the server. */ readonly publicIps: pulumi.Output<outputs.InstanceServerPublicIp[]>; /** * If true, the server will be replaced if `type` is changed. Otherwise, the server will migrate. */ readonly replaceOnTypeChange: pulumi.Output<boolean | undefined>; /** * Root [volume](https://developers.scaleway.com/en/products/instance/api/#volumes-7e8a39) attached to the server on creation. */ readonly rootVolume: pulumi.Output<outputs.InstanceServerRootVolume>; /** * If true, the server will support routed ips only. Changing it to true will migrate the server and its IP to routed type. * * > **Important:** Enabling routed ip will restart the server */ readonly routedIpEnabled: pulumi.Output<boolean>; /** * The [security group](https://developers.scaleway.com/en/products/instance/api/#security-groups-8d7f89) the server is attached to. */ readonly securityGroupId: pulumi.Output<string>; /** * The state of the server. Possible values are: `started`, `stopped` or `standby`. */ readonly state: pulumi.Output<string | undefined>; /** * The tags associated with the server. */ readonly tags: pulumi.Output<string[] | undefined>; /** * The commercial type of the server. * You find all the available types on the [pricing page](https://www.scaleway.com/en/pricing/). * Updates to this field will migrate the server, local storage constraint must be respected. [More info](https://www.scaleway.com/en/docs/compute/instances/api-cli/migrating-instances/). * Use `replaceOnTypeChange` to trigger replacement instead of migration. * * > **Important:** If `type` change and migration occurs, the server will be stopped and changed backed to its original state. It will be started again if it was running. */ readonly type: pulumi.Output<string>; /** * The user data associated with the server. * Use the `cloud-init` key to use [cloud-init](https://cloudinit.readthedocs.io/en/latest/) on your instance. * You can define values using: * - string * - UTF-8 encoded file content using file * - Binary files using filebase64. */ readonly userData: pulumi.Output<{ [key: string]: string; }>; /** * `zone`) The zone in which the server should be created. */ readonly zone: pulumi.Output<string>; /** * Create a InstanceServer resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: InstanceServerArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering InstanceServer resources. */ export interface InstanceServerState { /** * The [additional volumes](https://developers.scaleway.com/en/products/instance/api/#volumes-7e8a39) * attached to the server. Updates to this field will trigger a stop/start of the server. * * > **Important:** If this field contains local volumes, the `state` must be set to `stopped`, otherwise it will fail. * * > **Important:** If this field contains local volumes, you have to first detach them, in one apply, and then delete the volume in another apply. */ additionalVolumeIds?: pulumi.Input<pulumi.Input<string>[]>; /** * The boot Type of the server. Possible values are: `local`, `bootscript` or `rescue`. */ bootType?: pulumi.Input<string>; /** * The ID of the bootscript to use (set bootType to `bootscript`). */ bootscriptId?: pulumi.Input<string>; /** * The cloud init script associated with this server */ cloudInit?: pulumi.Input<string>; /** * If true a dynamic IP will be attached to the server. */ enableDynamicIp?: pulumi.Input<boolean>; /** * Determines if IPv6 is enabled for the server. */ enableIpv6?: pulumi.Input<boolean>; /** * The UUID or the label of the base image used by the server. You can use [this endpoint](https://api-marketplace.scaleway.com/images?page=1&per_page=100) * to find either the right `label` or the right local image `ID` for a given `type`. Optional when creating an instance with an existing root volume. * * You can check the available labels with our [CLI](https://www.scaleway.com/en/docs/compute/instances/api-cli/creating-managing-instances-with-cliv2/). ```scw marketplace image list``` * * To retrieve more information by label please use: ```scw marketplace image get label=<LABEL>``` */ image?: pulumi.Input<string>; /** * The ID of the reserved IP that is attached to the server. */ ipId?: pulumi.Input<string>; /** * List of ID of reserved IPs that are attached to the server. Cannot be used with `ipId`. */ ipIds?: pulumi.Input<pulumi.Input<string>[]>; /** * The default ipv6 address routed to the server. ( Only set when enableIpv6 is set to true ) */ ipv6Address?: pulumi.Input<string>; /** * The ipv6 gateway address. ( Only set when enableIpv6 is set to true ) */ ipv6Gateway?: pulumi.Input<string>; /** * The prefix length of the ipv6 subnet routed to the server. ( Only set when enableIpv6 is set to true ) */ ipv6PrefixLength?: pulumi.Input<number>; /** * The name of the server. */ name?: pulumi.Input<string>; /** * The organization ID the server is associated with. */ organizationId?: pulumi.Input<string>; /** * The [placement group](https://developers.scaleway.com/en/products/instance/api/#placement-groups-d8f653) the server is attached to. * * * > **Important:** When updating `placementGroupId` the `state` must be set to `stopped`, otherwise it will fail. */ placementGroupId?: pulumi.Input<string>; /** * True when the placement group policy is respected. */ placementGroupPolicyRespected?: pulumi.Input<boolean>; /** * The Scaleway internal IP address of the server. */ privateIp?: pulumi.Input<string>; /** * The private network associated with the server. * Use the `pnId` key to attach a [privateNetwork](https://developers.scaleway.com/en/products/instance/api/#private-nics-a42eea) on your instance. */ privateNetworks?: pulumi.Input<pulumi.Input<inputs.InstanceServerPrivateNetwork>[]>; /** * `projectId`) The ID of the project the server is associated with. */ projectId?: pulumi.Input<string>; /** * The public IP address of the server. */ publicIp?: pulumi.Input<string>; /** * The list of public IPs of the server. */ publicIps?: pulumi.Input<pulumi.Input<inputs.InstanceServerPublicIp>[]>; /** * If true, the server will be replaced if `type` is changed. Otherwise, the server will migrate. */ replaceOnTypeChange?: pulumi.Input<boolean>; /** * Root [volume](https://developers.scaleway.com/en/products/instance/api/#volumes-7e8a39) attached to the server on creation. */ rootVolume?: pulumi.Input<inputs.InstanceServerRootVolume>; /** * If true, the server will support routed ips only. Changing it to true will migrate the server and its IP to routed type. * * > **Important:** Enabling routed ip will restart the server */ routedIpEnabled?: pulumi.Input<boolean>; /** * The [security group](https://developers.scaleway.com/en/products/instance/api/#security-groups-8d7f89) the server is attached to. */ securityGroupId?: pulumi.Input<string>; /** * The state of the server. Possible values are: `started`, `stopped` or `standby`. */ state?: pulumi.Input<string>; /** * The tags associated with the server. */ tags?: pulumi.Input<pulumi.Input<string>[]>; /** * The commercial type of the server. * You find all the available types on the [pricing page](https://www.scaleway.com/en/pricing/). * Updates to this field will migrate the server, local storage constraint must be respected. [More info](https://www.scaleway.com/en/docs/compute/instances/api-cli/migrating-instances/). * Use `replaceOnTypeChange` to trigger replacement instead of migration. * * > **Important:** If `type` change and migration occurs, the server will be stopped and changed backed to its original state. It will be started again if it was running. */ type?: pulumi.Input<string>; /** * The user data associated with the server. * Use the `cloud-init` key to use [cloud-init](https://cloudinit.readthedocs.io/en/latest/) on your instance. * You can define values using: * - string * - UTF-8 encoded file content using file * - Binary files using filebase64. */ userData?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * `zone`) The zone in which the server should be created. */ zone?: pulumi.Input<string>; } /** * The set of arguments for constructing a InstanceServer resource. */ export interface InstanceServerArgs { /** * The [additional volumes](https://developers.scaleway.com/en/products/instance/api/#volumes-7e8a39) * attached to the server. Updates to this field will trigger a stop/start of the server. * * > **Important:** If this field contains local volumes, the `state` must be set to `stopped`, otherwise it will fail. * * > **Important:** If this field contains local volumes, you have to first detach them, in one apply, and then delete the volume in another apply. */ additionalVolumeIds?: pulumi.Input<pulumi.Input<string>[]>; /** * The boot Type of the server. Possible values are: `local`, `bootscript` or `rescue`. */ bootType?: pulumi.Input<string>; /** * The ID of the bootscript to use (set bootType to `bootscript`). */ bootscriptId?: pulumi.Input<string>; /** * The cloud init script associated with this server */ cloudInit?: pulumi.Input<string>; /** * If true a dynamic IP will be attached to the server. */ enableDynamicIp?: pulumi.Input<boolean>; /** * Determines if IPv6 is enabled for the server. */ enableIpv6?: pulumi.Input<boolean>; /** * The UUID or the label of the base image used by the server. You can use [this endpoint](https://api-marketplace.scaleway.com/images?page=1&per_page=100) * to find either the right `label` or the right local image `ID` for a given `type`. Optional when creating an instance with an existing root volume. * * You can check the available labels with our [CLI](https://www.scaleway.com/en/docs/compute/instances/api-cli/creating-managing-instances-with-cliv2/). ```scw marketplace image list``` * * To retrieve more information by label please use: ```scw marketplace image get label=<LABEL>``` */ image?: pulumi.Input<string>; /** * The ID of the reserved IP that is attached to the server. */ ipId?: pulumi.Input<string>; /** * List of ID of reserved IPs that are attached to the server. Cannot be used with `ipId`. */ ipIds?: pulumi.Input<pulumi.Input<string>[]>; /** * The name of the server. */ name?: pulumi.Input<string>; /** * The [placement group](https://developers.scaleway.com/en/products/instance/api/#placement-groups-d8f653) the server is attached to. * * * > **Important:** When updating `placementGroupId` the `state` must be set to `stopped`, otherwise it will fail. */ placementGroupId?: pulumi.Input<string>; /** * The private network associated with the server. * Use the `pnId` key to attach a [privateNetwork](https://developers.scaleway.com/en/products/instance/api/#private-nics-a42eea) on your instance. */ privateNetworks?: pulumi.Input<pulumi.Input<inputs.InstanceServerPrivateNetwork>[]>; /** * `projectId`) The ID of the project the server is associated with. */ projectId?: pulumi.Input<string>; /** * The list of public IPs of the server. */ publicIps?: pulumi.Input<pulumi.Input<inputs.InstanceServerPublicIp>[]>; /** * If true, the server will be replaced if `type` is changed. Otherwise, the server will migrate. */ replaceOnTypeChange?: pulumi.Input<boolean>; /** * Root [volume](https://developers.scaleway.com/en/products/instance/api/#volumes-7e8a39) attached to the server on creation. */ rootVolume?: pulumi.Input<inputs.InstanceServerRootVolume>; /** * If true, the server will support routed ips only. Changing it to true will migrate the server and its IP to routed type. * * > **Important:** Enabling routed ip will restart the server */ routedIpEnabled?: pulumi.Input<boolean>; /** * The [security group](https://developers.scaleway.com/en/products/instance/api/#security-groups-8d7f89) the server is attached to. */ securityGroupId?: pulumi.Input<string>; /** * The state of the server. Possible values are: `started`, `stopped` or `standby`. */ state?: pulumi.Input<string>; /** * The tags associated with the server. */ tags?: pulumi.Input<pulumi.Input<string>[]>; /** * The commercial type of the server. * You find all the available types on the [pricing page](https://www.scaleway.com/en/pricing/). * Updates to this field will migrate the server, local storage constraint must be respected. [More info](https://www.scaleway.com/en/docs/compute/instances/api-cli/migrating-instances/). * Use `replaceOnTypeChange` to trigger replacement instead of migration. * * > **Important:** If `type` change and migration occurs, the server will be stopped and changed backed to its original state. It will be started again if it was running. */ type: pulumi.Input<string>; /** * The user data associated with the server. * Use the `cloud-init` key to use [cloud-init](https://cloudinit.readthedocs.io/en/latest/) on your instance. * You can define values using: * - string * - UTF-8 encoded file content using file * - Binary files using filebase64. */ userData?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * `zone`) The zone in which the server should be created. */ zone?: pulumi.Input<string>; }