From cace9a879be856ca230b8dc085ac59779261b5e4 Mon Sep 17 00:00:00 2001 From: Toby Pettit Date: Tue, 6 Aug 2019 11:02:45 +0100 Subject: [PATCH 01/14] add proximity placement group support --- azurerm/resource_arm_virtual_machine.go | 19 +++++++++++++++++++ website/docs/r/virtual_machine.html.markdown | 2 ++ 2 files changed, 21 insertions(+) diff --git a/azurerm/resource_arm_virtual_machine.go b/azurerm/resource_arm_virtual_machine.go index 0db2cee0b388..d6796d26f151 100644 --- a/azurerm/resource_arm_virtual_machine.go +++ b/azurerm/resource_arm_virtual_machine.go @@ -80,6 +80,12 @@ func resourceArmVirtualMachine() *schema.Resource { ConflictsWith: []string{"zones"}, }, + "proximity_placement_group_id": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "identity": { Type: schema.TypeList, Optional: true, @@ -648,6 +654,15 @@ func resourceArmVirtualMachineCreateUpdate(d *schema.ResourceData, meta interfac properties.AvailabilitySet = &availSet } + if v, ok := d.GetOk("proximity_placement_group_id"); ok { + proximityPlacementGroup := v.(string) + ppg := compute.SubResource{ + ID: &proximityPlacementGroup, + } + + properties.ProximityPlacementGroup = &ppg + } + vm := compute.VirtualMachine{ Name: &name, Location: &location, @@ -754,6 +769,10 @@ func resourceArmVirtualMachineRead(d *schema.ResourceData, meta interface{}) err d.Set("availability_set_id", strings.ToLower(*availabilitySet.ID)) } + if proximityPlacementGroup := props.ProximityPlacementGroup; proximityPlacementGroup != nil { + d.Set("proximity_placement_group_id", *proximityPlacementGroup.ID) + } + if profile := props.HardwareProfile; profile != nil { d.Set("vm_size", profile.VMSize) } diff --git a/website/docs/r/virtual_machine.html.markdown b/website/docs/r/virtual_machine.html.markdown index 212efc59fe8a..29ddae138755 100644 --- a/website/docs/r/virtual_machine.html.markdown +++ b/website/docs/r/virtual_machine.html.markdown @@ -132,6 +132,8 @@ The following arguments are supported: * `primary_network_interface_id` - (Optional) The ID of the Network Interface (which must be attached to the Virtual Machine) which should be the Primary Network Interface for this Virtual Machine. +* `proximity_placement_group_id` - (Optional) The ID of the Proximity Placement Group to which this Virtual Machine should be assigned. + * `storage_data_disk` - (Optional) One or more `storage_data_disk` blocks. ~> **Please Note:** Data Disks can also be attached either using this block or [the `azurerm_virtual_machine_data_disk_attachment` resource](virtual_machine_data_disk_attachment.html) - but not both. From b915bf1b2773a9772586cbbf7c7772560bee35e1 Mon Sep 17 00:00:00 2001 From: Toby Pettit Date: Tue, 6 Aug 2019 16:18:57 +0100 Subject: [PATCH 02/14] New resource & data source: azurerm_proximity_placement_group --- azurerm/config.go | 5 + .../data_source_proximity_placement_group.go | 47 +++ ...a_source_proximity_placement_group_test.go | 56 +++ azurerm/provider.go | 356 +++++++++--------- azurerm/resource_arm_availability_set.go | 34 +- .../resource_arm_proximity_placement_group.go | 126 +++++++ ...urce_arm_proximity_placement_group_test.go | 275 ++++++++++++++ azurerm/resource_arm_virtual_machine.go | 14 +- .../resource_arm_virtual_machine_scale_set.go | 34 +- azurerm/resource_arm_virtual_network.go | 2 +- .../d/proximity_placement_group.html.markdown | 38 ++ website/docs/r/availability_set.html.markdown | 2 + .../r/proximity_placement_group.html.markdown | 65 ++++ .../r/virtual_machine_scale_set.html.markdown | 2 + 14 files changed, 865 insertions(+), 191 deletions(-) create mode 100644 azurerm/data_source_proximity_placement_group.go create mode 100644 azurerm/data_source_proximity_placement_group_test.go create mode 100644 azurerm/resource_arm_proximity_placement_group.go create mode 100644 azurerm/resource_arm_proximity_placement_group_test.go create mode 100644 website/docs/d/proximity_placement_group.html.markdown create mode 100644 website/docs/r/proximity_placement_group.html.markdown diff --git a/azurerm/config.go b/azurerm/config.go index e4231bd3d0bb..861bc7e39696 100644 --- a/azurerm/config.go +++ b/azurerm/config.go @@ -154,6 +154,7 @@ type ArmClient struct { galleriesClient compute.GalleriesClient galleryImagesClient compute.GalleryImagesClient galleryImageVersionsClient compute.GalleryImageVersionsClient + ppgClient compute.ProximityPlacementGroupsClient snapshotsClient compute.SnapshotsClient usageOpsClient compute.UsageClient vmExtensionImageClient compute.VirtualMachineExtensionImagesClient @@ -456,6 +457,10 @@ func (c *ArmClient) registerComputeClients(endpoint, subscriptionId string, auth galleryImageVersionsClient := compute.NewGalleryImageVersionsClientWithBaseURI(endpoint, subscriptionId) c.configureClient(&galleryImageVersionsClient.Client, auth) c.galleryImageVersionsClient = galleryImageVersionsClient + + proximityPlacementGroupsClient := compute.NewProximityPlacementGroupsClientWithBaseURI(endpoint, subscriptionId) + c.configureClient(&proximityPlacementGroupsClient.Client, auth) + c.ppgClient = proximityPlacementGroupsClient } func (c *ArmClient) registerDatabases(endpoint, subscriptionId string, auth autorest.Authorizer, sender autorest.Sender) { diff --git a/azurerm/data_source_proximity_placement_group.go b/azurerm/data_source_proximity_placement_group.go new file mode 100644 index 000000000000..b6473ac23db2 --- /dev/null +++ b/azurerm/data_source_proximity_placement_group.go @@ -0,0 +1,47 @@ +package azurerm + +import ( + "fmt" + + "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func dataSourceArmProximityPlacementGroup() *schema.Resource { + return &schema.Resource{ + Read: dataSourceArmProximityPlacementGroupRead, + Schema: map[string]*schema.Schema{ + "resource_group_name": azure.SchemaResourceGroupNameForDataSource(), + + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + }, + } +} + +func dataSourceArmProximityPlacementGroupRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).ppgClient + ctx := meta.(*ArmClient).StopContext + + resGroup := d.Get("resource_group_name").(string) + name := d.Get("name").(string) + + resp, err := client.Get(ctx, resGroup, name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Error: Proximity Placement Group %q (Resource Group %q) was not found", name, resGroup) + } + + return fmt.Errorf("Error making Read request on Proximity Placement Group %q (Resource Group %q): %+v", name, resGroup, err) + } + + d.SetId(*resp.ID) + flattenAndSetTags(d, resp.Tags) + + return nil +} diff --git a/azurerm/data_source_proximity_placement_group_test.go b/azurerm/data_source_proximity_placement_group_test.go new file mode 100644 index 000000000000..f05baaeac098 --- /dev/null +++ b/azurerm/data_source_proximity_placement_group_test.go @@ -0,0 +1,56 @@ +package azurerm + +import ( + "fmt" + "testing" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" + + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccDataSourceProximityPlacementGroup_basic(t *testing.T) { + dataSourceName := "data.azurerm_proximity_placement_group.test" + ri := tf.AccRandTimeInt() + location := testLocation() + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccDataSourceProximityPlacementGroup_basic(ri, location), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet(dataSourceName, "location"), + resource.TestCheckResourceAttrSet(dataSourceName, "name"), + resource.TestCheckResourceAttrSet(dataSourceName, "resource_group_name"), + resource.TestCheckResourceAttr(dataSourceName, "tags.%", "1"), + ), + }, + }, + }) +} + +func testAccDataSourceProximityPlacementGroup_basic(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%[1]d" + location = "%[2]s" +} + +resource "azurerm_proximity_placement_group" "test" { + name = "acctestppg-%[1]d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + tags = { + "foo" = "bar" + } +} + +data "azurerm_proximity_placement_group" "test" { + resource_group_name = "${azurerm_resource_group.test.name}" + name = "${azurerm_proximity_placement_group.test.name}" +} +`, rInt, location) +} diff --git a/azurerm/provider.go b/azurerm/provider.go index 72157676d3de..372ce5b097ff 100644 --- a/azurerm/provider.go +++ b/azurerm/provider.go @@ -155,6 +155,7 @@ func Provider() terraform.ResourceProvider { "azurerm_notification_hub": dataSourceNotificationHub(), "azurerm_platform_image": dataSourceArmPlatformImage(), "azurerm_policy_definition": dataSourceArmPolicyDefinition(), + "azurerm_proximity_placement_group": dataSourceArmProximityPlacementGroup(), "azurerm_public_ip": dataSourceArmPublicIP(), "azurerm_public_ips": dataSourceArmPublicIPs(), "azurerm_recovery_services_vault": dataSourceArmRecoveryServicesVault(), @@ -185,183 +186,183 @@ func Provider() terraform.ResourceProvider { }, ResourcesMap: map[string]*schema.Resource{ - "azurerm_analysis_services_server": resourceArmAnalysisServicesServer(), - "azurerm_api_management": resourceArmApiManagementService(), - "azurerm_api_management_api": resourceArmApiManagementApi(), - "azurerm_api_management_api_operation": resourceArmApiManagementApiOperation(), - "azurerm_api_management_api_operation_policy": resourceArmApiManagementApiOperationPolicy(), - "azurerm_api_management_api_policy": resourceArmApiManagementApiPolicy(), - "azurerm_api_management_api_schema": resourceArmApiManagementApiSchema(), - "azurerm_api_management_api_version_set": resourceArmApiManagementApiVersionSet(), - "azurerm_api_management_authorization_server": resourceArmApiManagementAuthorizationServer(), - "azurerm_api_management_backend": resourceArmApiManagementBackend(), - "azurerm_api_management_certificate": resourceArmApiManagementCertificate(), - "azurerm_api_management_group": resourceArmApiManagementGroup(), - "azurerm_api_management_group_user": resourceArmApiManagementGroupUser(), - "azurerm_api_management_logger": resourceArmApiManagementLogger(), - "azurerm_api_management_openid_connect_provider": resourceArmApiManagementOpenIDConnectProvider(), - "azurerm_api_management_product": resourceArmApiManagementProduct(), - "azurerm_api_management_product_api": resourceArmApiManagementProductApi(), - "azurerm_api_management_product_group": resourceArmApiManagementProductGroup(), - "azurerm_api_management_product_policy": resourceArmApiManagementProductPolicy(), - "azurerm_api_management_property": resourceArmApiManagementProperty(), - "azurerm_api_management_subscription": resourceArmApiManagementSubscription(), - "azurerm_api_management_user": resourceArmApiManagementUser(), - "azurerm_app_service_active_slot": resourceArmAppServiceActiveSlot(), - "azurerm_app_service_custom_hostname_binding": resourceArmAppServiceCustomHostnameBinding(), - "azurerm_app_service_plan": resourceArmAppServicePlan(), - "azurerm_app_service_slot": resourceArmAppServiceSlot(), - "azurerm_app_service": resourceArmAppService(), - "azurerm_application_gateway": resourceArmApplicationGateway(), - "azurerm_application_insights_api_key": resourceArmApplicationInsightsAPIKey(), - "azurerm_application_insights": resourceArmApplicationInsights(), - "azurerm_application_insights_web_test": resourceArmApplicationInsightsWebTests(), - "azurerm_application_security_group": resourceArmApplicationSecurityGroup(), - "azurerm_automation_account": resourceArmAutomationAccount(), - "azurerm_automation_credential": resourceArmAutomationCredential(), - "azurerm_automation_dsc_configuration": resourceArmAutomationDscConfiguration(), - "azurerm_automation_dsc_nodeconfiguration": resourceArmAutomationDscNodeConfiguration(), - "azurerm_automation_module": resourceArmAutomationModule(), - "azurerm_automation_runbook": resourceArmAutomationRunbook(), - "azurerm_automation_schedule": resourceArmAutomationSchedule(), - "azurerm_automation_variable_bool": resourceArmAutomationVariableBool(), - "azurerm_automation_variable_datetime": resourceArmAutomationVariableDateTime(), - "azurerm_automation_variable_int": resourceArmAutomationVariableInt(), - "azurerm_automation_variable_string": resourceArmAutomationVariableString(), - "azurerm_autoscale_setting": resourceArmAutoScaleSetting(), - "azurerm_availability_set": resourceArmAvailabilitySet(), - "azurerm_azuread_application": resourceArmActiveDirectoryApplication(), - "azurerm_azuread_service_principal_password": resourceArmActiveDirectoryServicePrincipalPassword(), - "azurerm_azuread_service_principal": resourceArmActiveDirectoryServicePrincipal(), - "azurerm_batch_account": resourceArmBatchAccount(), - "azurerm_batch_application": resourceArmBatchApplication(), - "azurerm_batch_certificate": resourceArmBatchCertificate(), - "azurerm_batch_pool": resourceArmBatchPool(), - "azurerm_cdn_endpoint": resourceArmCdnEndpoint(), - "azurerm_cdn_profile": resourceArmCdnProfile(), - "azurerm_cognitive_account": resourceArmCognitiveAccount(), - "azurerm_connection_monitor": resourceArmConnectionMonitor(), - "azurerm_container_group": resourceArmContainerGroup(), - "azurerm_container_registry": resourceArmContainerRegistry(), - "azurerm_container_service": resourceArmContainerService(), - "azurerm_cosmosdb_account": resourceArmCosmosDbAccount(), - "azurerm_cosmosdb_cassandra_keyspace": resourceArmCosmosDbCassandraKeyspace(), - "azurerm_cosmosdb_mongo_collection": resourceArmCosmosDbMongoCollection(), - "azurerm_cosmosdb_mongo_database": resourceArmCosmosDbMongoDatabase(), - "azurerm_cosmosdb_sql_database": resourceArmCosmosDbSQLDatabase(), - "azurerm_cosmosdb_table": resourceArmCosmosDbTable(), - "azurerm_data_factory": resourceArmDataFactory(), - "azurerm_data_factory_dataset_mysql": resourceArmDataFactoryDatasetMySQL(), - "azurerm_data_factory_dataset_postgresql": resourceArmDataFactoryDatasetPostgreSQL(), - "azurerm_data_factory_dataset_sql_server_table": resourceArmDataFactoryDatasetSQLServerTable(), - "azurerm_data_factory_linked_service_data_lake_storage_gen2": resourceArmDataFactoryLinkedServiceDataLakeStorageGen2(), - "azurerm_data_factory_linked_service_mysql": resourceArmDataFactoryLinkedServiceMySQL(), - "azurerm_data_factory_linked_service_postgresql": resourceArmDataFactoryLinkedServicePostgreSQL(), - "azurerm_data_factory_linked_service_sql_server": resourceArmDataFactoryLinkedServiceSQLServer(), - "azurerm_data_factory_pipeline": resourceArmDataFactoryPipeline(), - "azurerm_data_lake_analytics_account": resourceArmDataLakeAnalyticsAccount(), - "azurerm_data_lake_analytics_firewall_rule": resourceArmDataLakeAnalyticsFirewallRule(), - "azurerm_data_lake_store_file": resourceArmDataLakeStoreFile(), - "azurerm_data_lake_store_firewall_rule": resourceArmDataLakeStoreFirewallRule(), - "azurerm_data_lake_store": resourceArmDataLakeStore(), - "azurerm_databricks_workspace": resourceArmDatabricksWorkspace(), - "azurerm_ddos_protection_plan": resourceArmDDoSProtectionPlan(), - "azurerm_dev_test_lab": resourceArmDevTestLab(), - "azurerm_dev_test_schedule": resourceArmDevTestLabSchedules(), - "azurerm_dev_test_linux_virtual_machine": resourceArmDevTestLinuxVirtualMachine(), - "azurerm_dev_test_policy": resourceArmDevTestPolicy(), - "azurerm_dev_test_virtual_network": resourceArmDevTestVirtualNetwork(), - "azurerm_dev_test_windows_virtual_machine": resourceArmDevTestWindowsVirtualMachine(), - "azurerm_devspace_controller": resourceArmDevSpaceController(), - "azurerm_dns_a_record": resourceArmDnsARecord(), - "azurerm_dns_aaaa_record": resourceArmDnsAAAARecord(), - "azurerm_dns_caa_record": resourceArmDnsCaaRecord(), - "azurerm_dns_cname_record": resourceArmDnsCNameRecord(), - "azurerm_dns_mx_record": resourceArmDnsMxRecord(), - "azurerm_dns_ns_record": resourceArmDnsNsRecord(), - "azurerm_dns_ptr_record": resourceArmDnsPtrRecord(), - "azurerm_dns_srv_record": resourceArmDnsSrvRecord(), - "azurerm_dns_txt_record": resourceArmDnsTxtRecord(), - "azurerm_dns_zone": resourceArmDnsZone(), - "azurerm_eventgrid_domain": resourceArmEventGridDomain(), - "azurerm_eventgrid_event_subscription": resourceArmEventGridEventSubscription(), - "azurerm_eventgrid_topic": resourceArmEventGridTopic(), - "azurerm_eventhub_authorization_rule": resourceArmEventHubAuthorizationRule(), - "azurerm_eventhub_consumer_group": resourceArmEventHubConsumerGroup(), - "azurerm_eventhub_namespace_authorization_rule": resourceArmEventHubNamespaceAuthorizationRule(), - "azurerm_eventhub_namespace": resourceArmEventHubNamespace(), - "azurerm_eventhub": resourceArmEventHub(), - "azurerm_express_route_circuit_authorization": resourceArmExpressRouteCircuitAuthorization(), - "azurerm_express_route_circuit_peering": resourceArmExpressRouteCircuitPeering(), - "azurerm_express_route_circuit": resourceArmExpressRouteCircuit(), - "azurerm_firewall_application_rule_collection": resourceArmFirewallApplicationRuleCollection(), - "azurerm_firewall_nat_rule_collection": resourceArmFirewallNatRuleCollection(), - "azurerm_firewall_network_rule_collection": resourceArmFirewallNetworkRuleCollection(), - "azurerm_firewall": resourceArmFirewall(), - "azurerm_function_app": resourceArmFunctionApp(), - "azurerm_hdinsight_hadoop_cluster": resourceArmHDInsightHadoopCluster(), - "azurerm_hdinsight_hbase_cluster": resourceArmHDInsightHBaseCluster(), - "azurerm_hdinsight_interactive_query_cluster": resourceArmHDInsightInteractiveQueryCluster(), - "azurerm_hdinsight_kafka_cluster": resourceArmHDInsightKafkaCluster(), - "azurerm_hdinsight_ml_services_cluster": resourceArmHDInsightMLServicesCluster(), - "azurerm_hdinsight_rserver_cluster": resourceArmHDInsightRServerCluster(), - "azurerm_hdinsight_spark_cluster": resourceArmHDInsightSparkCluster(), - "azurerm_hdinsight_storm_cluster": resourceArmHDInsightStormCluster(), - "azurerm_image": resourceArmImage(), - "azurerm_iot_dps": resourceArmIotDPS(), - "azurerm_iot_dps_certificate": resourceArmIotDPSCertificate(), - "azurerm_iothub_consumer_group": resourceArmIotHubConsumerGroup(), - "azurerm_iothub": resourceArmIotHub(), - "azurerm_iothub_shared_access_policy": resourceArmIotHubSharedAccessPolicy(), - "azurerm_key_vault_access_policy": resourceArmKeyVaultAccessPolicy(), - "azurerm_key_vault_certificate": resourceArmKeyVaultCertificate(), - "azurerm_key_vault_key": resourceArmKeyVaultKey(), - "azurerm_key_vault_secret": resourceArmKeyVaultSecret(), - "azurerm_key_vault": resourceArmKeyVault(), - "azurerm_kubernetes_cluster": resourceArmKubernetesCluster(), - "azurerm_lb_backend_address_pool": resourceArmLoadBalancerBackendAddressPool(), - "azurerm_lb_nat_pool": resourceArmLoadBalancerNatPool(), - "azurerm_lb_nat_rule": resourceArmLoadBalancerNatRule(), - "azurerm_lb_probe": resourceArmLoadBalancerProbe(), - "azurerm_lb_outbound_rule": resourceArmLoadBalancerOutboundRule(), - "azurerm_lb_rule": resourceArmLoadBalancerRule(), - "azurerm_lb": resourceArmLoadBalancer(), - "azurerm_local_network_gateway": resourceArmLocalNetworkGateway(), - "azurerm_log_analytics_solution": resourceArmLogAnalyticsSolution(), - "azurerm_log_analytics_linked_service": resourceArmLogAnalyticsLinkedService(), - "azurerm_log_analytics_workspace_linked_service": resourceArmLogAnalyticsWorkspaceLinkedService(), - "azurerm_log_analytics_workspace": resourceArmLogAnalyticsWorkspace(), - "azurerm_logic_app_action_custom": resourceArmLogicAppActionCustom(), - "azurerm_logic_app_action_http": resourceArmLogicAppActionHTTP(), - "azurerm_logic_app_trigger_custom": resourceArmLogicAppTriggerCustom(), - "azurerm_logic_app_trigger_http_request": resourceArmLogicAppTriggerHttpRequest(), - "azurerm_logic_app_trigger_recurrence": resourceArmLogicAppTriggerRecurrence(), - "azurerm_logic_app_workflow": resourceArmLogicAppWorkflow(), - "azurerm_managed_disk": resourceArmManagedDisk(), - "azurerm_management_group": resourceArmManagementGroup(), - "azurerm_management_lock": resourceArmManagementLock(), - "azurerm_maps_account": resourceArmMapsAccount(), - "azurerm_mariadb_database": resourceArmMariaDbDatabase(), - "azurerm_mariadb_firewall_rule": resourceArmMariaDBFirewallRule(), - "azurerm_mariadb_server": resourceArmMariaDbServer(), - "azurerm_media_services_account": resourceArmMediaServicesAccount(), - "azurerm_metric_alertrule": resourceArmMetricAlertRule(), - "azurerm_monitor_autoscale_setting": resourceArmMonitorAutoScaleSetting(), - "azurerm_monitor_action_group": resourceArmMonitorActionGroup(), - "azurerm_monitor_activity_log_alert": resourceArmMonitorActivityLogAlert(), - "azurerm_monitor_diagnostic_setting": resourceArmMonitorDiagnosticSetting(), - "azurerm_monitor_log_profile": resourceArmMonitorLogProfile(), - "azurerm_monitor_metric_alert": resourceArmMonitorMetricAlert(), - "azurerm_monitor_metric_alertrule": resourceArmMonitorMetricAlertRule(), - "azurerm_mssql_elasticpool": resourceArmMsSqlElasticPool(), - "azurerm_mysql_configuration": resourceArmMySQLConfiguration(), - "azurerm_mysql_database": resourceArmMySqlDatabase(), - "azurerm_mysql_firewall_rule": resourceArmMySqlFirewallRule(), - "azurerm_mysql_server": resourceArmMySqlServer(), - "azurerm_mysql_virtual_network_rule": resourceArmMySqlVirtualNetworkRule(), - "azurerm_network_connection_monitor": resourceArmNetworkConnectionMonitor(), - "azurerm_network_ddos_protection_plan": resourceArmNetworkDDoSProtectionPlan(), - "azurerm_network_interface": resourceArmNetworkInterface(), + "azurerm_analysis_services_server": resourceArmAnalysisServicesServer(), + "azurerm_api_management": resourceArmApiManagementService(), + "azurerm_api_management_api": resourceArmApiManagementApi(), + "azurerm_api_management_api_operation": resourceArmApiManagementApiOperation(), + "azurerm_api_management_api_operation_policy": resourceArmApiManagementApiOperationPolicy(), + "azurerm_api_management_api_policy": resourceArmApiManagementApiPolicy(), + "azurerm_api_management_api_schema": resourceArmApiManagementApiSchema(), + "azurerm_api_management_api_version_set": resourceArmApiManagementApiVersionSet(), + "azurerm_api_management_authorization_server": resourceArmApiManagementAuthorizationServer(), + "azurerm_api_management_backend": resourceArmApiManagementBackend(), + "azurerm_api_management_certificate": resourceArmApiManagementCertificate(), + "azurerm_api_management_group": resourceArmApiManagementGroup(), + "azurerm_api_management_group_user": resourceArmApiManagementGroupUser(), + "azurerm_api_management_logger": resourceArmApiManagementLogger(), + "azurerm_api_management_openid_connect_provider": resourceArmApiManagementOpenIDConnectProvider(), + "azurerm_api_management_product": resourceArmApiManagementProduct(), + "azurerm_api_management_product_api": resourceArmApiManagementProductApi(), + "azurerm_api_management_product_group": resourceArmApiManagementProductGroup(), + "azurerm_api_management_product_policy": resourceArmApiManagementProductPolicy(), + "azurerm_api_management_property": resourceArmApiManagementProperty(), + "azurerm_api_management_subscription": resourceArmApiManagementSubscription(), + "azurerm_api_management_user": resourceArmApiManagementUser(), + "azurerm_app_service_active_slot": resourceArmAppServiceActiveSlot(), + "azurerm_app_service_custom_hostname_binding": resourceArmAppServiceCustomHostnameBinding(), + "azurerm_app_service_plan": resourceArmAppServicePlan(), + "azurerm_app_service_slot": resourceArmAppServiceSlot(), + "azurerm_app_service": resourceArmAppService(), + "azurerm_application_gateway": resourceArmApplicationGateway(), + "azurerm_application_insights_api_key": resourceArmApplicationInsightsAPIKey(), + "azurerm_application_insights": resourceArmApplicationInsights(), + "azurerm_application_insights_web_test": resourceArmApplicationInsightsWebTests(), + "azurerm_application_security_group": resourceArmApplicationSecurityGroup(), + "azurerm_automation_account": resourceArmAutomationAccount(), + "azurerm_automation_credential": resourceArmAutomationCredential(), + "azurerm_automation_dsc_configuration": resourceArmAutomationDscConfiguration(), + "azurerm_automation_dsc_nodeconfiguration": resourceArmAutomationDscNodeConfiguration(), + "azurerm_automation_module": resourceArmAutomationModule(), + "azurerm_automation_runbook": resourceArmAutomationRunbook(), + "azurerm_automation_schedule": resourceArmAutomationSchedule(), + "azurerm_automation_variable_bool": resourceArmAutomationVariableBool(), + "azurerm_automation_variable_datetime": resourceArmAutomationVariableDateTime(), + "azurerm_automation_variable_int": resourceArmAutomationVariableInt(), + "azurerm_automation_variable_string": resourceArmAutomationVariableString(), + "azurerm_autoscale_setting": resourceArmAutoScaleSetting(), + "azurerm_availability_set": resourceArmAvailabilitySet(), + "azurerm_azuread_application": resourceArmActiveDirectoryApplication(), + "azurerm_azuread_service_principal_password": resourceArmActiveDirectoryServicePrincipalPassword(), + "azurerm_azuread_service_principal": resourceArmActiveDirectoryServicePrincipal(), + "azurerm_batch_account": resourceArmBatchAccount(), + "azurerm_batch_application": resourceArmBatchApplication(), + "azurerm_batch_certificate": resourceArmBatchCertificate(), + "azurerm_batch_pool": resourceArmBatchPool(), + "azurerm_cdn_endpoint": resourceArmCdnEndpoint(), + "azurerm_cdn_profile": resourceArmCdnProfile(), + "azurerm_cognitive_account": resourceArmCognitiveAccount(), + "azurerm_connection_monitor": resourceArmConnectionMonitor(), + "azurerm_container_group": resourceArmContainerGroup(), + "azurerm_container_registry": resourceArmContainerRegistry(), + "azurerm_container_service": resourceArmContainerService(), + "azurerm_cosmosdb_account": resourceArmCosmosDbAccount(), + "azurerm_cosmosdb_cassandra_keyspace": resourceArmCosmosDbCassandraKeyspace(), + "azurerm_cosmosdb_mongo_collection": resourceArmCosmosDbMongoCollection(), + "azurerm_cosmosdb_mongo_database": resourceArmCosmosDbMongoDatabase(), + "azurerm_cosmosdb_sql_database": resourceArmCosmosDbSQLDatabase(), + "azurerm_cosmosdb_table": resourceArmCosmosDbTable(), + "azurerm_data_factory": resourceArmDataFactory(), + "azurerm_data_factory_dataset_mysql": resourceArmDataFactoryDatasetMySQL(), + "azurerm_data_factory_dataset_postgresql": resourceArmDataFactoryDatasetPostgreSQL(), + "azurerm_data_factory_dataset_sql_server_table": resourceArmDataFactoryDatasetSQLServerTable(), + "azurerm_data_factory_linked_service_data_lake_storage_gen2": resourceArmDataFactoryLinkedServiceDataLakeStorageGen2(), + "azurerm_data_factory_linked_service_mysql": resourceArmDataFactoryLinkedServiceMySQL(), + "azurerm_data_factory_linked_service_postgresql": resourceArmDataFactoryLinkedServicePostgreSQL(), + "azurerm_data_factory_linked_service_sql_server": resourceArmDataFactoryLinkedServiceSQLServer(), + "azurerm_data_factory_pipeline": resourceArmDataFactoryPipeline(), + "azurerm_data_lake_analytics_account": resourceArmDataLakeAnalyticsAccount(), + "azurerm_data_lake_analytics_firewall_rule": resourceArmDataLakeAnalyticsFirewallRule(), + "azurerm_data_lake_store_file": resourceArmDataLakeStoreFile(), + "azurerm_data_lake_store_firewall_rule": resourceArmDataLakeStoreFirewallRule(), + "azurerm_data_lake_store": resourceArmDataLakeStore(), + "azurerm_databricks_workspace": resourceArmDatabricksWorkspace(), + "azurerm_ddos_protection_plan": resourceArmDDoSProtectionPlan(), + "azurerm_dev_test_lab": resourceArmDevTestLab(), + "azurerm_dev_test_schedule": resourceArmDevTestLabSchedules(), + "azurerm_dev_test_linux_virtual_machine": resourceArmDevTestLinuxVirtualMachine(), + "azurerm_dev_test_policy": resourceArmDevTestPolicy(), + "azurerm_dev_test_virtual_network": resourceArmDevTestVirtualNetwork(), + "azurerm_dev_test_windows_virtual_machine": resourceArmDevTestWindowsVirtualMachine(), + "azurerm_devspace_controller": resourceArmDevSpaceController(), + "azurerm_dns_a_record": resourceArmDnsARecord(), + "azurerm_dns_aaaa_record": resourceArmDnsAAAARecord(), + "azurerm_dns_caa_record": resourceArmDnsCaaRecord(), + "azurerm_dns_cname_record": resourceArmDnsCNameRecord(), + "azurerm_dns_mx_record": resourceArmDnsMxRecord(), + "azurerm_dns_ns_record": resourceArmDnsNsRecord(), + "azurerm_dns_ptr_record": resourceArmDnsPtrRecord(), + "azurerm_dns_srv_record": resourceArmDnsSrvRecord(), + "azurerm_dns_txt_record": resourceArmDnsTxtRecord(), + "azurerm_dns_zone": resourceArmDnsZone(), + "azurerm_eventgrid_domain": resourceArmEventGridDomain(), + "azurerm_eventgrid_event_subscription": resourceArmEventGridEventSubscription(), + "azurerm_eventgrid_topic": resourceArmEventGridTopic(), + "azurerm_eventhub_authorization_rule": resourceArmEventHubAuthorizationRule(), + "azurerm_eventhub_consumer_group": resourceArmEventHubConsumerGroup(), + "azurerm_eventhub_namespace_authorization_rule": resourceArmEventHubNamespaceAuthorizationRule(), + "azurerm_eventhub_namespace": resourceArmEventHubNamespace(), + "azurerm_eventhub": resourceArmEventHub(), + "azurerm_express_route_circuit_authorization": resourceArmExpressRouteCircuitAuthorization(), + "azurerm_express_route_circuit_peering": resourceArmExpressRouteCircuitPeering(), + "azurerm_express_route_circuit": resourceArmExpressRouteCircuit(), + "azurerm_firewall_application_rule_collection": resourceArmFirewallApplicationRuleCollection(), + "azurerm_firewall_nat_rule_collection": resourceArmFirewallNatRuleCollection(), + "azurerm_firewall_network_rule_collection": resourceArmFirewallNetworkRuleCollection(), + "azurerm_firewall": resourceArmFirewall(), + "azurerm_function_app": resourceArmFunctionApp(), + "azurerm_hdinsight_hadoop_cluster": resourceArmHDInsightHadoopCluster(), + "azurerm_hdinsight_hbase_cluster": resourceArmHDInsightHBaseCluster(), + "azurerm_hdinsight_interactive_query_cluster": resourceArmHDInsightInteractiveQueryCluster(), + "azurerm_hdinsight_kafka_cluster": resourceArmHDInsightKafkaCluster(), + "azurerm_hdinsight_ml_services_cluster": resourceArmHDInsightMLServicesCluster(), + "azurerm_hdinsight_rserver_cluster": resourceArmHDInsightRServerCluster(), + "azurerm_hdinsight_spark_cluster": resourceArmHDInsightSparkCluster(), + "azurerm_hdinsight_storm_cluster": resourceArmHDInsightStormCluster(), + "azurerm_image": resourceArmImage(), + "azurerm_iot_dps": resourceArmIotDPS(), + "azurerm_iot_dps_certificate": resourceArmIotDPSCertificate(), + "azurerm_iothub_consumer_group": resourceArmIotHubConsumerGroup(), + "azurerm_iothub": resourceArmIotHub(), + "azurerm_iothub_shared_access_policy": resourceArmIotHubSharedAccessPolicy(), + "azurerm_key_vault_access_policy": resourceArmKeyVaultAccessPolicy(), + "azurerm_key_vault_certificate": resourceArmKeyVaultCertificate(), + "azurerm_key_vault_key": resourceArmKeyVaultKey(), + "azurerm_key_vault_secret": resourceArmKeyVaultSecret(), + "azurerm_key_vault": resourceArmKeyVault(), + "azurerm_kubernetes_cluster": resourceArmKubernetesCluster(), + "azurerm_lb_backend_address_pool": resourceArmLoadBalancerBackendAddressPool(), + "azurerm_lb_nat_pool": resourceArmLoadBalancerNatPool(), + "azurerm_lb_nat_rule": resourceArmLoadBalancerNatRule(), + "azurerm_lb_probe": resourceArmLoadBalancerProbe(), + "azurerm_lb_outbound_rule": resourceArmLoadBalancerOutboundRule(), + "azurerm_lb_rule": resourceArmLoadBalancerRule(), + "azurerm_lb": resourceArmLoadBalancer(), + "azurerm_local_network_gateway": resourceArmLocalNetworkGateway(), + "azurerm_log_analytics_solution": resourceArmLogAnalyticsSolution(), + "azurerm_log_analytics_linked_service": resourceArmLogAnalyticsLinkedService(), + "azurerm_log_analytics_workspace_linked_service": resourceArmLogAnalyticsWorkspaceLinkedService(), + "azurerm_log_analytics_workspace": resourceArmLogAnalyticsWorkspace(), + "azurerm_logic_app_action_custom": resourceArmLogicAppActionCustom(), + "azurerm_logic_app_action_http": resourceArmLogicAppActionHTTP(), + "azurerm_logic_app_trigger_custom": resourceArmLogicAppTriggerCustom(), + "azurerm_logic_app_trigger_http_request": resourceArmLogicAppTriggerHttpRequest(), + "azurerm_logic_app_trigger_recurrence": resourceArmLogicAppTriggerRecurrence(), + "azurerm_logic_app_workflow": resourceArmLogicAppWorkflow(), + "azurerm_managed_disk": resourceArmManagedDisk(), + "azurerm_management_group": resourceArmManagementGroup(), + "azurerm_management_lock": resourceArmManagementLock(), + "azurerm_maps_account": resourceArmMapsAccount(), + "azurerm_mariadb_database": resourceArmMariaDbDatabase(), + "azurerm_mariadb_firewall_rule": resourceArmMariaDBFirewallRule(), + "azurerm_mariadb_server": resourceArmMariaDbServer(), + "azurerm_media_services_account": resourceArmMediaServicesAccount(), + "azurerm_metric_alertrule": resourceArmMetricAlertRule(), + "azurerm_monitor_autoscale_setting": resourceArmMonitorAutoScaleSetting(), + "azurerm_monitor_action_group": resourceArmMonitorActionGroup(), + "azurerm_monitor_activity_log_alert": resourceArmMonitorActivityLogAlert(), + "azurerm_monitor_diagnostic_setting": resourceArmMonitorDiagnosticSetting(), + "azurerm_monitor_log_profile": resourceArmMonitorLogProfile(), + "azurerm_monitor_metric_alert": resourceArmMonitorMetricAlert(), + "azurerm_monitor_metric_alertrule": resourceArmMonitorMetricAlertRule(), + "azurerm_mssql_elasticpool": resourceArmMsSqlElasticPool(), + "azurerm_mysql_configuration": resourceArmMySQLConfiguration(), + "azurerm_mysql_database": resourceArmMySqlDatabase(), + "azurerm_mysql_firewall_rule": resourceArmMySqlFirewallRule(), + "azurerm_mysql_server": resourceArmMySqlServer(), + "azurerm_mysql_virtual_network_rule": resourceArmMySqlVirtualNetworkRule(), + "azurerm_network_connection_monitor": resourceArmNetworkConnectionMonitor(), + "azurerm_network_ddos_protection_plan": resourceArmNetworkDDoSProtectionPlan(), + "azurerm_network_interface": resourceArmNetworkInterface(), "azurerm_network_interface_application_gateway_backend_address_pool_association": resourceArmNetworkInterfaceApplicationGatewayBackendAddressPoolAssociation(), "azurerm_network_interface_application_security_group_association": resourceArmNetworkInterfaceApplicationSecurityGroupAssociation(), "azurerm_network_interface_backend_address_pool_association": resourceArmNetworkInterfaceBackendAddressPoolAssociation(), @@ -385,6 +386,7 @@ func Provider() terraform.ResourceProvider { "azurerm_postgresql_virtual_network_rule": resourceArmPostgreSQLVirtualNetworkRule(), "azurerm_private_dns_zone": resourceArmPrivateDnsZone(), "azurerm_private_dns_a_record": resourceArmPrivateDnsARecord(), + "azurerm_proximity_placement_group": resourceArmProximityPlacementGroup(), "azurerm_public_ip": resourceArmPublicIp(), "azurerm_public_ip_prefix": resourceArmPublicIpPrefix(), "azurerm_recovery_services_protected_vm": resourceArmRecoveryServicesProtectedVm(), diff --git a/azurerm/resource_arm_availability_set.go b/azurerm/resource_arm_availability_set.go index f3f5b7a6e538..34374b925691 100644 --- a/azurerm/resource_arm_availability_set.go +++ b/azurerm/resource_arm_availability_set.go @@ -57,6 +57,15 @@ func resourceArmAvailabilitySet() *schema.Resource { ForceNew: true, }, + "proximity_placement_group_id": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + StateFunc: func(id interface{}) string { + return strings.ToLower(id.(string)) + }, + }, + "tags": tagsSchema(), }, } @@ -90,13 +99,24 @@ func resourceArmAvailabilitySetCreateUpdate(d *schema.ResourceData, meta interfa managed := d.Get("managed").(bool) tags := d.Get("tags").(map[string]interface{}) + properties := compute.AvailabilitySetProperties{ + PlatformFaultDomainCount: utils.Int32(int32(faultDomainCount)), + PlatformUpdateDomainCount: utils.Int32(int32(updateDomainCount)), + } + + if v, ok := d.GetOk("proximity_placement_group_id"); ok { + proximityPlacementGroup := v.(string) + ppg := compute.SubResource{ + ID: &proximityPlacementGroup, + } + + properties.ProximityPlacementGroup = &ppg + } + availSet := compute.AvailabilitySet{ Name: &name, Location: &location, - AvailabilitySetProperties: &compute.AvailabilitySetProperties{ - PlatformFaultDomainCount: utils.Int32(int32(faultDomainCount)), - PlatformUpdateDomainCount: utils.Int32(int32(updateDomainCount)), - }, + AvailabilitySetProperties: &properties, Tags: expandTags(tags), } @@ -149,6 +169,12 @@ func resourceArmAvailabilitySetRead(d *schema.ResourceData, meta interface{}) er if props := resp.AvailabilitySetProperties; props != nil { d.Set("platform_update_domain_count", props.PlatformUpdateDomainCount) d.Set("platform_fault_domain_count", props.PlatformFaultDomainCount) + + if proximityPlacementGroup := props.ProximityPlacementGroup; proximityPlacementGroup != nil { + // Lowercase due to incorrect capitalisation of resource group name in + // proximity placement group ID in response from get VM API request + d.Set("proximity_placement_group_id", strings.ToLower(*proximityPlacementGroup.ID)) + } } flattenAndSetTags(d, resp.Tags) diff --git a/azurerm/resource_arm_proximity_placement_group.go b/azurerm/resource_arm_proximity_placement_group.go new file mode 100644 index 000000000000..03ff5484b48b --- /dev/null +++ b/azurerm/resource_arm_proximity_placement_group.go @@ -0,0 +1,126 @@ +package azurerm + +import ( + "fmt" + "log" + + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-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" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func resourceArmProximityPlacementGroup() *schema.Resource { + return &schema.Resource{ + Create: resourceArmProximityPlacementGroupCreateUpdate, + Read: resourceArmProximityPlacementGroupRead, + Update: resourceArmProximityPlacementGroupCreateUpdate, + Delete: resourceArmProximityPlacementGroupDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "resource_group_name": azure.SchemaResourceGroupName(), + + "location": azure.SchemaLocation(), + + "tags": tagsSchema(), + }, + } +} + +func resourceArmProximityPlacementGroupCreateUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).ppgClient + ctx := meta.(*ArmClient).StopContext + + log.Printf("[INFO] preparing arguments for AzureRM Proximity Placement Group creation.") + + name := d.Get("name").(string) + resGroup := d.Get("resource_group_name").(string) + + if requireResourcesToBeImported && d.IsNewResource() { + existing, err := client.Get(ctx, resGroup, name) + if err != nil { + if !utils.ResponseWasNotFound(existing.Response) { + return fmt.Errorf("Error checking for presence of existing Proximity Placement Group %q (Resource Group %q): %s", name, resGroup, err) + } + } + + if existing.ID != nil && *existing.ID != "" { + return tf.ImportAsExistsError("azurerm_proximity_placement_group", *existing.ID) + } + } + + location := azure.NormalizeLocation(d.Get("location").(string)) + tags := d.Get("tags").(map[string]interface{}) + + ppg := compute.ProximityPlacementGroup{ + Name: &name, + Location: &location, + Tags: expandTags(tags), + } + + resp, err := client.CreateOrUpdate(ctx, resGroup, name, ppg) + if err != nil { + return err + } + + d.SetId(*resp.ID) + + return resourceArmProximityPlacementGroupRead(d, meta) +} + +func resourceArmProximityPlacementGroupRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).ppgClient + ctx := meta.(*ArmClient).StopContext + + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + resGroup := id.ResourceGroup + name := id.Path["proximityPlacementGroups"] + + resp, err := client.Get(ctx, resGroup, name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + d.SetId("") + return nil + } + return fmt.Errorf("Error making Read request on Proximity Placement Group %q (Resource Group %q): %+v", name, resGroup, err) + } + + d.Set("name", resp.Name) + d.Set("resource_group_name", resGroup) + if location := resp.Location; location != nil { + d.Set("location", azure.NormalizeLocation(*location)) + } + + flattenAndSetTags(d, resp.Tags) + + return nil +} + +func resourceArmProximityPlacementGroupDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).ppgClient + ctx := meta.(*ArmClient).StopContext + + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + resGroup := id.ResourceGroup + name := id.Path["proximityPlacementGroup"] + + _, err = client.Delete(ctx, resGroup, name) + + return err +} diff --git a/azurerm/resource_arm_proximity_placement_group_test.go b/azurerm/resource_arm_proximity_placement_group_test.go new file mode 100644 index 000000000000..050692de1858 --- /dev/null +++ b/azurerm/resource_arm_proximity_placement_group_test.go @@ -0,0 +1,275 @@ +package azurerm + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/terraform" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/response" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func TestAccAzureRMProximityPlacementGroup_basic(t *testing.T) { + resourceName := "azurerm_proximity_placement_group.test" + ri := tf.AccRandTimeInt() + config := testAccAzureRMProximityPlacementGroup_basic(ri, testLocation()) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMProximityPlacementGroupDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMProximityPlacementGroupExists(resourceName), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMProximityPlacementGroup_requiresImport(t *testing.T) { + if !requireResourcesToBeImported { + t.Skip("Skipping since resources aren't required to be imported") + return + } + + resourceName := "azurerm_proximity_placement_group.test" + ri := tf.AccRandTimeInt() + location := testLocation() + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMProximityPlacementGroupDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMProximityPlacementGroup_basic(ri, location), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMProximityPlacementGroupExists(resourceName), + ), + }, + { + Config: testAccAzureRMProximityPlacementGroup_requiresImport(ri, location), + ExpectError: testRequiresImportError("azurerm_proximity_placement_group"), + }, + }, + }) +} + +func TestAccAzureRMProximityPlacementGroup_disappears(t *testing.T) { + resourceName := "azurerm_proximity_placement_group.test" + ri := tf.AccRandTimeInt() + config := testAccAzureRMProximityPlacementGroup_basic(ri, testLocation()) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMProximityPlacementGroupDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMProximityPlacementGroupExists(resourceName), + testCheckAzureRMProximityPlacementGroupDisappears(resourceName), + ), + ExpectNonEmptyPlan: true, + }, + }, + }) +} + +func TestAccAzureRMProximityPlacementGroup_withTags(t *testing.T) { + resourceName := "azurerm_proximity_placement_group.test" + ri := tf.AccRandTimeInt() + location := testLocation() + preConfig := testAccAzureRMProximityPlacementGroup_withTags(ri, location) + postConfig := testAccAzureRMProximityPlacementGroup_withUpdatedTags(ri, location) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMProximityPlacementGroupDestroy, + Steps: []resource.TestStep{ + { + Config: preConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMProximityPlacementGroupExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), + resource.TestCheckResourceAttr(resourceName, "tags.environment", "Production"), + resource.TestCheckResourceAttr(resourceName, "tags.cost_center", "MSFT"), + ), + }, + { + Config: postConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMProximityPlacementGroupExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(resourceName, "tags.environment", "staging"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testCheckAzureRMProximityPlacementGroupExists(resourceName string) resource.TestCheckFunc { + return func(s *terraform.State) error { + // Ensure we have enough information in state to look up in API + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return fmt.Errorf("Not found: %s", resourceName) + } + + ppgName := rs.Primary.Attributes["name"] + resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] + if !hasResourceGroup { + return fmt.Errorf("Bad: no resource group found in state for proximity placement group: %s", ppgName) + } + + client := testAccProvider.Meta().(*ArmClient).ppgClient + ctx := testAccProvider.Meta().(*ArmClient).StopContext + resp, err := client.Get(ctx, resourceGroup, ppgName) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Bad: Availability Set %q (resource group: %q) does not exist", ppgName, resourceGroup) + } + + return fmt.Errorf("Bad: Get on ppgClient: %+v", err) + } + + return nil + } +} + +func testCheckAzureRMProximityPlacementGroupDisappears(resourceName string) resource.TestCheckFunc { + return func(s *terraform.State) error { + // Ensure we have enough information in state to look up in API + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return fmt.Errorf("Not found: %s", resourceName) + } + + ppgName := rs.Primary.Attributes["name"] + resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] + if !hasResourceGroup { + return fmt.Errorf("Bad: no resource group found in state for proximity placement group: %s", ppgName) + } + + client := testAccProvider.Meta().(*ArmClient).ppgClient + ctx := testAccProvider.Meta().(*ArmClient).StopContext + resp, err := client.Delete(ctx, resourceGroup, ppgName) + if err != nil { + if !response.WasNotFound(resp.Response) { + return fmt.Errorf("Bad: Delete on ppgClient: %+v", err) + } + } + + return nil + } +} + +func testCheckAzureRMProximityPlacementGroupDestroy(s *terraform.State) error { + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_proximity_placement_group" { + continue + } + + name := rs.Primary.Attributes["name"] + resourceGroup := rs.Primary.Attributes["resource_group_name"] + + client := testAccProvider.Meta().(*ArmClient).ppgClient + ctx := testAccProvider.Meta().(*ArmClient).StopContext + resp, err := client.Get(ctx, resourceGroup, name) + + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return nil + } + return err + } + + return fmt.Errorf("Proximity placement group still exists:\n%#v", resp.ProximityPlacementGroupProperties) + } + + return nil +} + +func testAccAzureRMProximityPlacementGroup_basic(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_proximity_placement_group" "test" { + name = "acctestppg-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" +} +`, rInt, location, rInt) +} + +func testAccAzureRMProximityPlacementGroup_requiresImport(rInt int, location string) string { + template := testAccAzureRMProximityPlacementGroup_basic(rInt, location) + return fmt.Sprintf(` +%s + +resource "azurerm_proximity_placement_group" "import" { + name = "${azurerm_proximity_placement_group.test.name}" + location = "${azurerm_proximity_placement_group.test.location}" + resource_group_name = "${azurerm_proximity_placement_group.test.resource_group_name}" +} +`, template) +} + +func testAccAzureRMProximityPlacementGroup_withTags(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_proximity_placement_group" "test" { + name = "acctestppg-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + tags = { + environment = "Production" + cost_center = "MSFT" + } +} +`, rInt, location, rInt) +} + +func testAccAzureRMProximityPlacementGroup_withUpdatedTags(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_proximity_placement_group" "test" { + name = "acctestppg-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + tags = { + environment = "staging" + } +} +`, rInt, location, rInt) +} diff --git a/azurerm/resource_arm_virtual_machine.go b/azurerm/resource_arm_virtual_machine.go index d6796d26f151..6583440d8bc4 100644 --- a/azurerm/resource_arm_virtual_machine.go +++ b/azurerm/resource_arm_virtual_machine.go @@ -84,6 +84,9 @@ func resourceArmVirtualMachine() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, + StateFunc: func(id interface{}) string { + return strings.ToLower(id.(string)) + }, }, "identity": { @@ -667,8 +670,8 @@ func resourceArmVirtualMachineCreateUpdate(d *schema.ResourceData, meta interfac Name: &name, Location: &location, VirtualMachineProperties: &properties, - Tags: expandedTags, - Zones: zones, + Tags: expandedTags, + Zones: zones, } if _, ok := d.GetOk("identity"); ok { @@ -765,12 +768,15 @@ func resourceArmVirtualMachineRead(d *schema.ResourceData, meta interface{}) err if props := resp.VirtualMachineProperties; props != nil { if availabilitySet := props.AvailabilitySet; availabilitySet != nil { - // TODO: why is this being lower-cased? + // Lowercase due to incorrect capitalisation of resource group name in + // availability set ID in response from get VM API request d.Set("availability_set_id", strings.ToLower(*availabilitySet.ID)) } if proximityPlacementGroup := props.ProximityPlacementGroup; proximityPlacementGroup != nil { - d.Set("proximity_placement_group_id", *proximityPlacementGroup.ID) + // Lowercase due to incorrect capitalisation of resource group name in + // proximity placement group ID in response from get VM API request + d.Set("proximity_placement_group_id", strings.ToLower(*proximityPlacementGroup.ID)) } if profile := props.HardwareProfile; profile != nil { diff --git a/azurerm/resource_arm_virtual_machine_scale_set.go b/azurerm/resource_arm_virtual_machine_scale_set.go index 92e8c20b1219..f20f75ce7673 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set.go +++ b/azurerm/resource_arm_virtual_machine_scale_set.go @@ -745,6 +745,15 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource { Set: resourceArmVirtualMachineScaleSetExtensionHash, }, + "proximity_placement_group_id": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + StateFunc: func(id interface{}) string { + return strings.ToLower(id.(string)) + }, + }, + "tags": tagsSchema(), }, @@ -855,13 +864,22 @@ func resourceArmVirtualMachineScaleSetCreateUpdate(d *schema.ResourceData, meta } } + if v, ok := d.GetOk("proximity_placement_group_id"); ok { + proximityPlacementGroup := v.(string) + ppg := compute.SubResource{ + ID: &proximityPlacementGroup, + } + + scaleSetProps.ProximityPlacementGroup = &ppg + } + properties := compute.VirtualMachineScaleSet{ - Name: &name, - Location: &location, - Tags: expandTags(tags), - Sku: sku, + Name: &name, + Location: &location, + Tags: expandTags(tags), + Sku: sku, VirtualMachineScaleSetProperties: &scaleSetProps, - Zones: zones, + Zones: zones, } if _, ok := d.GetOk("identity"); ok { @@ -950,6 +968,12 @@ func resourceArmVirtualMachineScaleSetRead(d *schema.ResourceData, meta interfac return fmt.Errorf("[DEBUG] Error setting Virtual Machine Scale Set Rolling Upgrade Policy error: %#v", err) } } + + if proximityPlacementGroup := properties.ProximityPlacementGroup; proximityPlacementGroup != nil { + // Lowercase due to incorrect capitalisation of resource group name in + // proximity placement group ID in response from get VM API request + d.Set("proximity_placement_group_id", strings.ToLower(*proximityPlacementGroup.ID)) + } } d.Set("overprovision", properties.Overprovision) d.Set("single_placement_group", properties.SinglePlacementGroup) diff --git a/azurerm/resource_arm_virtual_network.go b/azurerm/resource_arm_virtual_network.go index f667d1d917e9..6cbe9f2bdf8e 100644 --- a/azurerm/resource_arm_virtual_network.go +++ b/azurerm/resource_arm_virtual_network.go @@ -151,7 +151,7 @@ func resourceArmVirtualNetworkCreateUpdate(d *schema.ResourceData, meta interfac Name: &name, Location: &location, VirtualNetworkPropertiesFormat: vnetProperties, - Tags: expandTags(tags), + Tags: expandTags(tags), } networkSecurityGroupNames := make([]string, 0) diff --git a/website/docs/d/proximity_placement_group.html.markdown b/website/docs/d/proximity_placement_group.html.markdown new file mode 100644 index 000000000000..372a0d07f115 --- /dev/null +++ b/website/docs/d/proximity_placement_group.html.markdown @@ -0,0 +1,38 @@ +--- +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_proximity_placement_group" +sidebar_current: "docs-azurerm-datasource-proximity-placement-group" +description: |- + Gets information about an existing Proximity Placement Group. +--- + +# Data Source: azurerm_proximity_placement_group + +Use this data source to access information about an existing Proximity Placement Group. + +## Example Usage + +```hcl +data "azurerm_proximity_placement_group" "example" { + name = "tf-appsecuritygroup" + resource_group_name = "my-resource-group" +} + +output "proximity_placement_group_id" { + value = "${data.azurerm_proximity_placement_group.example.id}" +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - The name of the Proximity Placement Group. + +* `resource_group_name` - The name of the resource group in which the Proximity Placement Group exists. + +## Attributes Reference + +The following attributes are exported: + +* `id` - The ID of the Proximity Placement Group. diff --git a/website/docs/r/availability_set.html.markdown b/website/docs/r/availability_set.html.markdown index 8aad2e8e1c3e..1a5ee4f4a9e8 100644 --- a/website/docs/r/availability_set.html.markdown +++ b/website/docs/r/availability_set.html.markdown @@ -48,6 +48,8 @@ The following arguments are supported: ~> **NOTE:** The number of Fault Domains varies depending on which Azure Region you're using - [a list can be found here](https://github.com/MicrosoftDocs/azure-docs/blob/master/includes/managed-disks-common-fault-domain-region-list.md). +* `proximity_placement_group_id` - (Optional) The ID of the Proximity Placement Group to which this Virtual Machine should be assigned. + * `managed` - (Optional) Specifies whether the availability set is managed or not. Possible values are `true` (to specify aligned) or `false` (to specify classic). Default is `false`. * `tags` - (Optional) A mapping of tags to assign to the resource. diff --git a/website/docs/r/proximity_placement_group.html.markdown b/website/docs/r/proximity_placement_group.html.markdown new file mode 100644 index 000000000000..53b0a15ecb7d --- /dev/null +++ b/website/docs/r/proximity_placement_group.html.markdown @@ -0,0 +1,65 @@ +--- +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_proximity_placement_group" +sidebar_current: "docs-azurerm-resource-compute-proximity-placement-group" +description: |- + Manages a proximity placement group for virtual machines, virtual machine scale sets and availability sets. + +--- + +# azurerm_proximity_placement_group + +Manages a proximity placement group for virtual machines, virtual machine scale sets and availability sets. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "resourceGroup1" + location = "West US" +} + +resource "azurerm_proximity_placement_group" "example" { + name = "exampleProximityPlacementGroup" + location = "${azurerm_resource_group.example.location}" + resource_group_name = "${azurerm_resource_group.example.name}" + + tags = { + environment = "Production" + } +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name of the availability set. Changing this forces a new resource to be created. + +* `resource_group_name` - (Required) The name of the resource group in which to create the availability set. Changing this forces a new resource to be created. + +* `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. + +* `tags` - (Optional) A mapping of tags to assign to the resource. + +## Attributes Reference + +The following attributes are exported: + +* `id` - The Proximity Placement Group ID. + +* `name` - The name of the Proximity Placement Group. + +* `location` - The location of the Proximity Placement Group. + +* `resource_group_name` - The name of the resource group in which the Proximity Placement Group exists. + +* `tags` - The tags attached to the Proximity Placement Group. + +## Import + +Proximity Placement Groups can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_proximity_placement_group.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example-rg/providers/Microsoft.Compute/proximityPlacementGroups/example-ppg +``` diff --git a/website/docs/r/virtual_machine_scale_set.html.markdown b/website/docs/r/virtual_machine_scale_set.html.markdown index 1001258e62bf..d588d860ab39 100644 --- a/website/docs/r/virtual_machine_scale_set.html.markdown +++ b/website/docs/r/virtual_machine_scale_set.html.markdown @@ -275,6 +275,8 @@ The following arguments are supported: * `os_profile_linux_config` - (Required, when a linux machine) A Linux config block as documented below. +* `proximity_placement_group_id` - (Optional) The ID of the Proximity Placement Group to which this Virtual Machine should be assigned. + * `sku` - (Required) A sku block as documented below. * `storage_profile_os_disk` - (Required) A storage profile os disk block as documented below From 3c6162df764936e346cb935e0ecf4f97b7fb1669 Mon Sep 17 00:00:00 2001 From: Toby Pettit Date: Sun, 11 Aug 2019 10:08:48 +0100 Subject: [PATCH 03/14] incorporate changes from review --- azurerm/data_source_proximity_placement_group.go | 6 +++--- azurerm/resource_arm_availability_set.go | 14 +++++++------- .../resource_arm_proximity_placement_group_test.go | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/azurerm/data_source_proximity_placement_group.go b/azurerm/data_source_proximity_placement_group.go index b6473ac23db2..15837f3df3ef 100644 --- a/azurerm/data_source_proximity_placement_group.go +++ b/azurerm/data_source_proximity_placement_group.go @@ -13,13 +13,13 @@ func dataSourceArmProximityPlacementGroup() *schema.Resource { return &schema.Resource{ Read: dataSourceArmProximityPlacementGroupRead, Schema: map[string]*schema.Schema{ - "resource_group_name": azure.SchemaResourceGroupNameForDataSource(), - "name": { Type: schema.TypeString, Required: true, ValidateFunc: validation.NoZeroValues, }, + + "resource_group_name": azure.SchemaResourceGroupNameForDataSource(), }, } } @@ -28,8 +28,8 @@ func dataSourceArmProximityPlacementGroupRead(d *schema.ResourceData, meta inter client := meta.(*ArmClient).ppgClient ctx := meta.(*ArmClient).StopContext - resGroup := d.Get("resource_group_name").(string) name := d.Get("name").(string) + resGroup := d.Get("resource_group_name").(string) resp, err := client.Get(ctx, resGroup, name) if err != nil { diff --git a/azurerm/resource_arm_availability_set.go b/azurerm/resource_arm_availability_set.go index 34374b925691..a4917159667b 100644 --- a/azurerm/resource_arm_availability_set.go +++ b/azurerm/resource_arm_availability_set.go @@ -104,6 +104,13 @@ func resourceArmAvailabilitySetCreateUpdate(d *schema.ResourceData, meta interfa PlatformUpdateDomainCount: utils.Int32(int32(updateDomainCount)), } + availSet := compute.AvailabilitySet{ + Name: &name, + Location: &location, + AvailabilitySetProperties: &properties, + Tags: expandTags(tags), + } + if v, ok := d.GetOk("proximity_placement_group_id"); ok { proximityPlacementGroup := v.(string) ppg := compute.SubResource{ @@ -113,13 +120,6 @@ func resourceArmAvailabilitySetCreateUpdate(d *schema.ResourceData, meta interfa properties.ProximityPlacementGroup = &ppg } - availSet := compute.AvailabilitySet{ - Name: &name, - Location: &location, - AvailabilitySetProperties: &properties, - Tags: expandTags(tags), - } - if managed { n := "Aligned" availSet.Sku = &compute.Sku{ diff --git a/azurerm/resource_arm_proximity_placement_group_test.go b/azurerm/resource_arm_proximity_placement_group_test.go index 050692de1858..29eced21a871 100644 --- a/azurerm/resource_arm_proximity_placement_group_test.go +++ b/azurerm/resource_arm_proximity_placement_group_test.go @@ -215,7 +215,7 @@ resource "azurerm_resource_group" "test" { } resource "azurerm_proximity_placement_group" "test" { - name = "acctestppg-%d" + name = "acctestPPG-%d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } @@ -243,7 +243,7 @@ resource "azurerm_resource_group" "test" { } resource "azurerm_proximity_placement_group" "test" { - name = "acctestppg-%d" + name = "acctestPPG-%d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" @@ -263,7 +263,7 @@ resource "azurerm_resource_group" "test" { } resource "azurerm_proximity_placement_group" "test" { - name = "acctestppg-%d" + name = "acctestPPG-%d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" From 25a6c8763642d42929ce7dc66f6a1592a714c3cf Mon Sep 17 00:00:00 2001 From: Toby Pettit Date: Sun, 11 Aug 2019 10:18:26 +0100 Subject: [PATCH 04/14] reworked availability set config --- azurerm/resource_arm_availability_set.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/azurerm/resource_arm_availability_set.go b/azurerm/resource_arm_availability_set.go index a4917159667b..f965cfcb8581 100644 --- a/azurerm/resource_arm_availability_set.go +++ b/azurerm/resource_arm_availability_set.go @@ -99,15 +99,13 @@ func resourceArmAvailabilitySetCreateUpdate(d *schema.ResourceData, meta interfa managed := d.Get("managed").(bool) tags := d.Get("tags").(map[string]interface{}) - properties := compute.AvailabilitySetProperties{ - PlatformFaultDomainCount: utils.Int32(int32(faultDomainCount)), - PlatformUpdateDomainCount: utils.Int32(int32(updateDomainCount)), - } - availSet := compute.AvailabilitySet{ Name: &name, Location: &location, - AvailabilitySetProperties: &properties, + AvailabilitySetProperties: &compute.AvailabilitySetProperties{ + PlatformFaultDomainCount: utils.Int32(int32(faultDomainCount)), + PlatformUpdateDomainCount: utils.Int32(int32(updateDomainCount)), + }, Tags: expandTags(tags), } @@ -117,7 +115,7 @@ func resourceArmAvailabilitySetCreateUpdate(d *schema.ResourceData, meta interfa ID: &proximityPlacementGroup, } - properties.ProximityPlacementGroup = &ppg + availSet.AvailabilitySetProperties.ProximityPlacementGroup = &ppg } if managed { From 332c8dc1314be8b58473e0b44cf908ca1bd0e63f Mon Sep 17 00:00:00 2001 From: Toby Pettit Date: Sun, 11 Aug 2019 10:26:44 +0100 Subject: [PATCH 05/14] corrected alphabetical ordering --- azurerm/provider.go | 356 ++++++++++++++++++++++---------------------- 1 file changed, 178 insertions(+), 178 deletions(-) diff --git a/azurerm/provider.go b/azurerm/provider.go index 4ee31c19adff..5381c42af620 100644 --- a/azurerm/provider.go +++ b/azurerm/provider.go @@ -122,183 +122,183 @@ func Provider() terraform.ResourceProvider { } resources := map[string]*schema.Resource{ - "azurerm_analysis_services_server": resourceArmAnalysisServicesServer(), - "azurerm_api_management": resourceArmApiManagementService(), - "azurerm_api_management_api": resourceArmApiManagementApi(), - "azurerm_api_management_api_operation": resourceArmApiManagementApiOperation(), - "azurerm_api_management_api_operation_policy": resourceArmApiManagementApiOperationPolicy(), - "azurerm_api_management_api_policy": resourceArmApiManagementApiPolicy(), - "azurerm_api_management_api_schema": resourceArmApiManagementApiSchema(), - "azurerm_api_management_api_version_set": resourceArmApiManagementApiVersionSet(), - "azurerm_api_management_authorization_server": resourceArmApiManagementAuthorizationServer(), - "azurerm_api_management_backend": resourceArmApiManagementBackend(), - "azurerm_api_management_certificate": resourceArmApiManagementCertificate(), - "azurerm_api_management_group": resourceArmApiManagementGroup(), - "azurerm_api_management_group_user": resourceArmApiManagementGroupUser(), - "azurerm_api_management_logger": resourceArmApiManagementLogger(), - "azurerm_api_management_openid_connect_provider": resourceArmApiManagementOpenIDConnectProvider(), - "azurerm_api_management_product": resourceArmApiManagementProduct(), - "azurerm_api_management_product_api": resourceArmApiManagementProductApi(), - "azurerm_api_management_product_group": resourceArmApiManagementProductGroup(), - "azurerm_api_management_product_policy": resourceArmApiManagementProductPolicy(), - "azurerm_api_management_property": resourceArmApiManagementProperty(), - "azurerm_api_management_subscription": resourceArmApiManagementSubscription(), - "azurerm_api_management_user": resourceArmApiManagementUser(), - "azurerm_app_service_active_slot": resourceArmAppServiceActiveSlot(), - "azurerm_app_service_custom_hostname_binding": resourceArmAppServiceCustomHostnameBinding(), - "azurerm_app_service_plan": resourceArmAppServicePlan(), - "azurerm_app_service_slot": resourceArmAppServiceSlot(), - "azurerm_app_service": resourceArmAppService(), - "azurerm_application_gateway": resourceArmApplicationGateway(), - "azurerm_application_insights_api_key": resourceArmApplicationInsightsAPIKey(), - "azurerm_application_insights": resourceArmApplicationInsights(), - "azurerm_application_insights_web_test": resourceArmApplicationInsightsWebTests(), - "azurerm_application_security_group": resourceArmApplicationSecurityGroup(), - "azurerm_automation_account": resourceArmAutomationAccount(), - "azurerm_automation_credential": resourceArmAutomationCredential(), - "azurerm_automation_dsc_configuration": resourceArmAutomationDscConfiguration(), - "azurerm_automation_dsc_nodeconfiguration": resourceArmAutomationDscNodeConfiguration(), - "azurerm_automation_module": resourceArmAutomationModule(), - "azurerm_automation_runbook": resourceArmAutomationRunbook(), - "azurerm_automation_schedule": resourceArmAutomationSchedule(), - "azurerm_automation_variable_bool": resourceArmAutomationVariableBool(), - "azurerm_automation_variable_datetime": resourceArmAutomationVariableDateTime(), - "azurerm_automation_variable_int": resourceArmAutomationVariableInt(), - "azurerm_automation_variable_string": resourceArmAutomationVariableString(), - "azurerm_autoscale_setting": resourceArmAutoScaleSetting(), - "azurerm_availability_set": resourceArmAvailabilitySet(), - "azurerm_azuread_application": resourceArmActiveDirectoryApplication(), - "azurerm_azuread_service_principal_password": resourceArmActiveDirectoryServicePrincipalPassword(), - "azurerm_azuread_service_principal": resourceArmActiveDirectoryServicePrincipal(), - "azurerm_batch_account": resourceArmBatchAccount(), - "azurerm_batch_application": resourceArmBatchApplication(), - "azurerm_batch_certificate": resourceArmBatchCertificate(), - "azurerm_batch_pool": resourceArmBatchPool(), - "azurerm_cdn_endpoint": resourceArmCdnEndpoint(), - "azurerm_cdn_profile": resourceArmCdnProfile(), - "azurerm_cognitive_account": resourceArmCognitiveAccount(), - "azurerm_connection_monitor": resourceArmConnectionMonitor(), - "azurerm_container_group": resourceArmContainerGroup(), - "azurerm_container_registry": resourceArmContainerRegistry(), - "azurerm_container_service": resourceArmContainerService(), - "azurerm_cosmosdb_account": resourceArmCosmosDbAccount(), - "azurerm_cosmosdb_cassandra_keyspace": resourceArmCosmosDbCassandraKeyspace(), - "azurerm_cosmosdb_mongo_collection": resourceArmCosmosDbMongoCollection(), - "azurerm_cosmosdb_mongo_database": resourceArmCosmosDbMongoDatabase(), - "azurerm_cosmosdb_sql_database": resourceArmCosmosDbSQLDatabase(), - "azurerm_cosmosdb_table": resourceArmCosmosDbTable(), - "azurerm_data_factory": resourceArmDataFactory(), - "azurerm_data_factory_dataset_mysql": resourceArmDataFactoryDatasetMySQL(), - "azurerm_data_factory_dataset_postgresql": resourceArmDataFactoryDatasetPostgreSQL(), - "azurerm_data_factory_dataset_sql_server_table": resourceArmDataFactoryDatasetSQLServerTable(), - "azurerm_data_factory_linked_service_data_lake_storage_gen2": resourceArmDataFactoryLinkedServiceDataLakeStorageGen2(), - "azurerm_data_factory_linked_service_mysql": resourceArmDataFactoryLinkedServiceMySQL(), - "azurerm_data_factory_linked_service_postgresql": resourceArmDataFactoryLinkedServicePostgreSQL(), - "azurerm_data_factory_linked_service_sql_server": resourceArmDataFactoryLinkedServiceSQLServer(), - "azurerm_data_factory_pipeline": resourceArmDataFactoryPipeline(), - "azurerm_data_lake_analytics_account": resourceArmDataLakeAnalyticsAccount(), - "azurerm_data_lake_analytics_firewall_rule": resourceArmDataLakeAnalyticsFirewallRule(), - "azurerm_data_lake_store_file": resourceArmDataLakeStoreFile(), - "azurerm_data_lake_store_firewall_rule": resourceArmDataLakeStoreFirewallRule(), - "azurerm_data_lake_store": resourceArmDataLakeStore(), - "azurerm_databricks_workspace": resourceArmDatabricksWorkspace(), - "azurerm_ddos_protection_plan": resourceArmDDoSProtectionPlan(), - "azurerm_dev_test_lab": resourceArmDevTestLab(), - "azurerm_dev_test_schedule": resourceArmDevTestLabSchedules(), - "azurerm_dev_test_linux_virtual_machine": resourceArmDevTestLinuxVirtualMachine(), - "azurerm_dev_test_policy": resourceArmDevTestPolicy(), - "azurerm_dev_test_virtual_network": resourceArmDevTestVirtualNetwork(), - "azurerm_dev_test_windows_virtual_machine": resourceArmDevTestWindowsVirtualMachine(), - "azurerm_devspace_controller": resourceArmDevSpaceController(), - "azurerm_dns_a_record": resourceArmDnsARecord(), - "azurerm_dns_aaaa_record": resourceArmDnsAAAARecord(), - "azurerm_dns_caa_record": resourceArmDnsCaaRecord(), - "azurerm_dns_cname_record": resourceArmDnsCNameRecord(), - "azurerm_dns_mx_record": resourceArmDnsMxRecord(), - "azurerm_dns_ns_record": resourceArmDnsNsRecord(), - "azurerm_dns_ptr_record": resourceArmDnsPtrRecord(), - "azurerm_dns_srv_record": resourceArmDnsSrvRecord(), - "azurerm_dns_txt_record": resourceArmDnsTxtRecord(), - "azurerm_dns_zone": resourceArmDnsZone(), - "azurerm_eventgrid_domain": resourceArmEventGridDomain(), - "azurerm_eventgrid_event_subscription": resourceArmEventGridEventSubscription(), - "azurerm_eventgrid_topic": resourceArmEventGridTopic(), - "azurerm_eventhub_authorization_rule": resourceArmEventHubAuthorizationRule(), - "azurerm_eventhub_consumer_group": resourceArmEventHubConsumerGroup(), - "azurerm_eventhub_namespace_authorization_rule": resourceArmEventHubNamespaceAuthorizationRule(), - "azurerm_eventhub_namespace": resourceArmEventHubNamespace(), - "azurerm_eventhub": resourceArmEventHub(), - "azurerm_express_route_circuit_authorization": resourceArmExpressRouteCircuitAuthorization(), - "azurerm_express_route_circuit_peering": resourceArmExpressRouteCircuitPeering(), - "azurerm_express_route_circuit": resourceArmExpressRouteCircuit(), - "azurerm_firewall_application_rule_collection": resourceArmFirewallApplicationRuleCollection(), - "azurerm_firewall_nat_rule_collection": resourceArmFirewallNatRuleCollection(), - "azurerm_firewall_network_rule_collection": resourceArmFirewallNetworkRuleCollection(), - "azurerm_firewall": resourceArmFirewall(), - "azurerm_function_app": resourceArmFunctionApp(), - "azurerm_hdinsight_hadoop_cluster": resourceArmHDInsightHadoopCluster(), - "azurerm_hdinsight_hbase_cluster": resourceArmHDInsightHBaseCluster(), - "azurerm_hdinsight_interactive_query_cluster": resourceArmHDInsightInteractiveQueryCluster(), - "azurerm_hdinsight_kafka_cluster": resourceArmHDInsightKafkaCluster(), - "azurerm_hdinsight_ml_services_cluster": resourceArmHDInsightMLServicesCluster(), - "azurerm_hdinsight_rserver_cluster": resourceArmHDInsightRServerCluster(), - "azurerm_hdinsight_spark_cluster": resourceArmHDInsightSparkCluster(), - "azurerm_hdinsight_storm_cluster": resourceArmHDInsightStormCluster(), - "azurerm_image": resourceArmImage(), - "azurerm_iot_dps": resourceArmIotDPS(), - "azurerm_iot_dps_certificate": resourceArmIotDPSCertificate(), - "azurerm_iothub_consumer_group": resourceArmIotHubConsumerGroup(), - "azurerm_iothub": resourceArmIotHub(), - "azurerm_iothub_shared_access_policy": resourceArmIotHubSharedAccessPolicy(), - "azurerm_key_vault_access_policy": resourceArmKeyVaultAccessPolicy(), - "azurerm_key_vault_certificate": resourceArmKeyVaultCertificate(), - "azurerm_key_vault_key": resourceArmKeyVaultKey(), - "azurerm_key_vault_secret": resourceArmKeyVaultSecret(), - "azurerm_key_vault": resourceArmKeyVault(), - "azurerm_kubernetes_cluster": resourceArmKubernetesCluster(), - "azurerm_lb_backend_address_pool": resourceArmLoadBalancerBackendAddressPool(), - "azurerm_lb_nat_pool": resourceArmLoadBalancerNatPool(), - "azurerm_lb_nat_rule": resourceArmLoadBalancerNatRule(), - "azurerm_lb_probe": resourceArmLoadBalancerProbe(), - "azurerm_lb_outbound_rule": resourceArmLoadBalancerOutboundRule(), - "azurerm_lb_rule": resourceArmLoadBalancerRule(), - "azurerm_lb": resourceArmLoadBalancer(), - "azurerm_local_network_gateway": resourceArmLocalNetworkGateway(), - "azurerm_log_analytics_solution": resourceArmLogAnalyticsSolution(), - "azurerm_log_analytics_linked_service": resourceArmLogAnalyticsLinkedService(), - "azurerm_log_analytics_workspace_linked_service": resourceArmLogAnalyticsWorkspaceLinkedService(), - "azurerm_log_analytics_workspace": resourceArmLogAnalyticsWorkspace(), - "azurerm_logic_app_action_custom": resourceArmLogicAppActionCustom(), - "azurerm_logic_app_action_http": resourceArmLogicAppActionHTTP(), - "azurerm_logic_app_trigger_custom": resourceArmLogicAppTriggerCustom(), - "azurerm_logic_app_trigger_http_request": resourceArmLogicAppTriggerHttpRequest(), - "azurerm_logic_app_trigger_recurrence": resourceArmLogicAppTriggerRecurrence(), - "azurerm_logic_app_workflow": resourceArmLogicAppWorkflow(), - "azurerm_managed_disk": resourceArmManagedDisk(), - "azurerm_management_group": resourceArmManagementGroup(), - "azurerm_management_lock": resourceArmManagementLock(), - "azurerm_maps_account": resourceArmMapsAccount(), - "azurerm_mariadb_database": resourceArmMariaDbDatabase(), - "azurerm_mariadb_firewall_rule": resourceArmMariaDBFirewallRule(), - "azurerm_mariadb_server": resourceArmMariaDbServer(), - "azurerm_media_services_account": resourceArmMediaServicesAccount(), - "azurerm_metric_alertrule": resourceArmMetricAlertRule(), - "azurerm_monitor_autoscale_setting": resourceArmMonitorAutoScaleSetting(), - "azurerm_monitor_action_group": resourceArmMonitorActionGroup(), - "azurerm_monitor_activity_log_alert": resourceArmMonitorActivityLogAlert(), - "azurerm_monitor_diagnostic_setting": resourceArmMonitorDiagnosticSetting(), - "azurerm_monitor_log_profile": resourceArmMonitorLogProfile(), - "azurerm_monitor_metric_alert": resourceArmMonitorMetricAlert(), - "azurerm_monitor_metric_alertrule": resourceArmMonitorMetricAlertRule(), - "azurerm_mssql_elasticpool": resourceArmMsSqlElasticPool(), - "azurerm_mysql_configuration": resourceArmMySQLConfiguration(), - "azurerm_mysql_database": resourceArmMySqlDatabase(), - "azurerm_mysql_firewall_rule": resourceArmMySqlFirewallRule(), - "azurerm_mysql_server": resourceArmMySqlServer(), - "azurerm_mysql_virtual_network_rule": resourceArmMySqlVirtualNetworkRule(), - "azurerm_network_connection_monitor": resourceArmNetworkConnectionMonitor(), - "azurerm_network_ddos_protection_plan": resourceArmNetworkDDoSProtectionPlan(), - "azurerm_network_interface": resourceArmNetworkInterface(), + "azurerm_analysis_services_server": resourceArmAnalysisServicesServer(), + "azurerm_api_management": resourceArmApiManagementService(), + "azurerm_api_management_api": resourceArmApiManagementApi(), + "azurerm_api_management_api_operation": resourceArmApiManagementApiOperation(), + "azurerm_api_management_api_operation_policy": resourceArmApiManagementApiOperationPolicy(), + "azurerm_api_management_api_policy": resourceArmApiManagementApiPolicy(), + "azurerm_api_management_api_schema": resourceArmApiManagementApiSchema(), + "azurerm_api_management_api_version_set": resourceArmApiManagementApiVersionSet(), + "azurerm_api_management_authorization_server": resourceArmApiManagementAuthorizationServer(), + "azurerm_api_management_backend": resourceArmApiManagementBackend(), + "azurerm_api_management_certificate": resourceArmApiManagementCertificate(), + "azurerm_api_management_group": resourceArmApiManagementGroup(), + "azurerm_api_management_group_user": resourceArmApiManagementGroupUser(), + "azurerm_api_management_logger": resourceArmApiManagementLogger(), + "azurerm_api_management_openid_connect_provider": resourceArmApiManagementOpenIDConnectProvider(), + "azurerm_api_management_product": resourceArmApiManagementProduct(), + "azurerm_api_management_product_api": resourceArmApiManagementProductApi(), + "azurerm_api_management_product_group": resourceArmApiManagementProductGroup(), + "azurerm_api_management_product_policy": resourceArmApiManagementProductPolicy(), + "azurerm_api_management_property": resourceArmApiManagementProperty(), + "azurerm_api_management_subscription": resourceArmApiManagementSubscription(), + "azurerm_api_management_user": resourceArmApiManagementUser(), + "azurerm_app_service_active_slot": resourceArmAppServiceActiveSlot(), + "azurerm_app_service_custom_hostname_binding": resourceArmAppServiceCustomHostnameBinding(), + "azurerm_app_service_plan": resourceArmAppServicePlan(), + "azurerm_app_service_slot": resourceArmAppServiceSlot(), + "azurerm_app_service": resourceArmAppService(), + "azurerm_application_gateway": resourceArmApplicationGateway(), + "azurerm_application_insights_api_key": resourceArmApplicationInsightsAPIKey(), + "azurerm_application_insights": resourceArmApplicationInsights(), + "azurerm_application_insights_web_test": resourceArmApplicationInsightsWebTests(), + "azurerm_application_security_group": resourceArmApplicationSecurityGroup(), + "azurerm_automation_account": resourceArmAutomationAccount(), + "azurerm_automation_credential": resourceArmAutomationCredential(), + "azurerm_automation_dsc_configuration": resourceArmAutomationDscConfiguration(), + "azurerm_automation_dsc_nodeconfiguration": resourceArmAutomationDscNodeConfiguration(), + "azurerm_automation_module": resourceArmAutomationModule(), + "azurerm_automation_runbook": resourceArmAutomationRunbook(), + "azurerm_automation_schedule": resourceArmAutomationSchedule(), + "azurerm_automation_variable_bool": resourceArmAutomationVariableBool(), + "azurerm_automation_variable_datetime": resourceArmAutomationVariableDateTime(), + "azurerm_automation_variable_int": resourceArmAutomationVariableInt(), + "azurerm_automation_variable_string": resourceArmAutomationVariableString(), + "azurerm_autoscale_setting": resourceArmAutoScaleSetting(), + "azurerm_availability_set": resourceArmAvailabilitySet(), + "azurerm_azuread_application": resourceArmActiveDirectoryApplication(), + "azurerm_azuread_service_principal_password": resourceArmActiveDirectoryServicePrincipalPassword(), + "azurerm_azuread_service_principal": resourceArmActiveDirectoryServicePrincipal(), + "azurerm_batch_account": resourceArmBatchAccount(), + "azurerm_batch_application": resourceArmBatchApplication(), + "azurerm_batch_certificate": resourceArmBatchCertificate(), + "azurerm_batch_pool": resourceArmBatchPool(), + "azurerm_cdn_endpoint": resourceArmCdnEndpoint(), + "azurerm_cdn_profile": resourceArmCdnProfile(), + "azurerm_cognitive_account": resourceArmCognitiveAccount(), + "azurerm_connection_monitor": resourceArmConnectionMonitor(), + "azurerm_container_group": resourceArmContainerGroup(), + "azurerm_container_registry": resourceArmContainerRegistry(), + "azurerm_container_service": resourceArmContainerService(), + "azurerm_cosmosdb_account": resourceArmCosmosDbAccount(), + "azurerm_cosmosdb_cassandra_keyspace": resourceArmCosmosDbCassandraKeyspace(), + "azurerm_cosmosdb_mongo_collection": resourceArmCosmosDbMongoCollection(), + "azurerm_cosmosdb_mongo_database": resourceArmCosmosDbMongoDatabase(), + "azurerm_cosmosdb_sql_database": resourceArmCosmosDbSQLDatabase(), + "azurerm_cosmosdb_table": resourceArmCosmosDbTable(), + "azurerm_data_factory": resourceArmDataFactory(), + "azurerm_data_factory_dataset_mysql": resourceArmDataFactoryDatasetMySQL(), + "azurerm_data_factory_dataset_postgresql": resourceArmDataFactoryDatasetPostgreSQL(), + "azurerm_data_factory_dataset_sql_server_table": resourceArmDataFactoryDatasetSQLServerTable(), + "azurerm_data_factory_linked_service_data_lake_storage_gen2": resourceArmDataFactoryLinkedServiceDataLakeStorageGen2(), + "azurerm_data_factory_linked_service_mysql": resourceArmDataFactoryLinkedServiceMySQL(), + "azurerm_data_factory_linked_service_postgresql": resourceArmDataFactoryLinkedServicePostgreSQL(), + "azurerm_data_factory_linked_service_sql_server": resourceArmDataFactoryLinkedServiceSQLServer(), + "azurerm_data_factory_pipeline": resourceArmDataFactoryPipeline(), + "azurerm_data_lake_analytics_account": resourceArmDataLakeAnalyticsAccount(), + "azurerm_data_lake_analytics_firewall_rule": resourceArmDataLakeAnalyticsFirewallRule(), + "azurerm_data_lake_store_file": resourceArmDataLakeStoreFile(), + "azurerm_data_lake_store_firewall_rule": resourceArmDataLakeStoreFirewallRule(), + "azurerm_data_lake_store": resourceArmDataLakeStore(), + "azurerm_databricks_workspace": resourceArmDatabricksWorkspace(), + "azurerm_ddos_protection_plan": resourceArmDDoSProtectionPlan(), + "azurerm_dev_test_lab": resourceArmDevTestLab(), + "azurerm_dev_test_schedule": resourceArmDevTestLabSchedules(), + "azurerm_dev_test_linux_virtual_machine": resourceArmDevTestLinuxVirtualMachine(), + "azurerm_dev_test_policy": resourceArmDevTestPolicy(), + "azurerm_dev_test_virtual_network": resourceArmDevTestVirtualNetwork(), + "azurerm_dev_test_windows_virtual_machine": resourceArmDevTestWindowsVirtualMachine(), + "azurerm_devspace_controller": resourceArmDevSpaceController(), + "azurerm_dns_a_record": resourceArmDnsARecord(), + "azurerm_dns_aaaa_record": resourceArmDnsAAAARecord(), + "azurerm_dns_caa_record": resourceArmDnsCaaRecord(), + "azurerm_dns_cname_record": resourceArmDnsCNameRecord(), + "azurerm_dns_mx_record": resourceArmDnsMxRecord(), + "azurerm_dns_ns_record": resourceArmDnsNsRecord(), + "azurerm_dns_ptr_record": resourceArmDnsPtrRecord(), + "azurerm_dns_srv_record": resourceArmDnsSrvRecord(), + "azurerm_dns_txt_record": resourceArmDnsTxtRecord(), + "azurerm_dns_zone": resourceArmDnsZone(), + "azurerm_eventgrid_domain": resourceArmEventGridDomain(), + "azurerm_eventgrid_event_subscription": resourceArmEventGridEventSubscription(), + "azurerm_eventgrid_topic": resourceArmEventGridTopic(), + "azurerm_eventhub_authorization_rule": resourceArmEventHubAuthorizationRule(), + "azurerm_eventhub_consumer_group": resourceArmEventHubConsumerGroup(), + "azurerm_eventhub_namespace_authorization_rule": resourceArmEventHubNamespaceAuthorizationRule(), + "azurerm_eventhub_namespace": resourceArmEventHubNamespace(), + "azurerm_eventhub": resourceArmEventHub(), + "azurerm_express_route_circuit_authorization": resourceArmExpressRouteCircuitAuthorization(), + "azurerm_express_route_circuit_peering": resourceArmExpressRouteCircuitPeering(), + "azurerm_express_route_circuit": resourceArmExpressRouteCircuit(), + "azurerm_firewall_application_rule_collection": resourceArmFirewallApplicationRuleCollection(), + "azurerm_firewall_nat_rule_collection": resourceArmFirewallNatRuleCollection(), + "azurerm_firewall_network_rule_collection": resourceArmFirewallNetworkRuleCollection(), + "azurerm_firewall": resourceArmFirewall(), + "azurerm_function_app": resourceArmFunctionApp(), + "azurerm_hdinsight_hadoop_cluster": resourceArmHDInsightHadoopCluster(), + "azurerm_hdinsight_hbase_cluster": resourceArmHDInsightHBaseCluster(), + "azurerm_hdinsight_interactive_query_cluster": resourceArmHDInsightInteractiveQueryCluster(), + "azurerm_hdinsight_kafka_cluster": resourceArmHDInsightKafkaCluster(), + "azurerm_hdinsight_ml_services_cluster": resourceArmHDInsightMLServicesCluster(), + "azurerm_hdinsight_rserver_cluster": resourceArmHDInsightRServerCluster(), + "azurerm_hdinsight_spark_cluster": resourceArmHDInsightSparkCluster(), + "azurerm_hdinsight_storm_cluster": resourceArmHDInsightStormCluster(), + "azurerm_image": resourceArmImage(), + "azurerm_iot_dps": resourceArmIotDPS(), + "azurerm_iot_dps_certificate": resourceArmIotDPSCertificate(), + "azurerm_iothub_consumer_group": resourceArmIotHubConsumerGroup(), + "azurerm_iothub": resourceArmIotHub(), + "azurerm_iothub_shared_access_policy": resourceArmIotHubSharedAccessPolicy(), + "azurerm_key_vault_access_policy": resourceArmKeyVaultAccessPolicy(), + "azurerm_key_vault_certificate": resourceArmKeyVaultCertificate(), + "azurerm_key_vault_key": resourceArmKeyVaultKey(), + "azurerm_key_vault_secret": resourceArmKeyVaultSecret(), + "azurerm_key_vault": resourceArmKeyVault(), + "azurerm_kubernetes_cluster": resourceArmKubernetesCluster(), + "azurerm_lb_backend_address_pool": resourceArmLoadBalancerBackendAddressPool(), + "azurerm_lb_nat_pool": resourceArmLoadBalancerNatPool(), + "azurerm_lb_nat_rule": resourceArmLoadBalancerNatRule(), + "azurerm_lb_probe": resourceArmLoadBalancerProbe(), + "azurerm_lb_outbound_rule": resourceArmLoadBalancerOutboundRule(), + "azurerm_lb_rule": resourceArmLoadBalancerRule(), + "azurerm_lb": resourceArmLoadBalancer(), + "azurerm_local_network_gateway": resourceArmLocalNetworkGateway(), + "azurerm_log_analytics_solution": resourceArmLogAnalyticsSolution(), + "azurerm_log_analytics_linked_service": resourceArmLogAnalyticsLinkedService(), + "azurerm_log_analytics_workspace_linked_service": resourceArmLogAnalyticsWorkspaceLinkedService(), + "azurerm_log_analytics_workspace": resourceArmLogAnalyticsWorkspace(), + "azurerm_logic_app_action_custom": resourceArmLogicAppActionCustom(), + "azurerm_logic_app_action_http": resourceArmLogicAppActionHTTP(), + "azurerm_logic_app_trigger_custom": resourceArmLogicAppTriggerCustom(), + "azurerm_logic_app_trigger_http_request": resourceArmLogicAppTriggerHttpRequest(), + "azurerm_logic_app_trigger_recurrence": resourceArmLogicAppTriggerRecurrence(), + "azurerm_logic_app_workflow": resourceArmLogicAppWorkflow(), + "azurerm_managed_disk": resourceArmManagedDisk(), + "azurerm_management_group": resourceArmManagementGroup(), + "azurerm_management_lock": resourceArmManagementLock(), + "azurerm_maps_account": resourceArmMapsAccount(), + "azurerm_mariadb_database": resourceArmMariaDbDatabase(), + "azurerm_mariadb_firewall_rule": resourceArmMariaDBFirewallRule(), + "azurerm_mariadb_server": resourceArmMariaDbServer(), + "azurerm_media_services_account": resourceArmMediaServicesAccount(), + "azurerm_metric_alertrule": resourceArmMetricAlertRule(), + "azurerm_monitor_autoscale_setting": resourceArmMonitorAutoScaleSetting(), + "azurerm_monitor_action_group": resourceArmMonitorActionGroup(), + "azurerm_monitor_activity_log_alert": resourceArmMonitorActivityLogAlert(), + "azurerm_monitor_diagnostic_setting": resourceArmMonitorDiagnosticSetting(), + "azurerm_monitor_log_profile": resourceArmMonitorLogProfile(), + "azurerm_monitor_metric_alert": resourceArmMonitorMetricAlert(), + "azurerm_monitor_metric_alertrule": resourceArmMonitorMetricAlertRule(), + "azurerm_mssql_elasticpool": resourceArmMsSqlElasticPool(), + "azurerm_mysql_configuration": resourceArmMySQLConfiguration(), + "azurerm_mysql_database": resourceArmMySqlDatabase(), + "azurerm_mysql_firewall_rule": resourceArmMySqlFirewallRule(), + "azurerm_mysql_server": resourceArmMySqlServer(), + "azurerm_mysql_virtual_network_rule": resourceArmMySqlVirtualNetworkRule(), + "azurerm_network_connection_monitor": resourceArmNetworkConnectionMonitor(), + "azurerm_network_ddos_protection_plan": resourceArmNetworkDDoSProtectionPlan(), + "azurerm_network_interface": resourceArmNetworkInterface(), "azurerm_network_interface_application_gateway_backend_address_pool_association": resourceArmNetworkInterfaceApplicationGatewayBackendAddressPoolAssociation(), "azurerm_network_interface_application_security_group_association": resourceArmNetworkInterfaceApplicationSecurityGroupAssociation(), "azurerm_network_interface_backend_address_pool_association": resourceArmNetworkInterfaceBackendAddressPoolAssociation(), @@ -322,8 +322,8 @@ func Provider() terraform.ResourceProvider { "azurerm_postgresql_virtual_network_rule": resourceArmPostgreSQLVirtualNetworkRule(), "azurerm_private_dns_zone": resourceArmPrivateDnsZone(), "azurerm_private_dns_a_record": resourceArmPrivateDnsARecord(), - "azurerm_proximity_placement_group": resourceArmProximityPlacementGroup(), "azurerm_private_dns_cname_record": resourceArmPrivateDnsCNameRecord(), + "azurerm_proximity_placement_group": resourceArmProximityPlacementGroup(), "azurerm_public_ip": resourceArmPublicIp(), "azurerm_public_ip_prefix": resourceArmPublicIpPrefix(), "azurerm_recovery_services_protected_vm": resourceArmRecoveryServicesProtectedVm(), From 83ccac53af9d1e037030f6db7e08e83c165cf93c Mon Sep 17 00:00:00 2001 From: Toby Pettit Date: Sun, 11 Aug 2019 10:36:03 +0100 Subject: [PATCH 06/14] go fmt files updated for ppg --- azurerm/resource_arm_availability_set.go | 4 ++-- azurerm/resource_arm_virtual_machine.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/azurerm/resource_arm_availability_set.go b/azurerm/resource_arm_availability_set.go index f965cfcb8581..f4fe66f29e81 100644 --- a/azurerm/resource_arm_availability_set.go +++ b/azurerm/resource_arm_availability_set.go @@ -100,8 +100,8 @@ func resourceArmAvailabilitySetCreateUpdate(d *schema.ResourceData, meta interfa tags := d.Get("tags").(map[string]interface{}) availSet := compute.AvailabilitySet{ - Name: &name, - Location: &location, + Name: &name, + Location: &location, AvailabilitySetProperties: &compute.AvailabilitySetProperties{ PlatformFaultDomainCount: utils.Int32(int32(faultDomainCount)), PlatformUpdateDomainCount: utils.Int32(int32(updateDomainCount)), diff --git a/azurerm/resource_arm_virtual_machine.go b/azurerm/resource_arm_virtual_machine.go index 6583440d8bc4..448178690384 100644 --- a/azurerm/resource_arm_virtual_machine.go +++ b/azurerm/resource_arm_virtual_machine.go @@ -670,8 +670,8 @@ func resourceArmVirtualMachineCreateUpdate(d *schema.ResourceData, meta interfac Name: &name, Location: &location, VirtualMachineProperties: &properties, - Tags: expandedTags, - Zones: zones, + Tags: expandedTags, + Zones: zones, } if _, ok := d.GetOk("identity"); ok { From 6a55d353e17d137a1f0b17223b4d286f7947d362 Mon Sep 17 00:00:00 2001 From: Toby Pettit Date: Sun, 11 Aug 2019 10:39:19 +0100 Subject: [PATCH 07/14] go fmt more files --- azurerm/provider.go | 354 +++++++++--------- .../resource_arm_virtual_machine_scale_set.go | 10 +- azurerm/resource_arm_virtual_network.go | 2 +- 3 files changed, 183 insertions(+), 183 deletions(-) diff --git a/azurerm/provider.go b/azurerm/provider.go index 5381c42af620..8c47cf9bf246 100644 --- a/azurerm/provider.go +++ b/azurerm/provider.go @@ -122,183 +122,183 @@ func Provider() terraform.ResourceProvider { } resources := map[string]*schema.Resource{ - "azurerm_analysis_services_server": resourceArmAnalysisServicesServer(), - "azurerm_api_management": resourceArmApiManagementService(), - "azurerm_api_management_api": resourceArmApiManagementApi(), - "azurerm_api_management_api_operation": resourceArmApiManagementApiOperation(), - "azurerm_api_management_api_operation_policy": resourceArmApiManagementApiOperationPolicy(), - "azurerm_api_management_api_policy": resourceArmApiManagementApiPolicy(), - "azurerm_api_management_api_schema": resourceArmApiManagementApiSchema(), - "azurerm_api_management_api_version_set": resourceArmApiManagementApiVersionSet(), - "azurerm_api_management_authorization_server": resourceArmApiManagementAuthorizationServer(), - "azurerm_api_management_backend": resourceArmApiManagementBackend(), - "azurerm_api_management_certificate": resourceArmApiManagementCertificate(), - "azurerm_api_management_group": resourceArmApiManagementGroup(), - "azurerm_api_management_group_user": resourceArmApiManagementGroupUser(), - "azurerm_api_management_logger": resourceArmApiManagementLogger(), - "azurerm_api_management_openid_connect_provider": resourceArmApiManagementOpenIDConnectProvider(), - "azurerm_api_management_product": resourceArmApiManagementProduct(), - "azurerm_api_management_product_api": resourceArmApiManagementProductApi(), - "azurerm_api_management_product_group": resourceArmApiManagementProductGroup(), - "azurerm_api_management_product_policy": resourceArmApiManagementProductPolicy(), - "azurerm_api_management_property": resourceArmApiManagementProperty(), - "azurerm_api_management_subscription": resourceArmApiManagementSubscription(), - "azurerm_api_management_user": resourceArmApiManagementUser(), - "azurerm_app_service_active_slot": resourceArmAppServiceActiveSlot(), - "azurerm_app_service_custom_hostname_binding": resourceArmAppServiceCustomHostnameBinding(), - "azurerm_app_service_plan": resourceArmAppServicePlan(), - "azurerm_app_service_slot": resourceArmAppServiceSlot(), - "azurerm_app_service": resourceArmAppService(), - "azurerm_application_gateway": resourceArmApplicationGateway(), - "azurerm_application_insights_api_key": resourceArmApplicationInsightsAPIKey(), - "azurerm_application_insights": resourceArmApplicationInsights(), - "azurerm_application_insights_web_test": resourceArmApplicationInsightsWebTests(), - "azurerm_application_security_group": resourceArmApplicationSecurityGroup(), - "azurerm_automation_account": resourceArmAutomationAccount(), - "azurerm_automation_credential": resourceArmAutomationCredential(), - "azurerm_automation_dsc_configuration": resourceArmAutomationDscConfiguration(), - "azurerm_automation_dsc_nodeconfiguration": resourceArmAutomationDscNodeConfiguration(), - "azurerm_automation_module": resourceArmAutomationModule(), - "azurerm_automation_runbook": resourceArmAutomationRunbook(), - "azurerm_automation_schedule": resourceArmAutomationSchedule(), - "azurerm_automation_variable_bool": resourceArmAutomationVariableBool(), - "azurerm_automation_variable_datetime": resourceArmAutomationVariableDateTime(), - "azurerm_automation_variable_int": resourceArmAutomationVariableInt(), - "azurerm_automation_variable_string": resourceArmAutomationVariableString(), - "azurerm_autoscale_setting": resourceArmAutoScaleSetting(), - "azurerm_availability_set": resourceArmAvailabilitySet(), - "azurerm_azuread_application": resourceArmActiveDirectoryApplication(), - "azurerm_azuread_service_principal_password": resourceArmActiveDirectoryServicePrincipalPassword(), - "azurerm_azuread_service_principal": resourceArmActiveDirectoryServicePrincipal(), - "azurerm_batch_account": resourceArmBatchAccount(), - "azurerm_batch_application": resourceArmBatchApplication(), - "azurerm_batch_certificate": resourceArmBatchCertificate(), - "azurerm_batch_pool": resourceArmBatchPool(), - "azurerm_cdn_endpoint": resourceArmCdnEndpoint(), - "azurerm_cdn_profile": resourceArmCdnProfile(), - "azurerm_cognitive_account": resourceArmCognitiveAccount(), - "azurerm_connection_monitor": resourceArmConnectionMonitor(), - "azurerm_container_group": resourceArmContainerGroup(), - "azurerm_container_registry": resourceArmContainerRegistry(), - "azurerm_container_service": resourceArmContainerService(), - "azurerm_cosmosdb_account": resourceArmCosmosDbAccount(), - "azurerm_cosmosdb_cassandra_keyspace": resourceArmCosmosDbCassandraKeyspace(), - "azurerm_cosmosdb_mongo_collection": resourceArmCosmosDbMongoCollection(), - "azurerm_cosmosdb_mongo_database": resourceArmCosmosDbMongoDatabase(), - "azurerm_cosmosdb_sql_database": resourceArmCosmosDbSQLDatabase(), - "azurerm_cosmosdb_table": resourceArmCosmosDbTable(), - "azurerm_data_factory": resourceArmDataFactory(), - "azurerm_data_factory_dataset_mysql": resourceArmDataFactoryDatasetMySQL(), - "azurerm_data_factory_dataset_postgresql": resourceArmDataFactoryDatasetPostgreSQL(), - "azurerm_data_factory_dataset_sql_server_table": resourceArmDataFactoryDatasetSQLServerTable(), - "azurerm_data_factory_linked_service_data_lake_storage_gen2": resourceArmDataFactoryLinkedServiceDataLakeStorageGen2(), - "azurerm_data_factory_linked_service_mysql": resourceArmDataFactoryLinkedServiceMySQL(), - "azurerm_data_factory_linked_service_postgresql": resourceArmDataFactoryLinkedServicePostgreSQL(), - "azurerm_data_factory_linked_service_sql_server": resourceArmDataFactoryLinkedServiceSQLServer(), - "azurerm_data_factory_pipeline": resourceArmDataFactoryPipeline(), - "azurerm_data_lake_analytics_account": resourceArmDataLakeAnalyticsAccount(), - "azurerm_data_lake_analytics_firewall_rule": resourceArmDataLakeAnalyticsFirewallRule(), - "azurerm_data_lake_store_file": resourceArmDataLakeStoreFile(), - "azurerm_data_lake_store_firewall_rule": resourceArmDataLakeStoreFirewallRule(), - "azurerm_data_lake_store": resourceArmDataLakeStore(), - "azurerm_databricks_workspace": resourceArmDatabricksWorkspace(), - "azurerm_ddos_protection_plan": resourceArmDDoSProtectionPlan(), - "azurerm_dev_test_lab": resourceArmDevTestLab(), - "azurerm_dev_test_schedule": resourceArmDevTestLabSchedules(), - "azurerm_dev_test_linux_virtual_machine": resourceArmDevTestLinuxVirtualMachine(), - "azurerm_dev_test_policy": resourceArmDevTestPolicy(), - "azurerm_dev_test_virtual_network": resourceArmDevTestVirtualNetwork(), - "azurerm_dev_test_windows_virtual_machine": resourceArmDevTestWindowsVirtualMachine(), - "azurerm_devspace_controller": resourceArmDevSpaceController(), - "azurerm_dns_a_record": resourceArmDnsARecord(), - "azurerm_dns_aaaa_record": resourceArmDnsAAAARecord(), - "azurerm_dns_caa_record": resourceArmDnsCaaRecord(), - "azurerm_dns_cname_record": resourceArmDnsCNameRecord(), - "azurerm_dns_mx_record": resourceArmDnsMxRecord(), - "azurerm_dns_ns_record": resourceArmDnsNsRecord(), - "azurerm_dns_ptr_record": resourceArmDnsPtrRecord(), - "azurerm_dns_srv_record": resourceArmDnsSrvRecord(), - "azurerm_dns_txt_record": resourceArmDnsTxtRecord(), - "azurerm_dns_zone": resourceArmDnsZone(), - "azurerm_eventgrid_domain": resourceArmEventGridDomain(), - "azurerm_eventgrid_event_subscription": resourceArmEventGridEventSubscription(), - "azurerm_eventgrid_topic": resourceArmEventGridTopic(), - "azurerm_eventhub_authorization_rule": resourceArmEventHubAuthorizationRule(), - "azurerm_eventhub_consumer_group": resourceArmEventHubConsumerGroup(), - "azurerm_eventhub_namespace_authorization_rule": resourceArmEventHubNamespaceAuthorizationRule(), - "azurerm_eventhub_namespace": resourceArmEventHubNamespace(), - "azurerm_eventhub": resourceArmEventHub(), - "azurerm_express_route_circuit_authorization": resourceArmExpressRouteCircuitAuthorization(), - "azurerm_express_route_circuit_peering": resourceArmExpressRouteCircuitPeering(), - "azurerm_express_route_circuit": resourceArmExpressRouteCircuit(), - "azurerm_firewall_application_rule_collection": resourceArmFirewallApplicationRuleCollection(), - "azurerm_firewall_nat_rule_collection": resourceArmFirewallNatRuleCollection(), - "azurerm_firewall_network_rule_collection": resourceArmFirewallNetworkRuleCollection(), - "azurerm_firewall": resourceArmFirewall(), - "azurerm_function_app": resourceArmFunctionApp(), - "azurerm_hdinsight_hadoop_cluster": resourceArmHDInsightHadoopCluster(), - "azurerm_hdinsight_hbase_cluster": resourceArmHDInsightHBaseCluster(), - "azurerm_hdinsight_interactive_query_cluster": resourceArmHDInsightInteractiveQueryCluster(), - "azurerm_hdinsight_kafka_cluster": resourceArmHDInsightKafkaCluster(), - "azurerm_hdinsight_ml_services_cluster": resourceArmHDInsightMLServicesCluster(), - "azurerm_hdinsight_rserver_cluster": resourceArmHDInsightRServerCluster(), - "azurerm_hdinsight_spark_cluster": resourceArmHDInsightSparkCluster(), - "azurerm_hdinsight_storm_cluster": resourceArmHDInsightStormCluster(), - "azurerm_image": resourceArmImage(), - "azurerm_iot_dps": resourceArmIotDPS(), - "azurerm_iot_dps_certificate": resourceArmIotDPSCertificate(), - "azurerm_iothub_consumer_group": resourceArmIotHubConsumerGroup(), - "azurerm_iothub": resourceArmIotHub(), - "azurerm_iothub_shared_access_policy": resourceArmIotHubSharedAccessPolicy(), - "azurerm_key_vault_access_policy": resourceArmKeyVaultAccessPolicy(), - "azurerm_key_vault_certificate": resourceArmKeyVaultCertificate(), - "azurerm_key_vault_key": resourceArmKeyVaultKey(), - "azurerm_key_vault_secret": resourceArmKeyVaultSecret(), - "azurerm_key_vault": resourceArmKeyVault(), - "azurerm_kubernetes_cluster": resourceArmKubernetesCluster(), - "azurerm_lb_backend_address_pool": resourceArmLoadBalancerBackendAddressPool(), - "azurerm_lb_nat_pool": resourceArmLoadBalancerNatPool(), - "azurerm_lb_nat_rule": resourceArmLoadBalancerNatRule(), - "azurerm_lb_probe": resourceArmLoadBalancerProbe(), - "azurerm_lb_outbound_rule": resourceArmLoadBalancerOutboundRule(), - "azurerm_lb_rule": resourceArmLoadBalancerRule(), - "azurerm_lb": resourceArmLoadBalancer(), - "azurerm_local_network_gateway": resourceArmLocalNetworkGateway(), - "azurerm_log_analytics_solution": resourceArmLogAnalyticsSolution(), - "azurerm_log_analytics_linked_service": resourceArmLogAnalyticsLinkedService(), - "azurerm_log_analytics_workspace_linked_service": resourceArmLogAnalyticsWorkspaceLinkedService(), - "azurerm_log_analytics_workspace": resourceArmLogAnalyticsWorkspace(), - "azurerm_logic_app_action_custom": resourceArmLogicAppActionCustom(), - "azurerm_logic_app_action_http": resourceArmLogicAppActionHTTP(), - "azurerm_logic_app_trigger_custom": resourceArmLogicAppTriggerCustom(), - "azurerm_logic_app_trigger_http_request": resourceArmLogicAppTriggerHttpRequest(), - "azurerm_logic_app_trigger_recurrence": resourceArmLogicAppTriggerRecurrence(), - "azurerm_logic_app_workflow": resourceArmLogicAppWorkflow(), - "azurerm_managed_disk": resourceArmManagedDisk(), - "azurerm_management_group": resourceArmManagementGroup(), - "azurerm_management_lock": resourceArmManagementLock(), - "azurerm_maps_account": resourceArmMapsAccount(), - "azurerm_mariadb_database": resourceArmMariaDbDatabase(), - "azurerm_mariadb_firewall_rule": resourceArmMariaDBFirewallRule(), - "azurerm_mariadb_server": resourceArmMariaDbServer(), - "azurerm_media_services_account": resourceArmMediaServicesAccount(), - "azurerm_metric_alertrule": resourceArmMetricAlertRule(), - "azurerm_monitor_autoscale_setting": resourceArmMonitorAutoScaleSetting(), - "azurerm_monitor_action_group": resourceArmMonitorActionGroup(), - "azurerm_monitor_activity_log_alert": resourceArmMonitorActivityLogAlert(), - "azurerm_monitor_diagnostic_setting": resourceArmMonitorDiagnosticSetting(), - "azurerm_monitor_log_profile": resourceArmMonitorLogProfile(), - "azurerm_monitor_metric_alert": resourceArmMonitorMetricAlert(), - "azurerm_monitor_metric_alertrule": resourceArmMonitorMetricAlertRule(), - "azurerm_mssql_elasticpool": resourceArmMsSqlElasticPool(), - "azurerm_mysql_configuration": resourceArmMySQLConfiguration(), - "azurerm_mysql_database": resourceArmMySqlDatabase(), - "azurerm_mysql_firewall_rule": resourceArmMySqlFirewallRule(), - "azurerm_mysql_server": resourceArmMySqlServer(), - "azurerm_mysql_virtual_network_rule": resourceArmMySqlVirtualNetworkRule(), - "azurerm_network_connection_monitor": resourceArmNetworkConnectionMonitor(), - "azurerm_network_ddos_protection_plan": resourceArmNetworkDDoSProtectionPlan(), - "azurerm_network_interface": resourceArmNetworkInterface(), + "azurerm_analysis_services_server": resourceArmAnalysisServicesServer(), + "azurerm_api_management": resourceArmApiManagementService(), + "azurerm_api_management_api": resourceArmApiManagementApi(), + "azurerm_api_management_api_operation": resourceArmApiManagementApiOperation(), + "azurerm_api_management_api_operation_policy": resourceArmApiManagementApiOperationPolicy(), + "azurerm_api_management_api_policy": resourceArmApiManagementApiPolicy(), + "azurerm_api_management_api_schema": resourceArmApiManagementApiSchema(), + "azurerm_api_management_api_version_set": resourceArmApiManagementApiVersionSet(), + "azurerm_api_management_authorization_server": resourceArmApiManagementAuthorizationServer(), + "azurerm_api_management_backend": resourceArmApiManagementBackend(), + "azurerm_api_management_certificate": resourceArmApiManagementCertificate(), + "azurerm_api_management_group": resourceArmApiManagementGroup(), + "azurerm_api_management_group_user": resourceArmApiManagementGroupUser(), + "azurerm_api_management_logger": resourceArmApiManagementLogger(), + "azurerm_api_management_openid_connect_provider": resourceArmApiManagementOpenIDConnectProvider(), + "azurerm_api_management_product": resourceArmApiManagementProduct(), + "azurerm_api_management_product_api": resourceArmApiManagementProductApi(), + "azurerm_api_management_product_group": resourceArmApiManagementProductGroup(), + "azurerm_api_management_product_policy": resourceArmApiManagementProductPolicy(), + "azurerm_api_management_property": resourceArmApiManagementProperty(), + "azurerm_api_management_subscription": resourceArmApiManagementSubscription(), + "azurerm_api_management_user": resourceArmApiManagementUser(), + "azurerm_app_service_active_slot": resourceArmAppServiceActiveSlot(), + "azurerm_app_service_custom_hostname_binding": resourceArmAppServiceCustomHostnameBinding(), + "azurerm_app_service_plan": resourceArmAppServicePlan(), + "azurerm_app_service_slot": resourceArmAppServiceSlot(), + "azurerm_app_service": resourceArmAppService(), + "azurerm_application_gateway": resourceArmApplicationGateway(), + "azurerm_application_insights_api_key": resourceArmApplicationInsightsAPIKey(), + "azurerm_application_insights": resourceArmApplicationInsights(), + "azurerm_application_insights_web_test": resourceArmApplicationInsightsWebTests(), + "azurerm_application_security_group": resourceArmApplicationSecurityGroup(), + "azurerm_automation_account": resourceArmAutomationAccount(), + "azurerm_automation_credential": resourceArmAutomationCredential(), + "azurerm_automation_dsc_configuration": resourceArmAutomationDscConfiguration(), + "azurerm_automation_dsc_nodeconfiguration": resourceArmAutomationDscNodeConfiguration(), + "azurerm_automation_module": resourceArmAutomationModule(), + "azurerm_automation_runbook": resourceArmAutomationRunbook(), + "azurerm_automation_schedule": resourceArmAutomationSchedule(), + "azurerm_automation_variable_bool": resourceArmAutomationVariableBool(), + "azurerm_automation_variable_datetime": resourceArmAutomationVariableDateTime(), + "azurerm_automation_variable_int": resourceArmAutomationVariableInt(), + "azurerm_automation_variable_string": resourceArmAutomationVariableString(), + "azurerm_autoscale_setting": resourceArmAutoScaleSetting(), + "azurerm_availability_set": resourceArmAvailabilitySet(), + "azurerm_azuread_application": resourceArmActiveDirectoryApplication(), + "azurerm_azuread_service_principal_password": resourceArmActiveDirectoryServicePrincipalPassword(), + "azurerm_azuread_service_principal": resourceArmActiveDirectoryServicePrincipal(), + "azurerm_batch_account": resourceArmBatchAccount(), + "azurerm_batch_application": resourceArmBatchApplication(), + "azurerm_batch_certificate": resourceArmBatchCertificate(), + "azurerm_batch_pool": resourceArmBatchPool(), + "azurerm_cdn_endpoint": resourceArmCdnEndpoint(), + "azurerm_cdn_profile": resourceArmCdnProfile(), + "azurerm_cognitive_account": resourceArmCognitiveAccount(), + "azurerm_connection_monitor": resourceArmConnectionMonitor(), + "azurerm_container_group": resourceArmContainerGroup(), + "azurerm_container_registry": resourceArmContainerRegistry(), + "azurerm_container_service": resourceArmContainerService(), + "azurerm_cosmosdb_account": resourceArmCosmosDbAccount(), + "azurerm_cosmosdb_cassandra_keyspace": resourceArmCosmosDbCassandraKeyspace(), + "azurerm_cosmosdb_mongo_collection": resourceArmCosmosDbMongoCollection(), + "azurerm_cosmosdb_mongo_database": resourceArmCosmosDbMongoDatabase(), + "azurerm_cosmosdb_sql_database": resourceArmCosmosDbSQLDatabase(), + "azurerm_cosmosdb_table": resourceArmCosmosDbTable(), + "azurerm_data_factory": resourceArmDataFactory(), + "azurerm_data_factory_dataset_mysql": resourceArmDataFactoryDatasetMySQL(), + "azurerm_data_factory_dataset_postgresql": resourceArmDataFactoryDatasetPostgreSQL(), + "azurerm_data_factory_dataset_sql_server_table": resourceArmDataFactoryDatasetSQLServerTable(), + "azurerm_data_factory_linked_service_data_lake_storage_gen2": resourceArmDataFactoryLinkedServiceDataLakeStorageGen2(), + "azurerm_data_factory_linked_service_mysql": resourceArmDataFactoryLinkedServiceMySQL(), + "azurerm_data_factory_linked_service_postgresql": resourceArmDataFactoryLinkedServicePostgreSQL(), + "azurerm_data_factory_linked_service_sql_server": resourceArmDataFactoryLinkedServiceSQLServer(), + "azurerm_data_factory_pipeline": resourceArmDataFactoryPipeline(), + "azurerm_data_lake_analytics_account": resourceArmDataLakeAnalyticsAccount(), + "azurerm_data_lake_analytics_firewall_rule": resourceArmDataLakeAnalyticsFirewallRule(), + "azurerm_data_lake_store_file": resourceArmDataLakeStoreFile(), + "azurerm_data_lake_store_firewall_rule": resourceArmDataLakeStoreFirewallRule(), + "azurerm_data_lake_store": resourceArmDataLakeStore(), + "azurerm_databricks_workspace": resourceArmDatabricksWorkspace(), + "azurerm_ddos_protection_plan": resourceArmDDoSProtectionPlan(), + "azurerm_dev_test_lab": resourceArmDevTestLab(), + "azurerm_dev_test_schedule": resourceArmDevTestLabSchedules(), + "azurerm_dev_test_linux_virtual_machine": resourceArmDevTestLinuxVirtualMachine(), + "azurerm_dev_test_policy": resourceArmDevTestPolicy(), + "azurerm_dev_test_virtual_network": resourceArmDevTestVirtualNetwork(), + "azurerm_dev_test_windows_virtual_machine": resourceArmDevTestWindowsVirtualMachine(), + "azurerm_devspace_controller": resourceArmDevSpaceController(), + "azurerm_dns_a_record": resourceArmDnsARecord(), + "azurerm_dns_aaaa_record": resourceArmDnsAAAARecord(), + "azurerm_dns_caa_record": resourceArmDnsCaaRecord(), + "azurerm_dns_cname_record": resourceArmDnsCNameRecord(), + "azurerm_dns_mx_record": resourceArmDnsMxRecord(), + "azurerm_dns_ns_record": resourceArmDnsNsRecord(), + "azurerm_dns_ptr_record": resourceArmDnsPtrRecord(), + "azurerm_dns_srv_record": resourceArmDnsSrvRecord(), + "azurerm_dns_txt_record": resourceArmDnsTxtRecord(), + "azurerm_dns_zone": resourceArmDnsZone(), + "azurerm_eventgrid_domain": resourceArmEventGridDomain(), + "azurerm_eventgrid_event_subscription": resourceArmEventGridEventSubscription(), + "azurerm_eventgrid_topic": resourceArmEventGridTopic(), + "azurerm_eventhub_authorization_rule": resourceArmEventHubAuthorizationRule(), + "azurerm_eventhub_consumer_group": resourceArmEventHubConsumerGroup(), + "azurerm_eventhub_namespace_authorization_rule": resourceArmEventHubNamespaceAuthorizationRule(), + "azurerm_eventhub_namespace": resourceArmEventHubNamespace(), + "azurerm_eventhub": resourceArmEventHub(), + "azurerm_express_route_circuit_authorization": resourceArmExpressRouteCircuitAuthorization(), + "azurerm_express_route_circuit_peering": resourceArmExpressRouteCircuitPeering(), + "azurerm_express_route_circuit": resourceArmExpressRouteCircuit(), + "azurerm_firewall_application_rule_collection": resourceArmFirewallApplicationRuleCollection(), + "azurerm_firewall_nat_rule_collection": resourceArmFirewallNatRuleCollection(), + "azurerm_firewall_network_rule_collection": resourceArmFirewallNetworkRuleCollection(), + "azurerm_firewall": resourceArmFirewall(), + "azurerm_function_app": resourceArmFunctionApp(), + "azurerm_hdinsight_hadoop_cluster": resourceArmHDInsightHadoopCluster(), + "azurerm_hdinsight_hbase_cluster": resourceArmHDInsightHBaseCluster(), + "azurerm_hdinsight_interactive_query_cluster": resourceArmHDInsightInteractiveQueryCluster(), + "azurerm_hdinsight_kafka_cluster": resourceArmHDInsightKafkaCluster(), + "azurerm_hdinsight_ml_services_cluster": resourceArmHDInsightMLServicesCluster(), + "azurerm_hdinsight_rserver_cluster": resourceArmHDInsightRServerCluster(), + "azurerm_hdinsight_spark_cluster": resourceArmHDInsightSparkCluster(), + "azurerm_hdinsight_storm_cluster": resourceArmHDInsightStormCluster(), + "azurerm_image": resourceArmImage(), + "azurerm_iot_dps": resourceArmIotDPS(), + "azurerm_iot_dps_certificate": resourceArmIotDPSCertificate(), + "azurerm_iothub_consumer_group": resourceArmIotHubConsumerGroup(), + "azurerm_iothub": resourceArmIotHub(), + "azurerm_iothub_shared_access_policy": resourceArmIotHubSharedAccessPolicy(), + "azurerm_key_vault_access_policy": resourceArmKeyVaultAccessPolicy(), + "azurerm_key_vault_certificate": resourceArmKeyVaultCertificate(), + "azurerm_key_vault_key": resourceArmKeyVaultKey(), + "azurerm_key_vault_secret": resourceArmKeyVaultSecret(), + "azurerm_key_vault": resourceArmKeyVault(), + "azurerm_kubernetes_cluster": resourceArmKubernetesCluster(), + "azurerm_lb_backend_address_pool": resourceArmLoadBalancerBackendAddressPool(), + "azurerm_lb_nat_pool": resourceArmLoadBalancerNatPool(), + "azurerm_lb_nat_rule": resourceArmLoadBalancerNatRule(), + "azurerm_lb_probe": resourceArmLoadBalancerProbe(), + "azurerm_lb_outbound_rule": resourceArmLoadBalancerOutboundRule(), + "azurerm_lb_rule": resourceArmLoadBalancerRule(), + "azurerm_lb": resourceArmLoadBalancer(), + "azurerm_local_network_gateway": resourceArmLocalNetworkGateway(), + "azurerm_log_analytics_solution": resourceArmLogAnalyticsSolution(), + "azurerm_log_analytics_linked_service": resourceArmLogAnalyticsLinkedService(), + "azurerm_log_analytics_workspace_linked_service": resourceArmLogAnalyticsWorkspaceLinkedService(), + "azurerm_log_analytics_workspace": resourceArmLogAnalyticsWorkspace(), + "azurerm_logic_app_action_custom": resourceArmLogicAppActionCustom(), + "azurerm_logic_app_action_http": resourceArmLogicAppActionHTTP(), + "azurerm_logic_app_trigger_custom": resourceArmLogicAppTriggerCustom(), + "azurerm_logic_app_trigger_http_request": resourceArmLogicAppTriggerHttpRequest(), + "azurerm_logic_app_trigger_recurrence": resourceArmLogicAppTriggerRecurrence(), + "azurerm_logic_app_workflow": resourceArmLogicAppWorkflow(), + "azurerm_managed_disk": resourceArmManagedDisk(), + "azurerm_management_group": resourceArmManagementGroup(), + "azurerm_management_lock": resourceArmManagementLock(), + "azurerm_maps_account": resourceArmMapsAccount(), + "azurerm_mariadb_database": resourceArmMariaDbDatabase(), + "azurerm_mariadb_firewall_rule": resourceArmMariaDBFirewallRule(), + "azurerm_mariadb_server": resourceArmMariaDbServer(), + "azurerm_media_services_account": resourceArmMediaServicesAccount(), + "azurerm_metric_alertrule": resourceArmMetricAlertRule(), + "azurerm_monitor_autoscale_setting": resourceArmMonitorAutoScaleSetting(), + "azurerm_monitor_action_group": resourceArmMonitorActionGroup(), + "azurerm_monitor_activity_log_alert": resourceArmMonitorActivityLogAlert(), + "azurerm_monitor_diagnostic_setting": resourceArmMonitorDiagnosticSetting(), + "azurerm_monitor_log_profile": resourceArmMonitorLogProfile(), + "azurerm_monitor_metric_alert": resourceArmMonitorMetricAlert(), + "azurerm_monitor_metric_alertrule": resourceArmMonitorMetricAlertRule(), + "azurerm_mssql_elasticpool": resourceArmMsSqlElasticPool(), + "azurerm_mysql_configuration": resourceArmMySQLConfiguration(), + "azurerm_mysql_database": resourceArmMySqlDatabase(), + "azurerm_mysql_firewall_rule": resourceArmMySqlFirewallRule(), + "azurerm_mysql_server": resourceArmMySqlServer(), + "azurerm_mysql_virtual_network_rule": resourceArmMySqlVirtualNetworkRule(), + "azurerm_network_connection_monitor": resourceArmNetworkConnectionMonitor(), + "azurerm_network_ddos_protection_plan": resourceArmNetworkDDoSProtectionPlan(), + "azurerm_network_interface": resourceArmNetworkInterface(), "azurerm_network_interface_application_gateway_backend_address_pool_association": resourceArmNetworkInterfaceApplicationGatewayBackendAddressPoolAssociation(), "azurerm_network_interface_application_security_group_association": resourceArmNetworkInterfaceApplicationSecurityGroupAssociation(), "azurerm_network_interface_backend_address_pool_association": resourceArmNetworkInterfaceBackendAddressPoolAssociation(), diff --git a/azurerm/resource_arm_virtual_machine_scale_set.go b/azurerm/resource_arm_virtual_machine_scale_set.go index f20f75ce7673..d0ce74883f31 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set.go +++ b/azurerm/resource_arm_virtual_machine_scale_set.go @@ -874,12 +874,12 @@ func resourceArmVirtualMachineScaleSetCreateUpdate(d *schema.ResourceData, meta } properties := compute.VirtualMachineScaleSet{ - Name: &name, - Location: &location, - Tags: expandTags(tags), - Sku: sku, + Name: &name, + Location: &location, + Tags: expandTags(tags), + Sku: sku, VirtualMachineScaleSetProperties: &scaleSetProps, - Zones: zones, + Zones: zones, } if _, ok := d.GetOk("identity"); ok { diff --git a/azurerm/resource_arm_virtual_network.go b/azurerm/resource_arm_virtual_network.go index 6cbe9f2bdf8e..f667d1d917e9 100644 --- a/azurerm/resource_arm_virtual_network.go +++ b/azurerm/resource_arm_virtual_network.go @@ -151,7 +151,7 @@ func resourceArmVirtualNetworkCreateUpdate(d *schema.ResourceData, meta interfac Name: &name, Location: &location, VirtualNetworkPropertiesFormat: vnetProperties, - Tags: expandTags(tags), + Tags: expandTags(tags), } networkSecurityGroupNames := make([]string, 0) From f76e6fa4751d2bcd789dd1bd78a5068a89743053 Mon Sep 17 00:00:00 2001 From: Toby Pettit Date: Mon, 12 Aug 2019 13:28:10 +0100 Subject: [PATCH 08/14] fixed id path in proximity group destroy --- azurerm/resource_arm_availability_set_test.go | 48 +++++++ .../resource_arm_proximity_placement_group.go | 2 +- ...urce_arm_virtual_machine_scale_set_test.go | 114 +++++++++++++++++ azurerm/resource_arm_virtual_machine_test.go | 121 ++++++++++++++++++ 4 files changed, 284 insertions(+), 1 deletion(-) diff --git a/azurerm/resource_arm_availability_set_test.go b/azurerm/resource_arm_availability_set_test.go index 470c7899071a..e46b8c411698 100644 --- a/azurerm/resource_arm_availability_set_test.go +++ b/azurerm/resource_arm_availability_set_test.go @@ -131,6 +131,31 @@ func TestAccAzureRMAvailabilitySet_withTags(t *testing.T) { }) } +func TestAccAzureRMAvailabilitySet_withPPG(t *testing.T) { + resourceName := "azurerm_availability_set.test" + ri := tf.AccRandTimeInt() + config := testAccAzureRMAvailabilitySet_withPPG(ri, testLocation()) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAvailabilitySetDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAvailabilitySetExists(resourceName), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func TestAccAzureRMAvailabilitySet_withDomainCounts(t *testing.T) { resourceName := "azurerm_availability_set.test" ri := tf.AccRandTimeInt() @@ -333,6 +358,29 @@ resource "azurerm_availability_set" "test" { `, rInt, location, rInt) } +func testAccAzureRMAvailabilitySet_withPPG(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_proximity_placement_group" "test" { + name = "acctestPPG-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" +} + +resource "azurerm_availability_set" "test" { + name = "acctestavset-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + proximity_placement_group_id = "${azurerm_proximity_placement_group.test.id}" +} +`, rInt, location, rInt, rInt) +} + func testAccAzureRMAvailabilitySet_withDomainCounts(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { diff --git a/azurerm/resource_arm_proximity_placement_group.go b/azurerm/resource_arm_proximity_placement_group.go index 03ff5484b48b..077c933655f4 100644 --- a/azurerm/resource_arm_proximity_placement_group.go +++ b/azurerm/resource_arm_proximity_placement_group.go @@ -118,7 +118,7 @@ func resourceArmProximityPlacementGroupDelete(d *schema.ResourceData, meta inter return err } resGroup := id.ResourceGroup - name := id.Path["proximityPlacementGroup"] + name := id.Path["proximityPlacementGroups"] _, err = client.Delete(ctx, resGroup, name) diff --git a/azurerm/resource_arm_virtual_machine_scale_set_test.go b/azurerm/resource_arm_virtual_machine_scale_set_test.go index 5e8eaa51477e..ce847f3a8f03 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set_test.go +++ b/azurerm/resource_arm_virtual_machine_scale_set_test.go @@ -123,6 +123,25 @@ func TestAccAzureRMVirtualMachineScaleSet_standardSSD(t *testing.T) { }) } +func TestAccAzureRMVirtualMachineScaleSet_withPPG(t *testing.T) { + resourceName := "azurerm_virtual_machine_scale_set.test" + ri := tf.AccRandTimeInt() + config := testAccAzureRMVirtualMachineScaleSet_withPPG(ri, testLocation()) + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMVirtualMachineScaleSetDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), + ), + }, + }, + }) +} + func TestAccAzureRMVirtualMachineScaleSet_basicPublicIP(t *testing.T) { resourceName := "azurerm_virtual_machine_scale_set.test" ri := tf.AccRandTimeInt() @@ -1860,6 +1879,101 @@ resource "azurerm_virtual_machine_scale_set" "test" { `, rInt, location) } +func testAccAzureRMVirtualMachineScaleSet_withPPG(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%[1]d" + location = "%[2]s" +} + +resource "azurerm_virtual_network" "test" { + name = "acctvn-%[1]d" + address_space = ["10.0.0.0/16"] + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" +} + +resource "azurerm_subnet" "test" { + name = "acctsub-%[1]d" + resource_group_name = "${azurerm_resource_group.test.name}" + virtual_network_name = "${azurerm_virtual_network.test.name}" + address_prefix = "10.0.2.0/24" +} + +resource "azurerm_storage_account" "test" { + name = "accsa%[1]d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + account_tier = "Standard" + account_replication_type = "LRS" + + tags = { + environment = "staging" + } +} + +resource "azurerm_storage_container" "test" { + name = "vhds" + resource_group_name = "${azurerm_resource_group.test.name}" + storage_account_name = "${azurerm_storage_account.test.name}" + container_access_type = "private" +} + +resource "azurerm_proximity_placement_group" "test" { + name = "accPPG-%[1]%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" +} + +resource "azurerm_virtual_machine_scale_set" "test" { + name = "acctvmss-%[1]d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + upgrade_policy_mode = "Manual" + single_placement_group = false + + sku { + name = "Standard_D1_v2" + tier = "Standard" + capacity = 2 + } + + os_profile { + computer_name_prefix = "testvm-%[1]d" + admin_username = "myadmin" + admin_password = "Passwword1234" + } + + network_profile { + name = "TestNetworkProfile-%[1]d" + primary = true + + ip_configuration { + name = "TestIPConfiguration" + primary = true + subnet_id = "${azurerm_subnet.test.id}" + } + } + + storage_profile_os_disk { + name = "" + caching = "ReadWrite" + create_option = "FromImage" + managed_disk_type = "StandardSSD_LRS" + } + + storage_profile_image_reference { + publisher = "Canonical" + offer = "UbuntuServer" + sku = "16.04-LTS" + version = "latest" + } + + proximity_placement_group_id = "${azure_proximity_placement_group.test.id}" +} +`, rInt, location) +} + func testAccAzureRMVirtualMachineScaleSet_basicPublicIP(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { diff --git a/azurerm/resource_arm_virtual_machine_test.go b/azurerm/resource_arm_virtual_machine_test.go index 7442c6e6df78..a700c61f2bac 100644 --- a/azurerm/resource_arm_virtual_machine_test.go +++ b/azurerm/resource_arm_virtual_machine_test.go @@ -106,6 +106,27 @@ func TestAccAzureRMVirtualMachine_multipleAssignedIdentity(t *testing.T) { }) } +func TestAccAzureRMVirtualMachine_withPPG(t *testing.T) { + var vm compute.VirtualMachine + resourceName := "azurerm_virtual_machine.test" + ri := tf.AccRandTimeInt() + rs := acctest.RandString(14) + config := testAccAzureRMVirtualMachinePPG(ri, testLocation(), rs) + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMVirtualMachineScaleSetDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMVirtualMachineExists(resourceName, &vm), + ), + }, + }, + }) +} + func testCheckAzureRMVirtualMachineExists(resourceName string, vm *compute.VirtualMachine) resource.TestCheckFunc { return func(s *terraform.State) error { // Ensure we have enough information in state to look up in API @@ -550,3 +571,103 @@ resource "azurerm_virtual_machine" "test" { } `, rInt, location, rInt, rInt, rInt, rInt, rString, rInt, rInt) } + +func testAccAzureRMVirtualMachinePPG(rInt int, location string, rString string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_virtual_network" "test" { + name = "acctvn-%d" + address_space = ["10.0.0.0/16"] + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" +} + +resource "azurerm_subnet" "test" { + name = "acctsub-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + virtual_network_name = "${azurerm_virtual_network.test.name}" + address_prefix = "10.0.2.0/24" +} + +resource "azurerm_network_interface" "test" { + name = "acctni-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + ip_configuration { + name = "testconfiguration1" + subnet_id = "${azurerm_subnet.test.id}" + private_ip_address_allocation = "Dynamic" + } +} + +resource "azurerm_storage_account" "test" { + name = "accsa%d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + account_tier = "Standard" + account_replication_type = "LRS" + + tags = { + environment = "staging" + } +} + +resource "azurerm_storage_container" "test" { + name = "vhds" + resource_group_name = "${azurerm_resource_group.test.name}" + storage_account_name = "${azurerm_storage_account.test.name}" + container_access_type = "private" +} + +resource "azurerm_proximity_placement_group" "test" { + name = "accPPG-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" +} + +resource "azurerm_virtual_machine" "test" { + name = "acctvm-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + network_interface_ids = ["${azurerm_network_interface.test.id}"] + vm_size = "Standard_D1_v2" + + storage_image_reference { + publisher = "Canonical" + offer = "UbuntuServer" + sku = "16.04-LTS" + version = "latest" + } + + storage_os_disk { + name = "myosdisk1" + vhd_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/myosdisk1.vhd" + caching = "ReadWrite" + create_option = "FromImage" + disk_size_gb = "45" + } + + os_profile { + computer_name = "hn%d" + admin_username = "testadmin" + admin_password = "Password1234!" + } + + os_profile_linux_config { + disable_password_authentication = false + } + + proximity_placement_group_id = "${azure_proximity_placement_group.test.id}" + + tags = { + environment = "Production" + cost-center = "Ops" + } +} +`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt, rInt) +} From 0d24f025ccdcbc9b8628e39a5035e75aba13bd54 Mon Sep 17 00:00:00 2001 From: Toby Pettit Date: Mon, 12 Aug 2019 13:53:29 +0100 Subject: [PATCH 09/14] changed to use new client structure --- azurerm/data_source_proximity_placement_group.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/data_source_proximity_placement_group.go b/azurerm/data_source_proximity_placement_group.go index 15837f3df3ef..88b38992dfe2 100644 --- a/azurerm/data_source_proximity_placement_group.go +++ b/azurerm/data_source_proximity_placement_group.go @@ -25,7 +25,7 @@ func dataSourceArmProximityPlacementGroup() *schema.Resource { } func dataSourceArmProximityPlacementGroupRead(d *schema.ResourceData, meta interface{}) error { - client := meta.(*ArmClient).ppgClient + client := meta.(*ArmClient).compute.ProximityPlacementGroupsClient ctx := meta.(*ArmClient).StopContext name := d.Get("name").(string) From fb8b2948ae47e64682c3ceee230ab33b6728c7be Mon Sep 17 00:00:00 2001 From: Toby Pettit Date: Mon, 12 Aug 2019 13:53:53 +0100 Subject: [PATCH 10/14] missed files for change of client structure --- azurerm/internal/services/compute/client.go | 30 +++++++++++-------- .../resource_arm_proximity_placement_group.go | 6 ++-- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/azurerm/internal/services/compute/client.go b/azurerm/internal/services/compute/client.go index 611873b73dbc..213573a91a52 100644 --- a/azurerm/internal/services/compute/client.go +++ b/azurerm/internal/services/compute/client.go @@ -6,19 +6,20 @@ import ( ) type Client struct { - AvailabilitySetsClient compute.AvailabilitySetsClient - DisksClient compute.DisksClient - GalleriesClient compute.GalleriesClient - GalleryImagesClient compute.GalleryImagesClient - GalleryImageVersionsClient compute.GalleryImageVersionsClient - ImagesClient compute.ImagesClient - SnapshotsClient compute.SnapshotsClient - UsageClient compute.UsageClient - VMExtensionImageClient compute.VirtualMachineExtensionImagesClient - VMExtensionClient compute.VirtualMachineExtensionsClient - VMScaleSetClient compute.VirtualMachineScaleSetsClient - VMClient compute.VirtualMachinesClient - VMImageClient compute.VirtualMachineImagesClient + AvailabilitySetsClient compute.AvailabilitySetsClient + DisksClient compute.DisksClient + GalleriesClient compute.GalleriesClient + GalleryImagesClient compute.GalleryImagesClient + GalleryImageVersionsClient compute.GalleryImageVersionsClient + ImagesClient compute.ImagesClient + ProximityPlacementGroupsClient compute.ProximityPlacementGroupsClient + SnapshotsClient compute.SnapshotsClient + UsageClient compute.UsageClient + VMExtensionImageClient compute.VirtualMachineExtensionImagesClient + VMExtensionClient compute.VirtualMachineExtensionsClient + VMScaleSetClient compute.VirtualMachineScaleSetsClient + VMClient compute.VirtualMachinesClient + VMImageClient compute.VirtualMachineImagesClient } func BuildClient(o *common.ClientOptions) *Client { @@ -42,6 +43,9 @@ func BuildClient(o *common.ClientOptions) *Client { c.ImagesClient = compute.NewImagesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&c.ImagesClient.Client, o.ResourceManagerAuthorizer) + c.ProximityPlacementGroupsClient = compute.NewProximityPlacementGroupsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + o.ConfigureClient(&c.ProximityPlacementGroupsClient.Client, o.ResourceManagerAuthorizer) + c.SnapshotsClient = compute.NewSnapshotsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&c.SnapshotsClient.Client, o.ResourceManagerAuthorizer) diff --git a/azurerm/resource_arm_proximity_placement_group.go b/azurerm/resource_arm_proximity_placement_group.go index 077c933655f4..39e4f07114af 100644 --- a/azurerm/resource_arm_proximity_placement_group.go +++ b/azurerm/resource_arm_proximity_placement_group.go @@ -38,7 +38,7 @@ func resourceArmProximityPlacementGroup() *schema.Resource { } func resourceArmProximityPlacementGroupCreateUpdate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*ArmClient).ppgClient + client := meta.(*ArmClient).compute.ProximityPlacementGroupsClient ctx := meta.(*ArmClient).StopContext log.Printf("[INFO] preparing arguments for AzureRM Proximity Placement Group creation.") @@ -79,7 +79,7 @@ func resourceArmProximityPlacementGroupCreateUpdate(d *schema.ResourceData, meta } func resourceArmProximityPlacementGroupRead(d *schema.ResourceData, meta interface{}) error { - client := meta.(*ArmClient).ppgClient + client := meta.(*ArmClient).compute.ProximityPlacementGroupsClient ctx := meta.(*ArmClient).StopContext id, err := parseAzureResourceID(d.Id()) @@ -110,7 +110,7 @@ func resourceArmProximityPlacementGroupRead(d *schema.ResourceData, meta interfa } func resourceArmProximityPlacementGroupDelete(d *schema.ResourceData, meta interface{}) error { - client := meta.(*ArmClient).ppgClient + client := meta.(*ArmClient).compute.ProximityPlacementGroupsClient ctx := meta.(*ArmClient).StopContext id, err := parseAzureResourceID(d.Id()) From f4f5b8b4eb27090aa2bc5184b7d97d767b240534 Mon Sep 17 00:00:00 2001 From: Toby Pettit Date: Mon, 12 Aug 2019 14:02:52 +0100 Subject: [PATCH 11/14] make tests pass --- azurerm/config.go | 2 +- azurerm/resource_arm_proximity_placement_group_test.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/azurerm/config.go b/azurerm/config.go index ec22e1a04462..14e5900b6835 100644 --- a/azurerm/config.go +++ b/azurerm/config.go @@ -395,4 +395,4 @@ func (c *ArmClient) getBlobStorageClientForStorageAccount(ctx context.Context, r blobClient := storageClient.GetBlobService() return &blobClient, true, nil -} \ No newline at end of file +} diff --git a/azurerm/resource_arm_proximity_placement_group_test.go b/azurerm/resource_arm_proximity_placement_group_test.go index 29eced21a871..85168d4350bc 100644 --- a/azurerm/resource_arm_proximity_placement_group_test.go +++ b/azurerm/resource_arm_proximity_placement_group_test.go @@ -139,7 +139,7 @@ func testCheckAzureRMProximityPlacementGroupExists(resourceName string) resource return fmt.Errorf("Bad: no resource group found in state for proximity placement group: %s", ppgName) } - client := testAccProvider.Meta().(*ArmClient).ppgClient + client := testAccProvider.Meta().(*ArmClient).compute.ProximityPlacementGroupsClient ctx := testAccProvider.Meta().(*ArmClient).StopContext resp, err := client.Get(ctx, resourceGroup, ppgName) if err != nil { @@ -147,7 +147,7 @@ func testCheckAzureRMProximityPlacementGroupExists(resourceName string) resource return fmt.Errorf("Bad: Availability Set %q (resource group: %q) does not exist", ppgName, resourceGroup) } - return fmt.Errorf("Bad: Get on ppgClient: %+v", err) + return fmt.Errorf("Bad: Get on Proximity Placement Groups Client: %+v", err) } return nil @@ -168,12 +168,12 @@ func testCheckAzureRMProximityPlacementGroupDisappears(resourceName string) reso return fmt.Errorf("Bad: no resource group found in state for proximity placement group: %s", ppgName) } - client := testAccProvider.Meta().(*ArmClient).ppgClient + client := testAccProvider.Meta().(*ArmClient).compute.ProximityPlacementGroupsClient ctx := testAccProvider.Meta().(*ArmClient).StopContext resp, err := client.Delete(ctx, resourceGroup, ppgName) if err != nil { if !response.WasNotFound(resp.Response) { - return fmt.Errorf("Bad: Delete on ppgClient: %+v", err) + return fmt.Errorf("Bad: Delete on Proximity Placement Groups Client: %+v", err) } } @@ -190,7 +190,7 @@ func testCheckAzureRMProximityPlacementGroupDestroy(s *terraform.State) error { name := rs.Primary.Attributes["name"] resourceGroup := rs.Primary.Attributes["resource_group_name"] - client := testAccProvider.Meta().(*ArmClient).ppgClient + client := testAccProvider.Meta().(*ArmClient).compute.ProximityPlacementGroupsClient ctx := testAccProvider.Meta().(*ArmClient).StopContext resp, err := client.Get(ctx, resourceGroup, name) From ff19089b7ce3483bf39ae5039527aa8df3db921b Mon Sep 17 00:00:00 2001 From: Toby Pettit Date: Mon, 12 Aug 2019 14:43:34 +0100 Subject: [PATCH 12/14] add tests for ppg --- azurerm/resource_arm_availability_set_test.go | 71 +++++++++++++------ ...urce_arm_virtual_machine_scale_set_test.go | 17 +++++ azurerm/resource_arm_virtual_machine_test.go | 70 ++++++++++++++++-- 3 files changed, 130 insertions(+), 28 deletions(-) diff --git a/azurerm/resource_arm_availability_set_test.go b/azurerm/resource_arm_availability_set_test.go index 254c8bdff740..85597d7e4919 100644 --- a/azurerm/resource_arm_availability_set_test.go +++ b/azurerm/resource_arm_availability_set_test.go @@ -2,8 +2,10 @@ package azurerm import ( "fmt" + "net/http" "testing" + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/response" @@ -145,6 +147,7 @@ func TestAccAzureRMAvailabilitySet_withPPG(t *testing.T) { Config: config, Check: resource.ComposeTestCheckFunc( testCheckAzureRMAvailabilitySetExists(resourceName), + testCheckAzureRMAvailabilitySetHasPPG(resourceName), ), }, { @@ -209,32 +212,40 @@ func TestAccAzureRMAvailabilitySet_managed(t *testing.T) { }) } -func testCheckAzureRMAvailabilitySetExists(resourceName string) resource.TestCheckFunc { - return func(s *terraform.State) error { - // Ensure we have enough information in state to look up in API - rs, ok := s.RootModule().Resources[resourceName] - if !ok { - return fmt.Errorf("Not found: %s", resourceName) - } +func testGetAzureRMAvailabilitySet(s *terraform.State, resourceName string) (result *compute.AvailabilitySet, err error) { + // Ensure we have enough information in state to look up in API + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return nil, fmt.Errorf("Not found: %s", resourceName) + } - availSetName := rs.Primary.Attributes["name"] - resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] - if !hasResourceGroup { - return fmt.Errorf("Bad: no resource group found in state for availability set: %s", availSetName) - } + // Name of the actual scale set + name := rs.Primary.Attributes["name"] - client := testAccProvider.Meta().(*ArmClient).compute.AvailabilitySetsClient - ctx := testAccProvider.Meta().(*ArmClient).StopContext - resp, err := client.Get(ctx, resourceGroup, availSetName) - if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("Bad: Availability Set %q (resource group: %q) does not exist", availSetName, resourceGroup) - } + resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] + if !hasResourceGroup { + return nil, fmt.Errorf("Bad: no resource group found in state for availability set: %s", name) + } - return fmt.Errorf("Bad: Get on availSetClient: %+v", err) - } + client := testAccProvider.Meta().(*ArmClient).compute.AvailabilitySetsClient + ctx := testAccProvider.Meta().(*ArmClient).StopContext - return nil + vmss, err := client.Get(ctx, resourceGroup, name) + if err != nil { + return nil, fmt.Errorf("Bad: Get on vmScaleSetClient: %+v", err) + } + + if vmss.StatusCode == http.StatusNotFound { + return nil, fmt.Errorf("Bad: VirtualMachineScaleSet %q (resource group: %q) does not exist", name, resourceGroup) + } + + return &vmss, err +} + +func testCheckAzureRMAvailabilitySetExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, err := testGetAzureRMAvailabilitySet(s, name) + return err } } @@ -291,6 +302,22 @@ func testCheckAzureRMAvailabilitySetDestroy(s *terraform.State) error { return nil } +func testCheckAzureRMAvailabilitySetHasPPG(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + resp, err := testGetAzureRMAvailabilitySet(s, name) + if err != nil { + return err + } + + id := resp.ProximityPlacementGroup.ID + if id == nil || *id == "" { + return fmt.Errorf("Bad: Could not get proximity placement group configurations for scale set %v", name) + } + + return nil + } +} + func testAccAzureRMAvailabilitySet_basic(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { diff --git a/azurerm/resource_arm_virtual_machine_scale_set_test.go b/azurerm/resource_arm_virtual_machine_scale_set_test.go index 7cb44ade794e..55e2c9a24cba 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set_test.go +++ b/azurerm/resource_arm_virtual_machine_scale_set_test.go @@ -136,6 +136,7 @@ func TestAccAzureRMVirtualMachineScaleSet_withPPG(t *testing.T) { Config: config, Check: resource.ComposeTestCheckFunc( testCheckAzureRMVirtualMachineScaleSetExists(resourceName), + testCheckAzureRMVirtualMachineScaleSetHasPPG(resourceName), ), }, }, @@ -1566,6 +1567,22 @@ func testCheckAzureRMVirtualMachineScaleSetHasDataDisks(name string) resource.Te } } +func testCheckAzureRMVirtualMachineScaleSetHasPPG(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + resp, err := testGetAzureRMVirtualMachineScaleSet(s, name) + if err != nil { + return err + } + + id := resp.ProximityPlacementGroup.ID + if id == nil || *id == "" { + return fmt.Errorf("Bad: Could not get proximity placement group configurations for scale set %v", name) + } + + return nil + } +} + func testAccAzureRMVirtualMachineScaleSet_basic(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { diff --git a/azurerm/resource_arm_virtual_machine_test.go b/azurerm/resource_arm_virtual_machine_test.go index b86617824b21..39d241930acf 100644 --- a/azurerm/resource_arm_virtual_machine_test.go +++ b/azurerm/resource_arm_virtual_machine_test.go @@ -15,8 +15,8 @@ import ( ) func TestAccAzureRMVirtualMachine_winTimeZone(t *testing.T) { - resourceName := "azurerm_virtual_machine.test" var vm compute.VirtualMachine + resourceName := "azurerm_virtual_machine.test" ri := tf.AccRandTimeInt() config := testAccAzureRMVirtualMachine_winTimeZone(ri, testLocation()) resource.ParallelTest(t, resource.TestCase{ @@ -27,7 +27,7 @@ func TestAccAzureRMVirtualMachine_winTimeZone(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &vm), + testCheckAzureRMVirtualMachineExists(resourceName, &vm), resource.TestCheckResourceAttr(resourceName, "os_profile_windows_config.59207889.timezone", "Pacific Standard Time"), ), }, @@ -43,7 +43,7 @@ func TestAccAzureRMVirtualMachine_SystemAssignedIdentity(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, - CheckDestroy: testCheckAzureRMVirtualMachineScaleSetDestroy, + CheckDestroy: testCheckAzureRMVirtualMachineDestroy, Steps: []resource.TestStep{ { Config: config, @@ -67,7 +67,7 @@ func TestAccAzureRMVirtualMachine_UserAssignedIdentity(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, - CheckDestroy: testCheckAzureRMVirtualMachineScaleSetDestroy, + CheckDestroy: testCheckAzureRMVirtualMachineDestroy, Steps: []resource.TestStep{ { Config: config, @@ -91,7 +91,7 @@ func TestAccAzureRMVirtualMachine_multipleAssignedIdentity(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, - CheckDestroy: testCheckAzureRMVirtualMachineScaleSetDestroy, + CheckDestroy: testCheckAzureRMVirtualMachineDestroy, Steps: []resource.TestStep{ { Config: config, @@ -115,18 +115,20 @@ func TestAccAzureRMVirtualMachine_withPPG(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, - CheckDestroy: testCheckAzureRMVirtualMachineScaleSetDestroy, + CheckDestroy: testCheckAzureRMVirtualMachineDestroy, Steps: []resource.TestStep{ { Config: config, Check: resource.ComposeTestCheckFunc( testCheckAzureRMVirtualMachineExists(resourceName, &vm), + testCheckAzureRMVirtualMachineHasPPG(resourceName), ), }, }, }) } +/* func testCheckAzureRMVirtualMachineExists(resourceName string, vm *compute.VirtualMachine) resource.TestCheckFunc { return func(s *terraform.State) error { // Ensure we have enough information in state to look up in API @@ -158,6 +160,46 @@ func testCheckAzureRMVirtualMachineExists(resourceName string, vm *compute.Virtu return nil } } +*/ + +func testGetAzureRMVirtualMachine(s *terraform.State, resourceName string) (result *compute.VirtualMachine, err error) { + // Ensure we have enough information in state to look up in API + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return nil, fmt.Errorf("Not found: %s", resourceName) + } + + // Name of the actual scale set + name := rs.Primary.Attributes["name"] + + resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] + if !hasResourceGroup { + return nil, fmt.Errorf("Bad: no resource group found in state for virtual machine: scale set %s", name) + } + + client := testAccProvider.Meta().(*ArmClient).compute.VMClient + ctx := testAccProvider.Meta().(*ArmClient).StopContext + + vm, err := client.Get(ctx, resourceGroup, name, "") + if err != nil { + return nil, fmt.Errorf("Bad: Get on vmClient: %+v", err) + } + + if vm.StatusCode == http.StatusNotFound { + return nil, fmt.Errorf("Bad: VirtualMachine %q (resource group: %q) does not exist", name, resourceGroup) + } + + return &vm, err +} + +func testCheckAzureRMVirtualMachineExists(name string, vm *compute.VirtualMachine) resource.TestCheckFunc { + return func(s *terraform.State) error { + resp, err := testGetAzureRMVirtualMachine(s, name) + + vm = resp + return err + } +} func testCheckAzureRMVirtualMachineDestroy(s *terraform.State) error { client := testAccProvider.Meta().(*ArmClient).compute.VMClient @@ -187,6 +229,22 @@ func testCheckAzureRMVirtualMachineDestroy(s *terraform.State) error { return nil } +func testCheckAzureRMVirtualMachineHasPPG(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + resp, err := testGetAzureRMVirtualMachine(s, name) + if err != nil { + return err + } + + id := resp.ProximityPlacementGroup.ID + if id == nil || *id == "" { + return fmt.Errorf("Bad: Could not get proximity placement group configurations for virtual machine %v", name) + } + + return nil + } +} + func testAccAzureRMVirtualMachine_winTimeZone(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { From cf2cd97e041e8a4a9cf538e285453fea97e6275c Mon Sep 17 00:00:00 2001 From: kt Date: Wed, 4 Sep 2019 18:25:38 -0700 Subject: [PATCH 13/14] address PR concerns --- .../data_source_proximity_placement_group.go | 19 ++-- ...a_source_proximity_placement_group_test.go | 25 ++---- azurerm/helpers/azure/location.go | 1 + azurerm/resource_arm_availability_set.go | 21 +++-- azurerm/resource_arm_availability_set_test.go | 72 ++++++---------- .../resource_arm_proximity_placement_group.go | 40 ++++----- ...urce_arm_proximity_placement_group_test.go | 30 +++---- azurerm/resource_arm_virtual_machine.go | 21 +++-- .../resource_arm_virtual_machine_scale_set.go | 20 ++--- ...urce_arm_virtual_machine_scale_set_test.go | 18 +--- azurerm/resource_arm_virtual_machine_test.go | 86 ++++--------------- 11 files changed, 124 insertions(+), 229 deletions(-) diff --git a/azurerm/data_source_proximity_placement_group.go b/azurerm/data_source_proximity_placement_group.go index 88b38992dfe2..cc1d184ca0dd 100644 --- a/azurerm/data_source_proximity_placement_group.go +++ b/azurerm/data_source_proximity_placement_group.go @@ -6,6 +6,7 @@ import ( "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) @@ -20,6 +21,10 @@ func dataSourceArmProximityPlacementGroup() *schema.Resource { }, "resource_group_name": azure.SchemaResourceGroupNameForDataSource(), + + "location": azure.SchemaLocationForDataSource(), + + "tags": tags.SchemaDataSource(), }, } } @@ -29,19 +34,21 @@ func dataSourceArmProximityPlacementGroupRead(d *schema.ResourceData, meta inter ctx := meta.(*ArmClient).StopContext name := d.Get("name").(string) - resGroup := d.Get("resource_group_name").(string) + resourceGroup := d.Get("resource_group_name").(string) - resp, err := client.Get(ctx, resGroup, name) + resp, err := client.Get(ctx, resourceGroup, name) if err != nil { if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("Error: Proximity Placement Group %q (Resource Group %q) was not found", name, resGroup) + return fmt.Errorf("Error: Proximity Placement Group %q (Resource Group %q) was not found", name, resourceGroup) } - return fmt.Errorf("Error making Read request on Proximity Placement Group %q (Resource Group %q): %+v", name, resGroup, err) + return fmt.Errorf("Error making Read request on Proximity Placement Group %q (Resource Group %q): %+v", name, resourceGroup, err) } d.SetId(*resp.ID) - flattenAndSetTags(d, resp.Tags) - return nil + if location := resp.Location; location != nil { + d.Set("location", azure.NormalizeLocation(*location)) + } + return tags.FlattenAndSet(d, resp.Tags) } diff --git a/azurerm/data_source_proximity_placement_group_test.go b/azurerm/data_source_proximity_placement_group_test.go index f05baaeac098..c0faa49ff11b 100644 --- a/azurerm/data_source_proximity_placement_group_test.go +++ b/azurerm/data_source_proximity_placement_group_test.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform/helper/resource" ) -func TestAccDataSourceProximityPlacementGroup_basic(t *testing.T) { +func TestAccProximityPlacementGroupDataSource_basic(t *testing.T) { dataSourceName := "data.azurerm_proximity_placement_group.test" ri := tf.AccRandTimeInt() location := testLocation() @@ -19,38 +19,25 @@ func TestAccDataSourceProximityPlacementGroup_basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceProximityPlacementGroup_basic(ri, location), + Config: testAccProximityPlacementGroupDataSource_basic(ri, location), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(dataSourceName, "location"), resource.TestCheckResourceAttrSet(dataSourceName, "name"), resource.TestCheckResourceAttrSet(dataSourceName, "resource_group_name"), - resource.TestCheckResourceAttr(dataSourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(dataSourceName, "tags.%", "2"), ), }, }, }) } -func testAccDataSourceProximityPlacementGroup_basic(rInt int, location string) string { +func testAccProximityPlacementGroupDataSource_basic(rInt int, location string) string { return fmt.Sprintf(` -resource "azurerm_resource_group" "test" { - name = "acctestRG-%[1]d" - location = "%[2]s" -} - -resource "azurerm_proximity_placement_group" "test" { - name = "acctestppg-%[1]d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - - tags = { - "foo" = "bar" - } -} +%s data "azurerm_proximity_placement_group" "test" { resource_group_name = "${azurerm_resource_group.test.name}" name = "${azurerm_proximity_placement_group.test.name}" } -`, rInt, location) +`, testAccProximityPlacementGroup_withTags(rInt, location)) } diff --git a/azurerm/helpers/azure/location.go b/azurerm/helpers/azure/location.go index 64c6bb78732d..c2d0341aaefa 100644 --- a/azurerm/helpers/azure/location.go +++ b/azurerm/helpers/azure/location.go @@ -27,6 +27,7 @@ func SchemaLocationOptional() *schema.Schema { } } +// todo should we change this to SchemaLocationComputed func SchemaLocationForDataSource() *schema.Schema { return &schema.Schema{ Type: schema.TypeString, diff --git a/azurerm/resource_arm_availability_set.go b/azurerm/resource_arm_availability_set.go index a251d14b8f60..f0b38cdab81b 100644 --- a/azurerm/resource_arm_availability_set.go +++ b/azurerm/resource_arm_availability_set.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "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" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" @@ -63,9 +64,12 @@ func resourceArmAvailabilitySet() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, - StateFunc: func(id interface{}) string { - return strings.ToLower(id.(string)) - }, + + // We have to ignore case due to incorrect capitalisation of resource group name in + // proximity placement group ID in the response we get from the API request + // + // todo can be removed when https://github.com/Azure/azure-sdk-for-go/issues/5699 is fixed + DiffSuppressFunc: suppress.CaseDifference, }, "tags": tags.Schema(), @@ -112,12 +116,9 @@ func resourceArmAvailabilitySetCreateUpdate(d *schema.ResourceData, meta interfa } if v, ok := d.GetOk("proximity_placement_group_id"); ok { - proximityPlacementGroup := v.(string) - ppg := compute.SubResource{ - ID: &proximityPlacementGroup, + availSet.AvailabilitySetProperties.ProximityPlacementGroup = &compute.SubResource{ + ID: utils.String(v.(string)), } - - availSet.AvailabilitySetProperties.ProximityPlacementGroup = &ppg } if managed { @@ -171,9 +172,7 @@ func resourceArmAvailabilitySetRead(d *schema.ResourceData, meta interface{}) er d.Set("platform_fault_domain_count", props.PlatformFaultDomainCount) if proximityPlacementGroup := props.ProximityPlacementGroup; proximityPlacementGroup != nil { - // Lowercase due to incorrect capitalisation of resource group name in - // proximity placement group ID in response from get VM API request - d.Set("proximity_placement_group_id", strings.ToLower(*proximityPlacementGroup.ID)) + d.Set("proximity_placement_group_id", proximityPlacementGroup.ID) } } diff --git a/azurerm/resource_arm_availability_set_test.go b/azurerm/resource_arm_availability_set_test.go index 33635f9f4fb1..c2abff1d1757 100644 --- a/azurerm/resource_arm_availability_set_test.go +++ b/azurerm/resource_arm_availability_set_test.go @@ -5,7 +5,6 @@ import ( "net/http" "testing" - "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/response" @@ -148,7 +147,7 @@ func TestAccAzureRMAvailabilitySet_withPPG(t *testing.T) { Config: config, Check: resource.ComposeTestCheckFunc( testCheckAzureRMAvailabilitySetExists(resourceName), - testCheckAzureRMAvailabilitySetHasPPG(resourceName), + resource.TestCheckResourceAttrSet(resourceName, "proximity_placement_group_id"), ), }, { @@ -213,40 +212,35 @@ func TestAccAzureRMAvailabilitySet_managed(t *testing.T) { }) } -func testGetAzureRMAvailabilitySet(s *terraform.State, resourceName string) (result *compute.AvailabilitySet, err error) { - // Ensure we have enough information in state to look up in API - rs, ok := s.RootModule().Resources[resourceName] - if !ok { - return nil, fmt.Errorf("Not found: %s", resourceName) - } - - // Name of the actual scale set - name := rs.Primary.Attributes["name"] +func testCheckAzureRMAvailabilitySetExists(resourceName string) resource.TestCheckFunc { + return func(s *terraform.State) error { + // Ensure we have enough information in state to look up in API + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return fmt.Errorf("Not found: %s", resourceName) + } - resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] - if !hasResourceGroup { - return nil, fmt.Errorf("Bad: no resource group found in state for availability set: %s", name) - } + // Name of the actual scale set + name := rs.Primary.Attributes["name"] - client := testAccProvider.Meta().(*ArmClient).compute.AvailabilitySetsClient - ctx := testAccProvider.Meta().(*ArmClient).StopContext + resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] + if !hasResourceGroup { + return fmt.Errorf("Bad: no resource group found in state for availability set: %s", name) + } - vmss, err := client.Get(ctx, resourceGroup, name) - if err != nil { - return nil, fmt.Errorf("Bad: Get on vmScaleSetClient: %+v", err) - } + client := testAccProvider.Meta().(*ArmClient).compute.AvailabilitySetsClient + ctx := testAccProvider.Meta().(*ArmClient).StopContext - if vmss.StatusCode == http.StatusNotFound { - return nil, fmt.Errorf("Bad: VirtualMachineScaleSet %q (resource group: %q) does not exist", name, resourceGroup) - } + vmss, err := client.Get(ctx, resourceGroup, name) + if err != nil { + return fmt.Errorf("Bad: Get on vmScaleSetClient: %+v", err) + } - return &vmss, err -} + if vmss.StatusCode == http.StatusNotFound { + return fmt.Errorf("Bad: VirtualMachineScaleSet %q (resource group: %q) does not exist", name, resourceGroup) + } -func testCheckAzureRMAvailabilitySetExists(name string) resource.TestCheckFunc { - return func(s *terraform.State) error { - _, err := testGetAzureRMAvailabilitySet(s, name) - return err + return nil } } @@ -303,22 +297,6 @@ func testCheckAzureRMAvailabilitySetDestroy(s *terraform.State) error { return nil } -func testCheckAzureRMAvailabilitySetHasPPG(name string) resource.TestCheckFunc { - return func(s *terraform.State) error { - resp, err := testGetAzureRMAvailabilitySet(s, name) - if err != nil { - return err - } - - id := resp.ProximityPlacementGroup.ID - if id == nil || *id == "" { - return fmt.Errorf("Bad: Could not get proximity placement group configurations for scale set %v", name) - } - - return nil - } -} - func testAccAzureRMAvailabilitySet_basic(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { @@ -394,7 +372,7 @@ resource "azurerm_resource_group" "test" { } resource "azurerm_proximity_placement_group" "test" { - name = "acctestPPG-%d" + name = "acctestPPG-%d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } diff --git a/azurerm/resource_arm_proximity_placement_group.go b/azurerm/resource_arm_proximity_placement_group.go index 39e4f07114af..a32a04d0c876 100644 --- a/azurerm/resource_arm_proximity_placement_group.go +++ b/azurerm/resource_arm_proximity_placement_group.go @@ -8,6 +8,8 @@ import ( "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" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) @@ -17,22 +19,24 @@ func resourceArmProximityPlacementGroup() *schema.Resource { Read: resourceArmProximityPlacementGroupRead, Update: resourceArmProximityPlacementGroupCreateUpdate, Delete: resourceArmProximityPlacementGroupDelete, + Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, Schema: map[string]*schema.Schema{ "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.NoEmptyStrings, }, "resource_group_name": azure.SchemaResourceGroupName(), "location": azure.SchemaLocation(), - "tags": tagsSchema(), + "tags": tags.Schema(), }, } } @@ -44,13 +48,13 @@ func resourceArmProximityPlacementGroupCreateUpdate(d *schema.ResourceData, meta log.Printf("[INFO] preparing arguments for AzureRM Proximity Placement Group creation.") name := d.Get("name").(string) - resGroup := d.Get("resource_group_name").(string) + resourceGroup := d.Get("resource_group_name").(string) if requireResourcesToBeImported && d.IsNewResource() { - existing, err := client.Get(ctx, resGroup, name) + existing, err := client.Get(ctx, resourceGroup, name) if err != nil { if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("Error checking for presence of existing Proximity Placement Group %q (Resource Group %q): %s", name, resGroup, err) + return fmt.Errorf("Error checking for presence of existing Proximity Placement Group %q (Resource Group %q): %s", name, resourceGroup, err) } } @@ -59,16 +63,13 @@ func resourceArmProximityPlacementGroupCreateUpdate(d *schema.ResourceData, meta } } - location := azure.NormalizeLocation(d.Get("location").(string)) - tags := d.Get("tags").(map[string]interface{}) - ppg := compute.ProximityPlacementGroup{ Name: &name, - Location: &location, - Tags: expandTags(tags), + Location: utils.String(azure.NormalizeLocation(d.Get("location").(string))), + Tags: tags.Expand(d.Get("tags").(map[string]interface{})), } - resp, err := client.CreateOrUpdate(ctx, resGroup, name, ppg) + resp, err := client.CreateOrUpdate(ctx, resourceGroup, name, ppg) if err != nil { return err } @@ -86,27 +87,25 @@ func resourceArmProximityPlacementGroupRead(d *schema.ResourceData, meta interfa if err != nil { return err } - resGroup := id.ResourceGroup + resourceGroup := id.ResourceGroup name := id.Path["proximityPlacementGroups"] - resp, err := client.Get(ctx, resGroup, name) + resp, err := client.Get(ctx, resourceGroup, name) if err != nil { if utils.ResponseWasNotFound(resp.Response) { d.SetId("") return nil } - return fmt.Errorf("Error making Read request on Proximity Placement Group %q (Resource Group %q): %+v", name, resGroup, err) + return fmt.Errorf("Error making Read request on Proximity Placement Group %q (Resource Group %q): %+v", name, resourceGroup, err) } d.Set("name", resp.Name) - d.Set("resource_group_name", resGroup) + d.Set("resource_group_name", resourceGroup) if location := resp.Location; location != nil { d.Set("location", azure.NormalizeLocation(*location)) } - flattenAndSetTags(d, resp.Tags) - - return nil + return tags.FlattenAndSet(d, resp.Tags) } func resourceArmProximityPlacementGroupDelete(d *schema.ResourceData, meta interface{}) error { @@ -121,6 +120,5 @@ func resourceArmProximityPlacementGroupDelete(d *schema.ResourceData, meta inter name := id.Path["proximityPlacementGroups"] _, err = client.Delete(ctx, resGroup, name) - return err } diff --git a/azurerm/resource_arm_proximity_placement_group_test.go b/azurerm/resource_arm_proximity_placement_group_test.go index 85168d4350bc..48b60c8f1eaf 100644 --- a/azurerm/resource_arm_proximity_placement_group_test.go +++ b/azurerm/resource_arm_proximity_placement_group_test.go @@ -11,10 +11,10 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) -func TestAccAzureRMProximityPlacementGroup_basic(t *testing.T) { +func TestAccProximityPlacementGroup_basic(t *testing.T) { resourceName := "azurerm_proximity_placement_group.test" ri := tf.AccRandTimeInt() - config := testAccAzureRMProximityPlacementGroup_basic(ri, testLocation()) + config := testAccProximityPlacementGroup_basic(ri, testLocation()) resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -36,7 +36,7 @@ func TestAccAzureRMProximityPlacementGroup_basic(t *testing.T) { }) } -func TestAccAzureRMProximityPlacementGroup_requiresImport(t *testing.T) { +func TestAccProximityPlacementGroup_requiresImport(t *testing.T) { if !requireResourcesToBeImported { t.Skip("Skipping since resources aren't required to be imported") return @@ -52,23 +52,23 @@ func TestAccAzureRMProximityPlacementGroup_requiresImport(t *testing.T) { CheckDestroy: testCheckAzureRMProximityPlacementGroupDestroy, Steps: []resource.TestStep{ { - Config: testAccAzureRMProximityPlacementGroup_basic(ri, location), + Config: testAccProximityPlacementGroup_basic(ri, location), Check: resource.ComposeTestCheckFunc( testCheckAzureRMProximityPlacementGroupExists(resourceName), ), }, { - Config: testAccAzureRMProximityPlacementGroup_requiresImport(ri, location), + Config: testAccProximityPlacementGroup_requiresImport(ri, location), ExpectError: testRequiresImportError("azurerm_proximity_placement_group"), }, }, }) } -func TestAccAzureRMProximityPlacementGroup_disappears(t *testing.T) { +func TestAccProximityPlacementGroup_disappears(t *testing.T) { resourceName := "azurerm_proximity_placement_group.test" ri := tf.AccRandTimeInt() - config := testAccAzureRMProximityPlacementGroup_basic(ri, testLocation()) + config := testAccProximityPlacementGroup_basic(ri, testLocation()) resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -87,12 +87,12 @@ func TestAccAzureRMProximityPlacementGroup_disappears(t *testing.T) { }) } -func TestAccAzureRMProximityPlacementGroup_withTags(t *testing.T) { +func TestAccProximityPlacementGroup_withTags(t *testing.T) { resourceName := "azurerm_proximity_placement_group.test" ri := tf.AccRandTimeInt() location := testLocation() - preConfig := testAccAzureRMProximityPlacementGroup_withTags(ri, location) - postConfig := testAccAzureRMProximityPlacementGroup_withUpdatedTags(ri, location) + preConfig := testAccProximityPlacementGroup_withTags(ri, location) + postConfig := testAccProximityPlacementGroup_withUpdatedTags(ri, location) resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -207,7 +207,7 @@ func testCheckAzureRMProximityPlacementGroupDestroy(s *terraform.State) error { return nil } -func testAccAzureRMProximityPlacementGroup_basic(rInt int, location string) string { +func testAccProximityPlacementGroup_basic(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { name = "acctestRG-%d" @@ -222,8 +222,8 @@ resource "azurerm_proximity_placement_group" "test" { `, rInt, location, rInt) } -func testAccAzureRMProximityPlacementGroup_requiresImport(rInt int, location string) string { - template := testAccAzureRMProximityPlacementGroup_basic(rInt, location) +func testAccProximityPlacementGroup_requiresImport(rInt int, location string) string { + template := testAccProximityPlacementGroup_basic(rInt, location) return fmt.Sprintf(` %s @@ -235,7 +235,7 @@ resource "azurerm_proximity_placement_group" "import" { `, template) } -func testAccAzureRMProximityPlacementGroup_withTags(rInt int, location string) string { +func testAccProximityPlacementGroup_withTags(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { name = "acctestRG-%d" @@ -255,7 +255,7 @@ resource "azurerm_proximity_placement_group" "test" { `, rInt, location, rInt) } -func testAccAzureRMProximityPlacementGroup_withUpdatedTags(rInt int, location string) string { +func testAccProximityPlacementGroup_withUpdatedTags(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { name = "acctestRG-%d" diff --git a/azurerm/resource_arm_virtual_machine.go b/azurerm/resource_arm_virtual_machine.go index b22ac2e70700..bfa4eb7b91ad 100644 --- a/azurerm/resource_arm_virtual_machine.go +++ b/azurerm/resource_arm_virtual_machine.go @@ -89,9 +89,12 @@ func resourceArmVirtualMachine() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, - StateFunc: func(id interface{}) string { - return strings.ToLower(id.(string)) - }, + + // We have to ignore case due to incorrect capitalisation of resource group name in + // proximity placement group ID in the response we get from the API request + // + // todo can be removed when https://github.com/Azure/azure-sdk-for-go/issues/5699 is fixed + DiffSuppressFunc: suppress.CaseDifference, }, "identity": { @@ -682,12 +685,9 @@ func resourceArmVirtualMachineCreateUpdate(d *schema.ResourceData, meta interfac } if v, ok := d.GetOk("proximity_placement_group_id"); ok { - proximityPlacementGroup := v.(string) - ppg := compute.SubResource{ - ID: &proximityPlacementGroup, + properties.ProximityPlacementGroup = &compute.SubResource{ + ID: utils.String(v.(string)), } - - properties.ProximityPlacementGroup = &ppg } vm := compute.VirtualMachine{ @@ -794,13 +794,12 @@ func resourceArmVirtualMachineRead(d *schema.ResourceData, meta interface{}) err if availabilitySet := props.AvailabilitySet; availabilitySet != nil { // Lowercase due to incorrect capitalisation of resource group name in // availability set ID in response from get VM API request + // todo can be removed when https://github.com/Azure/azure-sdk-for-go/issues/5699 is fixed d.Set("availability_set_id", strings.ToLower(*availabilitySet.ID)) } if proximityPlacementGroup := props.ProximityPlacementGroup; proximityPlacementGroup != nil { - // Lowercase due to incorrect capitalisation of resource group name in - // proximity placement group ID in response from get VM API request - d.Set("proximity_placement_group_id", strings.ToLower(*proximityPlacementGroup.ID)) + d.Set("proximity_placement_group_id", proximityPlacementGroup.ID) } if profile := props.HardwareProfile; profile != nil { diff --git a/azurerm/resource_arm_virtual_machine_scale_set.go b/azurerm/resource_arm_virtual_machine_scale_set.go index f1dafcba00b6..198bdec879bf 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set.go +++ b/azurerm/resource_arm_virtual_machine_scale_set.go @@ -751,9 +751,12 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, - StateFunc: func(id interface{}) string { - return strings.ToLower(id.(string)) - }, + + // We have to ignore case due to incorrect capitalisation of resource group name in + // proximity placement group ID in the response we get from the API request + // + // todo can be removed when https://github.com/Azure/azure-sdk-for-go/issues/5699 is fixed + DiffSuppressFunc: suppress.CaseDifference, }, "tags": tags.Schema(), @@ -867,12 +870,9 @@ func resourceArmVirtualMachineScaleSetCreateUpdate(d *schema.ResourceData, meta } if v, ok := d.GetOk("proximity_placement_group_id"); ok { - proximityPlacementGroup := v.(string) - ppg := compute.SubResource{ - ID: &proximityPlacementGroup, + scaleSetProps.ProximityPlacementGroup = &compute.SubResource{ + ID: utils.String(v.(string)), } - - scaleSetProps.ProximityPlacementGroup = &ppg } properties := compute.VirtualMachineScaleSet{ @@ -972,9 +972,7 @@ func resourceArmVirtualMachineScaleSetRead(d *schema.ResourceData, meta interfac } if proximityPlacementGroup := properties.ProximityPlacementGroup; proximityPlacementGroup != nil { - // Lowercase due to incorrect capitalisation of resource group name in - // proximity placement group ID in response from get VM API request - d.Set("proximity_placement_group_id", strings.ToLower(*proximityPlacementGroup.ID)) + d.Set("proximity_placement_group_id", proximityPlacementGroup.ID) } } d.Set("overprovision", properties.Overprovision) diff --git a/azurerm/resource_arm_virtual_machine_scale_set_test.go b/azurerm/resource_arm_virtual_machine_scale_set_test.go index bd1f43fcd26e..168556a4f76f 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set_test.go +++ b/azurerm/resource_arm_virtual_machine_scale_set_test.go @@ -137,7 +137,7 @@ func TestAccAzureRMVirtualMachineScaleSet_withPPG(t *testing.T) { Config: config, Check: resource.ComposeTestCheckFunc( testCheckAzureRMVirtualMachineScaleSetExists(resourceName), - testCheckAzureRMVirtualMachineScaleSetHasPPG(resourceName), + resource.TestCheckResourceAttrSet(resourceName, "proximity_placement_group_id"), ), }, }, @@ -1568,22 +1568,6 @@ func testCheckAzureRMVirtualMachineScaleSetHasDataDisks(name string) resource.Te } } -func testCheckAzureRMVirtualMachineScaleSetHasPPG(name string) resource.TestCheckFunc { - return func(s *terraform.State) error { - resp, err := testGetAzureRMVirtualMachineScaleSet(s, name) - if err != nil { - return err - } - - id := resp.ProximityPlacementGroup.ID - if id == nil || *id == "" { - return fmt.Errorf("Bad: Could not get proximity placement group configurations for scale set %v", name) - } - - return nil - } -} - func testAccAzureRMVirtualMachineScaleSet_basic(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { diff --git a/azurerm/resource_arm_virtual_machine_test.go b/azurerm/resource_arm_virtual_machine_test.go index 39d241930acf..6f967b816bb3 100644 --- a/azurerm/resource_arm_virtual_machine_test.go +++ b/azurerm/resource_arm_virtual_machine_test.go @@ -111,24 +111,23 @@ func TestAccAzureRMVirtualMachine_withPPG(t *testing.T) { resourceName := "azurerm_virtual_machine.test" ri := tf.AccRandTimeInt() rs := acctest.RandString(14) - config := testAccAzureRMVirtualMachinePPG(ri, testLocation(), rs) + resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testCheckAzureRMVirtualMachineDestroy, Steps: []resource.TestStep{ { - Config: config, + Config: testAccAzureRMVirtualMachinePPG(ri, testLocation(), rs), Check: resource.ComposeTestCheckFunc( testCheckAzureRMVirtualMachineExists(resourceName, &vm), - testCheckAzureRMVirtualMachineHasPPG(resourceName), + resource.TestCheckResourceAttrSet(resourceName, "proximity_placement_group_id"), ), }, }, }) } -/* func testCheckAzureRMVirtualMachineExists(resourceName string, vm *compute.VirtualMachine) resource.TestCheckFunc { return func(s *terraform.State) error { // Ensure we have enough information in state to look up in API @@ -160,46 +159,6 @@ func testCheckAzureRMVirtualMachineExists(resourceName string, vm *compute.Virtu return nil } } -*/ - -func testGetAzureRMVirtualMachine(s *terraform.State, resourceName string) (result *compute.VirtualMachine, err error) { - // Ensure we have enough information in state to look up in API - rs, ok := s.RootModule().Resources[resourceName] - if !ok { - return nil, fmt.Errorf("Not found: %s", resourceName) - } - - // Name of the actual scale set - name := rs.Primary.Attributes["name"] - - resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] - if !hasResourceGroup { - return nil, fmt.Errorf("Bad: no resource group found in state for virtual machine: scale set %s", name) - } - - client := testAccProvider.Meta().(*ArmClient).compute.VMClient - ctx := testAccProvider.Meta().(*ArmClient).StopContext - - vm, err := client.Get(ctx, resourceGroup, name, "") - if err != nil { - return nil, fmt.Errorf("Bad: Get on vmClient: %+v", err) - } - - if vm.StatusCode == http.StatusNotFound { - return nil, fmt.Errorf("Bad: VirtualMachine %q (resource group: %q) does not exist", name, resourceGroup) - } - - return &vm, err -} - -func testCheckAzureRMVirtualMachineExists(name string, vm *compute.VirtualMachine) resource.TestCheckFunc { - return func(s *terraform.State) error { - resp, err := testGetAzureRMVirtualMachine(s, name) - - vm = resp - return err - } -} func testCheckAzureRMVirtualMachineDestroy(s *terraform.State) error { client := testAccProvider.Meta().(*ArmClient).compute.VMClient @@ -229,22 +188,6 @@ func testCheckAzureRMVirtualMachineDestroy(s *terraform.State) error { return nil } -func testCheckAzureRMVirtualMachineHasPPG(name string) resource.TestCheckFunc { - return func(s *terraform.State) error { - resp, err := testGetAzureRMVirtualMachine(s, name) - if err != nil { - return err - } - - id := resp.ProximityPlacementGroup.ID - if id == nil || *id == "" { - return fmt.Errorf("Bad: Could not get proximity placement group configurations for virtual machine %v", name) - } - - return nil - } -} - func testAccAzureRMVirtualMachine_winTimeZone(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { @@ -633,26 +576,27 @@ resource "azurerm_virtual_machine" "test" { func testAccAzureRMVirtualMachinePPG(rInt int, location string, rString string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } + resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } resource "azurerm_network_interface" "test" { - name = "acctni-%d" + name = "acctni-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" @@ -664,7 +608,7 @@ resource "azurerm_network_interface" "test" { } resource "azurerm_storage_account" "test" { - name = "accsa%d" + name = "accsa%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" account_tier = "Standard" @@ -683,13 +627,13 @@ resource "azurerm_storage_container" "test" { } resource "azurerm_proximity_placement_group" "test" { - name = "accPPG-%d" + name = "accPPG-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_virtual_machine" "test" { - name = "acctvm-%d" + name = "acctvm-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" network_interface_ids = ["${azurerm_network_interface.test.id}"] @@ -711,7 +655,7 @@ resource "azurerm_virtual_machine" "test" { } os_profile { - computer_name = "hn%d" + computer_name = "hn%[1]d" admin_username = "testadmin" admin_password = "Password1234!" } @@ -720,12 +664,12 @@ resource "azurerm_virtual_machine" "test" { disable_password_authentication = false } - proximity_placement_group_id = "${azure_proximity_placement_group.test.id}" + proximity_placement_group_id = "${azurerm_proximity_placement_group.test.id}" tags = { environment = "Production" cost-center = "Ops" } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } From 843ce8aa296b8718c16d83bfc5c2716eb421231c Mon Sep 17 00:00:00 2001 From: kt Date: Wed, 4 Sep 2019 18:35:01 -0700 Subject: [PATCH 14/14] fix docs --- azurerm/resource_arm_virtual_machine_scale_set_test.go | 4 ++-- website/docs/r/availability_set.html.markdown | 2 +- website/docs/r/virtual_machine.html.markdown | 2 +- website/docs/r/virtual_machine_scale_set.html.markdown | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/azurerm/resource_arm_virtual_machine_scale_set_test.go b/azurerm/resource_arm_virtual_machine_scale_set_test.go index 168556a4f76f..209b07b1090e 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set_test.go +++ b/azurerm/resource_arm_virtual_machine_scale_set_test.go @@ -1922,7 +1922,7 @@ resource "azurerm_storage_container" "test" { } resource "azurerm_proximity_placement_group" "test" { - name = "accPPG-%[1]%d" + name = "accPPG-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } @@ -1971,7 +1971,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { version = "latest" } - proximity_placement_group_id = "${azure_proximity_placement_group.test.id}" + proximity_placement_group_id = "${azurerm_proximity_placement_group.test.id}" } `, rInt, location) } diff --git a/website/docs/r/availability_set.html.markdown b/website/docs/r/availability_set.html.markdown index 1a5ee4f4a9e8..4dffa5a7ad0d 100644 --- a/website/docs/r/availability_set.html.markdown +++ b/website/docs/r/availability_set.html.markdown @@ -48,7 +48,7 @@ The following arguments are supported: ~> **NOTE:** The number of Fault Domains varies depending on which Azure Region you're using - [a list can be found here](https://github.com/MicrosoftDocs/azure-docs/blob/master/includes/managed-disks-common-fault-domain-region-list.md). -* `proximity_placement_group_id` - (Optional) The ID of the Proximity Placement Group to which this Virtual Machine should be assigned. +* `proximity_placement_group_id` - (Optional) The ID of the Proximity Placement Group to which this Virtual Machine should be assigned. Changing this forces a new resource to be created * `managed` - (Optional) Specifies whether the availability set is managed or not. Possible values are `true` (to specify aligned) or `false` (to specify classic). Default is `false`. diff --git a/website/docs/r/virtual_machine.html.markdown b/website/docs/r/virtual_machine.html.markdown index 02fc03783c85..79087877e668 100644 --- a/website/docs/r/virtual_machine.html.markdown +++ b/website/docs/r/virtual_machine.html.markdown @@ -134,7 +134,7 @@ The following arguments are supported: * `primary_network_interface_id` - (Optional) The ID of the Network Interface (which must be attached to the Virtual Machine) which should be the Primary Network Interface for this Virtual Machine. -* `proximity_placement_group_id` - (Optional) The ID of the Proximity Placement Group to which this Virtual Machine should be assigned. +* `proximity_placement_group_id` - (Optional) The ID of the Proximity Placement Group to which this Virtual Machine should be assigned. Changing this forces a new resource to be created * `storage_data_disk` - (Optional) One or more `storage_data_disk` blocks. diff --git a/website/docs/r/virtual_machine_scale_set.html.markdown b/website/docs/r/virtual_machine_scale_set.html.markdown index 77067f0a9ec5..1e871c78681c 100644 --- a/website/docs/r/virtual_machine_scale_set.html.markdown +++ b/website/docs/r/virtual_machine_scale_set.html.markdown @@ -275,7 +275,7 @@ The following arguments are supported: * `os_profile_linux_config` - (Required, when a linux machine) A Linux config block as documented below. -* `proximity_placement_group_id` - (Optional) The ID of the Proximity Placement Group to which this Virtual Machine should be assigned. +* `proximity_placement_group_id` - (Optional) The ID of the Proximity Placement Group to which this Virtual Machine should be assigned. Changing this forces a new resource to be created * `sku` - (Required) A sku block as documented below.