Skip to content

Commit

Permalink
feat: add option to create managed image in Azure (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
sternik authored Oct 24, 2024
1 parent 9ba4ba5 commit 2f78a59
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ terraform {
required_providers {
imagefactory = {
source = "nordcloud/imagefactory"
version = "1.11.0"
version = "1.12.0"
}
}
}
Expand Down
1 change: 1 addition & 0 deletions docs/resources/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ Optional:

- `additional_data_disks` (Block List, Max: 10) (see [below for nested schema](#nestedblock--config--azure--additional_data_disks))
- `additional_signatures` (Block List) Additional UEFI keys that are used to validate the boot loader. This feature allows you to bind UEFI keys for driver/kernel modules that are signed by using a private key that's owned by third-party vendors. (see [below for nested schema](#nestedblock--config--azure--additional_signatures))
- `create_managed_image` (Boolean) Enable to create an additional legacy managed image, apart from the default image that will be created in Azure Compute Gallery.
- `eol_date_option` (Boolean) Default value is set to true
- `exclude_from_latest` (Boolean)
- `replica_regions` (List of String)
Expand Down
2 changes: 1 addition & 1 deletion examples/provider/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ terraform {
required_providers {
imagefactory = {
source = "nordcloud/imagefactory"
version = "1.11.0"
version = "1.12.0"
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions imagefactory/imagetemplate/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ var azureTemplateConfigResource = &schema.Resource{
Type: schema.TypeBool,
Optional: true,
},
"create_managed_image": {
Type: schema.TypeBool,
Optional: true,
Description: "Enable to create an additional legacy managed image, " +
"apart from the default image that will be created in Azure Compute Gallery.",
},
"additional_signatures": {
Type: schema.TypeList,
Optional: true,
Expand Down
12 changes: 7 additions & 5 deletions imagefactory/imagetemplate/structures.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,20 @@ func expandTemplateAzureConfig(in []interface{}) *graphql.NewTemplateAZUREConfig
e := graphql.Boolean(m["exclude_from_latest"].(bool))
eol := graphql.Boolean(m["eol_date_option"].(bool))
tl := graphql.Boolean(m["trusted_launch"].(bool))
mi := graphql.Boolean(m["create_managed_image"].(bool))

rr := []graphql.String{}
for _, v := range m["replica_regions"].([]interface{}) {
rr = append(rr, graphql.String(v.(string)))
}

out := &graphql.NewTemplateAZUREConfig{
ExcludeFromLatest: &e,
EolDateOption: &eol,
ReplicaRegions: &rr,
TrustedLaunch: &tl,
VmImageDefinition: expandVMImageDefinitionTemplateAzureConfig(m["vm_image_definition"].([]interface{})),
ExcludeFromLatest: &e,
EolDateOption: &eol,
ReplicaRegions: &rr,
TrustedLaunch: &tl,
CreateManagedImage: &mi,
VmImageDefinition: expandVMImageDefinitionTemplateAzureConfig(m["vm_image_definition"].([]interface{})),
}

if m["additional_data_disks"] != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/graphql/graphql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions pkg/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,7 @@ type TemplateAZUREConfig {
additionalDataDisks: [AdditionalDataDisks!]
trustedLaunch: Boolean
additionalSignatures: [UefiKey!]
createManagedImage: Boolean
}

type TemplateExoscaleConfig {
Expand Down Expand Up @@ -1217,6 +1218,14 @@ input NewTemplateAZUREConfig {
"""
additionalDataDisks: [NewAdditionalDataDisks!]

"""
`createManagedImage` defines whether the image should also be created as a managed image during the imaging process.
Create a managed image that can be used to deploy virtual machines and virtual machine scale sets.
By default, images are created in Azure Compute Gallery. If this option is set to true additional managed image will be created.
"""
createManagedImage: Boolean
}

input NewTemplateExoscaleConfig {
Expand Down

0 comments on commit 2f78a59

Please sign in to comment.