Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename azurerm_graph_account to azurerm_graph_services_account #22665

Merged
merged 5 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/labeler-issue-triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)*)###'
Expand Down
2 changes: 1 addition & 1 deletion .github/labeler-pull-request-triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ service/frontdoor:
- internal/services/frontdoor/**/*

service/graph:
- internal/services/graph/**/*
- internal/services/graphservices/**/*

service/hdinsight:
- internal/services/hdinsight/**/*
Expand Down
2 changes: 1 addition & 1 deletion .teamcity/components/generated/services.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var services = mapOf(
"firewall" to "Firewall",
"fluidrelay" to "Fluid Relay",
"frontdoor" to "FrontDoor",
"graph" to "Graph",
"graphservices" to "Graph Services",
"hdinsight" to "HDInsight",
"hpccache" to "HPC Cache",
"hsm" to "Hardware Security Module",
Expand Down
2 changes: 1 addition & 1 deletion internal/clients/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,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"
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -157,7 +157,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration {
domainservices.Registration{},
eventhub.Registration{},
fluidrelay.Registration{},
graph.Registration{},
graphservices.Registration{},
hybridcompute.Registration{},
iothub.Registration{},
iotcentral.Registration{},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package graph
package graphservices

import (
"context"
Expand All @@ -16,11 +16,28 @@ 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{}

// AccountResource remove this in 4.0
type AccountResource struct{}

func (r AccountResource) DeprecatedInFavourOfResource() string {
return "azurerm_graph_services_account"
}

func (r AccountResource) ModelObject() interface{} {
return &AccountResourceSchema{}
}
Expand Down Expand Up @@ -90,7 +107,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{
Expand Down Expand Up @@ -193,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)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package graph_test
package graphservices_test

import (
"context"
Expand All @@ -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,
Expand All @@ -29,10 +33,25 @@ func TestAccGraphAccount(t *testing.T) {

type AccountTestResource struct{}

func testAccGraphAccount_basic(t *testing.T) {
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{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Expand All @@ -45,7 +64,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{}

Expand All @@ -61,7 +80,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{
Expand All @@ -76,7 +95,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{
Expand Down Expand Up @@ -116,7 +135,8 @@ func (r AccountTestResource) Exists(ctx context.Context, clients *clients.Client

return utils.Bool(resp.Model != nil), nil
}
func (r AccountTestResource) basic(data acceptance.TestData) string {

func (r AccountTestResource) legacy(data acceptance.TestData) string {
return fmt.Sprintf(`
%s

Expand All @@ -128,14 +148,26 @@ resource "azurerm_graph_account" "test" {
`, r.template(data), data.RandomInteger, os.Getenv("ARM_CLIENT_ID"))
}

func (r AccountTestResource) basic(data acceptance.TestData) string {
return fmt.Sprintf(`
%s

resource "azurerm_graph_services_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) 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))
}
Expand All @@ -144,7 +176,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"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package graph
package graphservices

import (
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
Expand All @@ -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
Expand All @@ -31,5 +31,6 @@ func (r Registration) DataSources() []sdk.DataSource {
func (r Registration) Resources() []sdk.Resource {
return []sdk.Resource{
AccountResource{},
ServicesAccountResource{},
}
}
2 changes: 1 addition & 1 deletion website/allowed-subcategories
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Digital Twins
Disks
Elastic
Fluid Relay
Graph
Graph Services
HDInsight
Hardware Security Module
Healthcare
Expand Down
8 changes: 5 additions & 3 deletions website/docs/r/graph_account.html.markdown
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
---
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) resource instead.

## Example Usage

Expand Down
70 changes: 70 additions & 0 deletions website/docs/r/graph_services_account.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
subcategory: "Graph Services"
layout: "azurerm"
page_title: "Azure Resource Manager: azurerm_graph_services_account"
description: |-
Manages a Microsoft Graph Services Account.
---

# azurerm_graph_services_account

Manages a Microsoft 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
```