Skip to content

Commit db95a6e

Browse files
committed
fix(instance): image: remove MaxItems on additional volumes + fix doc
1 parent 27a6b65 commit db95a6e

File tree

6 files changed

+11372
-1941
lines changed

6 files changed

+11372
-1941
lines changed

docs/resources/instance_image.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ resource "scaleway_instance_snapshot" "server_snapshot" {
6969
resource "scaleway_instance_image" "image" {
7070
name = "image_with_extra_volumes"
7171
root_volume_id = scaleway_instance_snapshot.server_snapshot.id
72-
additional_volumes = [
72+
additional_volume_ids = [
7373
scaleway_instance_snapshot.volume_snapshot.id
7474
]
7575
}
@@ -83,9 +83,6 @@ The following arguments are supported:
8383
- `name` - (Optional) The name of the image. If not provided it will be randomly generated.
8484
- `architecture` - (Optional, default `x86_64`) The architecture the image is compatible with. Possible values are: `x86_64` or `arm`.
8585
- `additional_volume_ids` - (Optional) List of IDs of the snapshots of the additional volumes to be attached to the image.
86-
87-
-> **Important:** For now it is only possible to have 1 additional_volume.
88-
8986
- `tags` - (Optional) A list of tags to apply to the image.
9087
- `public` - (Optional) Set to `true` if the image is public.
9188
- `zone` - (Defaults to provider `zone`) The [zone](../guides/regions_and_zones.md#zones) in which the image should be created.

internal/services/instance/image.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ func ResourceImage() *schema.Resource {
5959
"additional_volume_ids": {
6060
Type: schema.TypeList,
6161
Optional: true,
62-
MaxItems: 1,
6362
Elem: &schema.Schema{
6463
Type: schema.TypeString,
6564
ValidateDiagFunc: verify.IsUUIDorUUIDWithLocality(),

internal/services/instance/image_test.go

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -133,44 +133,41 @@ func TestAccImage_ExternalBlockVolume(t *testing.T) {
133133
size_in_gb = 50
134134
iops = 5000
135135
}
136-
137-
resource "scaleway_block_snapshot" "main" {
138-
volume_id = scaleway_block_volume.main.id
139-
}
140-
`,
141-
},
142-
{
143-
Config: `
144-
resource "scaleway_block_volume" "main" {
136+
resource "scaleway_block_volume" "additional1" {
145137
size_in_gb = 50
146138
iops = 5000
147139
}
148-
149-
resource "scaleway_block_volume" "additional1" {
140+
resource "scaleway_block_volume" "additional2" {
150141
size_in_gb = 50
151142
iops = 5000
152143
}
153144
154145
resource "scaleway_block_snapshot" "main" {
155146
volume_id = scaleway_block_volume.main.id
156147
}
157-
158148
resource "scaleway_block_snapshot" "additional1" {
159149
volume_id = scaleway_block_volume.additional1.id
160150
}
151+
resource "scaleway_block_snapshot" "additional2" {
152+
volume_id = scaleway_block_volume.additional2.id
153+
}
161154
162155
resource "scaleway_instance_image" "main" {
163156
name = "tf-test-image-external-block-volume"
164157
root_volume_id = scaleway_block_snapshot.main.id
165-
additional_volume_ids = [scaleway_block_snapshot.additional1.id]
158+
additional_volume_ids = [
159+
scaleway_block_snapshot.additional1.id,
160+
scaleway_block_snapshot.additional2.id
161+
]
166162
}
167163
`,
168164
Check: resource.ComposeTestCheckFunc(
169165
instancechecks.DoesImageExists(tt, "scaleway_instance_image.main"),
170166
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "root_volume_id", "scaleway_block_snapshot.main", "id"),
171167
resource.TestCheckResourceAttr("scaleway_instance_image.main", "architecture", "x86_64"),
172-
resource.TestCheckResourceAttr("scaleway_instance_image.main", "additional_volume_ids.#", "1"),
168+
resource.TestCheckResourceAttr("scaleway_instance_image.main", "additional_volume_ids.#", "2"),
173169
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "additional_volume_ids.0", "scaleway_block_snapshot.additional1", "id"),
170+
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "additional_volume_ids.1", "scaleway_block_snapshot.additional2", "id"),
174171
),
175172
},
176173
{
@@ -179,19 +176,24 @@ func TestAccImage_ExternalBlockVolume(t *testing.T) {
179176
size_in_gb = 50
180177
iops = 5000
181178
}
182-
183179
resource "scaleway_block_volume" "additional1" {
184180
size_in_gb = 50
185181
iops = 5000
186182
}
183+
resource "scaleway_block_volume" "additional2" {
184+
size_in_gb = 50
185+
iops = 5000
186+
}
187187
188188
resource "scaleway_block_snapshot" "main" {
189189
volume_id = scaleway_block_volume.main.id
190190
}
191-
192191
resource "scaleway_block_snapshot" "additional1" {
193192
volume_id = scaleway_block_volume.additional1.id
194193
}
194+
resource "scaleway_block_snapshot" "additional2" {
195+
volume_id = scaleway_block_volume.additional2.id
196+
}
195197
196198
resource "scaleway_instance_image" "main" {
197199
name = "tf-test-image-external-block-volume"
@@ -463,27 +465,15 @@ func TestAccImage_ServerWithLocalVolume(t *testing.T) {
463465
volume_type = "l_ssd"
464466
}
465467
}
466-
resource "scaleway_instance_snapshot" "local01" {
467-
volume_id = scaleway_instance_server.server01.root_volume.0.volume_id
468-
depends_on = [ scaleway_instance_server.server01 ]
469-
}
470-
`,
471-
Check: resource.ComposeTestCheckFunc(
472-
isServerPresent(tt, "scaleway_instance_server.server01"),
473-
isSnapshotPresent(tt, "scaleway_instance_snapshot.local01"),
474-
),
475-
},
476-
{
477-
Config: `
478-
resource "scaleway_instance_server" "server01" {
468+
resource "scaleway_instance_server" "server02" {
479469
image = "ubuntu_focal"
480470
type = "DEV1-S"
481471
root_volume {
482-
size_in_gb = 15
472+
size_in_gb = 10
483473
volume_type = "l_ssd"
484474
}
485475
}
486-
resource "scaleway_instance_server" "server02" {
476+
resource "scaleway_instance_server" "server03" {
487477
image = "ubuntu_focal"
488478
type = "DEV1-S"
489479
root_volume {
@@ -494,18 +484,21 @@ func TestAccImage_ServerWithLocalVolume(t *testing.T) {
494484
495485
resource "scaleway_instance_snapshot" "local01" {
496486
volume_id = scaleway_instance_server.server01.root_volume.0.volume_id
497-
depends_on = [ scaleway_instance_server.server01 ]
498487
}
499488
resource "scaleway_instance_snapshot" "local02" {
500489
volume_id = scaleway_instance_server.server02.root_volume.0.volume_id
501-
depends_on = [ scaleway_instance_server.server02 ]
490+
}
491+
resource "scaleway_instance_snapshot" "local03" {
492+
volume_id = scaleway_instance_server.server03.root_volume.0.volume_id
502493
}
503494
`,
504495
Check: resource.ComposeTestCheckFunc(
505496
isServerPresent(tt, "scaleway_instance_server.server01"),
506497
isServerPresent(tt, "scaleway_instance_server.server02"),
498+
isServerPresent(tt, "scaleway_instance_server.server03"),
507499
isSnapshotPresent(tt, "scaleway_instance_snapshot.local01"),
508500
isSnapshotPresent(tt, "scaleway_instance_snapshot.local02"),
501+
isSnapshotPresent(tt, "scaleway_instance_snapshot.local03"),
509502
),
510503
},
511504
{
@@ -526,33 +519,43 @@ func TestAccImage_ServerWithLocalVolume(t *testing.T) {
526519
volume_type = "l_ssd"
527520
}
528521
}
522+
resource "scaleway_instance_server" "server03" {
523+
image = "ubuntu_focal"
524+
type = "DEV1-S"
525+
root_volume {
526+
size_in_gb = 10
527+
volume_type = "l_ssd"
528+
}
529+
}
529530
530531
resource "scaleway_instance_snapshot" "local01" {
531532
volume_id = scaleway_instance_server.server01.root_volume.0.volume_id
532-
depends_on = [ scaleway_instance_server.server01 ]
533533
}
534534
resource "scaleway_instance_snapshot" "local02" {
535535
volume_id = scaleway_instance_server.server02.root_volume.0.volume_id
536-
depends_on = [ scaleway_instance_server.server02 ]
536+
}
537+
resource "scaleway_instance_snapshot" "local03" {
538+
volume_id = scaleway_instance_server.server03.root_volume.0.volume_id
537539
}
538540
539541
resource "scaleway_instance_image" "main" {
540542
root_volume_id = scaleway_instance_snapshot.local01.id
541-
additional_volume_ids = [ scaleway_instance_snapshot.local02.id ]
542-
depends_on = [
543-
scaleway_instance_snapshot.local01,
544-
scaleway_instance_snapshot.local02,
543+
additional_volume_ids = [
544+
scaleway_instance_snapshot.local02.id,
545+
scaleway_instance_snapshot.local03.id
545546
]
546547
}
547548
`,
548549
Check: resource.ComposeTestCheckFunc(
549-
isServerPresent(tt, "scaleway_instance_server.server01"),
550-
isServerPresent(tt, "scaleway_instance_server.server02"),
551550
isSnapshotPresent(tt, "scaleway_instance_snapshot.local01"),
552551
isSnapshotPresent(tt, "scaleway_instance_snapshot.local02"),
552+
isSnapshotPresent(tt, "scaleway_instance_snapshot.local03"),
553553
instancechecks.DoesImageExists(tt, "scaleway_instance_image.main"),
554554
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "root_volume_id", "scaleway_instance_snapshot.local01", "id"),
555-
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "additional_volumes.0.id", "scaleway_instance_snapshot.local02", "id"),
555+
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "additional_volumes.1.id", "scaleway_instance_snapshot.local02", "id"),
556+
resource.TestCheckResourceAttr("scaleway_instance_image.main", "additional_volumes.1.volume_type", "l_ssd"),
557+
resource.TestCheckResourceAttr("scaleway_instance_image.main", "additional_volumes.1.size", "10000000000"),
558+
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "additional_volumes.0.id", "scaleway_instance_snapshot.local03", "id"),
556559
resource.TestCheckResourceAttr("scaleway_instance_image.main", "additional_volumes.0.volume_type", "l_ssd"),
557560
resource.TestCheckResourceAttr("scaleway_instance_image.main", "additional_volumes.0.size", "10000000000"),
558561
),

internal/services/instance/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ func ResourceServer() *schema.Resource {
290290
Type: schema.TypeMap,
291291
Optional: true,
292292
Computed: true,
293-
Description: "The user data associated with the server", // TODO: document reserved keys (`cloud-init`)
293+
Description: "The user data associated with the server",
294294
Elem: &schema.Schema{
295295
Type: schema.TypeString,
296296
},

0 commit comments

Comments
 (0)