-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
azurerm_api_management_api - support for subscription_required
#4885
azurerm_api_management_api - support for subscription_required
#4885
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Brunhil, thanks for opening this PR. There are a couple misspellings which cause the provider to panic which might cause us to lose users statefiles. Once those are fixed up, can you add tests to confirm this functionality works. Those tests are useful to catch these panics before review time as well.
Good catch with the spelling @mbfrahry , it was one of those days yesterday -_-. I'll get the tests added and other changes fixed and push them up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Brunhil, unfortunately we're still not quite there. One test panicked and the other 2 modified in this PR failed.
@@ -28,6 +28,8 @@ func TestAccAzureRMApiManagementApi_basic(t *testing.T) { | |||
resource.TestCheckResourceAttr(resourceName, "soap_pass_through", "false"), | |||
resource.TestCheckResourceAttr(resourceName, "is_current", "true"), | |||
resource.TestCheckResourceAttr(resourceName, "is_online", "false"), | |||
resource.TestCheckResourceAttr(resourceName, "authentication_settings.#", "1"), | |||
resource.TestCheckResourceAttr(resourceName, "authentication_settings.0.subscription_key_required", "true"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test now errors. It doesn't look like this is being set properly
------- Stdout: -------
=== RUN TestAccAzureRMApiManagementApi_basic
--- FAIL: TestAccAzureRMApiManagementApi_basic (2612.17s)
testing.go:569: Step 0 error: Check failed: Check 6/6 error: azurerm_api_management_api.test: Attribute 'authentication_settings.0.subscription_key_required' not found
FAIL
@@ -120,6 +122,33 @@ func TestAccAzureRMApiManagementApi_version(t *testing.T) { | |||
}) | |||
} | |||
|
|||
func TestAccAzureRMApiManagementApi_authenticationSettings(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is also failing
=== RUN TestAccAzureRMApiManagementApi_authenticationSettings
--- FAIL: TestAccAzureRMApiManagementApi_authenticationSettings (2825.43s)
testing.go:569: Step 0 error: Check failed: Check 3/3 error: azurerm_api_management_api.test: Attribute 'authentication_settings.0.subscription_key_required' not found
FAIL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @Brunhil
Thanks for pushing those changes - running the tests again it looks like the AuthenticationSettings block may not be being returned from the API here (which is why this shows as missing):
Out of interest are you able to confirm if this is present in the response for a provisioned APIM API? It's generally easiest to see this in the resource response via resources.azure.com (or by proxing Terraform via Charles/Fiddler depending on your OS)
Thanks!
"authentication_settings": { | ||
Type: schema.TypeList, | ||
Optional: true, | ||
Computed: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running the tests for this - both the basic and authenticationRequired tests fail:
=== RUN TestAccAzureRMApiManagementApi_authenticationSettings
--- FAIL: TestAccAzureRMApiManagementApi_authenticationSettings (2264.83s)
testing.go:569: Step 0 error: Check failed: Check 3/3 error: azurerm_api_management_api.test: Attribute 'authentication_settings.0.subscription_key_required' not found
FAIL
and
------- Stdout: -------
=== RUN TestAccAzureRMApiManagementApi_basic
--- FAIL: TestAccAzureRMApiManagementApi_basic (2276.86s)
testing.go:569: Step 0 error: Check failed: Check 6/6 error: azurerm_api_management_api.test: Attribute 'authentication_settings.0.subscription_key_required' not found
FAIL
is it possible this information isn't returned from the API? If so, we may need to update the flatten function to set a default value here: https://github.com/terraform-providers/terraform-provider-azurerm/pull/4885/files#diff-e28c81f44cf2e8523cae5b19081cf837R494
e.g. something like this:
func flattenApiManagementAuthenticationSettings(input *apimanagement.AuthenticationSettingsContract) []interface{} {
subscriptionKeyRequired := false
if input != nil && input.SubscriptionKeyRequired != nil {
subscriptionKeyRequired = *paramNames.SubscriptionKeyRequired
}
return []interface{}{
map[string]interface{}{
"subscription_key_required": subscriptionKeyRequired,
},
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this actually is a misunderstanding on my part...I'll explain more in the message on this PR.
@tombuildsstuff , after digging further into this, it turns out we have to wait for the new API Management API Version. The 'AuthenticationSettings' field is a 2019-01-01 API Version property. So these changes are actually for 2019-01-01. I was implementing this when looking at the REST API here. I had modified the try-it option to point at 2018-01-1 and assumed the documentation on the left updated, it did not :). After testing/verifying in 2018-01-01, the response body for GET is as follows:
Then attempting to set the value in the body for subscriptionRequired in the REST API led to,
As a result, I'm marking this PR as WIP. We would need to update to 2019-01-01 API version to support this field, and this is blocked by the upstream issues that #2613 is blocked by. |
Assigning this to the "blocked" milestone since this is blocked on upgrading to 2019-01-01, which is blocked on Azure/azure-rest-api-specs#6372 |
Looks like this should be close, from the blocking issue
|
@Brunhil can we have an estimated date when this will get released? Blocked as we want to consume this resource from terraform in our module |
what about linking to an authorization_server (oauth / openidc) ??? is this included in this PR? |
subscription_required
subscription_required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @Brunhil, thanks for the PR! however it looks like some tests are failing:
est Failed
------- Stdout: -------
=== RUN TestAccAzureRMApiManagementApi_basic
TestAccAzureRMApiManagementApi_basic: testing.go:640: Step 0 error: Check failed: Check 5/5 error: azurerm_api_management_api.test: Attribute 'subscription_required' expected "true", got "false"
--- FAIL: TestAccAzureRMApiManagementApi_basic (2574.11s)
are you sure the default is true for the property?
@katbyte , when this was initially implemented Subscription Required was turned on by default. They may have changed their behavior in the new API version. |
@Brunhil Do you have any update on when this might be ready? |
We're also blocked with this current issue. Do you have an ETA? |
1c2bdb8
to
b968fff
Compare
Sorry all, forgot to hit push! The test should be fixed if it defaults to false. Let me know if there's any other requested changes. Thanks for reviewing! |
Thanks you all for this, can't wait for this to get merged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @Brunhil! LGTM now 🚀
This has been released in version 2.16.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 = "~> 2.16.0"
}
# ... other configuration ... |
…hicorp#4885) Add subscription_required to data and resource for azurerm_api_management_api (fixes hashicorp#3863 )
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 👉 [email protected]. Thanks! |
Add
subscription_required
to data and resource for azurerm_api_management_api(fixes ##3863 )