-
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
New Resource: azurerm_security_center_subscription_pricing #2043
Conversation
|
||
# azurerm_securitycenter_subscription_pricing | ||
|
||
Manages the subscription's Security Center pricing tier. |
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.
Does this resource need Owner
permission here?
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.
From memory I believe this does - but it'd be worth confirming/documenting here
}, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"tier": { |
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.
Does the API support in-place update ?
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.
Yep
client := meta.(*ArmClient).securityCenterPricingClient | ||
ctx := meta.(*ArmClient).StopContext | ||
|
||
resp, err := client.GetSubscriptionPricing(ctx, "default") |
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.
merge to single line?
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.
It cannot be done as resp is used below
client := meta.(*ArmClient).securityCenterPricingClient | ||
ctx := meta.(*ArmClient).StopContext | ||
|
||
resp, err := client.GetSubscriptionPricing(ctx, "default") |
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.
Shall we move "default" to a constant variable?
|
||
resp, err := client.GetSubscriptionPricing(ctx, "default") | ||
if err != nil { | ||
if utils.ResponseWasNotFound(resp.Response) { |
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.
Is it because of terraform import
?
}, | ||
} | ||
|
||
_, err := client.UpdateSubscriptionPricing(ctx, "default", pricing) |
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.
move to constant variable?
return fmt.Errorf("Error creating/updating Security Center Subscription pricing: %+v", err) | ||
} | ||
|
||
resp, err := client.GetSubscriptionPricing(ctx, "default") |
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.
Is the GetSubscriptionPricing
duplicated with resourceArmSecurityCenterSubscriptionPricingRead
?
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.
LGTM with some suggestions.
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.
a few minor comments but this otherwise LGTM 👍
"tier": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
DiffSuppressFunc: suppress.CaseDifference, |
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.
we can remove this since we're requiring the case matches below
} | ||
|
||
func resourceArmSecurityCenterSubscriptionPricingDelete(_ *schema.ResourceData, _ interface{}) error { | ||
return nil //cannot be 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.
can we revert to whatever the default value is? we do this for the Postgresql/MySql configuration value resources
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" | ||
) | ||
|
||
func resourceArmSecurityCenterSubscriptionPricing() *schema.Resource { |
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.
thinking about this longer term - I think this'd make more sense as a nested element on the azurerm_subscription
resource (but this is fine as an independent resource for the moment) 🤔
azurerm/provider.go
Outdated
@@ -243,6 +243,7 @@ func Provider() terraform.ResourceProvider { | |||
"azurerm_route": resourceArmRoute(), | |||
"azurerm_route_table": resourceArmRouteTable(), | |||
"azurerm_search_service": resourceArmSearchService(), | |||
"azurerm_securitycenter_subscription_pricing": resourceArmSecurityCenterSubscriptionPricing(), |
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.
securitycenter
-> security_center
page_title: "Azure Resource Manager: azurerm_securitycenter_subscription_pricing" | ||
sidebar_current: "docs-azurerm-securitycenter-subscription-pricing" | ||
description: |- | ||
Manages the subscription's Security Center pricing tier. |
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.
I think this'd read clearer as Manages the Pricing Tier for Azure Security Center in the current subscription
- what do you think (and below too)
|
||
# azurerm_securitycenter_subscription_pricing | ||
|
||
Manages the subscription's Security Center pricing tier. |
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.
From memory I believe this does - but it'd be worth confirming/documenting here
|
||
* `tier` - (Required) The pricing tier to use. Must be one of `Free` or `Standard`. | ||
|
||
~> **NOTE:** Changing the pricing tier to `Standard` affects all resources in the subscription and could be quite costly. |
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.
👍
8fa67b0
to
0f32cf6
Compare
0f32cf6
to
1ee95b2
Compare
Tests pass:
|
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.
a few minor things but this otherwise LGTM 👍
) | ||
|
||
func TestAccAzureRMSecurityCenterSubscriptionPricing_update(t *testing.T) { | ||
resourceName := "azurerm_security_center_subscription_pricing.test" |
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 fine for now - we may want to add a feature-toggle for this in time
The pricing tier can be imported using the `resource id`, e.g. | ||
|
||
```shell | ||
terraform import azurerm_securitycenter_subscription_pricing.example /subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Security/pricings/default |
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.
securitycenter
-> security_center
|
||
The following arguments are supported: | ||
|
||
* `tier` - (Required) The pricing tier to use. Must be one of `Free` or `Standard`. |
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.
to match the other resources this'd be better as:
Possible values are `Free` and `Standard`
|
||
Manages the Pricing Tier for Azure Security Center in the current subscription. | ||
|
||
~> **NOTE:** Owner access permission is 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.
Would this be clearer as:
This resource requires the `Owner` permission on the Subscription
|
||
# azurerm_security_center_subscription_pricing | ||
|
||
Manages the Pricing Tier for Azure Security Center in the current subscription. |
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.
IMO we should add a note about Deletion here
433fac6
to
4a4268b
Compare
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! |
No description provided.