Skip to content

Commit

Permalink
Address PR #2043 comments
Browse files Browse the repository at this point in the history
  • Loading branch information
katbyte committed Oct 13, 2018
1 parent 64dfcad commit 8fa67b0
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion azurerm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func Provider() terraform.ResourceProvider {
"azurerm_route": resourceArmRoute(),
"azurerm_route_table": resourceArmRouteTable(),
"azurerm_search_service": resourceArmSearchService(),
"azurerm_securitycenter_subscription_pricing": resourceArmSecurityCenterSubscriptionPricing(),
"azurerm_security_center_subscription_pricing": resourceArmSecurityCenterSubscriptionPricing(),
"azurerm_servicebus_namespace": resourceArmServiceBusNamespace(),
"azurerm_servicebus_namespace_authorization_rule": resourceArmServiceBusNamespaceAuthorizationRule(),
"azurerm_servicebus_queue": resourceArmServiceBusQueue(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ import (
"log"

"github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/2017-08-01-preview/security"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/suppress"

"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

//NOTE: seems default is the only valid pricing name:
//Code="InvalidInputJson" Message="Pricing name 'kt's price' is not allowed. Expected 'default' for this scope."
const securityCenterConfigurationSubscriptionPricingName = "default"

func resourceArmSecurityCenterSubscriptionPricing() *schema.Resource {
return &schema.Resource{
Create: resourceArmSecurityCenterSubscriptionPricingCreateUpdate,
Create: resourceArmSecurityCenterSubscriptionPricingUpdate,
Read: resourceArmSecurityCenterSubscriptionPricingRead,
Update: resourceArmSecurityCenterSubscriptionPricingCreateUpdate,
Update: resourceArmSecurityCenterSubscriptionPricingUpdate,
Delete: resourceArmSecurityCenterSubscriptionPricingDelete,

Importer: &schema.ResourceImporter{
Expand All @@ -27,7 +29,6 @@ func resourceArmSecurityCenterSubscriptionPricing() *schema.Resource {
"tier": {
Type: schema.TypeString,
Required: true,
DiffSuppressFunc: suppress.CaseDifference,
ValidateFunc: validation.StringInSlice([]string{
string(security.Free),
string(security.Standard),
Expand All @@ -37,9 +38,9 @@ func resourceArmSecurityCenterSubscriptionPricing() *schema.Resource {
}
}

//NOTE: seems default is the only valid pricing name:
//Code="InvalidInputJson" Message="Pricing name '360k Sponsored' is not allowed. Expected 'default' for this scope."
func resourceArmSecurityCenterSubscriptionPricingCreateUpdate(d *schema.ResourceData, meta interface{}) error {

func resourceArmSecurityCenterSubscriptionPricingUpdate(d *schema.ResourceData, meta interface{}) error {
name := securityCenterConfigurationSubscriptionPricingName
client := meta.(*ArmClient).securityCenterPricingClient
ctx := meta.(*ArmClient).StopContext

Expand All @@ -49,12 +50,12 @@ func resourceArmSecurityCenterSubscriptionPricingCreateUpdate(d *schema.Resource
},
}

_, err := client.UpdateSubscriptionPricing(ctx, "default", pricing)
_, err := client.UpdateSubscriptionPricing(ctx, name, pricing)
if err != nil {
return fmt.Errorf("Error creating/updating Security Center Subscription pricing: %+v", err)
}

resp, err := client.GetSubscriptionPricing(ctx, "default")
resp, err := client.GetSubscriptionPricing(ctx, name)
if err != nil {
return fmt.Errorf("Error reading Security Center Subscription pricing: %+v", err)
}
Expand All @@ -68,10 +69,11 @@ func resourceArmSecurityCenterSubscriptionPricingCreateUpdate(d *schema.Resource
}

func resourceArmSecurityCenterSubscriptionPricingRead(d *schema.ResourceData, meta interface{}) error {
name := securityCenterConfigurationSubscriptionPricingName
client := meta.(*ArmClient).securityCenterPricingClient
ctx := meta.(*ArmClient).StopContext

resp, err := client.GetSubscriptionPricing(ctx, "default")
resp, err := client.GetSubscriptionPricing(ctx, name)
if err != nil {
if utils.ResponseWasNotFound(resp.Response) {
log.Printf("[DEBUG] Security Center Subscription was not found: %v", err)
Expand All @@ -90,5 +92,5 @@ func resourceArmSecurityCenterSubscriptionPricingRead(d *schema.ResourceData, me
}

func resourceArmSecurityCenterSubscriptionPricingDelete(_ *schema.ResourceData, _ interface{}) error {
return nil //cannot be deleted
return nil //cannot be deleted.
}
6 changes: 3 additions & 3 deletions website/azurerm.erb
Original file line number Diff line number Diff line change
Expand Up @@ -973,11 +973,11 @@
</ul>
</li>

<li<%= sidebar_current("docs-azurerm-resource-securitycenter") %>>
<li<%= sidebar_current("docs-azurerm-resource-security-center") %>>
<a href="#">Security Center Resources</a>
<ul class="nav nav-visible">
<li<%= sidebar_current("docs-azurerm-securitycenter-subscription-pricing") %>>
<a href="/docs/providers/azurerm/r/securitycenter_subscription_pricing.html">azurerm_securitycenter_subscription_pricing</a>
<li<%= sidebar_current("docs-azurerm-security-center-subscription-pricing") %>>
<a href="/docs/providers/azurerm/r/security_center_subscription_pricing.html">azurerm_security_center_subscription_pricing</a>
</li>
</ul>
</li>
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/search_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: |-

# azurerm_search_service

Allows you to manage an Azure Search Service
Allows you to manage an Azure Search Service.

## Example Usage

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
---
layout: "azurerm"
page_title: "Azure Resource Manager: azurerm_securitycenter_subscription_pricing"
sidebar_current: "docs-azurerm-securitycenter-subscription-pricing"
page_title: "Azure Resource Manager: azurerm_security_center_subscription_pricing"
sidebar_current: "docs-azurerm-security-center-subscription-pricing"
description: |-
Manages the subscription's Security Center pricing tier.
Manages the Pricing Tier for Azure Security Center in the current subscription.
---

# azurerm_securitycenter_subscription_pricing
# azurerm_security_center_subscription_pricing

Manages the subscription's Security Center pricing tier.
Manages the Pricing Tier for Azure Security Center in the current subscription.

~> **NOTE:** Owner access permission is required.

## Example Usage

```hcl
resource "azurerm_securitycenter_subscription_pricing" "example" {
resource "azurerm_security_center_subscription_pricing" "example" {
tier = "Standard"
}
```
Expand Down

0 comments on commit 8fa67b0

Please sign in to comment.