Créer des VM

Vous pouvez créer une ou plusieurs machines virtuelles (VM) personnalisées dans le Cloud public ou dans un Net.

Vous pouvez définir les différentes caractéristiques des VM, et créer plusieurs VM dans une même requête de création. Ces VM sont groupées dans une même réservation. Pour modifier les caractéristiques que vous avez définies pour une VM, voir Modifier un attribut d’une VM.

Toutes les OMI officielles utilisent des keypairs comme système d’authentification. Pour créer une VM depuis une OMI officielle, vous devez spécifier une keypair. Cependant, les OMI non officielles peuvent utiliser n’importe quel système d’authentification. Pour créer une VM depuis une OMI non officielle, vous devez vérifier si une keypair est requise. Pour en savoir plus, voir À propos des keypairs.

Créer des VM avec Cockpit v2

Cockpit v2 vous permet de créer plusieurs VM dans une même requête de création. Ces VM sont groupées dans une même réservation.

Ouvrir la fenêtre Créer une VM

Dans le dashboard VM, cliquez sur IconAddFull Créer des VMs.
La fenêtre CRÉER DES VM apparaît.

Configurer votre VM

Choisir un nom, une option d’allocation et un comportement d’arrêt

  1. (optionnel) Dans le champ Nom de la VM, tapez un nom pour votre VM.

    Ce nom doit contenir entre 1 et 255 caractères ASCII imprimables.

    Ce nom est utilisé comme tag associé à votre VM.

  2. (optionnel) Cochez la case Dédiée pour créer des VM dédiées.
    Pour en savoir plus, voir À propos des VM.

  3. (optionnel) Dans la liste Comportement à la coupure, sélectionnez une des valeurs suivantes :

    • Arrêter : Lorsque vous coupez les VM, elles s’arrêtent.

    • Terminer : Lorsque vous coupez les VM, elles s’arrêtent puis sont terminées.

    • Redémarrer : Lorsque vous coupez les VM, elles s’arrêtent puis redémarrent automatiquement.

  4. Cliquez sur Suivant.
    L’écran de sélection d’une image apparaît.

Choisir une image

  1. Sélectionnez une image pour vos VM.

  2. Cliquez sur Suivant.
    L’écran de sélection du type de VM apparaît.

Choisir un type de VM et le nombre de VM

  1. Spécifiez les attributs suivants pour vos VM :

    • Génération du CPU : La génération du processeur.

    • Performance : L’indicateur de performance.

      • Très haute : Capacité de calcul maximum sur tous les vCPU de la VM. Cette valeur est idéale pour les applications de calcul intensif demandant des performances stables durant le cycle de vie de la VM.

      • Haute : Haute capacité de calcul sur tous les vCPU de la VM. Cette valeur s’applique à la plupart des cas et offre des performances variables dans le temps.

      • Moyenne : Performance à variation significative sur tous les vCPU de la VM. Cette valeur ne garantit pas des performances constantes, mais est idéale pour les machines à faible demande CPU.

    • Cœur(s) : Le nombre de vCores, jusqu’à 78.

    • Mémoire (Gio) : La quantité de mémoire, jusqu’à 1039 Gio.

    Pour en savoir plus sur les types de VM, voir Types de VM.

    Pour fonctionner correctement, les VM Windows nécessitent au moins un processeur de génération v3, 2 vCores et 4 Gio de mémoire.

  2. Spécifiez combien de VM vous voulez créer.

  3. Cliquez sur Suivant.
    L’écran Net apparaît.

Choisir entre le Cloud public, un Net et une sous-région

  1. Si vous voulez créer des VM dans le Cloud public :

    1. Laissez Cloud public activé.

    2. Sélectionnez la sous-région dans laquelle vous voulez créer vos VM.

      Dans le Cloud public, vous ne pouvez pas définir l’IP privée de vos VM.

  2. Si vous voulez créer des VM dans un Net :

    1. Désactivez Cloud public.

    2. Sélectionnez un de vos subnets dans la liste Subnet.

    3. (optionnel) Dans le champ IP privée, si vous créez une seule VM, tapez l’IP privée de la VM.

      Lorsque vous créez des VM dans un Net avec Cockpit v2 :

      • Seule la sous-région du Subnet choisi est affichée.

      • Des Network interface cards (NIC) sont automatiquement créées et attachées aux VM.

  3. Cliquez sur Suivant.
    L’écran de sélection d’un volume système apparaît.

Choisir un volume système

  1. Si vous voulez que vos VM utilisent un volume système par défaut :

    1. Sélectionnez Poursuivre avec un volume système par défaut.

    2. (optionnel) Dans le champ Nom du volume, tapez un nom pour votre volume système.

  2. Si vous voulez personnaliser le volume système de vos VM :

    1. Sélectionnez Personnaliser le volume système.

    2. (optionnel) Dans le champ Nom du volume, tapez un nom pour votre volume système.

    3. Sélectionnez une des valeurs suivantes dans la liste Volume Type :

      • standard pour un volume Magnetic

      • gp2 pour un volume Performance

      • io1 pour un volume Enterprise

        Si vous sélectionnez io1, vous devez définir le nombre d’IOPS dont vous avez besoin.

    4. Dans le champ Taille du volume, spécifiez la taille du volume (en Gio).

  3. Cliquez sur Suivant.
    L’écran Security group apparaît.

Choisir des security groups

  1. Si vous voulez associer un nouveau security group à vos VM, sélectionnez Créer un nouveau security group :

    1. Dans le champ Nom, tapez un nom pour le security group.

    2. Dans le champ Description, tapez sa description.

      • Le nom doit être unique dans votre compte pour le Cloud public ou pour chaque Net.

      • Le nom du security group ne doit pas commencer par sg-.

      • Chaque nom et description peut contenir entre 1 et 255 caractères. Les caractères autorisés sont a-z, A-Z, 0-9, l’espace et _.-:/()#,@[]+=&;\{}!$*.

  2. Si vous voulez associer un ou plusieurs security groups existants à vos VM, sélectionnez Sélectionner un ou plusieurs security groups et sélectionnez-les dans la liste qui apparaît.

    Cette liste dépend du choix effectué dans l’écran Public/Net. Si vous avez sélectionné un Net, seuls les security groups du Net choisi sont affichés.

  3. Si vous voulez associer un security group par défaut à vos VM, sélectionnez Poursuivre avec un security group par défaut.

  4. Cliquez sur Suivant.
    L’écran de sélection d’une keypair apparaît.

Choisir une keypair

  1. Si vous voulez attribuer une keypair existante à vos VM, sélectionnez-la dans la liste.

    Seules les keypairs RSA peuvent déchiffrer le mot de passe d’une VM Windows.

  2. Si vous voulez créer une nouvelle keypair à attribuer à vos VM, sélectionnez Créer une nouvelle keypair :

    1. Dans le champ Nom de la keypair, tapez un nom pour la keypair.

    2. Cliquez Créer et télécharger la keypair.

      Sauvegardez ce document avec précaution, car vous aurez besoin de son contenu à chaque connexion à vos ressources. Il ne peut pas être récupéré auprès de 3DS OUTSCALE en cas de perte.

  3. Si vous ne voulez pas attribuer une keypair à vos VM, sélectionnez Poursuivre sans keypair.

    Avec Cockpit v2, vous pouvez créer une VM sans y associer de keypair. Cependant, toutes les images officielles utilisent des keypairs comme système d’authentification. Si vous voulez accéder à une VM créée à partir d’une image officielle, vous devez donc y associer une keypair pendant cette étape ou plus tard. Pour associer une keypair plus tard, voir Modifier un attribut d’une VM.

  4. Cliquez sur Suivant.
    L’écran User data / Cloud-init apparaît.

Spécifier des user data

  1. (optionnel) Tapez des user data pour les VM dans le champ Section Outscale.
    Pour en savoir plus, voir Configurer une VM avec les user data et les tags OUTSCALE.

    Cockpit v2 encode ensuite ces user data en Base64. La taille des user data encodées en Base64 ne doit pas dépasser 500 kibioctets (Kio).

  2. (optionnel) Tapez des user data pour les VM dans le champ Section libre / Cloud-init.
    Pour en savoir plus, voir Utiliser cloud-init avec les user data.

    Cockpit v2 encode ensuite ces user data en Base64. La taille des user data encodées en Base64 ne doit pas dépasser 500 kibioctets (Kio).

  3. Cliquez sur Suivant.
    L’écran Récapitulatif apparaît.

Confirmer la création des VM

  1. Vérifiez l’ensemble des paramètres des VM.

    L’estimation du coût du type de VM est basée sur le catalogue des prix publics OUTSCALE et prend uniquement en compte la génération de CPU, l’indicateur de performance, et la quantité de mémoire.
    Cette estimation ne fait pas office de devis ou de facture et n’est valable que pour une durée limitée. Les prix indiqués sont sujets à changement.

  2. Cliquez sur Créer des VM.
    Les VM sont créées.

Créer des VM avec OSC CLI

À ce jour, cette section est disponible en anglais uniquement.

The CreateVms command creates virtual machines (VMs), and then launches them.
This action enables you to create a specified number of VMs using an OUTSCALE machine image (OMI) that you are allowed to use, and then to automatically launch them.
The VMs remain in the pending state until they are created and ready to be used. Once automatically launched, they are in the running state.
To check the state of your VMs, call the ReadVms method.
If not specified, the security group used by the service is the default one.
The metadata server enables you to get the public key provided when the VM is launched. Official OMIs contain a script to get this public key and put it inside the VM to provide secure access without password.

For more information, see About VMs.

Request sample: Creating a VM (minimal syntax)
$ osc-cli api CreateVms --profile "default" \
    --ImageId "ami-12345678"
Request sample: Creating a VM in a Net
$ osc-cli api CreateVms --profile "default" \
    --ImageId "ami-12345678" \
    --VmType "tinav5.c1r1p2" \
    --KeypairName "keypair-example" \
    --SecurityGroupIds '["sg-12345678"]' \
    --SubnetId "subnet-12345678" \
    --UserData "$(base64 -i user_data.txt)"
Request sample: Creating a VM with block device mappings
$ osc-cli api CreateVms --profile "default" \
    --ImageId "ami-12345678" \
    --VmType "tinav5.c1r1p2" \
    --KeypairName "keypair-example" \
    --SecurityGroupIds '["sg-12345678"]' \
    --SubnetId "subnet-12345678" \
    --UserData "$(base64 -i user_data.txt)" \
    --BlockDeviceMappings '[
        {
          "DeviceName": "/dev/sda1",
          "Bsu": {"VolumeSize": 15, "VolumeType": "gp2"},
        },
        {
          "DeviceName": "/dev/sdb",
          "Bsu": {"SnapshotId": "snap-12345678", "VolumeSize": 22, "VolumeType": "io1", "Iops": 150},
        },
      ]'
Request sample: Creating a VM with a NIC
$ osc-cli api CreateVms --profile "default" \
    --ImageId "ami-12345678" \
    --VmType "tinav5.c1r1p2" \
    --KeypairName "keypair-example" \
    --UserData "$(base64 -i user_data.txt)" \
    --Nics '[
        {
          "DeviceNumber": 0,
          "NicId": "eni-12345678",
        },
      ]'

This command contains the following attributes that you need to specify:

  • BlockDeviceMappings: (optional) One or more block device mappings.

    • Bsu: (optional) Information about the BSU volume to create.

      • DeleteOnVmDeletion: (optional) By default or if set to true, the volume is deleted when terminating the VM. If false, the volume is not deleted when terminating the VM.

      • Iops: (optional) The number of I/O operations per second (IOPS). This parameter must be specified only if you create an io1 volume. The maximum number of IOPS allowed for io1 volumes is 13000 with a maximum performance ratio of 300 IOPS per gibibyte.

      • SnapshotId: (optional) The ID of the snapshot used to create the volume.

      • VolumeSize: (optional) The size of the volume, in gibibytes (GiB).
        If you specify a snapshot ID, the volume size must be at least equal to the snapshot size.
        If you specify a snapshot ID but no volume size, the volume is created with a size similar to the snapshot one.

      • VolumeType: (optional) The type of the volume (standard | io1 | gp2). If not specified in the request, a standard volume is created.
        For more information about volume types, see About Volumes > Volume Types and IOPS.

    • DeviceName: (optional) The device name for the volume. For a root device, you must use /dev/sda1. For other volumes, you must use /dev/sdX, /dev/sdXX, /dev/xvdX, or /dev/xvdXX (where the first X is a letter between b and z, and the second X is a letter between a and z).

    • NoDevice: (optional) Removes the device which is included in the block device mapping of the OMI.

    • VirtualDeviceName: (optional) The name of the virtual device (ephemeralN).

  • BootOnCreation: (optional) By default or if true, the VM is started on creation. If false, the VM is stopped on creation.

  • BsuOptimized: (optional) This parameter is not available. It is present in our API for the sake of historical compatibility with AWS.

  • ClientToken: (optional) A unique identifier which enables you to manage the idempotency.

  • DeletionProtection: (optional) If true, you cannot delete the VM unless you change this parameter back to false.

  • DryRun: (optional) If true, checks whether you have the required permissions to perform the action.

  • ImageId: The ID of the OMI used to create the VM. You can find the list of OMIs by calling the ReadImages method.

  • KeypairName: (optional) The name of the keypair.

  • MaxVmsCount: (optional) The maximum number of VMs you want to create. If all the VMs cannot be created, the largest possible number of VMs above MinVmsCount is created.

  • MinVmsCount: (optional) The minimum number of VMs you want to create. If this number of VMs cannot be created, no VMs are created.

  • NestedVirtualization: (optional) (dedicated tenancy only) If true, nested virtualization is enabled. If false, it is disabled.

  • Nics: (optional) One or more NICs. If you specify this parameter, you must not specify the SubnetId and SubregionName parameters. You also must define one NIC as the primary network interface of the VM with 0 as its device number.

    • DeleteOnVmDeletion: (optional) If true, the NIC is deleted when the VM is terminated. You can specify this parameter only for a new NIC. To modify this value for an existing NIC, see UpdateNic.

    • Description: (optional) The description of the NIC, if you are creating a NIC when creating the VM.

    • DeviceNumber: (optional) The index of the VM device for the NIC attachment (between 0 and 7, both included). This parameter is required if you create a NIC when creating the VM.

    • NicId: (optional) The ID of the NIC, if you are attaching an existing NIC when creating a VM.

    • PrivateIps: (optional) One or more private IPs to assign to the NIC, if you create a NIC when creating a VM. Only one private IP can be the primary private IP.

      • IsPrimary: (optional) If true, the IP is the primary private IP of the NIC.

      • PrivateIp: (optional) The private IP of the NIC.

    • SecondaryPrivateIpCount: (optional) The number of secondary private IPs, if you create a NIC when creating a VM. This parameter cannot be specified if you specified more than one private IP in the PrivateIps parameter.

    • SecurityGroupIds: (optional) One or more IDs of security groups for the NIC, if you create a NIC when creating a VM.

    • SubnetId: (optional) The ID of the Subnet for the NIC, if you create a NIC when creating a VM. This parameter is required if you create a NIC when creating the VM.

  • Performance: (optional) The performance of the VM (medium | high | highest). By default, high. This parameter is ignored if you specify a performance flag directly in the VmType parameter.

  • Placement: (optional) Information about the placement of the VM.

    • SubregionName: (optional) The name of the Subregion. If you specify this parameter, you must not specify the Nics parameter.

    • Tenancy: (optional) The tenancy of the VM (default, dedicated, or a dedicated group ID).

  • PrivateIps: (optional) One or more private IPs of the VM.

  • SecurityGroupIds: (optional) One or more IDs of security group for the VMs.

  • SecurityGroups: (optional) One or more names of security groups for the VMs.

  • SubnetId: (optional) The ID of the Subnet in which you want to create the VM. If you specify this parameter, you must not specify the Nics parameter.

  • UserData: (optional) Data or script used to add a specific configuration to the VM. It must be Base64-encoded and is limited to 500 kibibytes (KiB).

  • VmInitiatedShutdownBehavior: (optional) The VM behavior when you stop it. By default or if set to stop, the VM stops. If set to restart, the VM stops then automatically restarts. If set to terminate, the VM stops and is terminated.

  • VmType: (optional) The type of VM. You can specify a TINA type (in the tinavW.cXrYpZ or tinavW.cXrY format), or an AWS type (for example, t2.small, which is the default value).
    If you specify an AWS type, it is converted in the background to its corresponding TINA type, but the AWS type is still returned. If the specified or converted TINA type includes a performance flag, this performance flag is applied regardless of the value you may have provided in the Performance parameter. For more information, see VM Types.

The CreateVms command returns the following elements:

  • ResponseContext: Information about the context of the response.

    • RequestId: The ID of the request.

  • Vms: Information about one or more created VMs.

    • Architecture: The architecture of the VM (i386 | x86_64).

    • BlockDeviceMappings: The block device mapping of the VM.

      • Bsu: Information about the created BSU volume.

        • DeleteOnVmDeletion: If true, the volume is deleted when terminating the VM. If false, the volume is not deleted when terminating the VM.

        • LinkDate: The date and time (UTC) at which the volume was attached to the VM, in ISO 8601 date-time format.

        • State: The state of the volume.

        • VolumeId: The ID of the volume.

      • DeviceName: The name of the device.

    • BsuOptimized: This parameter is not available. It is present in our API for the sake of historical compatibility with AWS.

    • ClientToken: The idempotency token provided when launching the VM.

    • CreationDate: The date and time (UTC) at which the VM was created.

    • DeletionProtection: If true, you cannot delete the VM unless you change this parameter back to false.

    • Hypervisor: The hypervisor type of the VMs (ovm | xen).

    • ImageId: The ID of the OMI used to create the VM.

    • IsSourceDestChecked: (Net only) If true, the source/destination check is enabled. If false, it is disabled.

    • KeypairName: The name of the keypair used when launching the VM.

    • LaunchNumber: The number for the VM when launching a group of several VMs (for example, 0, 1, 2, and so on).

    • NestedVirtualization: If true, nested virtualization is enabled. If false, it is disabled.

    • NetId: The ID of the Net in which the VM is running.

    • Nics: (Net only) The network interface cards (NICs) the VMs are attached to.

      • AccountId: The account ID of the owner of the NIC.

      • Description: The description of the NIC.

      • IsSourceDestChecked: (Net only) If true, the source/destination check is enabled. If false, it is disabled.

      • LinkNic: Information about the network interface card (NIC).

        • DeleteOnVmDeletion: If true, the NIC is deleted when the VM is terminated.

        • DeviceNumber: The device index for the NIC attachment (between 1 and 7, both included).

        • LinkNicId: The ID of the NIC to attach.

        • State: The state of the attachment (attaching | attached | detaching | detached).

      • LinkPublicIp: Information about the public IP associated with the NIC.

        • PublicDnsName: The name of the public DNS.

        • PublicIp: The public IP associated with the NIC.

        • PublicIpAccountId: The account ID of the owner of the public IP.

      • MacAddress: The Media Access Control (MAC) address of the NIC.

      • NetId: The ID of the Net for the NIC.

      • NicId: The ID of the NIC.

      • PrivateDnsName: The name of the private DNS.

      • PrivateIps: The private IP or IPs of the NIC.

        • IsPrimary: If true, the IP is the primary private IP of the NIC.

        • LinkPublicIp: Information about the public IP associated with the NIC.

          • PublicDnsName: The name of the public DNS.

          • PublicIp: The public IP associated with the NIC.

          • PublicIpAccountId: The account ID of the owner of the public IP.

        • PrivateDnsName: The name of the private DNS.

        • PrivateIp: The private IP.

      • SecurityGroups: One or more IDs of security groups for the NIC.

        • SecurityGroupId: The ID of the security group.

        • SecurityGroupName: The name of the security group.

      • State: The state of the NIC (available | attaching | in-use | detaching).

      • SubnetId: The ID of the Subnet for the NIC.

    • OsFamily: Indicates the operating system (OS) of the VM.

    • Performance: The performance of the VM (medium | high | highest).

    • Placement: Information about the placement of the VM.

      • SubregionName: The name of the Subregion. If you specify this parameter, you must not specify the Nics parameter.

      • Tenancy: The tenancy of the VM (default, dedicated, or a dedicated group ID).

    • PrivateDnsName: The name of the private DNS.

    • PrivateIp: The primary private IP of the VM.

    • ProductCodes: The product codes associated with the OMI used to create the VM.

    • PublicDnsName: The name of the public DNS.

    • PublicIp: The public IP of the VM.

    • ReservationId: The reservation ID of the VM.

    • RootDeviceName: The name of the root device for the VM (for example, /dev/sda1).

    • RootDeviceType: The type of root device used by the VM (always bsu).

    • SecurityGroups: One or more security groups associated with the VM.

      • SecurityGroupId: The ID of the security group.

      • SecurityGroupName: The name of the security group.

    • State: The state of the VM (pending | running | stopping | stopped | shutting-down | terminated | quarantine).

    • StateReason: The reason explaining the current state of the VM.

    • SubnetId: The ID of the Subnet for the VM.

    • Tags: One or more tags associated with the VM.

      • Key: The key of the tag, with a minimum of 1 character.

      • Value: The value of the tag, between 0 and 255 characters.

    • UserData: The Base64-encoded MIME user data.

    • VmId: The ID of the VM.

    • VmInitiatedShutdownBehavior: The VM behavior when you stop it. If set to stop, the VM stops. If set to restart, the VM stops then automatically restarts. If set to terminate, the VM stops and is deleted.

    • VmType: The type of VM. For more information, see VM Types.

Result sample: Creating a VM (minimal syntax)
{
  "Vms": [
    {
      "VmType": "t2.small",
      "VmInitiatedShutdownBehavior": "stop",
      "State": "pending",
      "StateReason": "",
      "RootDeviceType": "ebs",
      "RootDeviceName": "/dev/sda1",
      "IsSourceDestChecked": true,
      "ImageId": "ami-12345678",
      "DeletionProtection": false,
      "Architecture": "x86_64",
      "NestedVirtualization": false,
      "BlockDeviceMappings": [
        {
          "DeviceName": "/dev/sda1",
          "Bsu": {
            "VolumeId": "vol-12345678",
            "State": "attaching",
            "LinkDate": "2010-10-01T12:34:56.789Z",
            "DeleteOnVmDeletion": true
          }
        }
      ],
      "VmId": "i-12345678",
      "ReservationId": "r-12345678",
      "Hypervisor": "xen",
      "Placement": {
        "Tenancy": "default",
        "SubregionName": "eu-west-2a"
      },
      "ProductCodes": [
        "0001"
      ],
      "CreationDate": "2010-10-01T12:34:56.789Z",
      "UserData": "...",
      "PrivateIp": "10.0.0.4",
      "SecurityGroups": [
        {
          "SecurityGroupName": "default",
          "SecurityGroupId": "sg-12345678"
        }
      ],
      "BsuOptimized": false,
      "LaunchNumber": 0,
      "Performance": "medium",
      "Tags": [],
      "PrivateDnsName": "ip-10-0-0-4.eu-west-2.compute.internal"
    }
  ],
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  }
}
Result sample: Creating a VM in a Net
{
  "Vms": [
    {
      "VmType": "tinav5.c1r1p2",
      "VmInitiatedShutdownBehavior": "stop",
      "State": "pending",
      "StateReason": "",
      "RootDeviceType": "ebs",
      "RootDeviceName": "/dev/sda1",
      "IsSourceDestChecked": true,
      "KeypairName": "keypair-example",
      "ImageId": "ami-12345678",
      "DeletionProtection": false,
      "Architecture": "x86_64",
      "NestedVirtualization": false,
      "BlockDeviceMappings": [
        {
          "DeviceName": "/dev/sda1",
          "Bsu": {
            "VolumeId": "vol-12345678",
            "State": "attaching",
            "LinkDate": "2010-10-01T12:34:56.789Z",
            "DeleteOnVmDeletion": true
          }
        }
      ],
      "VmId": "i-12345678",
      "ReservationId": "r-12345678",
      "Hypervisor": "xen",
      "Placement": {
        "Tenancy": "default",
        "SubregionName": "eu-west-2a"
      },
      "ProductCodes": [
        "0001"
      ],
      "CreationDate": "2010-10-01T12:34:56.789Z",
      "UserData": "...",
      "SubnetId": "subnet-12345678",
      "PrivateIp": "10.0.0.4",
      "SecurityGroups": [
        {
          "SecurityGroupName": "security-group-example",
          "SecurityGroupId": "sg-12345678"
        }
      ],
      "BsuOptimized": false,
      "LaunchNumber": 0,
      "NetId": "vpc-12345678",
      "Nics": [
        {
          "SubnetId": "subnet-12345678",
          "State": "in-use",
          "LinkNic": {
            "State": "attached",
            "DeviceNumber": 0,
            "LinkNicId": "eni-attach-12345678",
            "DeleteOnVmDeletion": true
          },
          "IsSourceDestChecked": true,
          "PrivateDnsName": "ip-10-0-0-4.eu-west-2.compute.internal",
          "Description": "Primary network interface",
          "AccountId": "123456789012",
          "SecurityGroups": [
            {
              "SecurityGroupName": "security-group-example",
              "SecurityGroupId": "sg-12345678"
            }
          ],
          "MacAddress": "A1:B2:C3:D4:E5:F6",
          "NetId": "vpc-12345678",
          "NicId": "eni-12345678",
          "PrivateIps": [
            {
              "PrivateDnsName": "ip-10-0-0-4.eu-west-2.compute.internal",
              "PrivateIp": "10.0.0.4",
              "IsPrimary": true
            }
          ]
        }
      ],
      "Performance": "high",
      "Tags": [],
      "PrivateDnsName": "ip-10-0-0-4.eu-west-2.compute.internal"
    }
  ],
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  }
}
Result sample: Creating a VM with block device mappings
{
  "Vms": [
    {
      "VmType": "tinav5.c1r1p2",
      "VmInitiatedShutdownBehavior": "stop",
      "State": "pending",
      "StateReason": "",
      "RootDeviceType": "ebs",
      "RootDeviceName": "/dev/sda1",
      "IsSourceDestChecked": true,
      "KeypairName": "keypair-example",
      "ImageId": "ami-12345678",
      "DeletionProtection": false,
      "Architecture": "x86_64",
      "NestedVirtualization": false,
      "BlockDeviceMappings": [
        {
          "DeviceName": "/dev/sda1",
          "Bsu": {
            "VolumeId": "vol-12345678",
            "State": "attaching",
            "LinkDate": "2010-10-01T12:34:56.789Z",
            "DeleteOnVmDeletion": true
          }
        },
        {
          "DeviceName": "/dev/sda1",
          "Bsu": {
            "VolumeId": "vol-87654321",
            "State": "attaching",
            "LinkDate": "2010-10-01T12:34:56.789Z",
            "DeleteOnVmDeletion": true
          }
        }
      ],
      "VmId": "i-12345678",
      "ReservationId": "r-12345678",
      "Hypervisor": "xen",
      "Placement": {
        "Tenancy": "default",
        "SubregionName": "eu-west-2a"
      },
      "ProductCodes": [
        "0001"
      ],
      "CreationDate": "2010-10-01T12:34:56.789Z",
      "UserData": "...",
      "SubnetId": "subnet-12345678",
      "PrivateIp": "10.0.0.4",
      "SecurityGroups": [
        {
          "SecurityGroupName": "security-group-example",
          "SecurityGroupId": "sg-12345678"
        }
      ],
      "BsuOptimized": false,
      "LaunchNumber": 0,
      "NetId": "vpc-12345678",
      "Nics": [
        {
          "SubnetId": "subnet-12345678",
          "State": "in-use",
          "LinkNic": {
            "State": "attached",
            "DeviceNumber": 0,
            "LinkNicId": "eni-attach-12345678",
            "DeleteOnVmDeletion": true
          },
          "IsSourceDestChecked": true,
          "PrivateDnsName": "ip-10-0-0-4.eu-west-2.compute.internal",
          "Description": "Primary network interface",
          "AccountId": "123456789012",
          "SecurityGroups": [
            {
              "SecurityGroupName": "security-group-example",
              "SecurityGroupId": "sg-12345678"
            }
          ],
          "MacAddress": "A1:B2:C3:D4:E5:F6",
          "NetId": "vpc-12345678",
          "NicId": "eni-12345678",
          "PrivateIps": [
            {
              "PrivateDnsName": "ip-10-0-0-4.eu-west-2.compute.internal",
              "PrivateIp": "10.0.0.4",
              "IsPrimary": true
            }
          ]
        }
      ],
      "Performance": "high",
      "Tags": [],
      "PrivateDnsName": "ip-10-0-0-4.eu-west-2.compute.internal"
    }
  ],
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  }
}
Result sample: Creating a VM with a NIC
{
  "Vms": [
    {
      "VmType": "tinav5.c1r1p2",
      "VmInitiatedShutdownBehavior": "stop",
      "State": "pending",
      "StateReason": "",
      "RootDeviceType": "ebs",
      "RootDeviceName": "/dev/sda1",
      "IsSourceDestChecked": true,
      "KeypairName": "keypair-example",
      "ImageId": "ami-12345678",
      "DeletionProtection": false,
      "Architecture": "x86_64",
      "NestedVirtualization": false,
      "BlockDeviceMappings": [
        {
          "DeviceName": "/dev/sda1",
          "Bsu": {
            "VolumeId": "vol-12345678",
            "State": "attaching",
            "LinkDate": "2010-10-01T12:34:56.789Z",
            "DeleteOnVmDeletion": true
          }
        }
      ],
      "VmId": "i-12345678",
      "ReservationId": "r-12345678",
      "Hypervisor": "xen",
      "Placement": {
        "Tenancy": "default",
        "SubregionName": "eu-west-2a"
      },
      "ProductCodes": [
        "0001"
      ],
      "CreationDate": "2010-10-01T12:34:56.789Z",
      "UserData": "...",
      "SubnetId": "subnet-12345678",
      "PrivateIp": "10.0.0.4",
      "SecurityGroups": [
        {
          "SecurityGroupName": "security-group-example",
          "SecurityGroupId": "sg-12345678"
        }
      ],
      "BsuOptimized": false,
      "LaunchNumber": 0,
      "NetId": "vpc-12345678",
      "Nics": [
        {
          "SubnetId": "subnet-12345678",
          "State": "in-use",
          "LinkNic": {
            "State": "attached",
            "DeviceNumber": 0,
            "LinkNicId": "eni-attach-12345678",
            "DeleteOnVmDeletion": true
          },
          "IsSourceDestChecked": true,
          "PrivateDnsName": "ip-10-0-0-4.eu-west-2.compute.internal",
          "Description": "Example NIC",
          "AccountId": "123456789012",
          "SecurityGroups": [
            {
              "SecurityGroupName": "security-group-example",
              "SecurityGroupId": "sg-12345678"
            }
          ],
          "MacAddress": "A1:B2:C3:D4:E5:F6",
          "NetId": "vpc-12345678",
          "NicId": "eni-12345678",
          "PrivateIps": [
            {
              "PrivateDnsName": "ip-10-0-0-4.eu-west-2.compute.internal",
              "PrivateIp": "10.0.0.4",
              "IsPrimary": true
            }
          ]
        }
      ],
      "Performance": "high",
      "Tags": [],
      "PrivateDnsName": "ip-10-0-0-4.eu-west-2.compute.internal"
    }
  ],
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  }
}

Lancer des instances avec AWS CLI

Pour lancer une ou plusieurs instances, utilisez la commande run-instances en suivant une de ces syntaxes :

Exemple de requête (syntaxe minimale)
$ aws ec2 run-instances \
    --profile YOUR_PROFILE \
    --image-id ami-12345678 \
    --endpoint https://fcu.eu-west-2.outscale.com
Exemple de requête (syntaxe complète)
$ aws ec2 run-instances \
    --profile YOUR_PROFILE \
    --image-id ami-12345678 \
    --key-name \
    --security-groups \
    --security-group-ids sg-187654321 \
    --user-data YOUR_USER_DATA \
    --instance-type t2.small \
    --placement  \
           "{ \
           \"AvailabilityZone\": \"eu-west-2a\", \
           \"Tenancy\": \"default\", \
           }" \
    --block-device-mappings YOUR_BLOCK_DEVICE_MAPPINGS \
    --subnet-id subnet-12345678 \
    --disable-api-termination \
    --instance-initiated-shutdown-behavior stop \
    --private-ip-address 10.0.1.100 \
    --client-token "" \
    --network-interfaces \
           "{ \
           \"NetworkInterfaceId\": \"eni-12345678\", \
           \"DeviceIndex\": 0, \
           \"SubnetId\": \"subnet-12345678\", \
           \"Description\": \"Network interface description\", \
           \"PrivateIpAddress\": \"10.0.1.100\", \
           \"Groups\": \"sg-187654321\", \
           \"DeleteOnTermination\": false \
           \"PrivateIpAddresses\": [ \
                                     { \
                                     \"PrivateIpAddress\": \"10.0.1.100\", \
                                     \"Primary\": true \
                                     } \
           }" \
    --ebs-optimized NOT_SPECIFIED \
    --count 1 \
    --endpoint https://fcu.eu-west-2.outscale.com

Cette commande contient les attributs suivants que vous devez spécifier :

  • (optionnel) profile : Le profil nommé que vous voulez utiliser, créé pendant la configuration d’AWS CLI. Pour en savoir plus, voir Installer et configurer AWS CLI.

  • image-id : L’ID de l’OMI à utiliser pour lancer l’instance. Pour en savoir plus, voir Obtenir des informations sur vos OMI.

  • (optionnel) key-name : Le nom de la keypair à utiliser pour l’instance. Pour en savoir plus, voir À propos des keypairs.

    Il est fortement recommandé de spécifier une keypair au lancement de l’instance. Sinon, vous ne pouvez pas vous connecter à l’instance avant de lui avoir ajouté une keypair. Pour en savoir plus, voir Modifier la keypair d’une VM.

  • (optionnel) security-groups : Un ou plusieurs noms de security groups (seulement dans le Cloud public). Si non spécifié, le security group Default est utilisé.

  • (optionnel) security-group-ids : Un ou plusieurs ID de security groups. Si non spécifié, le security group Default est utilisé.

  • (optionnel) user-data : Les user data pour l’instance. Pour en savoir plus, voir Configurer une VM avec les user data et les tags OUTSCALE.

    AWS CLI encode ensuite ces user data en Base64. La taille des user data encodées en Base64 ne doit pas dépasser 500 kibioctets (Kio).

  • (optionnel) instance-type : Le type d’instance. Si non spécifié, une instance t2.small est lancée. Pour en savoir plus, voir Types de VM.

    Pour fonctionner correctement, les VMs Windows nécessitent au moins un processeur de génération v3, 2 vCores et 4 Gio de mémoire.

  • (optionnel) placement : Le placement de l’instance. Cet attribut contient les éléments suivants que vous devez spécifier :

    • AvailabilityZone : L’Availability Zone (AZ) dans laquelle vous voulez lancer l’instance.

      Si vous ne spécifiez aucune Sous-région, la Sous-région A est utilisée par défaut.

    • Tenancy : L’option d’allocation de l’instance (dedicated | default). Pour en savoir plus, voir À propos des VM > Allocation des VM et VM dédiées.

  • (optionnel) block-device-mappings : Un ou plusieurs block device mappings pour l’instance. Pour en savoir plus, voir Définir des block device mappings.

  • (optionnel) subnet-id : Dans un VPC, l’ID du subnet dans lequel vous souhaitez lancer l’instance.

  • (optionnel) disable-api-termination|enable-api-termination : Désactive ou active la possibilité de terminer l’instance (par défaut, activé).

  • (optionnel) instance-initiated-shutdown-behavior : Par défaut ou si paramétré sur stop, l’instance est arrêtée lorsque vous l’arrêtez ou la terminez. Si paramétré sur terminate, elle est arrêtée puis terminée. Si paramétré sur restart, l’instance est arrêtée puis automatiquement redémarrée. Pour en savoir plus, voir À propos du cycle de vie des VM > Suppression.

  • (optionnel) private-ip-address : Dans un VPC, l’IP principale.

    L’IP doit faire partie de la plage d’IP du subnet.

  • (optionnel) client-token : Un identifiant unique qui vous permet de gérer l’idempotence (s’il y en a un).

  • (optionnel) network-interfaces : Une ou plusieurs interfaces réseau. Si vous spécifiez ce paramètre, vous devez définir l’interface réseau principale de l’instance avec 0 en index du périphérique.
    Cet attribut contient les éléments suivants que vous devez spécifier :

    • NetworkInterfaceId : L’ID de l’interface réseau de l’instance.

    • DeviceIndex : L’index du périphérique pour l’interface réseau (entre 0 et 7, tous deux inclus).

    • SubnetId : L’ID du subnet associé à l’interface réseau, si vous en créez une en lançant l’instance.

    • Description : Une description de l’interface réseau.

    • PrivateIpAddress : L’IP privée de l’interface réseau.

    • Groups : L’ID d’un ou plusieurs security groups à associer à l’interface réseau.

    • DeleteOnTermination : Par défaut ou si paramétré sur true, l’interface réseau est supprimée lorsque l’instance est terminée. Vous pouvez spécifier ce paramètre uniquement pour une nouvelle interface réseau. Pour modifier cette valeur pour une interface réseau existante, voir Modifier un attribut d’une NIC.

    • PrivateIpAddresses : Une ou plusieurs IP privées à associer à l’interface réseau.

      • Primary : Si paramétré sur true, l’IP est la principale.

        Une seule IP peut être principale.

      • PrivateIpAddress : L’IP privée.

  • (optionnel) ebs-optimized : Indique si l’instance est optimisée pour BSU.

  • (optionnel) count : Le nombre d’instances à lancer.

    Vous pouvez spécifier :

    • Un nombre seul, considéré comme le nombre minimum d’instances à lancer (par défaut, 1).

    • Une plage de nombres au format min:max. Le premier nombre est le nombre minimum d’instances à lancer, le deuxième est le maximum.

  • endpoint : Le endpoint correspondant à la Région à laquelle vous voulez envoyer la requête.

La commande run-instances renvoie les éléments suivants :

  • OwnerId : L’ID de compte du propriétaire de l’instance.

  • Reservation : L’ID de la réservation. Pour en savoir plus, voir À propos des VM > Informations générales sur les VM.

  • Groups : Informations à propos des security groups associés à l’instance.

  • Instances : Informations à propos d’une ou plusieurs instances. Cet élément contient les informations suivantes pour chaque instance :

    • Monitoring : Indique si le monitoring est activé pour l’instance (toujours disabled).

    • PublicDnsName : Le nom DNS public de l’instance.

    • Platform : Pas d’information renvoyée.

    • State : Informations à propos de l’état de l’instance (le code et le nom de l’état).

    • EbsOptimized : Indique si l’instance est optimisée pour BSU.

    • LaunchTime : Le moment auquel l’instance a été lancée.

    • PublicIpAddress : Dans un Cloud public, l’IP publique associée à l’instance (remplacée par l’External IP, s’il y en a une). Dans un VPC, l’External IP associée à l’instance, s’il y en a une.

    • PrivateIpAddress : L’IP privée de l’instance.

    • ProductCodes : Pas d’information renvoyée si vous utilisez une OMI officielle.

    • Tags : Un ou plusieurs tags associés à l’instance, avec leur Value et leur Key (s’il y en a).

    • VpcId : L’ID du VPC dans lequel l’instance est.

    • InstanceId : L’ID de l’instance.

    • ImageId : L’ID de l’OMI utilisée pour lancer l’instance.

    • PrivateDnsName : Le nom DNS privé de l’instance.

    • KeyName : Le nom de la keypair utilisée pour l’instance. Pour en savoir plus, voir À propos des keypairs.

    • SecurityGroups : Les security groups associés à l’instance (nom et ID).

    • ClientToken : Un identifiant unique qui vous permet de gérer l’idempotence (s’il y en a un).

    • InstanceType : Le type d’instance. Pour en savoir plus, voir Types de VM.

    • NetworkInterfaces : Dans un VPC, une ou plusieurs interfaces réseau pour l’instance.

    • Placement : Information à propos du placement de l’instance. Cet élément contient les informations suivantes :

    • SourceDestCheck : Si true, la vérification source/destination du trafic réseau est activée. Si false, elle ne l’est pas.

    • Hypervisor : Le type d’hyperviseur de l’instance (toujours xen).

    • BlockDeviceMappings : Un ou plusieurs block device mappings pour l’nstance. Pour en savoir plus, voir Définir des block device mappings.

    • Architecture : L’architecture de l’instance.

    • KernelId : Pas d’information renvoyée.

    • RootDeviceName : Le nom du périphérique associé au volume système de l’instance.

    • VirtualizationType : Le type de virtualisation (toujours hvm).

    • RootDeviceType : Le type de volume système de l’instance (toujours ebs).

    • AmiLaunchIndex : L’index de lancement de l’instance. Pour en savoir plus, voir À propos des VM > Informations générales sur les VM.

Exemple de résultat
{
    "OwnerId": "1234567890000",
    "ReservationId": "r-87654321",
    "Groups": [
        {
            "GroupName": "default",
            "GroupId": "sg-12345678"
        }
    ],
    "Instances": [
        {
            "Monitoring": {
                "State": "disabled"
            },
            "PublicDnsName": "",
            "Platform": "",
            "State": {
                "Code": 0,
                "Name": "pending"
            },
            "EbsOptimized": false,
            "LaunchTime": "2016-04-20T08:26:26.540Z",
            "PrivateIpAddress": "10.10.10.0",
            "ProductCodes": [],
            "VpcId": "vpc-56781234",
            "InstanceId": "i-12345678",
            "ImageId": "ami-87654321",
            "PrivateDnsName": "ip-10-10-10-0.eu-west-2.compute.internal",
            "KeyName": "key name",
            "SecurityGroups": [
                {
                    "GroupName": "default",
                    "GroupId": "sg-12345678"
                }
            ],
            "ClientToken": "",
            "SubnetId": "subnet-56781234",
            "InstanceType": "t2.small",
            "NetworkInterfaces": [
                {
                    "Status": "in-use",
                    "MacAddress": "aa:c0:00:00:00:00",
                    "SourceDestCheck": true,
                    "VpcId": "vpc-56781234",
                    "Description": "Primary network interface",
                    "NetworkInterfaceId": "eni-12345678",
                    "PrivateIpAddresses": [
                        {
                            "PrivateDnsName": "ip-10-10-10-0.eu-west-2.compute.internal",
                            "Primary": true,
                            "PrivateIpAddress": "10.10.10.0"
                        }
                    ],
                    "PrivateDnsName": "ip-10-10-10-0.eu-west-2.compute.internal",
                    "Attachment": {
                        "Status": "attached",
                        "DeviceIndex": 0,
                        "DeleteOnTermination": true,
                        "AttachmentId": "eni-attach-12345678",
                        "AttachTime": "2016-04-20T08:26:26.540Z"
                    },
                    "Groups": [
                        {}
                    ],
                    "SubnetId": "subnet-56781234",
                    "OwnerId": "249064296596",
                    "PrivateIpAddress": "10.10.10.0"
                }
            ],
            "SourceDestCheck": true,
            "Placement": {
                "Tenancy": "default",
                "GroupName": "",
                "AvailabilityZone": "eu-west-2a"
            },
            "Hypervisor": "xen",
            "BlockDeviceMappings": [
                {
                    "DeviceName": "/dev/sda1",
                    "Ebs": {
                        "Status": "attaching",
                        "DeleteOnTermination": true,
                        "VolumeId": "vol-87654321",
                        "AttachTime": "2016-04-20T08:26:26.540Z"
                    }
                }
            ],
            "Architecture": "x86_64",
            "KernelId": "",
            "RootDeviceName": "/dev/sda1",
            "VirtualizationType": "hvm",
            "RootDeviceType": "ebs",
            "AmiLaunchIndex": 0
        }
    ]
}

Les instances sont lancées.

Pages connexes

Méthodes API correspondantes

AWS™ et Amazon Web Services™ sont des marques de commerce d’Amazon Technologies, Inc. ou de ses affiliées aux États-Unis et/ou dans les autres pays.