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

FourPointOh - remove from service/compute #28348

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
87 changes: 0 additions & 87 deletions internal/services/compute/encryption_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,70 +6,11 @@ package compute
import (
"github.com/hashicorp/go-azure-sdk/resource-manager/compute/2022-03-02/snapshots"
"github.com/hashicorp/go-azure-sdk/resource-manager/compute/2023-04-02/disks"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/utils"
)

func encryptionSettingsSchema() *pluginsdk.Schema {
if !features.FourPointOhBeta() {
return &pluginsdk.Schema{
Type: pluginsdk.TypeList,
Optional: true,
MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: true,

// Azure can change enabled from false to true, but not the other way around, so
// to keep idempotency, we'll conservatively set this to ForceNew=true
ForceNew: true,
Deprecated: "Deprecated, Azure Disk Encryption is now configured directly by `disk_encryption_key` and `key_encryption_key`. To disable Azure Disk Encryption, please remove `encryption_settings` block. To enabled, specify a `encryption_settings` block`",
},
"disk_encryption_key": {
Type: pluginsdk.TypeList,
Optional: true,
MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"secret_url": {
Type: pluginsdk.TypeString,
Required: true,
},

"source_vault_id": {
Type: pluginsdk.TypeString,
Required: true,
},
},
},
},
"key_encryption_key": {
Type: pluginsdk.TypeList,
Optional: true,
MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"key_url": {
Type: pluginsdk.TypeString,
Required: true,
},

"source_vault_id": {
Type: pluginsdk.TypeString,
Required: true,
},
},
},
},
},
},
}
}

return &pluginsdk.Schema{
Type: pluginsdk.TypeList,
Optional: true,
Expand Down Expand Up @@ -127,10 +68,6 @@ func expandSnapshotDiskEncryptionSettings(settingsList []interface{}) *snapshots
Enabled: true,
}

if !features.FourPointOhBeta() {
config.Enabled = settings["enabled"].(bool)
}

var diskEncryptionKey *snapshots.KeyVaultAndSecretReference
if v := settings["disk_encryption_key"].([]interface{}); len(v) > 0 {
dek := v[0].(map[string]interface{})
Expand Down Expand Up @@ -216,16 +153,6 @@ func flattenSnapshotDiskEncryptionSettings(encryptionSettings *snapshots.Encrypt
}

if len(diskEncryptionKeys) > 0 {
if !features.FourPointOhBeta() {
return []interface{}{
map[string]interface{}{
"enabled": true,
"disk_encryption_key": diskEncryptionKeys,
"key_encryption_key": keyEncryptionKeys,
},
}
}

return []interface{}{
map[string]interface{}{
"disk_encryption_key": diskEncryptionKeys,
Expand All @@ -247,10 +174,6 @@ func expandManagedDiskEncryptionSettings(settingsList []interface{}) *disks.Encr
Enabled: true,
}

if !features.FourPointOhBeta() {
config.Enabled = settings["enabled"].(bool)
}

var diskEncryptionKey *disks.KeyVaultAndSecretReference
if v := settings["disk_encryption_key"].([]interface{}); len(v) > 0 {
dek := v[0].(map[string]interface{})
Expand Down Expand Up @@ -336,16 +259,6 @@ func flattenManagedDiskEncryptionSettings(encryptionSettings *disks.EncryptionSe
}

if len(diskEncryptionKeys) > 0 {
if !features.FourPointOhBeta() {
return []interface{}{
map[string]interface{}{
"enabled": true,
"disk_encryption_key": diskEncryptionKeys,
"key_encryption_key": keyEncryptionKeys,
},
}
}

return []interface{}{
map[string]interface{}{
"disk_encryption_key": diskEncryptionKeys,
Expand Down
39 changes: 12 additions & 27 deletions internal/services/compute/image_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/hashicorp/go-azure-sdk/resource-manager/compute/2022-03-01/images"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress"
Expand All @@ -26,7 +25,7 @@ import (
)

func resourceImage() *pluginsdk.Resource {
resource := &pluginsdk.Resource{
return &pluginsdk.Resource{
Create: resourceImageCreateUpdate,
Read: resourceImageRead,
Update: resourceImageCreateUpdate,
Expand Down Expand Up @@ -219,13 +218,6 @@ func resourceImage() *pluginsdk.Resource {
"tags": commonschema.Tags(),
},
}

if !features.FourPointOhBeta() {
delete(resource.Schema["os_disk"].Elem.(*pluginsdk.Resource).Schema, "storage_type")
delete(resource.Schema["data_disk"].Elem.(*pluginsdk.Resource).Schema, "storage_type")
}

return resource
}

func resourceImageCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error {
Expand Down Expand Up @@ -403,9 +395,8 @@ func expandImageOSDisk(input []interface{}) *images.ImageOSDisk {
}
}

if features.FourPointOhBeta() {
out.StorageAccountType = pointer.To(images.StorageAccountTypes(config["storage_type"].(string)))
}
out.StorageAccountType = pointer.To(images.StorageAccountTypes(config["storage_type"].(string)))

return out
}

Expand Down Expand Up @@ -443,9 +434,7 @@ func expandImageDataDisks(disks []interface{}) *[]images.ImageDataDisk {
}
}

if features.FourPointOhBeta() {
item.StorageAccountType = pointer.To(images.StorageAccountTypes(config["storage_type"].(string)))
}
item.StorageAccountType = pointer.To(images.StorageAccountTypes(config["storage_type"].(string)))

output = append(output, item)
}
Expand Down Expand Up @@ -490,13 +479,11 @@ func flattenImageOSDisk(input *images.ImageStorageProfile) []interface{} {
"disk_encryption_set_id": diskEncryptionSetId,
}

if features.FourPointOhBeta() {
storageType := ""
if v.StorageAccountType != nil {
storageType = string(*v.StorageAccountType)
}
properties["storage_type"] = storageType
storageType := ""
if v.StorageAccountType != nil {
storageType = string(*v.StorageAccountType)
}
properties["storage_type"] = storageType

output = append(output, properties)
}
Expand Down Expand Up @@ -542,13 +529,11 @@ func flattenImageDataDisks(input *images.ImageStorageProfile) []interface{} {
"disk_encryption_set_id": diskEncryptionSetId,
}

if features.FourPointOhBeta() {
storageType := ""
if disk.StorageAccountType != nil {
storageType = string(*disk.StorageAccountType)
}
properties["storage_type"] = storageType
storageType := ""
if disk.StorageAccountType != nil {
storageType = string(*disk.StorageAccountType)
}
properties["storage_type"] = storageType

output = append(output, properties)
}
Expand Down
61 changes: 0 additions & 61 deletions internal/services/compute/image_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/ssh"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/utils"
)
Expand Down Expand Up @@ -524,16 +523,6 @@ func (r ImageResource) standaloneImageProvision(data acceptance.TestData, hyperV
caching = "None"
storage_type = "StandardSSD_LRS"
}`
if !features.FourPointOhBeta() {
osDisk = `
os_disk {
os_type = "Linux"
os_state = "Generalized"
blob_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/myosdisk1.vhd"
size_gb = 30
caching = "None"
}`
}

template := r.setupUnmanagedDisks(data)

Expand Down Expand Up @@ -569,16 +558,6 @@ func (r ImageResource) standaloneImageRequiresImport(data acceptance.TestData) s
caching = "None"
storage_type = "StandardSSD_LRS"
}`
if !features.FourPointOhBeta() {
osDisk = `
os_disk {
os_type = "Linux"
os_state = "Generalized"
blob_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/myosdisk1.vhd"
size_gb = 30
caching = "None"
}`
}

return fmt.Sprintf(`
%[1]s
Expand Down Expand Up @@ -610,16 +589,6 @@ func (r ImageResource) customImageFromVMWithUnmanagedDisksProvision(data accepta
caching = "None"
storage_type = "StandardSSD_LRS"
}`
if !features.FourPointOhBeta() {
osDisk = `
os_disk {
os_type = "Linux"
os_state = "Generalized"
blob_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/myosdisk1.vhd"
size_gb = 30
caching = "None"
}`
}

return fmt.Sprintf(`
%[1]s
Expand Down Expand Up @@ -764,16 +733,6 @@ func (r ImageResource) customImageFromVMSSWithUnmanagedDisksProvision(data accep
caching = "None"
storage_type = "StandardSSD_LRS"
}`
if !features.FourPointOhBeta() {
osDisk = `
os_disk {
os_type = "Linux"
os_state = "Generalized"
blob_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/myosdisk1.vhd"
size_gb = 30
caching = "None"
}`
}

return fmt.Sprintf(`
%[1]s
Expand Down Expand Up @@ -846,17 +805,6 @@ func (r ImageResource) standaloneImageEncrypt(data acceptance.TestData) string {
disk_encryption_set_id = azurerm_disk_encryption_set.test.id
storage_type = "StandardSSD_LRS"
}`
if !features.FourPointOhBeta() {
osDisk = `
os_disk {
os_type = "Linux"
os_state = "Generalized"
blob_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/myosdisk1.vhd"
size_gb = 30
caching = "None"
disk_encryption_set_id = azurerm_disk_encryption_set.test.id
}`
}

dataDisk := `
data_disk {
Expand All @@ -866,15 +814,6 @@ func (r ImageResource) standaloneImageEncrypt(data acceptance.TestData) string {
disk_encryption_set_id = azurerm_disk_encryption_set.test.id
storage_type = "StandardSSD_LRS"
}`
if !features.FourPointOhBeta() {
dataDisk = `
data_disk {
blob_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/myosdisk1.vhd"
size_gb = 30
caching = "None"
disk_encryption_set_id = azurerm_disk_encryption_set.test.id
}`
}

return fmt.Sprintf(`
%[1]s
Expand Down
Loading
Loading