|
| 1 | +--- |
| 2 | +page_title: "Scaleway: scaleway_instance_image" |
| 3 | +description: |- |
| 4 | +Manages Scaleway Instance Images. |
| 5 | +--- |
| 6 | + |
| 7 | +# scaleway_instance_image |
| 8 | + |
| 9 | +Creates and manages Scaleway Compute Images. |
| 10 | +For more information, see [the documentation](https://developers.scaleway.com/en/products/instance/api/#images-41389b). |
| 11 | + |
| 12 | +## Example |
| 13 | + |
| 14 | +### From a volume |
| 15 | + |
| 16 | +```hcl |
| 17 | +resource "scaleway_instance_volume" "volume" { |
| 18 | + type = "b_ssd" |
| 19 | + size_in_gb = 20 |
| 20 | +} |
| 21 | +
|
| 22 | +resource "scaleway_instance_snapshot" "volume_snapshot" { |
| 23 | + volume_id = scaleway_instance_volume.volume.id |
| 24 | +} |
| 25 | +
|
| 26 | +resource "scaleway_instance_image" "volume_image" { |
| 27 | + name = "image_from_volume" |
| 28 | + root_volume_id = scaleway_instance_snapshot.volume_snapshot.id |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +### From a server |
| 33 | + |
| 34 | +```hcl |
| 35 | +resource "scaleway_instance_server" "server" { |
| 36 | + image = "ubuntu_focal" |
| 37 | + type = "DEV1-S" |
| 38 | +} |
| 39 | +
|
| 40 | +resource "scaleway_instance_snapshot" "server_snapshot" { |
| 41 | + volume_id = scaleway_instance_server.main.root_volume.0.volume_id |
| 42 | +} |
| 43 | +
|
| 44 | +resource "scaleway_instance_image" "server_image" { |
| 45 | + name = "image_from_server" |
| 46 | + root_volume_id = scaleway_instance_snapshot.server_snapshot.id |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +### With additional volumes |
| 51 | + |
| 52 | +```hcl |
| 53 | +resource "scaleway_instance_server" "server" { |
| 54 | + image = "ubuntu_focal" |
| 55 | + type = "DEV1-S" |
| 56 | +} |
| 57 | +
|
| 58 | +resource "scaleway_instance_volume" "volume" { |
| 59 | + type = "b_ssd" |
| 60 | + size_in_gb = 20 |
| 61 | +} |
| 62 | +
|
| 63 | +resource "scaleway_instance_snapshot" "volume_snapshot" { |
| 64 | + volume_id = scaleway_instance_volume.volume.id |
| 65 | +} |
| 66 | +resource "scaleway_instance_snapshot" "server_snapshot" { |
| 67 | + volume_id = scaleway_instance_server.main.root_volume.0.volume_id |
| 68 | +} |
| 69 | +
|
| 70 | +resource "scaleway_instance_image" "image" { |
| 71 | + name = "image_with_extra_volumes" |
| 72 | + root_volume_id = scaleway_instance_snapshot.server_snapshot.id |
| 73 | + additional_volumes = [ |
| 74 | + scaleway_instance_snapshot.volume_snapshot.id |
| 75 | + ] |
| 76 | +} |
| 77 | +``` |
| 78 | + |
| 79 | +## Arguments Reference |
| 80 | + |
| 81 | +The following arguments are supported: |
| 82 | + |
| 83 | +- `root_volume_id` - (Required) The ID of the snapshot of the volume to be used as root in the image. |
| 84 | +- `name` - (Optional) The name of the image. If not provided it will be randomly generated. |
| 85 | +- `architecture` - (Optional, default `x86_64`) The architecture the image is compatible with. Possible values are: `x86_64` or `arm`. |
| 86 | +- `additional_volume_ids` - (Optional) List of IDs of the snapshots of the additional volumes to be attached to the image. |
| 87 | + |
| 88 | +-> **Important:** For now it is only possible to have 1 additional_volume. |
| 89 | + |
| 90 | +- `tags` - (Optional) A list of tags to apply to the image. |
| 91 | +- `public` - (Optional) Set to `true` if the image is public. |
| 92 | +- `zone` - (Defaults to provider `zone`) The [zone](../guides/regions_and_zones.md#zones) in which the image should be created. |
| 93 | +- `project_id` - (Defaults to provider `project_id`) The ID of the project the image is associated with. |
| 94 | + |
| 95 | +## Attributes Reference |
| 96 | + |
| 97 | +In addition to all above arguments, the following attributes are exported: |
| 98 | + |
| 99 | +- `id` - The ID of the image. |
| 100 | +- `creation_date` - Date of the image creation. |
| 101 | +- `modification_date` - Date of image latest update. |
| 102 | +- `from_server_id` - ID of the server the image is based on (in case it is a backup). |
| 103 | +- `state` - State of the image. Possible values are: `available`, `creating` or `error`. |
| 104 | +- `organization_id` - The organization ID the image is associated with. |
| 105 | +- `additional_volumes` - The description of the extra volumes attached to the image. |
| 106 | + |
| 107 | + -> The `additional_volumes` block contains : |
| 108 | + - `id` - The ID of the volume. |
| 109 | + - `name` - The name of the volume. |
| 110 | + - `export_uri` - The export URI of the volume. |
| 111 | + - `size` - The size of the volume. |
| 112 | + - `volume_type` - The type of volume, possible values are `l_ssd` and `b_ssd`. |
| 113 | + - `creation_date` - Date of the volume creation. |
| 114 | + - `modification_date` - Date of volume latest update. |
| 115 | + - `organization` - The organization ID the volume is associated with. |
| 116 | + - `project` - ID of the project the volume is associated with |
| 117 | + - `tags` - List of tags associated with the volume. |
| 118 | + - `state` - State of the volume. |
| 119 | + - `zone` - The [zone](../guides/regions_and_zones.md#zones) in which the volume is. |
| 120 | + - `server` - Description of the server containing the volume (in case the image is a backup from a server). |
| 121 | + |
| 122 | + -> The `server` block contains : |
| 123 | + - `id` - ID of the server containing the volume. |
| 124 | + - `name` - Name of the server containing the volume. |
| 125 | + |
| 126 | +## Import |
| 127 | + |
| 128 | +Images can be imported using the `{zone}/{id}`, e.g. |
| 129 | + |
| 130 | +```bash |
| 131 | +$ terraform import scaleway_instance_image.main fr-par-1/11111111-1111-1111-1111-111111111111 |
| 132 | +``` |
0 commit comments