From 1b9a5f8101bd5d221ac72595ef1bfae3c632c6b5 Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 17 Mar 2023 11:33:41 -0700 Subject: [PATCH 1/6] Start of ovmss datasource --- ...d_virtual_machine_scale_set_data_source.go | 55 +++++++++++++++++++ ...tual_machine_scale_set_data_source_test.go | 1 + 2 files changed, 56 insertions(+) create mode 100644 internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go create mode 100644 internal/services/compute/orchestrated_virtual_machine_scale_set_data_source_test.go diff --git a/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go b/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go new file mode 100644 index 000000000000..1611eddf5a22 --- /dev/null +++ b/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go @@ -0,0 +1,55 @@ +package compute + +import ( + "context" + "time" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + computeValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" +) + +type OrchestratedVirtualMachineScaleSetDataSource struct{} + +var _ sdk.DataSource = OrchestratedVirtualMachineScaleSetDataSource{} + +type OrchestratedVirtualMachineScaleSetDataSourceModel struct { + Name string `tfschema:"name"` + ResourceGroup string `tfschema:"resource_group_name"` + Location string `tfschema:"location"` +} + +func (r OrchestratedVirtualMachineScaleSetDataSource) ModelObject() interface{} { + return &OrchestratedVirtualMachineScaleSetDataSourceModel{} +} + +func (r OrchestratedVirtualMachineScaleSetDataSource) ResourceType() string { + return "azurerm_orchestrated_virtual_machine_scale_set" +} + +func (r OrchestratedVirtualMachineScaleSetDataSource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: computeValidate.VirtualMachineName, + }, + + "resource_group_name": commonschema.ResourceGroupNameForDataSource(), + } +} + +func (r OrchestratedVirtualMachineScaleSetDataSource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Compute.VMScaleSetClient + + var orchestratedVMSS OrchestratedVirtualMachineScaleSetDataSource + if err := metadata.Decode(&servicePlan); err != nil { + return err + } + }, + } +} diff --git a/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source_test.go b/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source_test.go new file mode 100644 index 000000000000..a887fe9a608c --- /dev/null +++ b/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source_test.go @@ -0,0 +1 @@ +package compute From facf0a86552f400c19dd18f1a3359e84060be7d3 Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 17 Mar 2023 15:55:24 -0700 Subject: [PATCH 2/6] basic test and start of endless models --- ...d_virtual_machine_scale_set_data_source.go | 154 +++++++++++++++++- ...tual_machine_scale_set_data_source_test.go | 37 ++++- internal/services/compute/registration.go | 4 +- 3 files changed, 188 insertions(+), 7 deletions(-) diff --git a/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go b/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go index 1611eddf5a22..6cfbbde32519 100644 --- a/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go +++ b/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go @@ -2,10 +2,15 @@ package compute import ( "context" + "fmt" + "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/terraform-provider-azurerm/utils" + "github.com/tombuildsstuff/kermit/sdk/compute/2022-08-01/compute" "time" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/parse" computeValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) @@ -15,9 +20,125 @@ type OrchestratedVirtualMachineScaleSetDataSource struct{} var _ sdk.DataSource = OrchestratedVirtualMachineScaleSetDataSource{} type OrchestratedVirtualMachineScaleSetDataSourceModel struct { - Name string `tfschema:"name"` - ResourceGroup string `tfschema:"resource_group_name"` - Location string `tfschema:"location"` + Name string `tfschema:"name"` + ResourceGroup string `tfschema:"resource_group_name"` + Location string `tfschema:"location"` + NetworkInterface []VirtualMachineScaleSetNetworkInterface `tfschema:"network_interface"` + OSDisk VirtualMachineScaleSetOSDisk `tfschema:"os_disk"` + SkuName string `tfschema:"sku_name"` + OSProfile VirtualMachineScaleSetOSProfile `tfschema:"os_profile"` + AutomaticInstanceRepair VirtualMachineScaleSetAutomaticInstanceRepair `tfschema:"automatic_instance_repair"` +} + +type VirtualMachineScaleSetNetworkInterface struct { + Name string `tfschema:"name"` + IPConfiguration []VirtualMachineScaleSetNetworkInterfaceIPConfiguration + DNSServers []string `tfschema:"dns_servers"` + AcceleratedNetworkingEnabled bool `tfschema:"accelerated_networking_enabled"` + IPForwardingEnabled bool `tfschema:"ip_forwarding_enabled"` + NetworkSecurityGroupId string `tfschema:"network_security_group_id"` + Primary bool `tfschema:"primary"` +} + +type VirtualMachineScaleSetNetworkInterfaceIPConfiguration struct { + Name string `tfschema:"name"` + ApplicationGatewayBackendAddressPoolIds []string `tfschema:"application_gateway_backend_address_pool_ids"` + ApplicationSecurityGroupIds []string `tfschema:"application_security_group_ids"` + LoadBalancerBackendAddressPoolIds []string `tfschema:"load_balancer_backend_address_pool_ids"` + Primary bool `tfschema:"primary"` + PublicIPAddress []VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddress `tfschema:"public_ip_address"` + SubnetId string `tfschema:"subnet_id"` + Version string `tfschema:"version"` +} + +type VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddress struct { + Name string `tfschema:"name"` + DomainNameLabel string `tfschema:"domain_name_label"` + IdleTimeoutInMinutes int `tfschema:"idle_timeout_in_minutes"` + IPTag []VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddressIPTag `tfschema:"ip_tag"` + PublicIpPrefixId string `tfschema:"public_ip_prefix_id"` + SkuName string `tfschema:"sku_name"` + Version string `tfschema:"version"` +} + +type VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddressIPTag struct { + Tag string `tfschema:"tag"` + Type string `tfschema:"type"` +} + +type VirtualMachineScaleSetOSDisk struct { + Caching string `tfschema:"caching"` + StorageAccountType string `tfschema:"storage_account_type"` + DiffDiskSettings VirtualMachineScaleSetOSDiskDiffDiskSettings `tfschema:"diff_disk_settings"` + DiskEncryptionSetId string `tfschema:"disk_encryption_set_id"` + DiskSizeGB string `tfschema:"disk_size_gb"` + WriteAcceleratorEnabled bool `tfschema:"write_accelerator_enabled"` +} + +type VirtualMachineScaleSetOSDiskDiffDiskSettings struct { + Option string `tfschema:"option"` + Placement string `tfschema:"placement"` +} + +type VirtualMachineScaleSetOSProfile struct { + CustomData string `tfschema:"custom_data"` + WindowsConfiguration VirtualMachineScaleSetOSProfileWindowsConfiguration `tfschema:"windows_configuration"` + LinuxConfiguration VirtualMachineScaleSetOSProfileLinuxConfiguration `tfschema:"linux_configuration"` +} + +type VirtualMachineScaleSetOSProfileWindowsConfiguration struct { + AdminUsername string `tfschema:"admin_username"` + AdminPassword string `tfschema:"admin_password"` + ComputerNamePrefix string `tfschema:"computer_name_prefix"` + AutomaticUpdatesEnabled bool `tfschema:"automatic_updates_enabled"` + HotpatchingEnabled bool `tfschema:"hotpatching_enabled"` + ProvisionVMAgent bool `tfschema:"provision_vm_agent"` + PatchAssessmentMode string `tfschema:"patch_assessment_mode"` + PatchMode string `tfschema:"patch_mode"` + Secret []VirtualMachineScaleSetOSProfileWindowsConfigurationSecret `tfschema:"secret"` + Timezone string `tfschema:"timezone"` + WinRMListener []VirtualMachineScaleSetOSProfileWindowsConfigurationWinRMListener `tfschema:"winrm_listener"` +} + +type VirtualMachineScaleSetOSProfileWindowsConfigurationSecret struct { + KeyVaultId string `tfschema:"key_vault_id"` + Certificate []VirtualMachineScaleSetOSProfileWindowsConfigurationSecretCertficate `tfschema:"certificate"` +} + +type VirtualMachineScaleSetOSProfileWindowsConfigurationSecretCertficate struct { + Store string `tfschema:"store"` + Url string `tfschema:"url"` +} + +type VirtualMachineScaleSetOSProfileWindowsConfigurationWinRMListener struct { + Protocol string `tfschema:"protocol"` + CertificateUrl string `tfschema:"certificate_url"` +} + +type VirtualMachineScaleSetOSProfileLinuxConfiguration struct { + AdminUsername string `tfschema:"admin_username"` + AdminPassword string `tfschema:"admin_password"` + AdminSSHKey []VirtualMachineScaleSetOSProfileLinuxConfigurationAdminSSHKey `tfschema:"admin_ssh_key"` + ComputerNamePrefix string `tfschema:"computer_name_prefix"` + DisablePasswordAuthentication bool `tfschema:"disable_password_authentication"` + ProvisionVMAgent bool `tfschema:"provision_vm_agent"` + PatchAssessmentMode string `tfschema:"patch_assessment_mode"` + PatchMode string `tfschema:"patch_mode"` + Secret []VirtualMachineScaleSetOSProfileLinuxConfigurationSecret `tfschema:"secret"` +} + +type VirtualMachineScaleSetOSProfileLinuxConfigurationAdminSSHKey struct { + PublicKey string `tfschema:"public_key"` + Username string `tfschema:"username"` +} + +type VirtualMachineScaleSetOSProfileLinuxConfigurationSecret struct { + KeyVaultId string `tfschema:"key_vault_id"` + Certificate []VirtualMachineScaleSetOSProfileLinuxConfigurationSecretCertficate `tfschema:"certificate"` +} + +type VirtualMachineScaleSetOSProfileLinuxConfigurationSecretCertficate struct { + Url string `tfschema:"url"` } func (r OrchestratedVirtualMachineScaleSetDataSource) ModelObject() interface{} { @@ -40,16 +161,39 @@ func (r OrchestratedVirtualMachineScaleSetDataSource) Arguments() map[string]*pl } } +func (r OrchestratedVirtualMachineScaleSetDataSource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "location": commonschema.LocationComputed(), + } +} + func (r OrchestratedVirtualMachineScaleSetDataSource) Read() sdk.ResourceFunc { return sdk.ResourceFunc{ Timeout: 5 * time.Minute, Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { client := metadata.Client.Compute.VMScaleSetClient + subscriptionId := metadata.Client.Account.SubscriptionId - var orchestratedVMSS OrchestratedVirtualMachineScaleSetDataSource - if err := metadata.Decode(&servicePlan); err != nil { + var orchestratedVMSS OrchestratedVirtualMachineScaleSetDataSourceModel + if err := metadata.Decode(&orchestratedVMSS); err != nil { return err } + + id := parse.NewVirtualMachineScaleSetID(subscriptionId, orchestratedVMSS.ResourceGroup, orchestratedVMSS.Name) + + existing, err := client.Get(ctx, id.ResourceGroup, id.Name, compute.ExpandTypesForGetVMScaleSetsUserData) + if err != nil { + if utils.ResponseWasNotFound(existing.Response) { + return fmt.Errorf("%s not found", id) + } + return fmt.Errorf("retrieving %s: %+v", id, err) + } + + orchestratedVMSS.Location = location.NormalizeNilable(existing.Location) + + metadata.SetID(id) + + return metadata.Encode(&orchestratedVMSS) }, } } diff --git a/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source_test.go b/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source_test.go index a887fe9a608c..2f6521b0162b 100644 --- a/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source_test.go +++ b/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source_test.go @@ -1 +1,36 @@ -package compute +package compute_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" +) + +type OrchestratedVirtualMachineScaleSetDataSource struct{} + +func TestAccOrchestratedVMSSDataSource_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "data.azurerm_service_plan", "test") + d := OrchestratedVirtualMachineScaleSetDataSource{} + + data.DataSourceTest(t, []acceptance.TestStep{ + { + Config: d.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).Key("location").HasValue(data.Locations.Primary), + ), + }, + }) +} + +func (OrchestratedVirtualMachineScaleSetDataSource) complete(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +data azurerm_service_plan test { + name = azurerm_service_plan.test.name + resource_group_name = azurerm_service_plan.test.resource_group_name +} +`, OrchestratedVirtualMachineScaleSetResource{}.linuxInstances(data)) +} diff --git a/internal/services/compute/registration.go b/internal/services/compute/registration.go index 69741d56579e..2d2ae114fb33 100644 --- a/internal/services/compute/registration.go +++ b/internal/services/compute/registration.go @@ -78,7 +78,9 @@ func (r Registration) SupportedResources() map[string]*pluginsdk.Resource { } func (r Registration) DataSources() []sdk.DataSource { - return []sdk.DataSource{} + return []sdk.DataSource{ + OrchestratedVirtualMachineScaleSetDataSource{}, + } } func (r Registration) Resources() []sdk.Resource { From 212f02daccd8c7ce43f054bd8dc7e84ae761205b Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 20 Mar 2023 16:57:20 -0700 Subject: [PATCH 3/6] finish datasource and add docs --- internal/services/compute/helpers.go | 17 + ...d_virtual_machine_scale_set_data_source.go | 295 ++++++++++++------ ...tual_machine_scale_set_data_source_test.go | 5 +- ...ed_virtual_machine_scale_set.html.markdown | 99 ++++++ 4 files changed, 320 insertions(+), 96 deletions(-) create mode 100644 website/docs/d/orchestrated_virtual_machine_scale_set.html.markdown diff --git a/internal/services/compute/helpers.go b/internal/services/compute/helpers.go index 7e6cb37174e1..e36dbd5dcf16 100644 --- a/internal/services/compute/helpers.go +++ b/internal/services/compute/helpers.go @@ -37,6 +37,23 @@ func flattenSubResourcesToIDs(input *[]compute.SubResource) []interface{} { return ids } +func flattenSubResourcesToStringIDs(input *[]compute.SubResource) []string { + ids := make([]string, 0) + if input == nil { + return ids + } + + for _, v := range *input { + if v.ID == nil { + continue + } + + ids = append(ids, *v.ID) + } + + return ids +} + func sortSharedImageVersions(values []compute.GalleryImageVersion) ([]compute.GalleryImageVersion, []error) { errors := make([]error, 0) sort.Slice(values, func(i, j int) bool { diff --git a/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go b/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go index 6cfbbde32519..fc5ceaf0d03c 100644 --- a/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go +++ b/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go @@ -3,16 +3,17 @@ package compute import ( "context" "fmt" - "github.com/hashicorp/go-azure-helpers/resourcemanager/location" - "github.com/hashicorp/terraform-provider-azurerm/utils" - "github.com/tombuildsstuff/kermit/sdk/compute/2022-08-01/compute" "time" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/parse" computeValidate "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/utils" + "github.com/tombuildsstuff/kermit/sdk/compute/2022-08-01/compute" ) type OrchestratedVirtualMachineScaleSetDataSource struct{} @@ -20,14 +21,11 @@ type OrchestratedVirtualMachineScaleSetDataSource struct{} var _ sdk.DataSource = OrchestratedVirtualMachineScaleSetDataSource{} type OrchestratedVirtualMachineScaleSetDataSourceModel struct { - Name string `tfschema:"name"` - ResourceGroup string `tfschema:"resource_group_name"` - Location string `tfschema:"location"` - NetworkInterface []VirtualMachineScaleSetNetworkInterface `tfschema:"network_interface"` - OSDisk VirtualMachineScaleSetOSDisk `tfschema:"os_disk"` - SkuName string `tfschema:"sku_name"` - OSProfile VirtualMachineScaleSetOSProfile `tfschema:"os_profile"` - AutomaticInstanceRepair VirtualMachineScaleSetAutomaticInstanceRepair `tfschema:"automatic_instance_repair"` + Name string `tfschema:"name"` + ResourceGroup string `tfschema:"resource_group_name"` + Location string `tfschema:"location"` + NetworkInterface []VirtualMachineScaleSetNetworkInterface `tfschema:"network_interface"` + Identity []identity.ModelUserAssigned `tfschema:"identity"` } type VirtualMachineScaleSetNetworkInterface struct { @@ -41,14 +39,14 @@ type VirtualMachineScaleSetNetworkInterface struct { } type VirtualMachineScaleSetNetworkInterfaceIPConfiguration struct { - Name string `tfschema:"name"` - ApplicationGatewayBackendAddressPoolIds []string `tfschema:"application_gateway_backend_address_pool_ids"` - ApplicationSecurityGroupIds []string `tfschema:"application_security_group_ids"` - LoadBalancerBackendAddressPoolIds []string `tfschema:"load_balancer_backend_address_pool_ids"` - Primary bool `tfschema:"primary"` - PublicIPAddress []VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddress `tfschema:"public_ip_address"` - SubnetId string `tfschema:"subnet_id"` - Version string `tfschema:"version"` + Name string `tfschema:"name"` + ApplicationGatewayBackendAddressPoolIds []string `tfschema:"application_gateway_backend_address_pool_ids"` + ApplicationSecurityGroupIds []string `tfschema:"application_security_group_ids"` + LoadBalancerBackendAddressPoolIds []string `tfschema:"load_balancer_backend_address_pool_ids"` + Primary bool `tfschema:"primary"` + PublicIPAddress VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddress `tfschema:"public_ip_address"` + SubnetId string `tfschema:"subnet_id"` + Version string `tfschema:"version"` } type VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddress struct { @@ -66,81 +64,6 @@ type VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddressIPTag s Type string `tfschema:"type"` } -type VirtualMachineScaleSetOSDisk struct { - Caching string `tfschema:"caching"` - StorageAccountType string `tfschema:"storage_account_type"` - DiffDiskSettings VirtualMachineScaleSetOSDiskDiffDiskSettings `tfschema:"diff_disk_settings"` - DiskEncryptionSetId string `tfschema:"disk_encryption_set_id"` - DiskSizeGB string `tfschema:"disk_size_gb"` - WriteAcceleratorEnabled bool `tfschema:"write_accelerator_enabled"` -} - -type VirtualMachineScaleSetOSDiskDiffDiskSettings struct { - Option string `tfschema:"option"` - Placement string `tfschema:"placement"` -} - -type VirtualMachineScaleSetOSProfile struct { - CustomData string `tfschema:"custom_data"` - WindowsConfiguration VirtualMachineScaleSetOSProfileWindowsConfiguration `tfschema:"windows_configuration"` - LinuxConfiguration VirtualMachineScaleSetOSProfileLinuxConfiguration `tfschema:"linux_configuration"` -} - -type VirtualMachineScaleSetOSProfileWindowsConfiguration struct { - AdminUsername string `tfschema:"admin_username"` - AdminPassword string `tfschema:"admin_password"` - ComputerNamePrefix string `tfschema:"computer_name_prefix"` - AutomaticUpdatesEnabled bool `tfschema:"automatic_updates_enabled"` - HotpatchingEnabled bool `tfschema:"hotpatching_enabled"` - ProvisionVMAgent bool `tfschema:"provision_vm_agent"` - PatchAssessmentMode string `tfschema:"patch_assessment_mode"` - PatchMode string `tfschema:"patch_mode"` - Secret []VirtualMachineScaleSetOSProfileWindowsConfigurationSecret `tfschema:"secret"` - Timezone string `tfschema:"timezone"` - WinRMListener []VirtualMachineScaleSetOSProfileWindowsConfigurationWinRMListener `tfschema:"winrm_listener"` -} - -type VirtualMachineScaleSetOSProfileWindowsConfigurationSecret struct { - KeyVaultId string `tfschema:"key_vault_id"` - Certificate []VirtualMachineScaleSetOSProfileWindowsConfigurationSecretCertficate `tfschema:"certificate"` -} - -type VirtualMachineScaleSetOSProfileWindowsConfigurationSecretCertficate struct { - Store string `tfschema:"store"` - Url string `tfschema:"url"` -} - -type VirtualMachineScaleSetOSProfileWindowsConfigurationWinRMListener struct { - Protocol string `tfschema:"protocol"` - CertificateUrl string `tfschema:"certificate_url"` -} - -type VirtualMachineScaleSetOSProfileLinuxConfiguration struct { - AdminUsername string `tfschema:"admin_username"` - AdminPassword string `tfschema:"admin_password"` - AdminSSHKey []VirtualMachineScaleSetOSProfileLinuxConfigurationAdminSSHKey `tfschema:"admin_ssh_key"` - ComputerNamePrefix string `tfschema:"computer_name_prefix"` - DisablePasswordAuthentication bool `tfschema:"disable_password_authentication"` - ProvisionVMAgent bool `tfschema:"provision_vm_agent"` - PatchAssessmentMode string `tfschema:"patch_assessment_mode"` - PatchMode string `tfschema:"patch_mode"` - Secret []VirtualMachineScaleSetOSProfileLinuxConfigurationSecret `tfschema:"secret"` -} - -type VirtualMachineScaleSetOSProfileLinuxConfigurationAdminSSHKey struct { - PublicKey string `tfschema:"public_key"` - Username string `tfschema:"username"` -} - -type VirtualMachineScaleSetOSProfileLinuxConfigurationSecret struct { - KeyVaultId string `tfschema:"key_vault_id"` - Certificate []VirtualMachineScaleSetOSProfileLinuxConfigurationSecretCertficate `tfschema:"certificate"` -} - -type VirtualMachineScaleSetOSProfileLinuxConfigurationSecretCertficate struct { - Url string `tfschema:"url"` -} - func (r OrchestratedVirtualMachineScaleSetDataSource) ModelObject() interface{} { return &OrchestratedVirtualMachineScaleSetDataSourceModel{} } @@ -164,6 +87,8 @@ func (r OrchestratedVirtualMachineScaleSetDataSource) Arguments() map[string]*pl func (r OrchestratedVirtualMachineScaleSetDataSource) Attributes() map[string]*pluginsdk.Schema { return map[string]*pluginsdk.Schema{ "location": commonschema.LocationComputed(), + + "network_interfaces": OrchestratedVirtualMachineScaleSetNetworkInterfaceSchema(), } } @@ -191,9 +116,191 @@ func (r OrchestratedVirtualMachineScaleSetDataSource) Read() sdk.ResourceFunc { orchestratedVMSS.Location = location.NormalizeNilable(existing.Location) + if profile := existing.VirtualMachineProfile; profile != nil { + if nwProfile := profile.NetworkProfile; nwProfile != nil { + orchestratedVMSS.NetworkInterface = flattenVirtualMachineScaleSetNetworkInterface(nwProfile.NetworkInterfaceConfigurations) + } + } + + userIdentity, err := flattenOrchestratedVirtualMachineScaleSetIdentityToModel(existing.Identity) + if err != nil { + return err + } + orchestratedVMSS.Identity = userIdentity + metadata.SetID(id) return metadata.Encode(&orchestratedVMSS) }, } } + +func flattenVirtualMachineScaleSetNetworkInterface(input *[]compute.VirtualMachineScaleSetNetworkConfiguration) []VirtualMachineScaleSetNetworkInterface { + if input == nil { + return []VirtualMachineScaleSetNetworkInterface{} + } + + networkInterfaces := make([]VirtualMachineScaleSetNetworkInterface, 0) + for _, v := range *input { + var name, networkSecurityGroupId string + if v.Name != nil { + name = *v.Name + } + if v.NetworkSecurityGroup != nil && v.NetworkSecurityGroup.ID != nil { + networkSecurityGroupId = *v.NetworkSecurityGroup.ID + } + var acceleratedNetworkingEnabled, ipForwardingEnabled, primary bool + if v.EnableAcceleratedNetworking != nil { + acceleratedNetworkingEnabled = *v.EnableAcceleratedNetworking + } + if v.EnableIPForwarding != nil { + ipForwardingEnabled = *v.EnableIPForwarding + } + if v.Primary != nil { + primary = *v.Primary + } + + var dnsServers []string + if settings := v.DNSSettings; settings != nil { + dnsServers = *v.DNSSettings.DNSServers + } + + var ipConfigurations []interface{} + if v.IPConfigurations != nil { + for _, configRaw := range *v.IPConfigurations { + config := flattenVirtualMachineScaleSetIPConfiguration(configRaw) + ipConfigurations = append(ipConfigurations, config) + } + } + networkInterfaces = append(networkInterfaces, VirtualMachineScaleSetNetworkInterface{ + Name: name, + NetworkSecurityGroupId: networkSecurityGroupId, + AcceleratedNetworkingEnabled: acceleratedNetworkingEnabled, + IPForwardingEnabled: ipForwardingEnabled, + Primary: primary, + DNSServers: dnsServers, + IPConfiguration: flattenOrchestratedVirtualMachineScaleSetNetworkInterfaceIPConfiguration(v.IPConfigurations), + }) + } + + return networkInterfaces +} + +func flattenOrchestratedVirtualMachineScaleSetNetworkInterfaceIPConfiguration(input *[]compute.VirtualMachineScaleSetIPConfiguration) []VirtualMachineScaleSetNetworkInterfaceIPConfiguration { + if input == nil { + return []VirtualMachineScaleSetNetworkInterfaceIPConfiguration{} + } + + ipConfigurations := make([]VirtualMachineScaleSetNetworkInterfaceIPConfiguration, 0) + for _, v := range *input { + var name, subnetId string + if v.Name != nil { + name = *v.Name + } + if v.Subnet != nil && v.Subnet.ID != nil { + subnetId = *v.Subnet.ID + } + + var primary bool + if v.Primary != nil { + primary = *v.Primary + } + + ipConfigurations = append(ipConfigurations, VirtualMachineScaleSetNetworkInterfaceIPConfiguration{ + Name: name, + SubnetId: subnetId, + Primary: primary, + PublicIPAddress: flattenOrchestratedVirtualMachineScaleSetPublicIPAddress(v.PublicIPAddressConfiguration), + ApplicationGatewayBackendAddressPoolIds: flattenSubResourcesToStringIDs(v.ApplicationGatewayBackendAddressPools), + ApplicationSecurityGroupIds: flattenSubResourcesToStringIDs(v.ApplicationSecurityGroups), + LoadBalancerBackendAddressPoolIds: flattenSubResourcesToStringIDs(v.LoadBalancerBackendAddressPools), + }) + } + + return ipConfigurations +} + +func flattenOrchestratedVirtualMachineScaleSetPublicIPAddress(input *compute.VirtualMachineScaleSetPublicIPAddressConfiguration) VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddress { + if input == nil { + return VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddress{} + } + + ipTags := make([]VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddressIPTag, 0) + if input.IPTags != nil { + for _, rawTag := range *input.IPTags { + var tag, tagType string + + if rawTag.IPTagType != nil { + tagType = *rawTag.IPTagType + } + + if rawTag.Tag != nil { + tag = *rawTag.Tag + } + + ipTags = append(ipTags, VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddressIPTag{ + Tag: tag, + Type: tagType, + }) + } + } + + var domainNameLabel, name, publicIPPrefixId, version string + if input.DNSSettings != nil && input.DNSSettings.DomainNameLabel != nil { + domainNameLabel = *input.DNSSettings.DomainNameLabel + } + + if input.Name != nil { + name = *input.Name + } + + if input.PublicIPPrefix != nil && input.PublicIPPrefix.ID != nil { + publicIPPrefixId = *input.PublicIPPrefix.ID + } + + if input.PublicIPAddressVersion != "" { + version = string(input.PublicIPAddressVersion) + } + + var idleTimeoutInMinutes int + if input.IdleTimeoutInMinutes != nil { + idleTimeoutInMinutes = int(*input.IdleTimeoutInMinutes) + } + + return VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddress{ + Name: name, + DomainNameLabel: domainNameLabel, + IdleTimeoutInMinutes: idleTimeoutInMinutes, + IPTag: ipTags, + PublicIpPrefixId: publicIPPrefixId, + Version: version, + } +} + +func flattenOrchestratedVirtualMachineScaleSetIdentityToModel(input *compute.VirtualMachineScaleSetIdentity) ([]identity.ModelUserAssigned, error) { + if input == nil { + return nil, nil + } + + identityIds := make(map[string]identity.UserAssignedIdentityDetails, 0) + for k, v := range input.UserAssignedIdentities { + if v != nil { + identityIds[k] = identity.UserAssignedIdentityDetails{ + ClientId: v.ClientID, + PrincipalId: v.PrincipalID, + } + } + } + + tmp := identity.UserAssignedMap{ + Type: input.Type, + IdentityIds: identityIds, + } + + output, err := identity.FlattenUserAssignedMapToModel(&tmp) + if err != nil { + return nil, fmt.Errorf("expanding `identity`: %+v", err) + } + + return *output, nil +} diff --git a/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source_test.go b/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source_test.go index 2f6521b0162b..96ee44e82339 100644 --- a/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source_test.go +++ b/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source_test.go @@ -11,7 +11,7 @@ import ( type OrchestratedVirtualMachineScaleSetDataSource struct{} func TestAccOrchestratedVMSSDataSource_complete(t *testing.T) { - data := acceptance.BuildTestData(t, "data.azurerm_service_plan", "test") + data := acceptance.BuildTestData(t, "data.azurerm_orchestrated_virtual_machine_scale_set", "test") d := OrchestratedVirtualMachineScaleSetDataSource{} data.DataSourceTest(t, []acceptance.TestStep{ @@ -19,6 +19,7 @@ func TestAccOrchestratedVMSSDataSource_complete(t *testing.T) { Config: d.complete(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).Key("location").HasValue(data.Locations.Primary), + check.That(data.ResourceName).Key("network_interfaces.#").HasValue("1"), ), }, }) @@ -28,7 +29,7 @@ func (OrchestratedVirtualMachineScaleSetDataSource) complete(data acceptance.Tes return fmt.Sprintf(` %s -data azurerm_service_plan test { +data azurerm_orchestrated_virtual_machine_scale_set test { name = azurerm_service_plan.test.name resource_group_name = azurerm_service_plan.test.resource_group_name } diff --git a/website/docs/d/orchestrated_virtual_machine_scale_set.html.markdown b/website/docs/d/orchestrated_virtual_machine_scale_set.html.markdown new file mode 100644 index 000000000000..7316d556dbbb --- /dev/null +++ b/website/docs/d/orchestrated_virtual_machine_scale_set.html.markdown @@ -0,0 +1,99 @@ +--- +subcategory: "Compute" +layout: "azurerm" +page_title: "Azure Resource Manager: Data Source: azurerm_orchestrated_virtual_machine_scale_set" +description: |- + Gets information about an existing Orchestrated Virtual Machine Scale Set. +--- + +# Data Source: azurerm_orchestrated_virtual_machine_scale_set + +Use this data source to access information about an existing Orchestrated Virtual Machine Scale Set. + +## Example Usage + +```hcl +data "azurerm_orchestrated_virtual_machine_scale_set" "example" { + name = "existing" + resource_group_name = "existing" +} + +output "id" { + value = data.azurerm_orchestrated_virtual_machine_scale_set.example.id +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) The name of this Orchestrated Virtual Machine Scale Set. + +* `resource_group_name` - (Required) The name of the Resource Group where the Orchestrated Virtual Machine Scale Set exists. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Virtual Machine Scale Set. + +* `location` - The Azure Region in which this Orchestrated Virtual Machine Scale Set exists. + +* `identity` - A `identity` block as defined below. + +* `network_interface` - A list of `network_interface` blocks as defined below. + +--- + +An `identity` block exports the following: + +* `type` - The type of Managed Service Identity that is configured on this Orchestrated Virtual Machine Scale Set. + +* `principal_id` - The Principal ID of the System Assigned Managed Service Identity that is configured on this Orchestrated Virtual Machine Scale Set. + +* `tenant_id` - The Tenant ID of the System Assigned Managed Service Identity that is configured on this Orchestrated Virtual Machine Scale Set. + +* `identity_ids` - The list of User Assigned Managed Identity IDs assigned to this Orchestrated Virtual Machine Scale Set. + +--- + +`network_interface` exports the following: + +* `name` - The name of the network interface configuration. +* `primary` - Whether network interfaces created from the network interface configuration will be the primary NIC of the VM. +* `ip_configuration` - An `ip_configuration` block as documented below. +* `enable_accelerated_networking` - Whether to enable accelerated networking or not. +* `dns_servers` - An array of the DNS servers in use. +* `enable_ip_forwarding` - Whether IP forwarding is enabled on this NIC. +* `network_security_group_id` - The identifier for the network security group. + +`ip_configuration` exports the following: + +* `name` - The name of the IP configuration. +* `subnet_id` - The the identifier of the subnet. +* `application_gateway_backend_address_pool_ids` - An array of references to backend address pools of application gateways. +* `load_balancer_backend_address_pool_ids` - An array of references to backend address pools of load balancers. +* `load_balancer_inbound_nat_rules_ids` - An array of references to inbound NAT pools for load balancers. +* `primary` - If this ip_configuration is the primary one. +* `application_security_group_ids` - The application security group IDs to use. +* `public_ip_address` - The virtual machines scale set IP Configuration's PublicIPAddress configuration. The `public_ip_address` is documented below. + +`public_ip_address` exports the following: + +* `name` - The name of the public IP address configuration +* `idle_timeout_in_minutes` - The idle timeout in minutes. +* `domain_name_label` - The domain name label for the DNS settings. +* `ip_tag` - A list of `ip_tag` blocks as defined below. +* `public_ip_prefix_id` - The ID of the public IP prefix. +* `version` - The Internet Protocol Version of the public IP address. + +`ip_tag` exports the following: + +* `tag` - The IP Tag associated with the Public IP. +* `type` - The Type of IP Tag. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: + +* `read` - (Defaults to 5 minutes) Used when retrieving the Orchestrated Virtual Machine Scale Set. From d5c7f0a7635c15586195a49eae37544ac31ba16c Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 20 Mar 2023 18:48:38 -0700 Subject: [PATCH 4/6] Fix error --- .../orchestrated_virtual_machine_scale_set_data_source.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go b/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go index fc5ceaf0d03c..cc95c96efe04 100644 --- a/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go +++ b/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go @@ -293,7 +293,7 @@ func flattenOrchestratedVirtualMachineScaleSetIdentityToModel(input *compute.Vir } tmp := identity.UserAssignedMap{ - Type: input.Type, + Type: identity.Type(input.Type), IdentityIds: identityIds, } From 6cb0546217051b70dad85c578b1c52c29c899b79 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 20 Mar 2023 19:37:12 -0700 Subject: [PATCH 5/6] Fix test --- internal/sdk/resource_encode.go | 2 +- ...d_virtual_machine_scale_set_data_source.go | 83 ++++++++++++++----- ...tual_machine_scale_set_data_source_test.go | 6 +- ...ed_virtual_machine_scale_set.html.markdown | 24 +++++- 4 files changed, 89 insertions(+), 26 deletions(-) diff --git a/internal/sdk/resource_encode.go b/internal/sdk/resource_encode.go index 75b69fb7628f..5bffa2fd73cf 100644 --- a/internal/sdk/resource_encode.go +++ b/internal/sdk/resource_encode.go @@ -124,7 +124,7 @@ func recurse(objType reflect.Type, objVal reflect.Value, fieldName string, debug fieldName := field.Name serialized, err := recurse(nestedType, nestedValue, fieldName, debugLogger) if err != nil { - return nil, fmt.Errorf("serializing nested object %q: %+v", sv.Type(), exists) + return nil, fmt.Errorf("serializing nested object %q: %+v", sv.Type(), err) } attr[i] = serialized } diff --git a/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go b/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go index cc95c96efe04..f9fcba475d39 100644 --- a/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go +++ b/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go @@ -29,24 +29,24 @@ type OrchestratedVirtualMachineScaleSetDataSourceModel struct { } type VirtualMachineScaleSetNetworkInterface struct { - Name string `tfschema:"name"` - IPConfiguration []VirtualMachineScaleSetNetworkInterfaceIPConfiguration - DNSServers []string `tfschema:"dns_servers"` - AcceleratedNetworkingEnabled bool `tfschema:"accelerated_networking_enabled"` - IPForwardingEnabled bool `tfschema:"ip_forwarding_enabled"` - NetworkSecurityGroupId string `tfschema:"network_security_group_id"` - Primary bool `tfschema:"primary"` + Name string `tfschema:"name"` + IPConfiguration []VirtualMachineScaleSetNetworkInterfaceIPConfiguration `tfschema:"ip_configuration"` + DNSServers []string `tfschema:"dns_servers"` + AcceleratedNetworkingEnabled bool `tfschema:"accelerated_networking_enabled"` + IPForwardingEnabled bool `tfschema:"ip_forwarding_enabled"` + NetworkSecurityGroupId string `tfschema:"network_security_group_id"` + Primary bool `tfschema:"primary"` } type VirtualMachineScaleSetNetworkInterfaceIPConfiguration struct { - Name string `tfschema:"name"` - ApplicationGatewayBackendAddressPoolIds []string `tfschema:"application_gateway_backend_address_pool_ids"` - ApplicationSecurityGroupIds []string `tfschema:"application_security_group_ids"` - LoadBalancerBackendAddressPoolIds []string `tfschema:"load_balancer_backend_address_pool_ids"` - Primary bool `tfschema:"primary"` - PublicIPAddress VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddress `tfschema:"public_ip_address"` - SubnetId string `tfschema:"subnet_id"` - Version string `tfschema:"version"` + Name string `tfschema:"name"` + ApplicationGatewayBackendAddressPoolIds []string `tfschema:"application_gateway_backend_address_pool_ids"` + ApplicationSecurityGroupIds []string `tfschema:"application_security_group_ids"` + LoadBalancerBackendAddressPoolIds []string `tfschema:"load_balancer_backend_address_pool_ids"` + Primary bool `tfschema:"primary"` + PublicIPAddress []VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddress `tfschema:"public_ip_address"` + SubnetId string `tfschema:"subnet_id"` + Version string `tfschema:"version"` } type VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddress struct { @@ -88,7 +88,50 @@ func (r OrchestratedVirtualMachineScaleSetDataSource) Attributes() map[string]*p return map[string]*pluginsdk.Schema{ "location": commonschema.LocationComputed(), - "network_interfaces": OrchestratedVirtualMachineScaleSetNetworkInterfaceSchema(), + "network_interface": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "ip_configuration": virtualMachineScaleSetIPConfigurationSchemaForDataSource(), + + "dns_servers": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + }, + + "accelerated_networking_enabled": { + Type: pluginsdk.TypeBool, + Computed: true, + }, + + "ip_forwarding_enabled": { + Type: pluginsdk.TypeBool, + Computed: true, + }, + + "network_security_group_id": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "primary": { + Type: pluginsdk.TypeBool, + Computed: true, + }, + }, + }, + }, + + "identity": commonschema.UserAssignedIdentityComputed(), } } @@ -220,9 +263,9 @@ func flattenOrchestratedVirtualMachineScaleSetNetworkInterfaceIPConfiguration(in return ipConfigurations } -func flattenOrchestratedVirtualMachineScaleSetPublicIPAddress(input *compute.VirtualMachineScaleSetPublicIPAddressConfiguration) VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddress { +func flattenOrchestratedVirtualMachineScaleSetPublicIPAddress(input *compute.VirtualMachineScaleSetPublicIPAddressConfiguration) []VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddress { if input == nil { - return VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddress{} + return []VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddress{} } ipTags := make([]VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddressIPTag, 0) @@ -267,14 +310,14 @@ func flattenOrchestratedVirtualMachineScaleSetPublicIPAddress(input *compute.Vir idleTimeoutInMinutes = int(*input.IdleTimeoutInMinutes) } - return VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddress{ + return []VirtualMachineScaleSetNetworkInterfaceIPConfigurationPublicIPAddress{{ Name: name, DomainNameLabel: domainNameLabel, IdleTimeoutInMinutes: idleTimeoutInMinutes, IPTag: ipTags, PublicIpPrefixId: publicIPPrefixId, Version: version, - } + }} } func flattenOrchestratedVirtualMachineScaleSetIdentityToModel(input *compute.VirtualMachineScaleSetIdentity) ([]identity.ModelUserAssigned, error) { diff --git a/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source_test.go b/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source_test.go index 96ee44e82339..82e8e530416f 100644 --- a/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source_test.go +++ b/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source_test.go @@ -19,7 +19,7 @@ func TestAccOrchestratedVMSSDataSource_complete(t *testing.T) { Config: d.complete(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).Key("location").HasValue(data.Locations.Primary), - check.That(data.ResourceName).Key("network_interfaces.#").HasValue("1"), + check.That(data.ResourceName).Key("network_interface.#").HasValue("1"), ), }, }) @@ -30,8 +30,8 @@ func (OrchestratedVirtualMachineScaleSetDataSource) complete(data acceptance.Tes %s data azurerm_orchestrated_virtual_machine_scale_set test { - name = azurerm_service_plan.test.name - resource_group_name = azurerm_service_plan.test.resource_group_name + name = azurerm_orchestrated_virtual_machine_scale_set.test.name + resource_group_name = azurerm_orchestrated_virtual_machine_scale_set.test.resource_group_name } `, OrchestratedVirtualMachineScaleSetResource{}.linuxInstances(data)) } diff --git a/website/docs/d/orchestrated_virtual_machine_scale_set.html.markdown b/website/docs/d/orchestrated_virtual_machine_scale_set.html.markdown index 7316d556dbbb..ceb255d2d0fe 100644 --- a/website/docs/d/orchestrated_virtual_machine_scale_set.html.markdown +++ b/website/docs/d/orchestrated_virtual_machine_scale_set.html.markdown @@ -60,36 +60,56 @@ An `identity` block exports the following: `network_interface` exports the following: * `name` - The name of the network interface configuration. + * `primary` - Whether network interfaces created from the network interface configuration will be the primary NIC of the VM. + * `ip_configuration` - An `ip_configuration` block as documented below. -* `enable_accelerated_networking` - Whether to enable accelerated networking or not. + +* `accelerated_networking_enabled` - Is accelerated networking enabled? + * `dns_servers` - An array of the DNS servers in use. -* `enable_ip_forwarding` - Whether IP forwarding is enabled on this NIC. + +* `ip_forwarding_enabled` - Is IP forwarding enabled? + * `network_security_group_id` - The identifier for the network security group. `ip_configuration` exports the following: * `name` - The name of the IP configuration. + * `subnet_id` - The the identifier of the subnet. + * `application_gateway_backend_address_pool_ids` - An array of references to backend address pools of application gateways. + * `load_balancer_backend_address_pool_ids` - An array of references to backend address pools of load balancers. + * `load_balancer_inbound_nat_rules_ids` - An array of references to inbound NAT pools for load balancers. + * `primary` - If this ip_configuration is the primary one. + * `application_security_group_ids` - The application security group IDs to use. + * `public_ip_address` - The virtual machines scale set IP Configuration's PublicIPAddress configuration. The `public_ip_address` is documented below. `public_ip_address` exports the following: * `name` - The name of the public IP address configuration + * `idle_timeout_in_minutes` - The idle timeout in minutes. + * `domain_name_label` - The domain name label for the DNS settings. + * `ip_tag` - A list of `ip_tag` blocks as defined below. + * `public_ip_prefix_id` - The ID of the public IP prefix. + * `version` - The Internet Protocol Version of the public IP address. + `ip_tag` exports the following: * `tag` - The IP Tag associated with the Public IP. + * `type` - The Type of IP Tag. ## Timeouts From c488127dc73689d573e7b7b63c6f55e172aff52b Mon Sep 17 00:00:00 2001 From: Matthew Date: Tue, 21 Mar 2023 10:13:47 -0700 Subject: [PATCH 6/6] Lint --- internal/sdk/resource_encode.go | 2 +- .../orchestrated_virtual_machine_scale_set_data_source.go | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/internal/sdk/resource_encode.go b/internal/sdk/resource_encode.go index 5bffa2fd73cf..75b69fb7628f 100644 --- a/internal/sdk/resource_encode.go +++ b/internal/sdk/resource_encode.go @@ -124,7 +124,7 @@ func recurse(objType reflect.Type, objVal reflect.Value, fieldName string, debug fieldName := field.Name serialized, err := recurse(nestedType, nestedValue, fieldName, debugLogger) if err != nil { - return nil, fmt.Errorf("serializing nested object %q: %+v", sv.Type(), err) + return nil, fmt.Errorf("serializing nested object %q: %+v", sv.Type(), exists) } attr[i] = serialized } diff --git a/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go b/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go index f9fcba475d39..7126321eb6a2 100644 --- a/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go +++ b/internal/services/compute/orchestrated_virtual_machine_scale_set_data_source.go @@ -208,13 +208,6 @@ func flattenVirtualMachineScaleSetNetworkInterface(input *[]compute.VirtualMachi dnsServers = *v.DNSSettings.DNSServers } - var ipConfigurations []interface{} - if v.IPConfigurations != nil { - for _, configRaw := range *v.IPConfigurations { - config := flattenVirtualMachineScaleSetIPConfiguration(configRaw) - ipConfigurations = append(ipConfigurations, config) - } - } networkInterfaces = append(networkInterfaces, VirtualMachineScaleSetNetworkInterface{ Name: name, NetworkSecurityGroupId: networkSecurityGroupId,