99 "github.com/scaleway/scaleway-sdk-go/scw"
1010 "github.com/scaleway/terraform-provider-scaleway/v2/internal/datasource"
1111 "github.com/scaleway/terraform-provider-scaleway/v2/internal/locality/zonal"
12+ "github.com/scaleway/terraform-provider-scaleway/v2/internal/verify"
1213)
1314
1415func DataSourceImage () * schema.Resource {
@@ -26,6 +27,13 @@ func DataSourceImage() *schema.Resource {
2627 Default : "DEV1-S" ,
2728 Description : "The instance commercial type of the desired image" ,
2829 },
30+ "image_type" : {
31+ Type : schema .TypeString ,
32+ Optional : true ,
33+ Default : "instance_local" , // Keep the old default as default to avoid a breaking change.
34+ Description : "The type of the desired image, instance_local or instance_sbs" ,
35+ ValidateDiagFunc : verify .ValidateEnum [marketplace.LocalImageType ](),
36+ },
2937 "zone" : zonal .Schema (),
3038 },
3139 }
@@ -41,7 +49,7 @@ func DataSourceMarketplaceImageRead(ctx context.Context, d *schema.ResourceData,
4149 ImageLabel : d .Get ("label" ).(string ),
4250 CommercialType : d .Get ("instance_type" ).(string ),
4351 Zone : zone ,
44- Type : marketplace .LocalImageTypeInstanceLocal ,
52+ Type : marketplace .LocalImageType ( d . Get ( "image_type" ).( string )) ,
4553 }, scw .WithContext (ctx ))
4654 if err != nil {
4755 return diag .FromErr (err )
@@ -52,6 +60,7 @@ func DataSourceMarketplaceImageRead(ctx context.Context, d *schema.ResourceData,
5260 _ = d .Set ("zone" , zone )
5361 _ = d .Set ("label" , d .Get ("label" ))
5462 _ = d .Set ("instance_type" , d .Get ("type" ))
63+ _ = d .Set ("image_type" , image .Type )
5564
5665 return nil
5766}
0 commit comments