diff --git a/azurerm/internal/services/apimanagement/api_management_diagnostic_resource.go b/azurerm/internal/services/apimanagement/api_management_diagnostic_resource.go index 20f99daab017..6caf48496309 100644 --- a/azurerm/internal/services/apimanagement/api_management_diagnostic_resource.go +++ b/azurerm/internal/services/apimanagement/api_management_diagnostic_resource.go @@ -11,6 +11,9 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/apimanagement/parse" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/apimanagement/validate" + azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) @@ -21,9 +24,11 @@ func resourceArmApiManagementDiagnostic() *schema.Resource { Read: resourceArmApiManagementDiagnosticRead, Update: resourceArmApiManagementDiagnosticCreateUpdate, Delete: resourceArmApiManagementDiagnosticDelete, - Importer: &schema.ResourceImporter{ - State: schema.ImportStatePassthrough, - }, + + Importer: azSchema.ValidateResourceIDPriorToImport(func(id string) error { + _, err := parse.ApiManagementDiagnosticID(id) + return err + }), Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(30 * time.Minute), @@ -46,6 +51,12 @@ func resourceArmApiManagementDiagnostic() *schema.Resource { "api_management_name": azure.SchemaApiManagementName(), + "api_management_logger_id": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.ApiManagementLoggerID, + }, + "enabled": { Type: schema.TypeBool, Optional: true, @@ -78,7 +89,9 @@ func resourceArmApiManagementDiagnosticCreateUpdate(d *schema.ResourceData, meta } parameters := apimanagement.DiagnosticContract{ - DiagnosticContractProperties: &apimanagement.DiagnosticContractProperties{}, + DiagnosticContractProperties: &apimanagement.DiagnosticContractProperties{ + LoggerID: utils.String(d.Get("api_management_logger_id").(string)), + }, } if _, err := client.CreateOrUpdate(ctx, resourceGroup, serviceName, diagnosticId, parameters, ""); err != nil { @@ -90,7 +103,7 @@ func resourceArmApiManagementDiagnosticCreateUpdate(d *schema.ResourceData, meta return fmt.Errorf("retrieving Diagnostic %q (Resource Group %q / API Management Service %q): %+v", diagnosticId, resourceGroup, serviceName, err) } if resp.ID == nil { - return fmt.Errorf("Cannot read ID for Diagnostic %q (Resource Group %q / API Management Service %q)", diagnosticId, resourceGroup, serviceName) + return fmt.Errorf("reading ID for Diagnostic %q (Resource Group %q / API Management Service %q): ID is empty", diagnosticId, resourceGroup, serviceName) } d.SetId(*resp.ID) @@ -102,28 +115,26 @@ func resourceArmApiManagementDiagnosticRead(d *schema.ResourceData, meta interfa ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseAzureResourceID(d.Id()) + diagnosticId, err := parse.ApiManagementDiagnosticID(d.Id()) if err != nil { return err } - resourceGroup := id.ResourceGroup - serviceName := id.Path["service"] - diagnosticId := id.Path["diagnostics"] - resp, err := client.Get(ctx, resourceGroup, serviceName, diagnosticId) + resp, err := client.Get(ctx, diagnosticId.ResourceGroup, diagnosticId.ServiceName, diagnosticId.Name) if err != nil { if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[DEBUG] Diagnostic %q (Resource Group %q / API Management Service %q) was not found - removing from state!", diagnosticId, resourceGroup, serviceName) + log.Printf("[DEBUG] Diagnostic %q (Resource Group %q / API Management Service %q) was not found - removing from state!", diagnosticId.Name, diagnosticId.ResourceGroup, diagnosticId.ServiceName) d.SetId("") return nil } - return fmt.Errorf("making Read request for Diagnostic %q (Resource Group %q / API Management Service %q): %+v", diagnosticId, resourceGroup, serviceName, err) + return fmt.Errorf("making Read request for Diagnostic %q (Resource Group %q / API Management Service %q): %+v", diagnosticId.Name, diagnosticId.ResourceGroup, diagnosticId.ServiceName, err) } d.Set("identifier", resp.Name) - d.Set("resource_group_name", resourceGroup) - d.Set("api_management_name", serviceName) + d.Set("resource_group_name", diagnosticId.ResourceGroup) + d.Set("api_management_name", diagnosticId.ServiceName) + d.Set("api_management_logger_id", resp.LoggerID) return nil } @@ -133,17 +144,14 @@ func resourceArmApiManagementDiagnosticDelete(d *schema.ResourceData, meta inter ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseAzureResourceID(d.Id()) + diagnosticId, err := parse.ApiManagementDiagnosticID(d.Id()) if err != nil { return err } - resourceGroup := id.ResourceGroup - serviceName := id.Path["service"] - diagnosticId := id.Path["diagnostics"] - if resp, err := client.Delete(ctx, resourceGroup, serviceName, diagnosticId, ""); err != nil { + if resp, err := client.Delete(ctx, diagnosticId.ResourceGroup, diagnosticId.ServiceName, diagnosticId.Name, ""); err != nil { if !utils.ResponseWasNotFound(resp) { - return fmt.Errorf("deleting Diagnostic %q (Resource Group %q / API Management Service %q): %+v", diagnosticId, resourceGroup, serviceName, err) + return fmt.Errorf("deleting Diagnostic %q (Resource Group %q / API Management Service %q): %+v", diagnosticId.Name, diagnosticId.ResourceGroup, diagnosticId.ServiceName, err) } } diff --git a/azurerm/internal/services/apimanagement/parse/apimanagement.go b/azurerm/internal/services/apimanagement/parse/apimanagement.go new file mode 100644 index 000000000000..048d60a45ec1 --- /dev/null +++ b/azurerm/internal/services/apimanagement/parse/apimanagement.go @@ -0,0 +1,69 @@ +package parse + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) + +type ApiManagementLoggerId struct { + ResourceGroup string + ServiceName string + Name string +} + +func ApiManagementLoggerID(input string) (*ApiManagementLoggerId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("parsing Api Management Logger ID %q: %+v", input, err) + } + + logger := ApiManagementLoggerId{ + ResourceGroup: id.ResourceGroup, + } + + if logger.ServiceName, err = id.PopSegment("service"); err != nil { + return nil, err + } + + if logger.Name, err = id.PopSegment("loggers"); err != nil { + return nil, err + } + + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &logger, nil +} + +type ApiManagementDiagnosticId struct { + ResourceGroup string + ServiceName string + Name string +} + +func ApiManagementDiagnosticID(input string) (*ApiManagementDiagnosticId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("parsing Api Management Diagnostic ID %q: %+v", input, err) + } + + diagnostic := ApiManagementDiagnosticId{ + ResourceGroup: id.ResourceGroup, + } + + if diagnostic.ServiceName, err = id.PopSegment("service"); err != nil { + return nil, err + } + + if diagnostic.Name, err = id.PopSegment("diagnostics"); err != nil { + return nil, err + } + + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &diagnostic, nil +} diff --git a/azurerm/internal/services/apimanagement/parse/apimanagement_test.go b/azurerm/internal/services/apimanagement/parse/apimanagement_test.go new file mode 100644 index 000000000000..b60734df3c87 --- /dev/null +++ b/azurerm/internal/services/apimanagement/parse/apimanagement_test.go @@ -0,0 +1,169 @@ +package parse + +import "testing" + +func TestApiManagementLoggerID(t *testing.T) { + testData := []struct { + Name string + Input string + Expected *ApiManagementLoggerId + }{ + { + Name: "Empty", + Input: "", + Expected: nil, + }, + { + Name: "No Resource Groups Segment", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + Expected: nil, + }, + { + Name: "No Resource Groups Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + Expected: nil, + }, + { + Name: "Resource Group ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", + Expected: nil, + }, + { + Name: "Missing Service Name", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ApiManagement/service/", + Expected: nil, + }, + { + Name: "Missing Logger", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ApiManagement/service/service1", + Expected: nil, + }, + { + Name: "Missing Logger Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ApiManagement/service/service1/loggers", + Expected: nil, + }, + { + Name: "Logger ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ApiManagement/service/service1/loggers/logger1", + Expected: &ApiManagementLoggerId{ + Name: "logger1", + ServiceName: "service1", + ResourceGroup: "resGroup1", + }, + }, + { + Name: "Wrong Casing", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ApiManagement/service/service1/Loggers/logger1", + Expected: nil, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Name) + + actual, err := ApiManagementLoggerID(v.Input) + if err != nil { + if v.Expected == nil { + continue + } + + t.Fatalf("Expected a value but got an error: %s", err) + } + + if actual.Name != v.Expected.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) + } + + if actual.ServiceName != v.Expected.ServiceName { + t.Fatalf("Expected %q but got %q for Service Name", v.Expected.Name, actual.Name) + } + + if actual.ResourceGroup != v.Expected.ResourceGroup { + t.Fatalf("Expected %q but got %q for Resource Group", v.Expected.ResourceGroup, actual.ResourceGroup) + } + } +} + +func TestApiManagementDiagnosticID(t *testing.T) { + testData := []struct { + Name string + Input string + Expected *ApiManagementDiagnosticId + }{ + { + Name: "Empty", + Input: "", + Expected: nil, + }, + { + Name: "No Resource Groups Segment", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + Expected: nil, + }, + { + Name: "No Resource Groups Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + Expected: nil, + }, + { + Name: "Resource Group ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", + Expected: nil, + }, + { + Name: "Missing Service Name", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ApiManagement/service/", + Expected: nil, + }, + { + Name: "Missing Diagnostic", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ApiManagement/service/service1", + Expected: nil, + }, + { + Name: "Missing Diagnostic Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ApiManagement/service/service1/diagnostics", + Expected: nil, + }, + { + Name: "Diagnostic ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ApiManagement/service/service1/diagnostics/diagnostic1", + Expected: &ApiManagementDiagnosticId{ + Name: "diagnostic1", + ServiceName: "service1", + ResourceGroup: "resGroup1", + }, + }, + { + Name: "Wrong Casing", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ApiManagement/service/service1/Diagnostics/diagnostic1", + Expected: nil, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Name) + + actual, err := ApiManagementDiagnosticID(v.Input) + if err != nil { + if v.Expected == nil { + continue + } + + t.Fatalf("Expected a value but got an error: %s", err) + } + + if actual.Name != v.Expected.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) + } + + if actual.ServiceName != v.Expected.ServiceName { + t.Fatalf("Expected %q but got %q for Service Name", v.Expected.Name, actual.Name) + } + + if actual.ResourceGroup != v.Expected.ResourceGroup { + t.Fatalf("Expected %q but got %q for Resource Group", v.Expected.ResourceGroup, actual.ResourceGroup) + } + } +} diff --git a/azurerm/internal/services/apimanagement/tests/api_management_diagnostic_resource_test.go b/azurerm/internal/services/apimanagement/tests/api_management_diagnostic_resource_test.go index 2728778fcbc6..c11dc02228d5 100644 --- a/azurerm/internal/services/apimanagement/tests/api_management_diagnostic_resource_test.go +++ b/azurerm/internal/services/apimanagement/tests/api_management_diagnostic_resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/apimanagement/parse" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) @@ -30,6 +31,32 @@ func TestAccAzureRMApiManagementDiagnostic_basic(t *testing.T) { }) } +func TestAccAzureRMApiManagementDiagnostic_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_api_management_diagnostic", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMApiManagementDiagnosticDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMApiManagementDiagnostic_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMApiManagementDiagnosticExists(data.ResourceName), + ), + }, + data.ImportStep(), + { + Config: testAccAzureRMApiManagementDiagnostic_update(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMApiManagementDiagnosticExists(data.ResourceName), + ), + }, + data.ImportStep(), + }, + }) +} + func TestAccAzureRMApiManagementDiagnostic_requiresImport(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_api_management_diagnostic", "test") @@ -58,11 +85,11 @@ func testCheckAzureRMApiManagementDiagnosticDestroy(s *terraform.State) error { continue } - identifier := rs.Primary.Attributes["identifier"] - resourceGroup := rs.Primary.Attributes["resource_group_name"] - serviceName := rs.Primary.Attributes["api_management_name"] - - resp, err := client.Get(ctx, resourceGroup, serviceName, identifier) + diagnosticId, err := parse.ApiManagementDiagnosticID(rs.Primary.ID) + if err != nil { + return err + } + resp, err := client.Get(ctx, diagnosticId.ResourceGroup, diagnosticId.ServiceName, diagnosticId.Name) if err != nil { if !utils.ResponseWasNotFound(resp.Response) { @@ -85,35 +112,43 @@ func testCheckAzureRMApiManagementDiagnosticExists(resourceName string) resource return fmt.Errorf("Not found: %s", resourceName) } - identifier := rs.Primary.Attributes["identifier"] - resourceGroup := rs.Primary.Attributes["resource_group_name"] - serviceName := rs.Primary.Attributes["api_management_name"] + diagnosticId, err := parse.ApiManagementDiagnosticID(rs.Primary.ID) + if err != nil { + return err + } - resp, err := client.Get(ctx, resourceGroup, serviceName, identifier) + resp, err := client.Get(ctx, diagnosticId.ResourceGroup, diagnosticId.ServiceName, diagnosticId.Name) if err != nil { if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("Bad: API Management Diagnostic %q (Resource Group %q / API Management Service %q) does not exist", identifier, resourceGroup, serviceName) + return fmt.Errorf("bad: API Management Diagnostic %q (Resource Group %q / API Management Service %q) does not exist", diagnosticId.Name, diagnosticId.ResourceGroup, diagnosticId.ServiceName) } - return fmt.Errorf("Bad: Get on apiManagementDiagnosticClient: %+v", err) + return fmt.Errorf("bad: Get on apiManagementDiagnosticClient: %+v", err) } return nil } } -func testAccAzureRMApiManagementDiagnostic_basic(data acceptance.TestData) string { +func testAccAzureRMApiManagementDiagnostic_template(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { features {} } resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" +} + +resource "azurerm_application_insights" "test" { + name = "acctestappinsights-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + application_type = "web" } resource "azurerm_api_management" "test" { - name = "acctestAM-%d" + name = "acctestAM-%[1]d" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name publisher_name = "pub1" @@ -121,13 +156,61 @@ resource "azurerm_api_management" "test" { sku_name = "Developer_1" } +resource "azurerm_api_management_logger" "test" { + name = "acctestapimnglogger-%[1]d" + api_management_name = azurerm_api_management.test.name + resource_group_name = azurerm_resource_group.test.name + + application_insights { + instrumentation_key = azurerm_application_insights.test.instrumentation_key + } +} +`, data.RandomInteger, data.Locations.Primary) +} + +func testAccAzureRMApiManagementDiagnostic_basic(data acceptance.TestData) string { + config := testAccAzureRMApiManagementDiagnostic_template(data) + return fmt.Sprintf(` +%s + resource "azurerm_api_management_diagnostic" "test" { - identifier = "applicationinsights" + identifier = "applicationinsights" + resource_group_name = azurerm_resource_group.test.name + api_management_name = azurerm_api_management.test.name + api_management_logger_id = azurerm_api_management_logger.test.id +} +`, config) +} + +func testAccAzureRMApiManagementDiagnostic_update(data acceptance.TestData) string { + config := testAccAzureRMApiManagementDiagnostic_template(data) + return fmt.Sprintf(` +%[1]s + +resource "azurerm_application_insights" "test2" { + name = "acctestappinsightsUpdate-%[2]d" + location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name + application_type = "web" +} + +resource "azurerm_api_management_logger" "test2" { + name = "acctestapimngloggerUpdate-%[2]d" api_management_name = azurerm_api_management.test.name - enabled = true + resource_group_name = azurerm_resource_group.test.name + + application_insights { + instrumentation_key = azurerm_application_insights.test2.instrumentation_key + } +} + +resource "azurerm_api_management_diagnostic" "test" { + identifier = "applicationinsights" + resource_group_name = azurerm_resource_group.test.name + api_management_name = azurerm_api_management.test.name + api_management_logger_id = azurerm_api_management_logger.test2.id } -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) +`, config, data.RandomInteger) } func testAccAzureRMApiManagementDiagnostic_requiresImport(data acceptance.TestData) string { @@ -136,10 +219,10 @@ func testAccAzureRMApiManagementDiagnostic_requiresImport(data acceptance.TestDa %s resource "azurerm_api_management_diagnostic" "import" { - identifier = azurerm_api_management_diagnostic.test.identifier - resource_group_name = azurerm_api_management_diagnostic.test.resource_group_name - api_management_name = azurerm_api_management_diagnostic.test.api_management_name - enabled = azurerm_api_management_diagnostic.test.enabled + identifier = azurerm_api_management_diagnostic.test.identifier + resource_group_name = azurerm_api_management_diagnostic.test.resource_group_name + api_management_name = azurerm_api_management_diagnostic.test.api_management_name + api_management_logger_id = azurerm_api_management_diagnostic.test.api_management_logger_id } `, template) } diff --git a/azurerm/internal/services/apimanagement/validate/apimanagement.go b/azurerm/internal/services/apimanagement/validate/apimanagement.go new file mode 100644 index 000000000000..13ffe7e59543 --- /dev/null +++ b/azurerm/internal/services/apimanagement/validate/apimanagement.go @@ -0,0 +1,21 @@ +package validate + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/apimanagement/parse" +) + +func ApiManagementLoggerID(i interface{}, k string) (warnings []string, errors []error) { + v, ok := i.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected type of %q to be string", k)) + return warnings, errors + } + + if _, err := parse.ApiManagementLoggerID(v); err != nil { + errors = append(errors, fmt.Errorf("can not parse %q as a Api Management Logger id: %v", k, err)) + } + + return warnings, errors +} diff --git a/website/docs/r/api_management_diagnostic.html.markdown b/website/docs/r/api_management_diagnostic.html.markdown index 7fd8e3af4076..37aede8b600b 100644 --- a/website/docs/r/api_management_diagnostic.html.markdown +++ b/website/docs/r/api_management_diagnostic.html.markdown @@ -13,25 +13,45 @@ Manages an API Management Service Diagnostic. ## Example Usage ```hcl -resource "azurerm_resource_group" "test" { +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "example" { name = "example-resources" location = "West Europe" } -resource "azurerm_api_management" "test" { +resource "azurerm_application_insights" "example" { + name = "example-appinsights" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + application_type = "web" +} + +resource "azurerm_api_management" "example" { name = "example-apim" - location = azurerm_resource_group.test.location - resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name publisher_name = "My Company" publisher_email = "company@terraform.io" sku_name = "Developer_1" } +resource "azurerm_api_management_logger" "example" { + name = "example-apimlogger" + api_management_name = azurerm_api_management.example.name + resource_group_name = azurerm_resource_group.example.name + + application_insights { + instrumentation_key = azurerm_application_insights.example.instrumentation_key + } +} -resource "azurerm_api_management_diagnostic" "test" { - identifier = "applicationinsights" - resource_group_name = azurerm_resource_group.test.name - api_management_name = azurerm_api_management.test.name - enabled = true +resource "azurerm_api_management_diagnostic" "example" { + identifier = "applicationinsights" + resource_group_name = azurerm_resource_group.example.name + api_management_name = azurerm_api_management.example.name + api_management_logger_id = azurerm_api_management_logger.example.id } ``` @@ -45,7 +65,7 @@ The following arguments are supported: * `resource_group_name` - (Required) The Name of the Resource Group where the API Management Service exists. Changing this forces a new resource to be created. -* `enabled` - (Required) Indicates whether a Diagnostic should receive data or not. +* `api_management_logger_id` - (Required) The id of the target API Management Logger where the API Management Diagnostic should be saved. --- @@ -69,5 +89,5 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/d API Management Diagnostics can be imported using the `resource id`, e.g. ```shell -terraform import azurerm_api_management_diagnostic.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.ApiManagement/service/instance1/diagnostics/applicationinsights +terraform import azurerm_api_management_diagnostic.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.ApiManagement/service/instance1/diagnostics/applicationinsights ``` diff --git a/website/docs/r/eventgrid_domain_topic.html.markdown b/website/docs/r/eventgrid_domain_topic.html.markdown index 1a1f45ede7dc..53189127e20a 100644 --- a/website/docs/r/eventgrid_domain_topic.html.markdown +++ b/website/docs/r/eventgrid_domain_topic.html.markdown @@ -63,4 +63,4 @@ EventGrid Domain Topics can be imported using the `resource id`, e.g. ```shell terraform import azurerm_eventgrid_domain_topic.topic1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.EventGrid/domains/domain1/topics/topic1 -``` \ No newline at end of file +```