Skip to content

Commit d05ef57

Browse files
authored
bugfix: setting ebs volume type (#84)
Co-authored-by: sternik <sternik@users.noreply.github.com>
1 parent a547a1a commit d05ef57

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ terraform {
3434
required_providers {
3535
imagefactory = {
3636
source = "nordcloud/imagefactory"
37-
version = "1.14.0"
37+
version = "1.14.1"
3838
}
3939
}
4040
}

docs/resources/template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ Optional:
341341

342342
- `additional_ebs_volumes` (Block List, Max: 10) (see [below for nested schema](#nestedblock--config--aws--additional_ebs_volumes))
343343
- `custom_image_name` (String)
344-
- `ebs_volume_type` (String) The type of the EBS volume. Available types are `gp2`, `gp3`. If not specified, volume type is used from the source image.
344+
- `ebs_volume_type` (String) The type of the EBS volume of primary block device. Available types are `gp2`, `gp3`. If not specified, volume type is used from the source image.
345345
- `kms_key_id` (String) The ID of the AWS KMS key that is used to encrypt the destination snapshot of the copied image. To allow use of this key, onboarded master role `ImageFactoryMasterRole` must have permission to use the key. You can use key ID, key ARN, alias name, or alias ARN.
346346
- `region` (String)
347347

examples/provider/provider.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ terraform {
77
required_providers {
88
imagefactory = {
99
source = "nordcloud/imagefactory"
10-
version = "1.14.0"
10+
version = "1.14.1"
1111
}
1212
}
1313
}

imagefactory/account/resource.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021-2023 Nordcloud Oy or its affiliates. All Rights Reserved.
1+
// Copyright 2021-2025 Nordcloud Oy or its affiliates. All Rights Reserved.
22

33
package account
44

@@ -39,7 +39,6 @@ func accountCreate(d *schema.ResourceData, m interface{}, provider graphql.Provi
3939
CloudProviderId: graphql.String(d.Get(getCloudProviderKeyName(provider)).(string)),
4040
Provider: provider,
4141
Scope: &scope,
42-
Properties: &graphql.AccountCloudPropertiesInput{},
4342
}
4443

4544
switch provider {
@@ -161,7 +160,7 @@ func setProps(d *schema.ResourceData, a sdk.Account) diag.Diagnostics {
161160
return diag.FromErr(err)
162161
}
163162

164-
if a.Provider == graphql.ProviderAWS {
163+
if a.Provider == graphql.ProviderAWS && a.Properties != nil {
165164
if err := d.Set("properties", []map[string]interface{}{
166165
flattenAccountProperties(a.Properties),
167166
}); err != nil {

imagefactory/imagetemplate/structures.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,17 @@ func expandAdditionalEBSVolumes(in []interface{}) *[]graphql.NewAdditionalEBSVol
5050
out := []graphql.NewAdditionalEBSVolumes{}
5151
for i := range in {
5252
m := in[i].(map[string]interface{})
53-
out = append(out, graphql.NewAdditionalEBSVolumes{
53+
v := graphql.NewAdditionalEBSVolumes{
5454
Size: graphql.Int(m["size"].(int)),
5555
DeviceName: graphql.String(m["device_name"].(string)),
56-
})
56+
}
57+
if m["volume_type"] != nil {
58+
volumeType := graphql.EBSVolumeType(m["volume_type"].(string))
59+
if volumeType != "" {
60+
v.VolumeType = &volumeType
61+
}
62+
}
63+
out = append(out, v)
5764
}
5865

5966
return &out
@@ -92,6 +99,13 @@ func expandTemplateAwsConfig(in []interface{}, scope graphql.Scope) (*graphql.Ne
9299
}
93100
}
94101

102+
if m["ebs_volume_type"] != nil {
103+
ebsVolumeType := graphql.EBSVolumeType(m["ebs_volume_type"].(string))
104+
if ebsVolumeType != "" {
105+
tplConfig.EbsVolumeType = &ebsVolumeType
106+
}
107+
}
108+
95109
return tplConfig, nil
96110
}
97111

0 commit comments

Comments
 (0)