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

r/azurerm_api_management_api_subscription: fix subscription for all apis #12829

Merged

Conversation

patst
Copy link
Contributor

@patst patst commented Aug 3, 2021

As stated in #4482 it is currently not possible to create a subscription for all apis.

Trying to do this by omitting product_id and api_id results in an error because the scope is wrong:

Error: creating/updating Subscription "7bf58dda-717a-4314-81c3-175c6b656c12" (API Management Service "apim-apim-box-gwc-apim" / Resource Group "rg-apim-box-gwc-apim"): apimanagement.SubscriptionClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="ValidationError" Message="One or more fields contain incorrect values:" Details=[{​​​​​​​​"code":"ValidationError","message":"Subscription scope should be one of '/apis', '/apis/{​​​​​​​​apiId}​​​​​​​​', '/products/{​​​​​​​​productId}​​​​​​​​'","target":"scope"}​​​​​​​​]

According to the REST docs the scope must be /apis to be valid for all apis:

I tested this pull requests with running two API management test cases:

terraform-provider-azurerm git:(4482-fix-all-apis-subscriptions) ✗ make testacc TEST='./azurerm/internal/services/apimanagement/api_management_subscription_resource_test.go' TESTARGS='-run=TestAccApiManagementSubscription_allApis' TESTTIMEOUT='120m'
==> Checking that code complies with gofmt requirements...
==> Checking that Custom Timeouts are used...
==> Checking that acceptance test packages are used...
TF_ACC=1 go test ./azurerm/internal/services/apimanagement/api_management_subscription_resource_test.go -v -run=TestAccApiManagementSubscription_allApis -timeout 120m -ldflags="-X=github.com/terraform-providers/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN   TestAccApiManagementSubscription_allApis
=== PAUSE TestAccApiManagementSubscription_allApis
=== CONT  TestAccApiManagementSubscription_allApis
--- PASS: TestAccApiManagementSubscription_allApis (4048.97s)
PASS
ok      command-line-arguments  4050.544s


 make testacc TEST='./azurerm/internal/services/apimanagement/api_management_subscription_resource_test.go' TESTARGS='-run=TestAccApiManagementSubscription_withApiId' TESTTIMEOUT='120m'
==> Checking that code complies with gofmt requirements...
==> Checking that Custom Timeouts are used...
==> Checking that acceptance test packages are used...
TF_ACC=1 go test ./azurerm/internal/services/apimanagement/api_management_subscription_resource_test.go -v -run=TestAccApiManagementSubscription_withApiId -timeout 120m -ldflags="-X=github.com/terraform-providers/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN   TestAccApiManagementSubscription_withApiId
=== PAUSE TestAccApiManagementSubscription_withApiId
=== CONT  TestAccApiManagementSubscription_withApiId
--- PASS: TestAccApiManagementSubscription_withApiId (3988.82s)
PASS
ok      command-line-arguments  3990.262s

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 @patst

Thanks for this PR.

I've taken a look through and left one comment inline but this otherwise LGTM 👍

Thanks!

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.

LGTM - thanks for pushing those changes @patst

@tombuildsstuff tombuildsstuff merged commit bdc1c97 into hashicorp:master Aug 4, 2021
tombuildsstuff added a commit that referenced this pull request Aug 4, 2021
@patst patst deleted the 4482-fix-all-apis-subscriptions branch August 4, 2021 10:04
@github-actions
Copy link

github-actions bot commented Aug 6, 2021

This functionality has been released in v2.71.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

github-actions bot commented Sep 6, 2021

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 6, 2021
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.

2 participants