-
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_new_relic_monitor
- support monitored_subscription
property
#28134
base: main
Are you sure you want to change the base?
Conversation
MinItems: 1, | ||
Elem: &pluginsdk.Resource{ | ||
Schema: map[string]*pluginsdk.Schema{ | ||
"subscription_id": { |
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 is not flattened because there are other properties in the monitoredSubscription but not supported by API for now and they might be supported in the future.
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.
Hi @teowa ,
Thanks for this PR - I've taken a look through and left some comments inline. If we can fix those up, this should be good to go 👍
|
||
monitoredSubscriptionsClient := metadata.Client.NewRelic.MonitoredSubscriptionsClient | ||
monitorId := monitoredsubscriptions.NewMonitorID(id.SubscriptionId, id.ResourceGroupName, id.MonitorName) | ||
if err := metadata.Client.NewRelic.MonitoredSubscriptionsClient.CreateOrUpdateThenPoll(ctx, monitorId, monitoredSubscriptionsProperties); err != nil { |
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.
Do we still need to create this resource if monitored_subscription
is not configured?
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.
fixed, now it will only create if monitored_subscription
is not configured
|
||
resp, err := client.Get(ctx, id) | ||
if err != nil { | ||
return resp, "Error", fmt.Errorf("retrieving NewRelic Monitored Subscriptions of %s: %+v", id, err) |
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.
The id
is created by monitoredsubscriptions
, not monitors
, other logs also have the same problem
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.
updated to use monitors.MonitorId
for error message
return func() (interface{}, string, error) { | ||
log.Printf("[DEBUG] Checking to see if NewRelic Monitored Subscriptions of %s is available ..", id) | ||
|
||
resp, err := client.Get(ctx, id) |
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.
will it return error if the resource is deleted?
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.
updated, now the waiting is removed as tested it is not necessary
Hi @ms-zhenhua , thanks for reviewing this! I have changed the code, please kindly take another look. |
}, | ||
} | ||
|
||
if err := metadata.Client.NewRelic.MonitoredSubscriptionsClient.CreateOrUpdateThenPoll(ctx, monitorId, monitoredSubscriptionsProperties); err != nil { |
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.
if err := metadata.Client.NewRelic.MonitoredSubscriptionsClient.CreateOrUpdateThenPoll(ctx, monitorId, monitoredSubscriptionsProperties); err != nil { | |
if err := monitoredSubscriptionsClient.CreateOrUpdateThenPoll(ctx, monitorId, monitoredSubscriptionsProperties); err != nil { |
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.
fixed
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.
Hi @teowa ,
Thank you for the updates. LGTM~
Community Note
Description
swagger: https://github.com/Azure/azure-rest-api-specs/blob/a0b2a34b9ff6d324c31e031d6e373fc3ceb38c81/specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-01-01/NewRelic.json#L1372
azure doc: https://learn.microsoft.com/en-us/azure/partner-solutions/new-relic/new-relic-how-to-manage#monitor-multiple-subscriptions
PR Checklist
For example: “
resource_name_here
- description of change e.g. adding propertynew_property_name_here
”Changes to existing Resource / Data Source
Testing
Change Log
Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.
azurerm_new_relic_monitor
- supportmonitored_subscription
propertyThis is a (please select all that apply):
Related Issue(s)
Fixes #0000
Note
If this PR changes meaningfully during the course of review please update the title and description as required.