Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update azurerm_shared_image - flip generalized to specialized #7525

Merged
merged 1 commit into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions azurerm/internal/services/compute/shared_image_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func dataSourceArmSharedImage() *schema.Resource {
Computed: true,
},

"generalized": {
"specialized": {
Type: schema.TypeBool,
Computed: true,
},
Expand Down Expand Up @@ -130,7 +130,7 @@ func dataSourceArmSharedImageRead(d *schema.ResourceData, meta interface{}) erro
d.Set("description", props.Description)
d.Set("eula", props.Eula)
d.Set("os_type", string(props.OsType))
d.Set("generalized", props.OsState != compute.Specialized)
d.Set("specialized", props.OsState == compute.Specialized)
d.Set("hyper_v_generation", string(props.HyperVGeneration))
d.Set("privacy_statement_uri", props.PrivacyStatementURI)
d.Set("release_note_uri", props.ReleaseNoteURI)
Expand Down
21 changes: 10 additions & 11 deletions azurerm/internal/services/compute/shared_image_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,6 @@ func resourceArmSharedImage() *schema.Resource {
}, false),
},

"generalized": {
Type: schema.TypeBool,
Optional: true,
Default: true,
ForceNew: true,
},

"hyper_v_generation": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -129,6 +122,12 @@ func resourceArmSharedImage() *schema.Resource {
Optional: true,
},

"specialized": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
},

"tags": tags.Schema(),
},
}
Expand Down Expand Up @@ -172,10 +171,10 @@ func resourceArmSharedImageCreateUpdate(d *schema.ResourceData, meta interface{}
Tags: tags.Expand(d.Get("tags").(map[string]interface{})),
}

if d.Get("generalized").(bool) {
image.GalleryImageProperties.OsState = compute.Generalized
} else {
if d.Get("specialized").(bool) {
image.GalleryImageProperties.OsState = compute.Specialized
} else {
image.GalleryImageProperties.OsState = compute.Generalized
}

future, err := client.CreateOrUpdate(ctx, resourceGroup, galleryName, name, image)
Expand Down Expand Up @@ -233,7 +232,7 @@ func resourceArmSharedImageRead(d *schema.ResourceData, meta interface{}) error
d.Set("description", props.Description)
d.Set("eula", props.Eula)
d.Set("os_type", string(props.OsType))
d.Set("generalized", props.OsState != compute.Specialized)
d.Set("specialized", props.OsState == compute.Specialized)
d.Set("hyper_v_generation", string(props.HyperVGeneration))
d.Set("privacy_statement_uri", props.PrivacyStatementURI)
d.Set("release_note_uri", props.ReleaseNoteURI)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ resource "azurerm_shared_image" "test" {
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
os_type = "Linux"
generalized = true
hyper_v_generation = var.hyper_v_generation != "" ? var.hyper_v_generation : null

identifier {
Expand Down Expand Up @@ -239,7 +238,7 @@ resource "azurerm_shared_image" "test" {
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
os_type = "Linux"
generalized = false
specialized = true
hyper_v_generation = var.hyper_v_generation != "" ? var.hyper_v_generation : null

identifier {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/shared_image.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The following attributes are exported:

* `location` - The supported Azure location where the Shared Image Gallery exists.

* `generalized` - Is the Operating System present in this Shared Image generalized or not. `false` indicates this image is specialized which for windows images means they have been sysprepped.
* `specialized` - Is the Operating System present in this Shared Image specialized or not. `true` indicates this image is specialized which for windows images means they have been sysprepped.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(same here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand. I will soon make another PR to update this doc entry


* `identifier` - An `identifier` block as defined below.

Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/shared_image.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The following arguments are supported:

* `eula` - (Optional) The End User Licence Agreement for the Shared Image.

* `generalized` - (Optional) Should the Operating System present in this Shared Image be generalized? Defaults to `true`. Setting this to `false` creates a specialized imagine which is the equivalent of sysprepping in windows. Changing this forces a new resource to be created.
* `specialized` - (Optional) Should the Operating System present in this Shared Image be specialized? Defaults to `false`. Setting this to `true` creates a specialized imagine which is the equivalent of sysprepping in windows. Changing this forces a new resource to be created.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a Generalized image is one where SysPrep has been applied - Specialised is one where the machine data (including the UUID) is reused - which can cause serious issues (I've personally seen production incidents/data corruption from where sysprep wasn't run) - so we should probably have a warning recommending to use a Generalized image where possible

Suggested change
* `specialized` - (Optional) Should the Operating System present in this Shared Image be specialized? Defaults to `false`. Setting this to `true` creates a specialized imagine which is the equivalent of sysprepping in windows. Changing this forces a new resource to be created.
* `specialized` - (Optional) Specifies that the Operating System used inside this Image has not been Generalized (for example, `sysprep` on Windows has not been run). Defaults to `false`. Changing this forces a new resource to be created.
!> **Note:** It's recommended to Generalize images where possible - Specialized Images reuse the same UUID internally within each Virtual Machine, which can have unintended side-effects.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand. I will soon make another PR to update this doc entry


* `hyper_v_generation` - (Optional) The generation of HyperV that the Virtual Machine used to create the Shared Image is based on. Possible values are `V1` and `V2`. Defaults to `V1`. Changing this forces a new resource to be created.

Expand Down