azurerm_security_center_pricing - force new resource to be created when subplan changes#27805
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
|
kindly bubble this up |
|
convert to draft to update |
|
@ziyeqf ping. There is a customer waiting for this since October. Microsoft is not looking very good here. |
| func resourceSecurityCenterSubscriptionPricing() *pluginsdk.Resource { | ||
| return &pluginsdk.Resource{ | ||
| Create: resourceSecurityCenterSubscriptionPricingUpdate, | ||
| res := &pluginsdk.Resource{ |
There was a problem hiding this comment.
We can remove this variable declaration since we're not patching anything in the resource here
| func resourceSecurityCenterSubscriptionPricingUpdate(d *pluginsdk.ResourceData, meta interface{}) error { | ||
| func resourceSecurityCenterSubscriptionPricingCreate(d *pluginsdk.ResourceData, meta interface{}) error { | ||
| client := meta.(*clients.Client).SecurityCenter.PricingClient | ||
|
|
|
|
||
| subscriptionId := meta.(*clients.Client).Account.SubscriptionId | ||
| ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) | ||
|
|
|
|
||
| func resourceSecurityCenterSubscriptionPricingUpdate(d *pluginsdk.ResourceData, meta interface{}) error { | ||
| client := meta.(*clients.Client).SecurityCenter.PricingClient | ||
|
|
|
|
||
| updateResponse, updateErr := client.Update(ctx, *id, update) | ||
| if updateErr != nil { | ||
| return fmt.Errorf("setting %s: %+v", id, updateErr) |
There was a problem hiding this comment.
| return fmt.Errorf("setting %s: %+v", id, updateErr) | |
| return fmt.Errorf("updating %s: %+v", id, updateErr) |
| return fmt.Errorf("setting %s: %+v", id, updateErr) | ||
| } | ||
|
|
||
| // The extensions list from backend might vary after `tier` changed, thus we need to retire it again. |
There was a problem hiding this comment.
should this be?
| // The extensions list from backend might vary after `tier` changed, thus we need to retire it again. | |
| // The extensions list from backend might vary after `tier` changed, thus we need to retrieve it again. |
| update.Properties.Extensions = extensions | ||
| _, updateErr := client.Update(ctx, *id, update) | ||
| if updateErr != nil { | ||
| return fmt.Errorf("setting %s: %+v", id, updateErr) |
There was a problem hiding this comment.
| return fmt.Errorf("setting %s: %+v", id, updateErr) | |
| return fmt.Errorf("updating %s: %+v", id, updateErr) |
| requiredAdditionalUpdate = currentlyFreeTier | ||
| } | ||
|
|
||
| updateResponse, updateErr := client.Update(ctx, *id, update) |
There was a problem hiding this comment.
we should be able to reuse err here
| updateResponse, updateErr := client.Update(ctx, *id, update) | |
| updateResponse, err := client.Update(ctx, *id, update) |
| return fmt.Errorf("setting %s: %+v", id, updateErr) | ||
| } | ||
| update.Properties.Extensions = extensions | ||
| _, updateErr := client.Update(ctx, *id, update) |
There was a problem hiding this comment.
| _, updateErr := client.Update(ctx, *id, update) | |
| _, err = client.Update(ctx, *id, update) |
| ### `azurerm_security_center_princing_tier` | ||
|
|
||
| * Changing the property `subplan` now forces a new resource to be created. | ||
|
|
There was a problem hiding this comment.
This isn't a 5.0 change anymore so this should be removed
|
kindly bubble this up |
|
kindly ping @stephybun |
* Update CHANGELOG.md for #28840 * Update CHANGELOG.md #28808 * Update CHANGELOG.md #27962 * Update CHANGELOG.md for #28859 * Update for #28825 * Update CHANGELOG.md for #28864 * Update CHANGELOG.md #28539 * Update CHANGELOG.md #28685 * Update CHANGELOG.md for #28818 * Update for #28857 #28799 #28856 * Update for #28122 * Update for #28248 #27805 * Update for #28853 * Update for #28316 #28494 #28696 * Update for #28754 * Update CHANGELOG.md #28771 * Update CHANGELOG.md #28842 * Update for #28879 * Update for #28199 * Update CHANGELOG.md #28862 * prep for release v4.21.0 --------- Co-authored-by: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Co-authored-by: Wodans Son <20408400+WodansSon@users.noreply.github.com> Co-authored-by: stephybun <steph@hashicorp.com> Co-authored-by: catriona-m <86247157+catriona-m@users.noreply.github.com> Co-authored-by: Matthew Frahry <mbfrahry@gmail.com> Co-authored-by: Wyatt Fry <wyattfry@gmail.com>
|
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. |
Community Note
Description
When
subplanchanges, there might be extensions enabled by default, force a new resource to be created to keep the resource consistent with configuration.PR Checklist
For example: “
resource_name_here- description of change e.g. adding propertynew_property_name_here”Changes to existing Resource / Data Source
Testing
azurerm_security_center_pricing- force new resource to be created when subplan changes [azurerm_security_center_pricing- force new resource to be created whensubplanchanges #27805]This is a (please select all that apply):
Related Issue(s)
Fixes #27338
Note
If this PR changes meaningfully during the course of review please update the title and description as required.