Créer une OMI depuis un snapshot

Vous pouvez créer des OUTSCALE machine images (OMI) directement depuis des snapshots. Avec AWS CLI, créer une OMI depuis un snapshot correspond à enregistrer celle-ci en spécifiant un ID de snapshot dans son block device mapping.

Créer une image depuis un snapshot avec Cockpit v2

Avant de commencer :

  1. Si vous souhaitez partager l’image avec d’autres comptes, nettoyez les informations critiques de la virtual machine (VM) que vous ne souhaitez pas partager :

  2. (VM Windows uniquement) Pour réinitialiser le système de votre VM Windows, exécutez le script OMI Creation Launcher dans le répertoire C:\Windows\Outscale\scripts de votre VM.

    • Ce script n’est disponible que sur les VM créées à partir d’une image officielle. Si la VM a été lancée à partir d’une image non officielle, vous pouvez faire un sysprep. Pour en savoir plus, voir la documentation officielle sysprep de Windows.

    • Ce script permet aux VM créées à partir de la future image d’être réinitialisées (ID, keypair, mot de passe administrateur, et ainsi de suite).

    La VM est automatiquement arrêtée une fois le script terminé.

  3. Créez un snapshot du volume système de la VM à partir de laquelle créer l’image. Pour en savoir plus, voir Créer un snapshot d’un volume.

  1. Dans le dashboard Images, cliquez sur IconAddFull Créer une image.
    La boîte de dialogue CRÉER UNE IMAGE apparaît.

    Vous pouvez également sélectionner un snapshot dans le dashboard Snapshots et cliquer sur IconAddFull Créer une image.

  2. Dans le champ Nom, tapez un nom pour l’image.

    Ce nom doit être unique et doit contenir entre 3 et 128 caractères. Les caractères autorisés sont a-z, A-Z, 0-9, l’espace et [_()/.-].

  3. (optionnel) Dans le champ Description, tapez une description pour l’image.

  4. Sélectionnez À partir d’un snapshot et sélectionnez un snapshot depuis la liste de sélection Snapshot.

  5. Dans la liste de sélection Architecture, sélectionnez une architecture pour l’image (i386 ou x86_64).

  6. Paramétrez l’option Supprimer à la suppression de la VM pour les volumes des VM créées à partir de l’image :

    • Pour supprimer automatiquement les volumes d’une VM que vous supprimez, réglez le bouton sur True.

      Les données stockées sur les volumes supprimés sont perdues et ne peuvent être récupérées.

      Avant de les supprimer, assurez-vous d’en avoir une copie ou un snapshot. Pour en savoir plus, voir Créer un snapshot d’un volume.

    • Pour conserver les volumes d’une VM que vous supprimez, réglez le bouton sur False.

  7. Cliquez sur Créer l’image.
    L’image est créée.

Créer une OMI depuis un snapshot avec OSC CLI

Avant de commencer :

  1. Si vous souhaitez partager l’OMI avec d’autres comptes, nettoyez les informations critiques de la VM que vous ne souhaitez pas partager :

  2. (VM Windows uniquement) Pour réinitialiser le système de votre VM Windows, exécutez le script OMI Creation Launcher dans le répertoire C:\Windows\Outscale\scripts de votre VM.

    • Ce script n’est disponible que sur les VM créées à partir d’une OMI officielle. Si la VM a été lancée à partir d’une OMI non officielle, vous pouvez faire un sysprep. Pour en savoir plus, voir la documentation officielle sysprep de Windows.

    • Ce script permet aux VM créées à partir de la future OMI d’être réinitialisées (ID, keypair, mot de passe administrateur, et ainsi de suite).

    La VM est automatiquement arrêtée une fois le script terminé.

  3. Créez un snapshot du volume système de la VM à partir de laquelle créer l’OMI. Pour en savoir plus, voir Créer un snapshot d’un volume.

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

The CreateImage command creates an OUTSCALE machine image (OMI).
You can use this method in different ways:

  • Creating from a VM: You create an OMI from one of your virtual machines (VMs).

  • Copying an OMI: You copy an existing OMI. The source OMI can be one of your own OMIs, or an OMI owned by another account that has granted you permission via the UpdateImage method.

  • Registering from a snapshot: You register an OMI from an existing snapshot. The source snapshot can be one of your own snapshots, or a snapshot owned by another account that has granted you permission via the UpdateSnapshot method.

  • Registering from a bucket by using a manifest file: You register an OMI from the manifest file of an OMI that was exported to an OUTSCALE Object Storage (OOS) bucket. First, the owner of the source OMI must export it to the bucket by using the CreateImageExportTask method. Then, they must grant you permission to read the manifest file via a pre-signed URL. For more information, see Creating a Pre-Signed URL.

Registering from a bucket enables you to copy an OMI across Regions.

For more information, see About OMIs.

Request sample: Registering from a snapshot
$ osc-cli api CreateImage --profile "default" \
    --ImageName "register-image-from-snapshot-example" \
    --BlockDeviceMappings '[
        {
          "DeviceName": "/dev/sda1",
          "Bsu": {"SnapshotId": "snap-12345678", "VolumeSize": 120, "VolumeType": "io1", "Iops": 150, "DeleteOnVmDeletion": True}
        }
      ]' \
    --RootDeviceName "/dev/sda1"

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

  • Architecture: (optional) (when registering from a snapshot) The architecture of the OMI (i386 or x86_64).

  • BlockDeviceMappings: (optional) (when registering from a snapshot) 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).

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

  • Description: (optional) A description for the new OMI.

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

  • ImageName: (optional) A unique name for the new OMI.
    Constraints: 3-128 alphanumeric characters, underscores (_), spaces ( ), parentheses (()), slashes (/), periods (.), or dashes (-).

  • ProductCodes: (optional) The product codes associated with the OMI.

  • RootDeviceName: (optional) (when registering from a snapshot) The name of the root device for the new OMI.

The CreateImage command returns the following elements:

  • Image: Information about the OMI.

    • AccountAlias: The account alias of the owner of the OMI.

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

    • Architecture: The architecture of the OMI.

    • BlockDeviceMappings: One or more block device mappings.

      • Bsu: Information about the BSU volume to create.

        • DeleteOnVmDeletion: 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: 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: The ID of the snapshot used to create the volume.

        • VolumeSize: 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: 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: 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).

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

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

    • Description: The description of the OMI.

    • FileLocation: The location from which the OMI files were created.

    • ImageId: The ID of the OMI.

    • ImageName: The name of the OMI.

    • ImageType: The type of the OMI.

    • PermissionsToLaunch: Permissions for the resource.

      • AccountIds: One or more account IDs that the permission is associated with.

      • GlobalPermission: A global permission for all accounts.
        (Request) Set this parameter to true to make the resource public (if the parent parameter is Additions) or to make the resource private (if the parent parameter is Removals).
        (Response) If true, the resource is public. If false, the resource is private.

    • ProductCodes: The product codes associated with the OMI.

    • RootDeviceName: The name of the root device.

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

    • State: The state of the OMI (pending | available | failed).

    • StateComment: Information about the change of state.

      • StateCode: The code of the change of state.

      • StateMessage: A message explaining the change of state.

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

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

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

  • ResponseContext: Information about the context of the response.

    • RequestId: The ID of the request.

Result sample: Registering from a snapshot
{
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  },
  "Image": {
    "StateComment": {},
    "State": "available",
    "RootDeviceType": "bsu",
    "RootDeviceName": "/dev/sda1",
    "ProductCodes": [
      "0001"
    ],
    "PermissionsToLaunch": {
      "GlobalPermission": false,
      "AccountIds": []
    },
    "AccountId": "123456789012",
    "Tags": [],
    "Description": "",
    "ImageId": "ami-12345678",
    "BlockDeviceMappings": [
      {
        "DeviceName": "/dev/sda1",
        "Bsu": {
          "VolumeType": "io1",
          "DeleteOnVmDeletion": true,
          "VolumeSize": 120,
          "Iops": 150,
          "SnapshotId": "snap-12345678"
        }
      }
    ],
    "ImageType": "machine",
    "CreationDate": "2010-10-01T12:34:56.789Z",
    "FileLocation": "123456789012/register-image-from-snapshot-example",
    "Architecture": "x86_64",
    "ImageName": "register-image-from-snapshot-example"
  }
}

Créer une OMI depuis un snapshot avec oapi-cli

Avant de commencer :

  1. Si vous souhaitez partager l’OMI avec d’autres comptes, nettoyez les informations critiques de la VM que vous ne souhaitez pas partager :

  2. (VM Windows uniquement) Pour réinitialiser le système de votre VM Windows, exécutez le script OMI Creation Launcher dans le répertoire C:\Windows\Outscale\scripts de votre VM.

    • Ce script n’est disponible que sur les VM créées à partir d’une OMI officielle. Si la VM a été lancée à partir d’une OMI non officielle, vous pouvez faire un sysprep. Pour en savoir plus, voir la documentation officielle sysprep de Windows.

    • Ce script permet aux VM créées à partir de la future OMI d’être réinitialisées (ID, keypair, mot de passe administrateur, et ainsi de suite).

    La VM est automatiquement arrêtée une fois le script terminé.

  3. Créez un snapshot du volume système de la VM à partir de laquelle créer l’OMI. Pour en savoir plus, voir Créer un snapshot d’un volume.

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

The CreateImage command creates an OUTSCALE machine image (OMI).
You can use this method in different ways:

  • Creating from a VM: You create an OMI from one of your virtual machines (VMs).

  • Copying an OMI: You copy an existing OMI. The source OMI can be one of your own OMIs, or an OMI owned by another account that has granted you permission via the UpdateImage method.

  • Registering from a snapshot: You register an OMI from an existing snapshot. The source snapshot can be one of your own snapshots, or a snapshot owned by another account that has granted you permission via the UpdateSnapshot method.

  • Registering from a bucket by using a manifest file: You register an OMI from the manifest file of an OMI that was exported to an OUTSCALE Object Storage (OOS) bucket. First, the owner of the source OMI must export it to the bucket by using the CreateImageExportTask method. Then, they must grant you permission to read the manifest file via a pre-signed URL. For more information, see Creating a Pre-Signed URL.

Registering from a bucket enables you to copy an OMI across Regions.

For more information, see About OMIs.

Request sample: Registering from a snapshot
$ oapi-cli --profile "default" CreateImage \
    --ImageName "register-image-from-snapshot-example" \
    --BlockDeviceMappings '[
        {
          "DeviceName": "/dev/sda1",
          "Bsu": {"SnapshotId": "snap-12345678", "VolumeSize": 120, "VolumeType": "io1", "Iops": 150, "DeleteOnVmDeletion": True}
        }
      ]' \
    --RootDeviceName "/dev/sda1"

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

  • Architecture: (optional) (when registering from a snapshot) The architecture of the OMI (i386 or x86_64).

  • BlockDeviceMappings: (optional) (when registering from a snapshot) 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).

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

  • Description: (optional) A description for the new OMI.

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

  • ImageName: (optional) A unique name for the new OMI.
    Constraints: 3-128 alphanumeric characters, underscores (_), spaces ( ), parentheses (()), slashes (/), periods (.), or dashes (-).

  • ProductCodes: (optional) The product codes associated with the OMI.

  • RootDeviceName: (optional) (when registering from a snapshot) The name of the root device for the new OMI.

The CreateImage command returns the following elements:

  • Image: Information about the OMI.

    • AccountAlias: The account alias of the owner of the OMI.

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

    • Architecture: The architecture of the OMI.

    • BlockDeviceMappings: One or more block device mappings.

      • Bsu: Information about the BSU volume to create.

        • DeleteOnVmDeletion: 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: 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: The ID of the snapshot used to create the volume.

        • VolumeSize: 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: 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: 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).

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

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

    • Description: The description of the OMI.

    • FileLocation: The location from which the OMI files were created.

    • ImageId: The ID of the OMI.

    • ImageName: The name of the OMI.

    • ImageType: The type of the OMI.

    • PermissionsToLaunch: Permissions for the resource.

      • AccountIds: One or more account IDs that the permission is associated with.

      • GlobalPermission: A global permission for all accounts.
        (Request) Set this parameter to true to make the resource public (if the parent parameter is Additions) or to make the resource private (if the parent parameter is Removals).
        (Response) If true, the resource is public. If false, the resource is private.

    • ProductCodes: The product codes associated with the OMI.

    • RootDeviceName: The name of the root device.

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

    • State: The state of the OMI (pending | available | failed).

    • StateComment: Information about the change of state.

      • StateCode: The code of the change of state.

      • StateMessage: A message explaining the change of state.

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

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

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

  • ResponseContext: Information about the context of the response.

    • RequestId: The ID of the request.

Result sample: Registering from a snapshot
{
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  },
  "Image": {
    "StateComment": {},
    "State": "available",
    "RootDeviceType": "bsu",
    "RootDeviceName": "/dev/sda1",
    "ProductCodes": [
      "0001"
    ],
    "PermissionsToLaunch": {
      "GlobalPermission": false,
      "AccountIds": []
    },
    "AccountId": "123456789012",
    "Tags": [],
    "Description": "",
    "ImageId": "ami-12345678",
    "BlockDeviceMappings": [
      {
        "DeviceName": "/dev/sda1",
        "Bsu": {
          "VolumeType": "io1",
          "DeleteOnVmDeletion": true,
          "VolumeSize": 120,
          "Iops": 150,
          "SnapshotId": "snap-12345678"
        }
      }
    ],
    "ImageType": "machine",
    "CreationDate": "2010-10-01T12:34:56.789Z",
    "FileLocation": "123456789012/register-image-from-snapshot-example",
    "Architecture": "x86_64",
    "ImageName": "register-image-from-snapshot-example"
  }
}

Créer une OMI depuis un snapshot avec AWS CLI

Avant de commencer :

  1. Installez et configurez AWS CLI. Pour en savoir plus, voir Installer et configurer AWS CLI.

  2. Si vous souhaitez partager l’OMI avec d’autres comptes, nettoyez les informations critiques de l’instance que vous ne souhaitez pas partager :

  3. (Instances Windows uniquement) Pour réinitialiser le système de votre VM Windows, exécutez le script OMI Creation Launcher dans le répertoire C:\Windows\Outscale\scripts de votre VM.

    • Ce script n’est disponible que sur les VMs créées à partir d’une OMI officielle. Si la VM a été créée à partir d’une OMI non officielle, vous pouvez faire un sysprep. Pour en savoir plus, voir la documentation officielle sysprep de Windows.

    • Ce script permet aux VMs créées à partir de la future OMI d’être réinitialisées (ID, keypair, mot de passe administrateur, et ainsi de suite).

    La VM est automatiquement arrêtée une fois le script terminé.

  4. Créez un snapshot du volume système de l’instance à partir de laquelle créer l’OMI. Pour en savoir plus, voir Créer un snapshot d’un volume.

Pour créer une OMI, utilisez la commande register-image en suivant cette syntaxe :

Exemple de requête
$ aws ec2 register-image \
    --profile YOUR_PROFILE \
    --name "Test Image" \
    --description "My test image" \
    --architecture x86_64 \
    --root-device-name /dev/sda1 \
    --block-device-mappings "[{\"DeviceName\": \"/dev/sda1\", \
                                \"Ebs\": \
                                        {\"SnapshotId\": \"snap-12345678\"} \
                             }]" \
    --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.

  • name : Le nom de l’OMI.

    Ce nom doit être unique et doit contenir entre 3 et 128 caractères. Les caractères autorisés sont a-z, A-Z, 0-9, l’espace et [_()/.-].

  • (optionnel) description : Une description pour l’OMI.

    Cette description peut contenir n’importe quel caractère Unicode, sans limite de longueur.

  • (optionnel) architecture : L’architecture de l’OMI. Par défaut, paramétré à i386 (architecture 32 bits).

  • root-device-name : Le nom du périphérique pour le volume système.

  • block-device-mappings : Le block device mapping qui indique le snapshot à utiliser pour le volume système. Cet attribut requiert les éléments suivants :

    • DeviceName : Le nom du périphérique pour le volume système.

      Le nom du périphérique doit être le même que celui spécifié pour l’attribut root-device-name.

    • Ebs : Informations à propos du volume système à créer. Cet élément requiert l’information suivante :

      • SnapshotId : L’ID du snapshot depuis lequel vous souhaitez créer l’OMI.

  • endpoint : Le endpoint correspondant à la Région à laquelle vous voulez envoyer la requête. Pour en savoir plus, voir Installer et configurer AWS CLI. La commande register-image renvoie les informations suivantes :

  • ImageId : L’ID de la nouvelle OMI.

Exemple de résultat
 {
    "ImageId": "ami-12345678"
}

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.