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

New Resource: azurerm_media_service_account #2711

Merged
merged 20 commits into from
Feb 22, 2019

Conversation

seushermsft
Copy link
Contributor

This change implements the creation and storage account configuration for Media Services, but doesn't expose other features such as the StreamingEndpoints.

Issue: #2710

@seushermsft
Copy link
Contributor Author

Newly added integration tests pass:

$ make testacc TESTARGS='-run=TestAccAzureRMMediaServicesAccount_singlestorage'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run=TestAccAzureRMMediaServicesAccount_singlestorage -timeout 180m -ldflags="-X=github.com/terraform-providers/terraform-provider-azurerm/version.ProviderVersion=acc"
?       github.com/terraform-providers/terraform-provider-azurerm       [no test files]
=== RUN   TestAccAzureRMMediaServicesAccount_singlestorage
=== PAUSE TestAccAzureRMMediaServicesAccount_singlestorage
=== CONT  TestAccAzureRMMediaServicesAccount_singlestorage
--- PASS: TestAccAzureRMMediaServicesAccount_singlestorage (154.81s)
PASS

$ make testacc TESTARGS='-run=TestAccAzureRMMediaServicesAccount_multiplestorage'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run=TestAccAzureRMMediaServicesAccount_multiplestorage -timeout 180m -ldflags="-X=github.com/terraform-providers/terraform-provider-azurerm/version.ProviderVersion=acc"
?       github.com/terraform-providers/terraform-provider-azurerm       [no test files]
=== RUN   TestAccAzureRMMediaServicesAccount_multiplestorage
=== PAUSE TestAccAzureRMMediaServicesAccount_multiplestorage
=== CONT  TestAccAzureRMMediaServicesAccount_multiplestorage
--- PASS: TestAccAzureRMMediaServicesAccount_multiplestorage (94.99s)

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @seushermsft,

Thanks for the new resource! It's off to a great start. I've left some mostly minor comments inline and once those are addressed we can get this merged 🙂

azurerm/resource_arm_media_services.go Outdated Show resolved Hide resolved
azurerm/resource_arm_media_services.go Outdated Show resolved Hide resolved
azurerm/resource_arm_media_services_test.go Outdated Show resolved Hide resolved
azurerm/resource_arm_media_services_test.go Outdated Show resolved Hide resolved
azurerm/resource_arm_media_services_test.go Outdated Show resolved Hide resolved
examples/media-services/multiple_storage_accounts/main.tf Outdated Show resolved Hide resolved
website/docs/r/media_services.html.markdown Outdated Show resolved Hide resolved
website/docs/r/media_services.html.markdown Outdated Show resolved Hide resolved
website/docs/r/media_services.html.markdown Outdated Show resolved Hide resolved
Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @seushermsft

Thanks for this PR :)

I've taken a look through and left some comments inline but this mostly LGTM - if we can fix those up (and the tests pass) then this should be good to merge 👍

Thanks!

azurerm/provider.go Outdated Show resolved Hide resolved
azurerm/resource_arm_media_services.go Outdated Show resolved Hide resolved
azurerm/resource_arm_media_services.go Outdated Show resolved Hide resolved
{
Config: generateTemplate_multiplestorage(resourceName, testLocation()),
Check: resource.ComposeAggregateTestCheckFunc(
checkAccAzureRMMediaServicesAccount("azurerm_media_services.ams", testLocation(), "2"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove this function and instead check the values persisted in the state? there's an example of this here https://github.com/terraform-providers/terraform-provider-azurerm/blob/master/azurerm/resource_arm_dev_test_windows_virtual_machine_test.go#L27

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkAccAzureRMMediaServicesAccount uses functions, such as resource.TestCheckResourceAttr internally to check the state. It only exists to remove the duplication since both acceptance tests have the same validation logic with slightly different values (ex: # of storage accounts).

azurerm/config.go Show resolved Hide resolved
func checkAccAzureRMMediaServicesAccount(resourceName string, location string, storageCount string) resource.TestCheckFunc {
// It would be ideal to also validate which storage account was Primary, but that isn't straight forward.
// The key for the storage account's Primary flag is non-deterministic (ex: storage_account.1137153885.is_primary) and
// isn't based on the storage account name.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh indeed, that said we should be able to remove this since the import stage verifies the config matches the local state

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect I still need this since its validating that the azure_media_services_account code correctly converts the terraform template to an AMS deployment+configuration. I've only ever used terraform in a tutorial, so I'm pretty ignorant in it, but its not clear how this can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tombuildsstuff - I disappeared for a week to work on some other stuff. Can you let me know if I'm misunderstanding the two remaining active comments?

website/docs/r/media_services.html.markdown Outdated Show resolved Hide resolved
website/docs/r/media_services.html.markdown Outdated Show resolved Hide resolved
website/docs/r/media_services.html.markdown Outdated Show resolved Hide resolved
website/docs/r/media_services.html.markdown Outdated Show resolved Hide resolved
@tombuildsstuff tombuildsstuff changed the title Create Terraform Resource for Azure Media Services New Resource: azurerm_media_service_account Jan 18, 2019
@tingulfsen
Copy link

@tombuildsstuff and @katbyte is there any chance you could take a look at this again regarding the latest comment from @seushermsft above? I would love for this PR to be merged, since I need the functionality provided.

@ghost ghost removed the waiting-response label Feb 7, 2019
@tombuildsstuff tombuildsstuff added this to the 1.23.0 milestone Feb 8, 2019
@tombuildsstuff tombuildsstuff self-assigned this Feb 15, 2019
@tombuildsstuff tombuildsstuff dismissed stale reviews from katbyte and themself February 22, 2019 10:43

dismissing since changes have been pushed

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @seushermsft

Thanks for pushing the updates to this PR - I've left a few comments inline but this is mostly looking good to me. I hope you don't mind but I'm going to push a couple of commits to fix the comments mentioned below so that we can get this merged 👍

Thanks!

azurerm/resource_arm_media_services_account.go Outdated Show resolved Hide resolved
azurerm/resource_arm_media_services_account.go Outdated Show resolved Hide resolved
azurerm/resource_arm_media_services_account.go Outdated Show resolved Hide resolved
azurerm/resource_arm_media_services_account.go Outdated Show resolved Hide resolved
azurerm/resource_arm_media_services_account.go Outdated Show resolved Hide resolved
azurerm/resource_arm_media_services_account.go Outdated Show resolved Hide resolved
azurerm/resource_arm_media_services_account.go Outdated Show resolved Hide resolved
"media_service_account_id": {
Type: schema.TypeString,
Computed: true,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in retrospect looks like this field isn't being deserialized correctly; will push a commit to remove this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upstream issue: Azure/azure-sdk-for-go#4124

@tombuildsstuff
Copy link
Contributor

Turns out there's a couple of bugs in the Azure API and SDK which mean we're going to have to ship support for this without Tags and the Media Service ID field:

For the moment I've removed support for these fields - but when these bugs are resolved we should be able to ship support for these.

… an API bug

```
$ acctests-proxy azurerm TestAccAzureRMMediaServicesAccount_basic
=== RUN   TestAccAzureRMMediaServicesAccount_basic
=== PAUSE TestAccAzureRMMediaServicesAccount_basic
=== CONT  TestAccAzureRMMediaServicesAccount_basic
--- FAIL: TestAccAzureRMMediaServicesAccount_basic (128.02s)
    testing.go:538: Step 0 error: After applying this step, the plan was not empty:

        DIFF:

        UPDATE: azurerm_media_services_account.test
          tags.%: "" => "<computed>"

        STATE:

        azurerm_media_services_account.test:
          ID = /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/190222174721721594/providers/Microsoft.Media/mediaservices/acctestmsarfshu
          provider = provider.azurerm
          location = westeurope
          name = acctestmsarfshu
          resource_group_name = 190222174721721594
          storage_account.# = 1
          storage_account.318018769.id = /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/190222174721721594/providers/Microsoft.Storage/storageAccounts/acctestsa1rfshu
          storage_account.318018769.is_primary = true

          Dependencies:
            azurerm_resource_group.test
            azurerm_storage_account.first
        azurerm_resource_group.test:
          ID = /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/190222174721721594
          provider = provider.azurerm
          location = westeurope
          name = 190222174721721594
          tags.% = 0
        azurerm_storage_account.first:
          ID = /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/190222174721721594/providers/Microsoft.Storage/storageAccounts/acctestsa1rfshu
          provider = provider.azurerm
          access_tier =
          account_encryption_source = Microsoft.Storage
          account_kind = Storage
          account_replication_type = GRS
          account_tier = Standard
          account_type = Standard_GRS
          enable_blob_encryption = true
          enable_file_encryption = true
          enable_https_traffic_only = false
          identity.# = 0
          location = westeurope
          name = acctestsa1rfshu
          network_rules.# = 0
          primary_access_key = 2De66EJdd5Am14XG8hYjkgpEf8PJLF0QEvY2QOLaaBzHApo32GWGBKrC5zXyQllegPNI5ex17Sgg0BI+jeYrHQ==
          primary_blob_connection_string = DefaultEndpointsProtocol=https;BlobEndpoint=https://acctestsa1rfshu.blob.core.windows.net/;AccountName=acctestsa1rfshu;AccountKey=2De66EJdd5Am14XG8hYjkgpEf8PJLF0QEvY2QOLaaBzHApo32GWGBKrC5zXyQllegPNI5ex17Sgg0BI+jeYrHQ==
          primary_blob_endpoint = https://acctestsa1rfshu.blob.core.windows.net/
          primary_connection_string = DefaultEndpointsProtocol=https;AccountName=acctestsa1rfshu;AccountKey=2De66EJdd5Am14XG8hYjkgpEf8PJLF0QEvY2QOLaaBzHApo32GWGBKrC5zXyQllegPNI5ex17Sgg0BI+jeYrHQ==;EndpointSuffix=core.windows.net
          primary_file_endpoint = https://acctestsa1rfshu.file.core.windows.net/
          primary_location = westeurope
          primary_queue_endpoint = https://acctestsa1rfshu.queue.core.windows.net/
          primary_table_endpoint = https://acctestsa1rfshu.table.core.windows.net/
          resource_group_name = 190222174721721594
          secondary_access_key = cT0gpMIavYw5zuG/DAxyaKHXpTyzglMfvRO0kAQFagWBuZIejsz0j4jZKWW6ct8/IvcMwp5Ers0C2pwJCvdGCw==
          secondary_connection_string = DefaultEndpointsProtocol=https;AccountName=acctestsa1rfshu;AccountKey=cT0gpMIavYw5zuG/DAxyaKHXpTyzglMfvRO0kAQFagWBuZIejsz0j4jZKWW6ct8/IvcMwp5Ers0C2pwJCvdGCw==;EndpointSuffix=core.windows.net
          secondary_location = northeurope
          tags.% = 0

          Dependencies:
            azurerm_resource_group.test
FAIL
FAIL	github.com/terraform-providers/terraform-provider-azurerm/azurerm	128.566s
```
@tombuildsstuff
Copy link
Contributor

Tests pass:

screenshot 2019-02-22 at 18 21 55

tombuildsstuff added a commit that referenced this pull request Feb 22, 2019
@tombuildsstuff tombuildsstuff merged commit 3c5211d into hashicorp:master Feb 22, 2019
@ghost
Copy link

ghost commented Mar 8, 2019

This has been released in version 1.23.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
	version = "~> 1.23.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Mar 25, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants