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

unset disk_size_gb, ignore encryption settings if disabled #563

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions azurerm/encryption_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ func expandManagedDiskEncryptionSettings(settings map[string]interface{}) *disk.
config := &disk.EncryptionSettings{
Enabled: utils.Bool(enabled),
}
if enabled == false {
return config
}
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add a test covering this scenario (disabling then enabling encryption)?


if v := settings["disk_encryption_key"].([]interface{}); len(v) > 0 {
dek := v[0].(map[string]interface{})
Expand Down
4 changes: 2 additions & 2 deletions azurerm/resource_arm_managed_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ func resourceArmManagedDisk() *schema.Resource {

func validateDiskSizeGB(v interface{}, k string) (ws []string, errors []error) {
value := v.(int)
if value < 1 || value > 4095 {
if value < 0 || value > 4095 {
errors = append(errors, fmt.Errorf(
"The `disk_size_gb` can only be between 1 and 4095"))
"The `disk_size_gb` can only be between 0 and 4095"))
}
return
}
Expand Down