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

compute: upgrading the API Version to 2019-07-01 #4331

Merged
merged 3 commits into from
Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion azurerm/data_source_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"regexp"
"sort"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/data_source_shared_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package azurerm
import (
"fmt"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/hashicorp/terraform/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate"
Expand Down
8 changes: 4 additions & 4 deletions azurerm/data_source_shared_image_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"log"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/hashicorp/terraform/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate"
Expand Down Expand Up @@ -110,11 +110,11 @@ func dataSourceArmSharedImageVersionRead(d *schema.ResourceData, meta interface{
if err := d.Set("target_region", flattenedRegions); err != nil {
return fmt.Errorf("Error setting `target_region`: %+v", err)
}
}

if profile := props.StorageProfile; profile != nil {
if source := profile.Source; source != nil {
if image := source.ManagedImage; image != nil {
d.Set("managed_image_id", image.ID)
}
d.Set("managed_image_id", source.ID)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions azurerm/data_source_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ func dataSourceArmSnapshotRead(d *schema.ResourceData, meta interface{}) error {
d.Set("disk_size_gb", int(*props.DiskSizeGB))
}

if props.EncryptionSettings != nil {
d.Set("encryption_settings", flattenManagedDiskEncryptionSettings(props.EncryptionSettings))
if err := d.Set("encryption_settings", flattenManagedDiskEncryptionSettings(props.EncryptionSettingsCollection)); err != nil {
return fmt.Errorf("Error setting `encryption_settings`: %+v", err)
}
}

Expand Down
63 changes: 41 additions & 22 deletions azurerm/encryption_settings.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package azurerm

import (
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/hashicorp/terraform/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)
Expand Down Expand Up @@ -63,18 +63,21 @@ func encryptionSettingsSchema() *schema.Schema {
}
}

func expandManagedDiskEncryptionSettings(settings map[string]interface{}) *compute.EncryptionSettings {
func expandManagedDiskEncryptionSettings(settings map[string]interface{}) *compute.EncryptionSettingsCollection {
enabled := settings["enabled"].(bool)
config := &compute.EncryptionSettings{
config := &compute.EncryptionSettingsCollection{
Enabled: utils.Bool(enabled),
}

var diskEncryptionKey *compute.KeyVaultAndSecretReference
var keyEncryptionKey *compute.KeyVaultAndKeyReference

if v := settings["disk_encryption_key"].([]interface{}); len(v) > 0 {
dek := v[0].(map[string]interface{})

secretURL := dek["secret_url"].(string)
sourceVaultId := dek["source_vault_id"].(string)
config.DiskEncryptionKey = &compute.KeyVaultAndSecretReference{
diskEncryptionKey = &compute.KeyVaultAndSecretReference{
SecretURL: utils.String(secretURL),
SourceVault: &compute.SourceVault{
ID: utils.String(sourceVaultId),
Expand All @@ -87,46 +90,62 @@ func expandManagedDiskEncryptionSettings(settings map[string]interface{}) *compu

secretURL := kek["key_url"].(string)
sourceVaultId := kek["source_vault_id"].(string)
config.KeyEncryptionKey = &compute.KeyVaultAndKeyReference{
keyEncryptionKey = &compute.KeyVaultAndKeyReference{
KeyURL: utils.String(secretURL),
SourceVault: &compute.SourceVault{
ID: utils.String(sourceVaultId),
},
}
}

// at this time we only support a single element
config.EncryptionSettings = &[]compute.EncryptionSettingsElement{
{
DiskEncryptionKey: diskEncryptionKey,
KeyEncryptionKey: keyEncryptionKey,
},
}
return config
}

func flattenManagedDiskEncryptionSettings(encryptionSettings *compute.EncryptionSettings) []interface{} {
func flattenManagedDiskEncryptionSettings(encryptionSettings *compute.EncryptionSettingsCollection) []interface{} {
if encryptionSettings == nil {
return []interface{}{}
}

value := map[string]interface{}{
"enabled": *encryptionSettings.Enabled,
}

if key := encryptionSettings.DiskEncryptionKey; key != nil {
keys := make(map[string]interface{})
for _, settings := range *encryptionSettings.EncryptionSettings {
if key := settings.DiskEncryptionKey; key != nil {
keys := make(map[string]interface{})

keys["secret_url"] = *key.SecretURL
if vault := key.SourceVault; vault != nil {
keys["source_vault_id"] = *vault.ID
}

keys["secret_url"] = *key.SecretURL
if vault := key.SourceVault; vault != nil {
keys["source_vault_id"] = *vault.ID
value["disk_encryption_key"] = []interface{}{keys}
}

value["disk_encryption_key"] = []interface{}{keys}
}
if key := settings.KeyEncryptionKey; key != nil {
keys := make(map[string]interface{})

if key := encryptionSettings.KeyEncryptionKey; key != nil {
keys := make(map[string]interface{})
keys["key_url"] = *key.KeyURL

keys["key_url"] = *key.KeyURL
if vault := key.SourceVault; vault != nil {
keys["source_vault_id"] = *vault.ID
}

if vault := key.SourceVault; vault != nil {
keys["source_vault_id"] = *vault.ID
value["key_encryption_key"] = []interface{}{keys}
}

value["key_encryption_key"] = []interface{}{keys}
// at this time we only support a single element
break
}

output := make([]interface{}, 0)
output = append(output, value)
return output
return []interface{}{
value,
}
}
2 changes: 1 addition & 1 deletion azurerm/internal/clients/compute.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package clients

import (
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common"
)
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_availability_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"strings"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"log"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/suppress"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features"
Expand Down
12 changes: 5 additions & 7 deletions azurerm/resource_arm_managed_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"strings"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
Expand Down Expand Up @@ -235,7 +235,7 @@ func resourceArmManagedDiskCreateUpdate(d *schema.ResourceData, meta interface{}
if v, ok := d.GetOk("encryption_settings"); ok {
encryptionSettings := v.([]interface{})
settings := encryptionSettings[0].(map[string]interface{})
createDisk.EncryptionSettings = expandManagedDiskEncryptionSettings(settings)
createDisk.EncryptionSettingsCollection = expandManagedDiskEncryptionSettings(settings)
}

future, err := client.CreateOrUpdate(ctx, resGroup, name, createDisk)
Expand Down Expand Up @@ -303,11 +303,9 @@ func resourceArmManagedDiskRead(d *schema.ResourceData, meta interface{}) error
flattenAzureRmManagedDiskCreationData(d, resp.CreationData)
}

if settings := resp.EncryptionSettings; settings != nil {
flattened := flattenManagedDiskEncryptionSettings(settings)
if err := d.Set("encryption_settings", flattened); err != nil {
return fmt.Errorf("Error setting encryption settings: %+v", err)
}
flattened := flattenManagedDiskEncryptionSettings(resp.EncryptionSettingsCollection)
if err := d.Set("encryption_settings", flattened); err != nil {
return fmt.Errorf("Error setting encryption settings: %+v", err)
}

return tags.FlattenAndSet(d, resp.Tags)
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_managed_disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/http"
"testing"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_proximity_placement_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"log"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/hashicorp/terraform/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_recovery_services_replicated_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2018-01-10/siterecovery"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_shared_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"log"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_shared_image_gallery.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"log"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/hashicorp/terraform/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/response"
Expand Down
18 changes: 8 additions & 10 deletions azurerm/resource_arm_shared_image_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"log"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/hashicorp/terraform/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/response"
Expand Down Expand Up @@ -122,10 +122,10 @@ func resourceArmSharedImageVersionCreateUpdate(d *schema.ResourceData, meta inte
PublishingProfile: &compute.GalleryImageVersionPublishingProfile{
ExcludeFromLatest: utils.Bool(excludeFromLatest),
TargetRegions: targetRegions,
Source: &compute.GalleryArtifactSource{
ManagedImage: &compute.ManagedArtifact{
ID: utils.String(managedImageId),
},
},
StorageProfile: &compute.GalleryImageVersionStorageProfile{
Source: &compute.GalleryArtifactVersionSource{
ID: utils.String(managedImageId),
},
},
},
Expand All @@ -141,8 +141,6 @@ func resourceArmSharedImageVersionCreateUpdate(d *schema.ResourceData, meta inte
return fmt.Errorf("Error waiting for the creation of Shared Image Version %q (Image %q / Gallery %q / Resource Group %q): %+v", imageVersion, imageName, galleryName, resourceGroup, err)
}

// TODO: poll?

read, err := client.Get(ctx, resourceGroup, galleryName, imageName, imageVersion, "")
if err != nil {
return fmt.Errorf("Error retrieving Shared Image Version %q (Image %q / Gallery %q / Resource Group %q): %+v", imageVersion, imageName, galleryName, resourceGroup, err)
Expand Down Expand Up @@ -194,11 +192,11 @@ func resourceArmSharedImageVersionRead(d *schema.ResourceData, meta interface{})
if err := d.Set("target_region", flattenedRegions); err != nil {
return fmt.Errorf("Error setting `target_region`: %+v", err)
}
}

if profile := props.StorageProfile; profile != nil {
if source := profile.Source; source != nil {
if image := source.ManagedImage; image != nil {
d.Set("managed_image_id", image.ID)
}
d.Set("managed_image_id", source.ID)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions azurerm/resource_arm_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"regexp"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
Expand Down Expand Up @@ -132,7 +132,7 @@ func resourceArmSnapshotCreateUpdate(d *schema.ResourceData, meta interface{}) e
if v, ok := d.GetOk("encryption_settings"); ok {
encryptionSettings := v.([]interface{})
settings := encryptionSettings[0].(map[string]interface{})
properties.EncryptionSettings = expandManagedDiskEncryptionSettings(settings)
properties.EncryptionSettingsCollection = expandManagedDiskEncryptionSettings(settings)
}

future, err := client.CreateOrUpdate(ctx, resourceGroup, name, properties)
Expand Down Expand Up @@ -197,8 +197,8 @@ func resourceArmSnapshotRead(d *schema.ResourceData, meta interface{}) error {
d.Set("disk_size_gb", int(*props.DiskSizeGB))
}

if props.EncryptionSettings != nil {
d.Set("encryption_settings", flattenManagedDiskEncryptionSettings(props.EncryptionSettings))
if err := d.Set("encryption_settings", flattenManagedDiskEncryptionSettings(props.EncryptionSettingsCollection)); err != nil {
return fmt.Errorf("Error setting `encryption_settings`: %+v", err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"log"
"strings"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2019-06-01/network"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"log"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_virtual_machine_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package azurerm
import (
"fmt"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/structure"
"github.com/hashicorp/terraform/helper/validation"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_virtual_machine_managed_disks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"testing"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_virtual_machine_scale_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"
"strings"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags"

Expand Down
Loading