Skip to content

Commit

Permalink
r/media_service_account: removing the media_service_account_id field
Browse files Browse the repository at this point in the history
  • Loading branch information
tombuildsstuff committed Feb 22, 2019
1 parent c949427 commit 0cffa30
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
18 changes: 8 additions & 10 deletions azurerm/resource_arm_media_services_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ func resourceArmMediaServicesAccount() *schema.Resource {
},

"tags": tagsSchema(),

"media_service_account_id": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -91,11 +86,14 @@ func resourceArmMediaServicesAccountCreateUpdate(d *schema.ResourceData, meta in
Tags: expandTags(tags),
}

service, err := client.CreateOrUpdate(ctx, resourceGroup, accountName, parameters)
if err != nil {
return fmt.Errorf("Error creating Media Service Account %q (Resource Group %q): %+v", accountName, resourceGroup, err)
if _, e := client.CreateOrUpdate(ctx, resourceGroup, accountName, parameters); e != nil {
return fmt.Errorf("Error creating Media Service Account %q (Resource Group %q): %+v", accountName, resourceGroup, e)
}

service, err := client.Get(ctx, resourceGroup, accountName)
if err != nil {
return fmt.Errorf("Error retrieving Media Service Account %q (Resource Group %q): %+v", accountName, resourceGroup, err)
}
d.SetId(*service.ID)

return nil
Expand Down Expand Up @@ -125,12 +123,12 @@ func resourceArmMediaServicesAccountRead(d *schema.ResourceData, meta interface{
}

d.Set("name", resp.Name)
d.Set("resource_group_name", resourceGroup)
if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}

if props := resp.ServiceProperties; props != nil {
d.Set("media_service_account_id", props.MediaServiceID.String())
accounts := flattenMediaServicesAccountStorageAccounts(props.StorageAccounts)
if e := d.Set("storage_account", accounts); e != nil {
return fmt.Errorf("Error flattening `storage_account`: %s", e)
Expand Down Expand Up @@ -202,7 +200,7 @@ func flattenMediaServicesAccountStorageAccounts(input *[]media.StorageAccount) [

results := make([]interface{}, 0)
for _, storageAccount := range *input {
output := make(map[string]interface{}, 0)
output := make(map[string]interface{})

if storageAccount.ID != nil {
output["id"] = *storageAccount.ID
Expand Down
13 changes: 10 additions & 3 deletions azurerm/resource_arm_media_services_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ func TestAccAzureRMMediaServicesAccount_complete(t *testing.T) {
Config: testAccAzureRMMediaServicesAccount_complete(ri, rs, testLocation()),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "storage_account.#", "1"),
resource.TestCheckResourceAttr(resourceName, "tags.#", "1"),
resource.TestCheckResourceAttrSet(resourceName, "media_service_account_id"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "1"),
),
},
{
Expand Down Expand Up @@ -81,7 +80,7 @@ func TestAccAzureRMMediaServicesAccount_multipleAccounts(t *testing.T) {
Check: resource.ComposeAggregateTestCheckFunc(
testCheckAzureRMMediaServicesAccountExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "storage_account.#", "2"),
resource.TestCheckResourceAttrSet(resourceName, "media_service_account_id"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "1"),
),
},
{
Expand Down Expand Up @@ -237,6 +236,10 @@ resource "azurerm_media_services_account" "test" {
id = "${azurerm_storage_account.second.id}"
is_primary = false
}
tags {
"Hello" = "World"
}
}
`, template, rString, rString)
}
Expand Down Expand Up @@ -268,6 +271,10 @@ resource "azurerm_media_services_account" "test" {
id = "${azurerm_storage_account.first.id}"
is_primary = true
}
tags {
"Hello" = "World"
}
}
`, template, rString, rString)
}
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/media_services_account.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ A `storage_account` block supports the following:

The following attributes are exported:

* `id` - The `resource id` of the Media Services account.
* `id` - The Resource ID of the Media Services Account.

## Import

Expand Down

0 comments on commit 0cffa30

Please sign in to comment.