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

azurerm_api_management_subscription - Support allow_tracing property #7969

Merged
merged 6 commits into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ func resourceArmApiManagementSubscription() *schema.Resource {
Computed: true,
Sensitive: true,
},

"allow_tracing": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

could we add an acceptance covering setting, and enabling/disabling this field - we should be able to add this to the 'update' test to confirm this works

},
}
}
Expand Down Expand Up @@ -123,13 +129,15 @@ func resourceArmApiManagementSubscriptionCreateUpdate(d *schema.ResourceData, me
productId := d.Get("product_id").(string)
state := d.Get("state").(string)
userId := d.Get("user_id").(string)
allowTracing := d.Get("allow_tracing").(bool)

params := apimanagement.SubscriptionCreateParameters{
SubscriptionCreateParameterProperties: &apimanagement.SubscriptionCreateParameterProperties{
DisplayName: utils.String(displayName),
Scope: utils.String(productId),
State: apimanagement.SubscriptionState(state),
OwnerID: utils.String(userId),
DisplayName: utils.String(displayName),
Scope: utils.String(productId),
State: apimanagement.SubscriptionState(state),
OwnerID: utils.String(userId),
AllowTracing: utils.Bool(allowTracing),
},
}

Expand Down Expand Up @@ -190,6 +198,7 @@ func resourceArmApiManagementSubscriptionRead(d *schema.ResourceData, meta inter
d.Set("state", string(props.State))
d.Set("product_id", props.Scope)
d.Set("user_id", props.OwnerID)
d.Set("allow_tracing", props.AllowTracing)
}

// Primary and secondary keys must be got from this additional api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func TestAccAzureRMAPIManagementSubscription_basic(t *testing.T) {
Config: testAccAzureRMAPIManagementSubscription_basic(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAPIManagementSubscriptionExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "allow_tracing", "true"),
resource.TestCheckResourceAttrSet(data.ResourceName, "subscription_id"),
resource.TestCheckResourceAttrSet(data.ResourceName, "primary_key"),
resource.TestCheckResourceAttrSet(data.ResourceName, "secondary_key"),
Expand Down Expand Up @@ -64,36 +65,44 @@ func TestAccAzureRMAPIManagementSubscription_update(t *testing.T) {
CheckDestroy: testCheckAzureRMAPIManagementSubscriptionDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMAPIManagementSubscription_update(data, "submitted"),
Config: testAccAzureRMAPIManagementSubscription_update(data, "submitted", "true"),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAPIManagementSubscriptionExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "state", "submitted"),
resource.TestCheckResourceAttr(data.ResourceName, "allow_tracing", "true"),
resource.TestCheckResourceAttrSet(data.ResourceName, "subscription_id"),
resource.TestCheckResourceAttrSet(data.ResourceName, "primary_key"),
resource.TestCheckResourceAttrSet(data.ResourceName, "secondary_key"),
),
},
{
Config: testAccAzureRMAPIManagementSubscription_update(data, "active"),
Config: testAccAzureRMAPIManagementSubscription_update(data, "active", "true"),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAPIManagementSubscriptionExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "state", "active"),
),
},
{
Config: testAccAzureRMAPIManagementSubscription_update(data, "suspended"),
Config: testAccAzureRMAPIManagementSubscription_update(data, "suspended", "true"),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAPIManagementSubscriptionExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "state", "suspended"),
),
},
{
Config: testAccAzureRMAPIManagementSubscription_update(data, "cancelled"),
Config: testAccAzureRMAPIManagementSubscription_update(data, "cancelled", "true"),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAPIManagementSubscriptionExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "state", "cancelled"),
),
},
{
Config: testAccAzureRMAPIManagementSubscription_update(data, "active", "false"),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAPIManagementSubscriptionExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "allow_tracing", "false"),
),
},
},
})
}
Expand All @@ -111,6 +120,7 @@ func TestAccAzureRMAPIManagementSubscription_complete(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAPIManagementSubscriptionExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "state", "active"),
resource.TestCheckResourceAttr(data.ResourceName, "allow_tracing", "false"),
resource.TestCheckResourceAttrSet(data.ResourceName, "subscription_id"),
resource.TestCheckResourceAttrSet(data.ResourceName, "primary_key"),
resource.TestCheckResourceAttrSet(data.ResourceName, "secondary_key"),
Expand Down Expand Up @@ -202,7 +212,7 @@ resource "azurerm_api_management_subscription" "import" {
`, template)
}

func testAccAzureRMAPIManagementSubscription_update(data acceptance.TestData, state string) string {
func testAccAzureRMAPIManagementSubscription_update(data acceptance.TestData, state string, allow_tracing string) string {
template := testAccAzureRMAPIManagementSubscription_template(data)
return fmt.Sprintf(`
%s
Expand All @@ -214,8 +224,9 @@ resource "azurerm_api_management_subscription" "test" {
product_id = azurerm_api_management_product.test.id
display_name = "Butter Parser API Enterprise Edition"
state = "%s"
allow_tracing = "%s"
}
`, template, state)
`, template, state, allow_tracing)
}

func testAccAzureRMAPIManagementSubscription_complete(data acceptance.TestData) string {
Expand All @@ -230,6 +241,7 @@ resource "azurerm_api_management_subscription" "test" {
product_id = azurerm_api_management_product.test.id
display_name = "Butter Parser API Enterprise Edition"
state = "active"
allow_tracing = "false"
}
`, template)
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/api_management_subscription.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ The following arguments are supported:

* `subscription_id` - (Optional) An Identifier which should used as the ID of this Subscription. If not specified a new Subscription ID will be generated. Changing this forces a new resource to be created.

* `allow_tracing` - (Optional) Determines whether tracing can be enabled. Defaults to `true`.

## Attributes Reference

In addition to all arguments above, the following attributes are exported:
Expand Down