From 6b49ec7621dad4afe71ffe54407e3a738bb90c2b Mon Sep 17 00:00:00 2001 From: Tao <104055472+teowa@users.noreply.github.com> Date: Tue, 25 Jul 2023 11:31:23 +0800 Subject: [PATCH 1/4] rename to graph_services_account --- .../services/graph/graph_account_resource.go | 18 ++++- .../graph/graph_account_resource_test.go | 20 +++--- internal/services/graph/registration.go | 1 + website/docs/r/graph_account.html.markdown | 2 + .../r/graph_services_account.html.markdown | 70 +++++++++++++++++++ 5 files changed, 100 insertions(+), 11 deletions(-) create mode 100644 website/docs/r/graph_services_account.html.markdown diff --git a/internal/services/graph/graph_account_resource.go b/internal/services/graph/graph_account_resource.go index 11470fccac5f..3b451dbcb35a 100644 --- a/internal/services/graph/graph_account_resource.go +++ b/internal/services/graph/graph_account_resource.go @@ -16,11 +16,27 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) +var _ sdk.Resource = ServicesAccountResource{} +var _ sdk.ResourceWithUpdate = ServicesAccountResource{} + +type ServicesAccountResource struct { + AccountResource +} + +func (r ServicesAccountResource) ResourceType() string { + return "azurerm_graph_services_account" +} + var _ sdk.Resource = AccountResource{} var _ sdk.ResourceWithUpdate = AccountResource{} +var _ sdk.ResourceWithDeprecationReplacedBy = AccountResource{} type AccountResource struct{} +func (r AccountResource) DeprecatedInFavourOfResource() string { + return "azurerm_graph_services_account" +} + func (r AccountResource) ModelObject() interface{} { return &AccountResourceSchema{} } @@ -90,7 +106,7 @@ func (r AccountResource) Create() sdk.ResourceFunc { } } if !response.WasNotFound(existing.HttpResponse) { - return metadata.ResourceRequiresImport(r.ResourceType(), id) + return metadata.ResourceRequiresImport("azurerm_graph_services_account", id) } payload := graphservicesprods.AccountResource{ diff --git a/internal/services/graph/graph_account_resource_test.go b/internal/services/graph/graph_account_resource_test.go index b748867ee453..4605cc6978b9 100644 --- a/internal/services/graph/graph_account_resource_test.go +++ b/internal/services/graph/graph_account_resource_test.go @@ -30,7 +30,7 @@ func TestAccGraphAccount(t *testing.T) { type AccountTestResource struct{} func testAccGraphAccount_basic(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_graph_account", "test") + data := acceptance.BuildTestData(t, "azurerm_graph_services_account", "test") r := AccountTestResource{} data.ResourceSequentialTest(t, r, []acceptance.TestStep{ @@ -45,7 +45,7 @@ func testAccGraphAccount_basic(t *testing.T) { } func testAccGraphAccount_requiresImport(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_graph_account", "test") + data := acceptance.BuildTestData(t, "azurerm_graph_services_account", "test") r := AccountTestResource{} @@ -61,7 +61,7 @@ func testAccGraphAccount_requiresImport(t *testing.T) { } func testAccGraphAccount_complete(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_graph_account", "test") + data := acceptance.BuildTestData(t, "azurerm_graph_services_account", "test") r := AccountTestResource{} data.ResourceSequentialTest(t, r, []acceptance.TestStep{ @@ -76,7 +76,7 @@ func testAccGraphAccount_complete(t *testing.T) { } func testAccGraphAccount_update(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_graph_account", "test") + data := acceptance.BuildTestData(t, "azurerm_graph_services_account", "test") r := AccountTestResource{} data.ResourceSequentialTest(t, r, []acceptance.TestStep{ @@ -120,7 +120,7 @@ func (r AccountTestResource) basic(data acceptance.TestData) string { return fmt.Sprintf(` %s -resource "azurerm_graph_account" "test" { +resource "azurerm_graph_services_account" "test" { name = "acctesta-%[2]d" application_id = "%[3]s" resource_group_name = azurerm_resource_group.test.name @@ -132,10 +132,10 @@ func (r AccountTestResource) requiresImport(data acceptance.TestData) string { return fmt.Sprintf(` %s -resource "azurerm_graph_account" "import" { - application_id = azurerm_graph_account.test.application_id - name = azurerm_graph_account.test.name - resource_group_name = azurerm_graph_account.test.resource_group_name +resource "azurerm_graph_services_account" "import" { + application_id = azurerm_graph_services_account.test.application_id + name = azurerm_graph_services_account.test.name + resource_group_name = azurerm_graph_services_account.test.resource_group_name } `, r.basic(data)) } @@ -144,7 +144,7 @@ func (r AccountTestResource) complete(data acceptance.TestData) string { return fmt.Sprintf(` %s -resource "azurerm_graph_account" "test" { +resource "azurerm_graph_services_account" "test" { name = "acctesta-%[2]d" resource_group_name = azurerm_resource_group.test.name application_id = "%[3]s" diff --git a/internal/services/graph/registration.go b/internal/services/graph/registration.go index 2310a70cc3f1..d0cd7e3e969f 100644 --- a/internal/services/graph/registration.go +++ b/internal/services/graph/registration.go @@ -31,5 +31,6 @@ func (r Registration) DataSources() []sdk.DataSource { func (r Registration) Resources() []sdk.Resource { return []sdk.Resource{ AccountResource{}, + ServicesAccountResource{}, } } diff --git a/website/docs/r/graph_account.html.markdown b/website/docs/r/graph_account.html.markdown index 36d47cb0ae1f..288bda1f0b98 100644 --- a/website/docs/r/graph_account.html.markdown +++ b/website/docs/r/graph_account.html.markdown @@ -10,6 +10,8 @@ description: |- Manages a Graph Account. +!> **NOTE:** This resource has been deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use [`azurerm_graph_services_account`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/graph_services_account) resources instead. + ## Example Usage ```hcl diff --git a/website/docs/r/graph_services_account.html.markdown b/website/docs/r/graph_services_account.html.markdown new file mode 100644 index 000000000000..59e54844c3c4 --- /dev/null +++ b/website/docs/r/graph_services_account.html.markdown @@ -0,0 +1,70 @@ +--- +subcategory: "Graph" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_graph_services_account" +description: |- + Manages a Graph Services Account. +--- + +# azurerm_graph_services_account + +Manages a Graph Services Account. + +## Example Usage + +```hcl +resource "azuread_application" "example" { + display_name = "example-app" +} +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} +resource "azurerm_graph_services_account" "example" { + name = "example" + resource_group_name = azurerm_resource_group.example.name + application_id = azuread_application.example.application_id + tags = { + environment = "Production" + } +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name of this Account. Changing this forces a new Account to be created. + +* `resource_group_name` - (Required) Specifies the name of the Resource Group within which this Account should exist. Changing this forces a new Account to be created. + +* `application_id` - (Required) Customer owned application ID. Changing this forces a new Account to be created. + +* `tags` - (Optional) A mapping of tags which should be assigned to the Account. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Account. + +* `billing_plan_id` - Billing Plan Id. + +--- + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating this Account. +* `delete` - (Defaults to 30 minutes) Used when deleting this Account. +* `read` - (Defaults to 5 minutes) Used when retrieving this Account. +* `update` - (Defaults to 30 minutes) Used when updating this Account. + +## Import + +An existing Account can be imported into Terraform using the `resource id`, e.g. + +```shell +terraform import azurerm_graph_services_account.example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.GraphServices/accounts/account1 +``` From 203b200e993bc4996f190caca49fce3637ddfea4 Mon Sep 17 00:00:00 2001 From: Tao <104055472+teowa@users.noreply.github.com> Date: Thu, 27 Jul 2023 02:07:45 +0800 Subject: [PATCH 2/4] rename category --- .github/labeler-issue-triage.yml | 7 +++++-- .teamcity/components/generated/services.kt | 2 +- internal/clients/client.go | 2 +- internal/provider/services.go | 4 ++-- .../services/{graph => graphservices}/client/client.go | 0 .../{graph => graphservices}/graph_account_resource.go | 2 +- .../graph_account_resource_test.go | 2 +- internal/services/{graph => graphservices}/registration.go | 6 +++--- website/allowed-subcategories | 2 +- website/docs/r/graph_account.html.markdown | 6 +++--- website/docs/r/graph_services_account.html.markdown | 6 +++--- 11 files changed, 21 insertions(+), 18 deletions(-) rename internal/services/{graph => graphservices}/client/client.go (100%) rename internal/services/{graph => graphservices}/graph_account_resource.go (99%) rename internal/services/{graph => graphservices}/graph_account_resource_test.go (99%) rename internal/services/{graph => graphservices}/registration.go (90%) diff --git a/.github/labeler-issue-triage.yml b/.github/labeler-issue-triage.yml index c4ddb57f8fe0..8f17e2a65b3d 100644 --- a/.github/labeler-issue-triage.yml +++ b/.github/labeler-issue-triage.yml @@ -142,7 +142,7 @@ service/frontdoor: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_frontdoor((.|\n)*)###' service/graph: - - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_graph_account((.|\n)*)###' + - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_graph_((.|\n)*)###' service/hdinsight: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_hdinsight_((.|\n)*)###' @@ -238,7 +238,10 @@ service/netapp: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_netapp_((.|\n)*)###' service/network: - - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_(application_gateway\W+|application_security_group\W+|bastion_host|express_route_|ip_group|local_network_gateway|nat_gateway|network_|point_to_site_vpn_gateway|private_endpoint\W+|private_endpoint_application_security_group_association\W+|private_endpoint_connection\W+|private_link_service\W+|private_link_service_endpoint_connections\W+|public_ip|route|subnet|virtual_hub\W+|virtual_hub_bgp_connection\W+|virtual_hub_connection\W+|virtual_hub_ip\W+|virtual_hub_route_table\W+|virtual_hub_route_table_route\W+|virtual_hub_security_partner_provider\W+|virtual_machine_packet_capture\W+|virtual_machine_scale_set_packet_capture\W+|virtual_network\W+|virtual_network_dns_servers\W+|virtual_network_gateway\W+|virtual_network_gateway_connection\W+|virtual_network_gateway_nat_rule\W+|virtual_network_peering\W+|virtual_wan\W+|vpn_|web_application_firewall_policy)((.|\n)*)###' + - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_(application_gateway\W+|application_security_group\W+|bastion_host|express_route_|ip_group|local_network_gateway|nat_gateway|network_connection_monitor\W+|network_ddos_protection_plan\W+|network_interface\W+|network_interface_application_gateway_backend_address_pool_association\W+|network_interface_application_security_group_association\W+|network_interface_backend_address_pool_association\W+|network_interface_nat_rule_association\W+|network_interface_security_group_association\W+|network_manager\W+|network_manager_admin_rule\W+|network_manager_admin_rule_collection\W+|network_manager_connectivity_configuration\W+|network_manager_deployment\W+|network_manager_management_group_connection\W+|network_manager_network_group\W+|network_manager_network_group\W+|network_manager_scope_connection\W+|network_manager_security_admin_configuration\W+|network_manager_static_member\W+|network_manager_subscription_connection\W+|network_packet_capture\W+|network_profile\W+|network_security_group\W+|network_security_rule\W+|network_service_tags\W+|network_watcher\W+|network_watcher_flow_log\W+|point_to_site_vpn_gateway|private_endpoint\W+|private_endpoint_application_security_group_association\W+|private_endpoint_connection\W+|private_link_service\W+|private_link_service_endpoint_connections\W+|public_ip|route|subnet|virtual_hub\W+|virtual_hub_bgp_connection\W+|virtual_hub_connection\W+|virtual_hub_ip\W+|virtual_hub_route_table\W+|virtual_hub_route_table_route\W+|virtual_hub_security_partner_provider\W+|virtual_machine_packet_capture\W+|virtual_machine_scale_set_packet_capture\W+|virtual_network\W+|virtual_network_dns_servers\W+|virtual_network_gateway\W+|virtual_network_gateway_connection\W+|virtual_network_gateway_nat_rule\W+|virtual_network_peering\W+|virtual_wan\W+|vpn_|web_application_firewall_policy)((.|\n)*)###' + +service/network-function: + - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_network_function_azure_traffic_collector((.|\n)*)###' service/nginx: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_nginx_((.|\n)*)###' diff --git a/.teamcity/components/generated/services.kt b/.teamcity/components/generated/services.kt index 4228783fe1fd..1bd422034a6f 100644 --- a/.teamcity/components/generated/services.kt +++ b/.teamcity/components/generated/services.kt @@ -52,7 +52,7 @@ var services = mapOf( "firewall" to "Firewall", "fluidrelay" to "Fluid Relay", "frontdoor" to "FrontDoor", - "graph" to "Graph", + "graph" to "Graph Services", "hdinsight" to "HDInsight", "hpccache" to "HPC Cache", "hsm" to "Hardware Security Module", diff --git a/internal/clients/client.go b/internal/clients/client.go index f70dc02ada3e..2ee7842ba185 100644 --- a/internal/clients/client.go +++ b/internal/clients/client.go @@ -68,7 +68,7 @@ import ( firewall "github.com/hashicorp/terraform-provider-azurerm/internal/services/firewall/client" fluidrelay "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/client" frontdoor "github.com/hashicorp/terraform-provider-azurerm/internal/services/frontdoor/client" - graph "github.com/hashicorp/terraform-provider-azurerm/internal/services/graph/client" + graph "github.com/hashicorp/terraform-provider-azurerm/internal/services/graphservices/client" hdinsight "github.com/hashicorp/terraform-provider-azurerm/internal/services/hdinsight/client" healthcare "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/client" hpccache "github.com/hashicorp/terraform-provider-azurerm/internal/services/hpccache/client" diff --git a/internal/provider/services.go b/internal/provider/services.go index 9092a224e507..f5679a8d419e 100644 --- a/internal/provider/services.go +++ b/internal/provider/services.go @@ -54,7 +54,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/services/firewall" "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay" "github.com/hashicorp/terraform-provider-azurerm/internal/services/frontdoor" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/graph" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/graphservices" "github.com/hashicorp/terraform-provider-azurerm/internal/services/hdinsight" "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare" "github.com/hashicorp/terraform-provider-azurerm/internal/services/hpccache" @@ -157,7 +157,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration { domainservices.Registration{}, eventhub.Registration{}, fluidrelay.Registration{}, - graph.Registration{}, + graphservices.Registration{}, hybridcompute.Registration{}, iothub.Registration{}, iotcentral.Registration{}, diff --git a/internal/services/graph/client/client.go b/internal/services/graphservices/client/client.go similarity index 100% rename from internal/services/graph/client/client.go rename to internal/services/graphservices/client/client.go diff --git a/internal/services/graph/graph_account_resource.go b/internal/services/graphservices/graph_account_resource.go similarity index 99% rename from internal/services/graph/graph_account_resource.go rename to internal/services/graphservices/graph_account_resource.go index 3b451dbcb35a..b670a15a4854 100644 --- a/internal/services/graph/graph_account_resource.go +++ b/internal/services/graphservices/graph_account_resource.go @@ -1,4 +1,4 @@ -package graph +package graphservices import ( "context" diff --git a/internal/services/graph/graph_account_resource_test.go b/internal/services/graphservices/graph_account_resource_test.go similarity index 99% rename from internal/services/graph/graph_account_resource_test.go rename to internal/services/graphservices/graph_account_resource_test.go index 4605cc6978b9..a3ffcf694a5b 100644 --- a/internal/services/graph/graph_account_resource_test.go +++ b/internal/services/graphservices/graph_account_resource_test.go @@ -1,4 +1,4 @@ -package graph_test +package graphservices_test import ( "context" diff --git a/internal/services/graph/registration.go b/internal/services/graphservices/registration.go similarity index 90% rename from internal/services/graph/registration.go rename to internal/services/graphservices/registration.go index d0cd7e3e969f..5f4337ed7294 100644 --- a/internal/services/graph/registration.go +++ b/internal/services/graphservices/registration.go @@ -1,4 +1,4 @@ -package graph +package graphservices import ( "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" @@ -14,12 +14,12 @@ func (r Registration) AssociatedGitHubLabel() string { // Name is the name of this Service func (r Registration) Name() string { - return "Graph" + return "Graph Services" } // WebsiteCategories returns a list of categories which can be used for the sidebar func (r Registration) WebsiteCategories() []string { - return []string{"Graph"} + return []string{"Graph Services"} } // DataSources returns a list of Data Sources supported by this Service diff --git a/website/allowed-subcategories b/website/allowed-subcategories index 96a4477e93be..21690feecb8e 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -46,7 +46,7 @@ Digital Twins Disks Elastic Fluid Relay -Graph +Graph Services HDInsight Hardware Security Module Healthcare diff --git a/website/docs/r/graph_account.html.markdown b/website/docs/r/graph_account.html.markdown index 288bda1f0b98..7179e06de8a3 100644 --- a/website/docs/r/graph_account.html.markdown +++ b/website/docs/r/graph_account.html.markdown @@ -1,14 +1,14 @@ --- -subcategory: "Graph" +subcategory: "Graph Services" layout: "azurerm" page_title: "Azure Resource Manager: azurerm_graph_account" description: |- - Manages a Account. + Manages a Microsoft Graph Services Account. --- # azurerm_graph_account -Manages a Graph Account. +Manages a Microsoft Graph Services Account. !> **NOTE:** This resource has been deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use [`azurerm_graph_services_account`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/graph_services_account) resources instead. diff --git a/website/docs/r/graph_services_account.html.markdown b/website/docs/r/graph_services_account.html.markdown index 59e54844c3c4..03fb63a64e22 100644 --- a/website/docs/r/graph_services_account.html.markdown +++ b/website/docs/r/graph_services_account.html.markdown @@ -1,14 +1,14 @@ --- -subcategory: "Graph" +subcategory: "Graph Services" layout: "azurerm" page_title: "Azure Resource Manager: azurerm_graph_services_account" description: |- - Manages a Graph Services Account. + Manages a Microsoft Graph Services Account. --- # azurerm_graph_services_account -Manages a Graph Services Account. +Manages a Microsoft Graph Services Account. ## Example Usage From 133fe61d45b77ec00055f1df8b8da9dd101fa923 Mon Sep 17 00:00:00 2001 From: Tao <104055472+teowa@users.noreply.github.com> Date: Thu, 27 Jul 2023 11:21:24 +0800 Subject: [PATCH 3/4] fix --- .github/labeler-pull-request-triage.yml | 2 +- .teamcity/components/generated/services.kt | 2 +- ....go => graph_services_account_resource.go} | 5 +-- ...> graph_services_account_resource_test.go} | 32 +++++++++++++++++++ 4 files changed, 37 insertions(+), 4 deletions(-) rename internal/services/graphservices/{graph_account_resource.go => graph_services_account_resource.go} (97%) rename internal/services/graphservices/{graph_account_resource_test.go => graph_services_account_resource_test.go} (86%) diff --git a/.github/labeler-pull-request-triage.yml b/.github/labeler-pull-request-triage.yml index 485b5b5f7965..619d366537a7 100644 --- a/.github/labeler-pull-request-triage.yml +++ b/.github/labeler-pull-request-triage.yml @@ -142,7 +142,7 @@ service/frontdoor: - internal/services/frontdoor/**/* service/graph: - - internal/services/graph/**/* + - internal/services/graphservices/**/* service/hdinsight: - internal/services/hdinsight/**/* diff --git a/.teamcity/components/generated/services.kt b/.teamcity/components/generated/services.kt index 1bd422034a6f..f6b781c382bc 100644 --- a/.teamcity/components/generated/services.kt +++ b/.teamcity/components/generated/services.kt @@ -52,7 +52,7 @@ var services = mapOf( "firewall" to "Firewall", "fluidrelay" to "Fluid Relay", "frontdoor" to "FrontDoor", - "graph" to "Graph Services", + "graphservices" to "Graph Services", "hdinsight" to "HDInsight", "hpccache" to "HPC Cache", "hsm" to "Hardware Security Module", diff --git a/internal/services/graphservices/graph_account_resource.go b/internal/services/graphservices/graph_services_account_resource.go similarity index 97% rename from internal/services/graphservices/graph_account_resource.go rename to internal/services/graphservices/graph_services_account_resource.go index b670a15a4854..e9cf9a893a7c 100644 --- a/internal/services/graphservices/graph_account_resource.go +++ b/internal/services/graphservices/graph_services_account_resource.go @@ -31,6 +31,7 @@ var _ sdk.Resource = AccountResource{} var _ sdk.ResourceWithUpdate = AccountResource{} var _ sdk.ResourceWithDeprecationReplacedBy = AccountResource{} +// AccountResource remove this in 4.0 type AccountResource struct{} func (r AccountResource) DeprecatedInFavourOfResource() string { @@ -209,13 +210,13 @@ func (r AccountResource) Update() sdk.ResourceFunc { if existing.Model == nil { return fmt.Errorf("retrieving existing %s: model was nil", *id) } - payload := *existing.Model + payload := graphservicesprods.TagUpdate{} if metadata.ResourceData.HasChange("tags") { payload.Tags = tags.Expand(config.Tags) } - if err := client.AccountsCreateAndUpdateThenPoll(ctx, *id, payload); err != nil { + if _, err := client.AccountsUpdate(ctx, *id, payload); err != nil { return fmt.Errorf("updating %s: %+v", *id, err) } diff --git a/internal/services/graphservices/graph_account_resource_test.go b/internal/services/graphservices/graph_services_account_resource_test.go similarity index 86% rename from internal/services/graphservices/graph_account_resource_test.go rename to internal/services/graphservices/graph_services_account_resource_test.go index a3ffcf694a5b..92baabdabbca 100644 --- a/internal/services/graphservices/graph_account_resource_test.go +++ b/internal/services/graphservices/graph_services_account_resource_test.go @@ -18,6 +18,10 @@ func TestAccGraphAccount(t *testing.T) { // NOTE: this is a combined test rather than separate split out tests due to // the account need a pre-existing AD application, here we use the service principal. acceptance.RunTestsInSequence(t, map[string]map[string]func(t *testing.T){ + // remove in 4.0 + "legacyAccount": { + "basic": testAccGraphAccount_legacy, + }, "account": { "basic": testAccGraphAccount_basic, "update": testAccGraphAccount_update, @@ -29,6 +33,21 @@ func TestAccGraphAccount(t *testing.T) { type AccountTestResource struct{} +func testAccGraphAccount_legacy(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_graph_account", "test") + r := AccountTestResource{} + + data.ResourceSequentialTest(t, r, []acceptance.TestStep{ + { + Config: r.legacy(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func testAccGraphAccount_basic(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_graph_services_account", "test") r := AccountTestResource{} @@ -116,6 +135,19 @@ func (r AccountTestResource) Exists(ctx context.Context, clients *clients.Client return utils.Bool(resp.Model != nil), nil } + +func (r AccountTestResource) legacy(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_graph_account" "test" { + name = "acctesta-%[2]d" + application_id = "%[3]s" + resource_group_name = azurerm_resource_group.test.name +} +`, r.template(data), data.RandomInteger, os.Getenv("ARM_CLIENT_ID")) +} + func (r AccountTestResource) basic(data acceptance.TestData) string { return fmt.Sprintf(` %s From 85c125967ee8e205079e266acc9bbfec1246a41d Mon Sep 17 00:00:00 2001 From: Tao <104055472+teowa@users.noreply.github.com> Date: Thu, 27 Jul 2023 11:23:36 +0800 Subject: [PATCH 4/4] fix doc --- website/docs/r/graph_account.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/graph_account.html.markdown b/website/docs/r/graph_account.html.markdown index 7179e06de8a3..95a06ce97d6a 100644 --- a/website/docs/r/graph_account.html.markdown +++ b/website/docs/r/graph_account.html.markdown @@ -10,7 +10,7 @@ description: |- Manages a Microsoft Graph Services Account. -!> **NOTE:** This resource has been deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use [`azurerm_graph_services_account`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/graph_services_account) resources instead. +!> **NOTE:** This resource has been deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use [`azurerm_graph_services_account`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/graph_services_account) resource instead. ## Example Usage