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_api_management_api_diagnostic #7873

Merged
merged 17 commits into from
Sep 9, 2020

Conversation

sirlatrom
Copy link
Contributor

@sirlatrom sirlatrom commented Jul 23, 2020

Closes #4760.
Adds support for azuremonitor as identifier to azurerm_api_management_diagnostic

Missing:

  • Tests for the new resource

@hctv19
Copy link

hctv19 commented Aug 6, 2020

Really looking forward to this resource being implemented - we currently have to set this configuration with ARM templates directly and there's a bug with the azurerm_template_deployment resource type that's been causing us some headaches. Thanks for this work @sirlatrom !

@jonatasbaldin
Copy link

Hi there! Look forward for this implementation too, thanks a lot for the hard work 💪

@sirlatrom
Copy link
Contributor Author

@jackofallops Can this be put on a milestone do you think?

@jackofallops jackofallops added this to the v2.24.0 milestone Aug 14, 2020
@jackofallops
Copy link
Member

Hi @sirlatrom
I started to review this and noticed a bug in the azurerm_api_management_diagnostic that I think you may have based this on (since the same bug is present). Specifically the diagnosticId and apiName parameters of the CreateOrUpdate call are in the wrong order. I'm going need to spend a little time digging into the implications of fixing that before I finish up this review, so apologies in advance if it takes a little while.

I wasn't involved in the other diagnostic resource (that I remember) - is there a reason that it, and this, doesn't support the other properties of the DiagnosticContractProperties? I'd like to understand the intended use-case better, as it currently feels a little lacking?

@sirlatrom
Copy link
Contributor Author

Hi @sirlatrom
I started to review this and noticed a bug in the azurerm_api_management_diagnostic that I think you may have based this on (since the same bug is present). Specifically the diagnosticId and apiName parameters of the CreateOrUpdate call are in the wrong order. I'm going need to spend a little time digging into the implications of fixing that before I finish up this review, so apologies in advance if it takes a little while.

I wasn't involved in the other diagnostic resource (that I remember) - is there a reason that it, and this, doesn't support the other properties of the DiagnosticContractProperties? I'd like to understand the intended use-case better, as it currently feels a little lacking?

You guessed correctly that I copied and modified the azurerm_api_management_diagnostic resource, so I assumed it did things correctly. Since this here is a new resource, I can fix the argument order for that resource in this PR, and azurerm_api_management_diagnostic can be fixed in another PR.

I'll get around to making changes and addressing your order concerns on Monday CEST.

@jackofallops
Copy link
Member

Thanks @sirlatrom - We need to be mindful that fixing the issue doesn't create a breaking change for existing resources, such as by changing ID's, recreating resources unexpectedly etc. It may be appropriate to have the change still, but knowing the impact in the first instance is important!

Thanks again :)

@sirlatrom
Copy link
Contributor Author

sirlatrom commented Aug 17, 2020

@jackofallops I've now verified that the order of arguments to apimanagement.APIDiagnosticClient.CreateOrUpdate is correct after the recently pushed commit c8ab23d.

PS: Since this is a new resource with regards to the Terraform provider, there are no existing users of it. I have not changed any ID parsing functions, but merely provided the correct order of arguments to the CreateOrUpdate function, whereas prior to c8ab23d the arguments were given in an incorrect order for apiid string and diagnosticID string.

@tombuildsstuff tombuildsstuff removed this from the v2.24.0 milestone Aug 20, 2020
@sirlatrom

This comment has been minimized.

Copy link
Member

@jackofallops jackofallops left a comment

Choose a reason for hiding this comment

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

Hi @sirlatrom

Thanks for the updates, I've left a few minor comments below, but otherwise LGTM.

Thanks!

Signed-off-by: Sune Keller <[email protected]>
@sirlatrom sirlatrom requested a review from jackofallops August 26, 2020 09:19
@sirlatrom
Copy link
Contributor Author

@jackofallops I've applied your suggestions, please let me know if any further modifications are needed.

@ghost ghost removed the waiting-response label Aug 26, 2020
@hctv19

This comment has been minimized.

@tombuildsstuff tombuildsstuff added this to the v2.27.0 milestone Sep 3, 2020
@sirlatrom
Copy link
Contributor Author

sirlatrom commented Sep 3, 2020

@tombuildsstuff I've added the client initialization in 5025a9d.

@ghost ghost removed the waiting-response label Sep 3, 2020
@jackofallops
Copy link
Member

Hi @sirlatrom
I ran the tests, and they all failed with:

Error: ID contained more segments than required: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/acctestRG-200904094049117016/providers/Microsoft.ApiManagement/service/acctestAM-200904094049117016/apis/acctestAMA-200904094049117016/diagnostics/applicationinsights"

I couldn't see an immediately obvious problem with your ID parse code, but it's somehow dropping through to the a fail on ValidateNoEmptySegments

Could you add a unit test for that parser and investigate?

Also output what paths are left in ValidateNoEmptySegments error case.

Signed-off-by: Sune Keller <[email protected]>
@sirlatrom
Copy link
Contributor Author

Hi @sirlatrom
I ran the tests, and they all failed with:

Error: ID contained more segments than required: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/acctestRG-200904094049117016/providers/Microsoft.ApiManagement/service/acctestAM-200904094049117016/apis/acctestAMA-200904094049117016/diagnostics/applicationinsights"

I couldn't see an immediately obvious problem with your ID parse code, but it's somehow dropping through to the a fail on ValidateNoEmptySegments

Could you add a unit test for that parser and investigate?

@jackofallops Thanks for finding that. I've added a unit test for that parser in 936bc51, and in
24f1206 suggested that the id.Path variable that is checked in ValidateNoEmptySegments is included in the error message, to help any future recipients of that error message.

Copy link
Member

@jackofallops jackofallops left a comment

Choose a reason for hiding this comment

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

Hi @sirlatrom
Thanks for adding the additional unit test, and the additional info to the path error output. It uncovered the root of the odd issue, which I've commented on below. (I think they're the only instances, might be worth another quick scan since these resources are so similarly named)

Thanks!

Copy link
Member

@jackofallops jackofallops left a comment

Choose a reason for hiding this comment

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

Hi @sirlatrom
Hope you don't mind, but I pushed a couple fixes this morning to your branch. The basic and requiresImport are now passing, but on re-review I'm not sure the update scenario is valid? Update tests are for in-place changes and there's a change to a Forcenew property in that scenario. The config for that scenario also fails as the test2 resources have the same names as the test, so trigger an import error. Can you review the test and adjust as appropriate?
Thanks.

@sirlatrom
Copy link
Contributor Author

Hi @sirlatrom
Hope you don't mind, but I pushed a couple fixes this morning to your branch. The basic and requiresImport are now passing, but on re-review I'm not sure the update scenario is valid? Update tests are for in-place changes and there's a change to a Forcenew property in that scenario. The config for that scenario also fails as the test2 resources have the same names as the test, so trigger an import error. Can you review the test and adjust as appropriate?
Thanks.

Hi @jackofallops,
Thanks for doing the work properly when I apparently failed to 😄
As for the update scenario, it should be testing changing the logger ID, but changing the API name should arguably result in a new resource.
I'll try and go through that scenario and make it actually do what it should.

@ghost ghost removed the waiting-response label Sep 8, 2020
Copy link
Member

@jackofallops jackofallops left a comment

Choose a reason for hiding this comment

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

Thanks @sirlatrom
This LGTM now, and tests are passing.

image

@jackofallops jackofallops merged commit ba2d0cb into hashicorp:master Sep 9, 2020
jackofallops added a commit that referenced this pull request Sep 9, 2020
fixed hashibot tags on changes
@sirlatrom sirlatrom deleted the fix-4760 branch September 9, 2020 13:40
@ghost
Copy link

ghost commented Sep 10, 2020

This has been released in version 2.27.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.27.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Oct 9, 2020

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!

@ghost ghost locked as resolved and limited conversation to collaborators Oct 9, 2020
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.

Feature request: azurerm_api_management_diagnostic
5 participants