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_logger: add resource_id attribute #10652

Merged
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 @@ -42,6 +42,12 @@ func resourceApiManagementLogger() *schema.Resource {

"api_management_name": schemaz.SchemaApiManagementName(),

"resource_id": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: azure.ValidateResourceID,
},

"eventhub": {
Type: schema.TypeList,
MaxItems: 1,
Expand Down Expand Up @@ -142,6 +148,10 @@ func resourceApiManagementLoggerCreate(d *schema.ResourceData, meta interface{})
parameters.Credentials = expandApiManagementLoggerApplicationInsights(appInsightsRaw)
}

if resourceId := d.Get("resource_id").(string); resourceId != "" {
parameters.ResourceID = utils.String(resourceId)
}

if _, err := client.CreateOrUpdate(ctx, resourceGroup, serviceName, name, parameters, ""); err != nil {
return fmt.Errorf("creating Logger %q (Resource Group %q / API Management Service %q): %+v", name, resourceGroup, serviceName, err)
}
Expand Down Expand Up @@ -184,6 +194,7 @@ func resourceApiManagementLoggerRead(d *schema.ResourceData, meta interface{}) e
d.Set("name", resp.Name)
d.Set("resource_group_name", resourceGroup)
d.Set("api_management_name", serviceName)
d.Set("resource_id", resp.ResourceID)

if properties := resp.LoggerContractProperties; properties != nil {
d.Set("buffered", properties.IsBuffered)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func TestAccApiManagementLogger_complete(t *testing.T) {
check.That(data.ResourceName).Key("eventhub.#").HasValue("0"),
check.That(data.ResourceName).Key("application_insights.#").HasValue("1"),
check.That(data.ResourceName).Key("application_insights.0.instrumentation_key").Exists(),
check.That(data.ResourceName).Key("resource_id").Exists(),
),
},
{
Expand Down Expand Up @@ -340,6 +341,7 @@ resource "azurerm_api_management_logger" "test" {
resource_group_name = azurerm_resource_group.test.name
description = "%s"
buffered = %s
resource_id = azurerm_application_insights.test.id

application_insights {
instrumentation_key = azurerm_application_insights.test.instrumentation_key
Expand Down
3 changes: 3 additions & 0 deletions website/docs/r/api_management_logger.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ resource "azurerm_api_management_logger" "example" {
name = "example-logger"
api_management_name = azurerm_api_management.example.name
resource_group_name = azurerm_resource_group.example.name
resource_id = azurerm_application_insights.example.id

application_insights {
instrumentation_key = azurerm_application_insights.example.instrumentation_key
Expand All @@ -66,6 +67,8 @@ The following arguments are supported:

* `eventhub` - (Optional) An `eventhub` block as documented below.

* `resource_id` - (Optional) The target resource id which will be linked in the API-Management portal page.
patst marked this conversation as resolved.
Show resolved Hide resolved

---

An `application_insights` block supports the following:
Expand Down