From 0f70cb2accae4499ed3b930357c23bb82ad772f8 Mon Sep 17 00:00:00 2001 From: Vladimir Lazarenko Date: Wed, 6 Oct 2021 09:53:25 +0200 Subject: [PATCH] New resource: `azurerm_data_factory_linked_service_cosmosdb_mongoapi` Fixes #8905 ``` $ TF_ACC=1 go test -v ./internal/services/datafactory -timeout=1000m -run='TestAccDataFactoryLinkedServiceCosmosDbMongoAPI' === RUN TestAccDataFactoryLinkedServiceCosmosDbMongoAPI_basic === PAUSE TestAccDataFactoryLinkedServiceCosmosDbMongoAPI_basic === RUN TestAccDataFactoryLinkedServiceCosmosDbMongoAPI_serverVersionAbove32 === PAUSE TestAccDataFactoryLinkedServiceCosmosDbMongoAPI_serverVersionAbove32 === RUN TestAccDataFactoryLinkedServiceCosmosDbMongoAPI_update === PAUSE TestAccDataFactoryLinkedServiceCosmosDbMongoAPI_update === CONT TestAccDataFactoryLinkedServiceCosmosDbMongoAPI_basic === CONT TestAccDataFactoryLinkedServiceCosmosDbMongoAPI_update === CONT TestAccDataFactoryLinkedServiceCosmosDbMongoAPI_serverVersionAbove32 --- PASS: TestAccDataFactoryLinkedServiceCosmosDbMongoAPI_serverVersionAbove32 (142.39s) --- PASS: TestAccDataFactoryLinkedServiceCosmosDbMongoAPI_basic (144.43s) --- PASS: TestAccDataFactoryLinkedServiceCosmosDbMongoAPI_update (189.73s) PASS ok github.com/hashicorp/terraform-provider-azurerm/internal/services/datafactory 191.256s ``` --- ...nked_service_cosmosdb_mongoapi_resource.go | 272 ++++++++++++++++++ ...service_cosmosdb_mongoapi_resource_test.go | 223 ++++++++++++++ internal/services/datafactory/registration.go | 1 + .../docs/guides/3.0-overview.html.markdown | 2 +- ...nsights_smart_detection_rule.html.markdown | 2 +- ...tory_linked_service_cosmosdb.html.markdown | 4 +- ...ed_service_cosmosdb_mongoapi.html.markdown | 92 ++++++ 7 files changed, 592 insertions(+), 4 deletions(-) create mode 100644 internal/services/datafactory/data_factory_linked_service_cosmosdb_mongoapi_resource.go create mode 100644 internal/services/datafactory/data_factory_linked_service_cosmosdb_mongoapi_resource_test.go create mode 100644 website/docs/r/data_factory_linked_service_cosmosdb_mongoapi.html.markdown diff --git a/internal/services/datafactory/data_factory_linked_service_cosmosdb_mongoapi_resource.go b/internal/services/datafactory/data_factory_linked_service_cosmosdb_mongoapi_resource.go new file mode 100644 index 0000000000000..11f4a38b8289b --- /dev/null +++ b/internal/services/datafactory/data_factory_linked_service_cosmosdb_mongoapi_resource.go @@ -0,0 +1,272 @@ +package datafactory + +import ( + "fmt" + "time" + + "github.com/Azure/azure-sdk-for-go/services/datafactory/mgmt/2018-06-01/datafactory" + "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" + "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/datafactory/parse" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/datafactory/validate" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" + "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +func resourceDataFactoryLinkedServiceCosmosDbMongoAPI() *pluginsdk.Resource { + return &pluginsdk.Resource{ + Create: resourceDataFactoryLinkedServiceCosmosDbMongoAPICreateUpdate, + Read: resourceDataFactoryLinkedServiceCosmosDbMongoAPIRead, + Update: resourceDataFactoryLinkedServiceCosmosDbMongoAPICreateUpdate, + Delete: resourceDataFactoryLinkedServiceCosmosDbMongoAPIDelete, + + // TODO: replace this with an importer which validates the ID during import + Importer: pluginsdk.DefaultImporter(), + + Timeouts: &pluginsdk.ResourceTimeout{ + Create: pluginsdk.DefaultTimeout(30 * time.Minute), + Read: pluginsdk.DefaultTimeout(5 * time.Minute), + Update: pluginsdk.DefaultTimeout(30 * time.Minute), + Delete: pluginsdk.DefaultTimeout(30 * time.Minute), + }, + + Schema: map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.LinkedServiceDatasetName, + }, + + "data_factory_name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.DataFactoryName(), + }, + + // There's a bug in the Azure API where this is returned in lower-case + // BUG: https://github.com/Azure/azure-rest-api-specs/issues/5788 + "resource_group_name": azure.SchemaResourceGroupNameDiffSuppress(), + + "connection_string": { + Type: pluginsdk.TypeString, + Optional: true, + Sensitive: true, + DiffSuppressFunc: azureRmDataFactoryLinkedServiceConnectionStringDiff, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "database": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "server_version_above_32": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + + "description": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "integration_runtime_name": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "parameters": { + Type: pluginsdk.TypeMap, + Optional: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + }, + + "annotations": { + Type: pluginsdk.TypeList, + Optional: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + }, + + "additional_properties": { + Type: pluginsdk.TypeMap, + Optional: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + }, + }, + } +} + +func resourceDataFactoryLinkedServiceCosmosDbMongoAPICreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).DataFactory.LinkedServiceClient + ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) + defer cancel() + + name := d.Get("name").(string) + dataFactoryName := d.Get("data_factory_name").(string) + resourceGroup := d.Get("resource_group_name").(string) + + if d.IsNewResource() { + existing, err := client.Get(ctx, resourceGroup, dataFactoryName, name, "") + if err != nil { + if !utils.ResponseWasNotFound(existing.Response) { + return fmt.Errorf("checking for presence of existing Data Factory Linked Service CosmosDb %q (Data Factory %q / Resource Group %q): %+v", name, dataFactoryName, resourceGroup, err) + } + } + + if existing.ID != nil && *existing.ID != "" { + return tf.ImportAsExistsError("azurerm_data_factory_linked_service_cosmosdb", *existing.ID) + } + } + + cosmosdbProperties := &datafactory.CosmosDbMongoDbAPILinkedServiceTypeProperties{} + + databaseName := d.Get("database").(string) + versionAbove32 := d.Get("server_version_above_32").(bool) + + connectionString := d.Get("connection_string").(string) + connectionStringSecureString := datafactory.SecureString{ + Value: &connectionString, + Type: datafactory.TypeSecureString, + } + cosmosdbProperties.ConnectionString = connectionStringSecureString + cosmosdbProperties.Database = databaseName + cosmosdbProperties.IsServerVersionAbove32 = versionAbove32 + + description := d.Get("description").(string) + + cosmosdbLinkedService := &datafactory.CosmosDbMongoDbAPILinkedService{ + Description: &description, + CosmosDbMongoDbAPILinkedServiceTypeProperties: cosmosdbProperties, + Type: datafactory.TypeBasicLinkedServiceTypeCosmosDbMongoDbAPI, + } + + if v, ok := d.GetOk("parameters"); ok { + cosmosdbLinkedService.Parameters = expandDataFactoryParameters(v.(map[string]interface{})) + } + + if v, ok := d.GetOk("integration_runtime_name"); ok { + cosmosdbLinkedService.ConnectVia = expandDataFactoryLinkedServiceIntegrationRuntime(v.(string)) + } + + if v, ok := d.GetOk("additional_properties"); ok { + cosmosdbLinkedService.AdditionalProperties = v.(map[string]interface{}) + } + + if v, ok := d.GetOk("annotations"); ok { + annotations := v.([]interface{}) + cosmosdbLinkedService.Annotations = &annotations + } + + linkedService := datafactory.LinkedServiceResource{ + Properties: cosmosdbLinkedService, + } + + if _, err := client.CreateOrUpdate(ctx, resourceGroup, dataFactoryName, name, linkedService, ""); err != nil { + return fmt.Errorf("creating/updating Data Factory Linked Service CosmosDb %q (Data Factory %q / Resource Group %q): %+v", name, dataFactoryName, resourceGroup, err) + } + + resp, err := client.Get(ctx, resourceGroup, dataFactoryName, name, "") + if err != nil { + return fmt.Errorf("retrieving Data Factory Linked Service CosmosDb %q (Data Factory %q / Resource Group %q): %+v", name, dataFactoryName, resourceGroup, err) + } + + if resp.ID == nil { + return fmt.Errorf("Cannot read Data Factory Linked Service CosmosDb %q (Data Factory %q / Resource Group %q): %+v", name, dataFactoryName, resourceGroup, err) + } + + d.SetId(*resp.ID) + + return resourceDataFactoryLinkedServiceCosmosDbMongoAPIRead(d, meta) +} + +func resourceDataFactoryLinkedServiceCosmosDbMongoAPIRead(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).DataFactory.LinkedServiceClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.LinkedServiceID(d.Id()) + if err != nil { + return err + } + + resp, err := client.Get(ctx, id.ResourceGroup, id.FactoryName, id.Name, "") + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + d.SetId("") + return nil + } + + return fmt.Errorf("retrieving Data Factory Linked Service CosmosDB %q (Data Factory %q / Resource Group %q): %+v", id.Name, id.FactoryName, id.ResourceGroup, err) + } + + d.Set("name", resp.Name) + d.Set("resource_group_name", id.ResourceGroup) + d.Set("data_factory_name", id.FactoryName) + + cosmosdb, ok := resp.Properties.AsCosmosDbMongoDbAPILinkedService() + if !ok { + return fmt.Errorf("classifying Data Factory Linked Service CosmosDb %q (Data Factory %q / Resource Group %q): Expected: %q Received: %q", id.Name, id.FactoryName, id.ResourceGroup, datafactory.TypeBasicLinkedServiceTypeCosmosDbMongoDbAPI, *resp.Type) + } + + d.Set("additional_properties", cosmosdb.AdditionalProperties) + d.Set("description", cosmosdb.Description) + + annotations := flattenDataFactoryAnnotations(cosmosdb.Annotations) + if err := d.Set("annotations", annotations); err != nil { + return fmt.Errorf("setting `annotations`: %+v", err) + } + + parameters := flattenDataFactoryParameters(cosmosdb.Parameters) + if err := d.Set("parameters", parameters); err != nil { + return fmt.Errorf("setting `parameters`: %+v", err) + } + + if connectVia := cosmosdb.ConnectVia; connectVia != nil { + if connectVia.ReferenceName != nil { + d.Set("integration_runtime_name", connectVia.ReferenceName) + } + } + + databaseName := cosmosdb.CosmosDbMongoDbAPILinkedServiceTypeProperties.Database + d.Set("database", databaseName) + + versionAbove32 := cosmosdb.CosmosDbMongoDbAPILinkedServiceTypeProperties.IsServerVersionAbove32 + d.Set("server_version_above_32", versionAbove32) + + return nil +} + +func resourceDataFactoryLinkedServiceCosmosDbMongoAPIDelete(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).DataFactory.LinkedServiceClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.LinkedServiceID(d.Id()) + if err != nil { + return err + } + + response, err := client.Delete(ctx, id.ResourceGroup, id.FactoryName, id.Name) + if err != nil { + if !utils.ResponseWasNotFound(response) { + return fmt.Errorf("deleting Data Factory Linked Service CosmosDb %q (Data Factory %q / Resource Group %q): %+v", id.Name, id.FactoryName, id.ResourceGroup, err) + } + } + + return nil +} diff --git a/internal/services/datafactory/data_factory_linked_service_cosmosdb_mongoapi_resource_test.go b/internal/services/datafactory/data_factory_linked_service_cosmosdb_mongoapi_resource_test.go new file mode 100644 index 0000000000000..76d5caf96f5ca --- /dev/null +++ b/internal/services/datafactory/data_factory_linked_service_cosmosdb_mongoapi_resource_test.go @@ -0,0 +1,223 @@ +package datafactory_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type LinkedServiceCosmosDBMongoAPIResource struct { +} + +func TestAccDataFactoryLinkedServiceCosmosDbMongoAPI_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_data_factory_linked_service_cosmosdb_mongoapi", "test") + r := LinkedServiceCosmosDBMongoAPIResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("connection_string"), + }) +} + +func TestAccDataFactoryLinkedServiceCosmosDbMongoAPI_serverVersionAbove32(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_data_factory_linked_service_cosmosdb_mongoapi", "test") + r := LinkedServiceCosmosDBMongoAPIResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.serverVersionAbove32(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("connection_string"), + }) +} + +func TestAccDataFactoryLinkedServiceCosmosDbMongoAPI_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_data_factory_linked_service_cosmosdb_mongoapi", "test") + r := LinkedServiceCosmosDBMongoAPIResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.update1(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("parameters.%").HasValue("2"), + check.That(data.ResourceName).Key("annotations.#").HasValue("3"), + check.That(data.ResourceName).Key("additional_properties.%").HasValue("2"), + check.That(data.ResourceName).Key("description").HasValue("test description"), + ), + }, + data.ImportStep("connection_string"), + { + Config: r.update2(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("parameters.%").HasValue("3"), + check.That(data.ResourceName).Key("annotations.#").HasValue("2"), + check.That(data.ResourceName).Key("additional_properties.%").HasValue("1"), + check.That(data.ResourceName).Key("description").HasValue("test description 2"), + ), + }, + data.ImportStep("connection_string"), + }) +} + +func (t LinkedServiceCosmosDBMongoAPIResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := azure.ParseAzureResourceID(state.ID) + if err != nil { + return nil, err + } + resourceGroup := id.ResourceGroup + dataFactoryName := id.Path["factories"] + name := id.Path["linkedservices"] + + resp, err := clients.DataFactory.LinkedServiceClient.Get(ctx, resourceGroup, dataFactoryName, name, "") + if err != nil { + return nil, fmt.Errorf("reading Data Factory Linked Service CosmosDB (%s): %+v", id, err) + } + + return utils.Bool(resp.ID != nil), nil +} + +func (LinkedServiceCosmosDBMongoAPIResource) basic(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-df-%d" + location = "%s" +} + +resource "azurerm_data_factory" "test" { + name = "acctestdf%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name +} + +resource "azurerm_data_factory_linked_service_cosmosdb_mongoapi" "test" { + name = "acctestlscosmosdb%d" + resource_group_name = azurerm_resource_group.test.name + data_factory_name = azurerm_data_factory.test.name + connection_string = "mongodb://testinstance:testkey@testinstance.documents.azure.com:10255/?ssl=true" +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) +} + +func (LinkedServiceCosmosDBMongoAPIResource) serverVersionAbove32(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-df-%d" + location = "%s" +} + +resource "azurerm_data_factory" "test" { + name = "acctestdf%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name +} + +resource "azurerm_data_factory_linked_service_cosmosdb_mongoapi" "test" { + name = "acctestlscosmosdb%d" + resource_group_name = azurerm_resource_group.test.name + data_factory_name = azurerm_data_factory.test.name + connection_string = "mongodb://testinstance:testkey@testinstance.documents.azure.com:10255/?ssl=true" + server_version_above_32 = true +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) +} + +func (LinkedServiceCosmosDBMongoAPIResource) update1(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-df-%d" + location = "%s" +} + +resource "azurerm_data_factory" "test" { + name = "acctestdf%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name +} + +resource "azurerm_data_factory_linked_service_cosmosdb_mongoapi" "test" { + name = "acctestlscosmosdb%d" + resource_group_name = azurerm_resource_group.test.name + data_factory_name = azurerm_data_factory.test.name + connection_string = "mongodb://testinstance:testkey@testinstance.documents.azure.com:10255/?ssl=true" + annotations = ["test1", "test2", "test3"] + description = "test description" + + parameters = { + foo = "test1" + bar = "test2" + } + + additional_properties = { + foo = "test1" + bar = "test2" + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) +} + +func (LinkedServiceCosmosDBMongoAPIResource) update2(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-df-%d" + location = "%s" +} + +resource "azurerm_data_factory" "test" { + name = "acctestdf%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name +} + +resource "azurerm_data_factory_linked_service_cosmosdb_mongoapi" "test" { + name = "acctestlscosmosdb%d" + resource_group_name = azurerm_resource_group.test.name + data_factory_name = azurerm_data_factory.test.name + connection_string = "mongodb://testinstance:testkey@testinstance.documents.azure.com:10255/?ssl=true" + annotations = ["test1", "test2"] + description = "test description 2" + + parameters = { + foo = "test1" + bar = "test2" + buzz = "test3" + } + + additional_properties = { + foo = "test1" + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) +} diff --git a/internal/services/datafactory/registration.go b/internal/services/datafactory/registration.go index 362e8c42b6157..bbfb08e2dcb9a 100644 --- a/internal/services/datafactory/registration.go +++ b/internal/services/datafactory/registration.go @@ -55,6 +55,7 @@ func (r Registration) SupportedResources() map[string]*pluginsdk.Resource { "azurerm_data_factory_linked_service_azure_sql_database": resourceDataFactoryLinkedServiceAzureSQLDatabase(), "azurerm_data_factory_linked_service_azure_table_storage": resourceDataFactoryLinkedServiceAzureTableStorage(), "azurerm_data_factory_linked_service_cosmosdb": resourceDataFactoryLinkedServiceCosmosDb(), + "azurerm_data_factory_linked_service_cosmosdb_mongoapi": resourceDataFactoryLinkedServiceCosmosDbMongoAPI(), "azurerm_data_factory_linked_service_data_lake_storage_gen2": resourceDataFactoryLinkedServiceDataLakeStorageGen2(), "azurerm_data_factory_linked_service_key_vault": resourceDataFactoryLinkedServiceKeyVault(), "azurerm_data_factory_linked_service_kusto": resourceDataFactoryLinkedServiceKusto(), diff --git a/website/docs/guides/3.0-overview.html.markdown b/website/docs/guides/3.0-overview.html.markdown index 72493df5a51d6..68620b24eeb21 100644 --- a/website/docs/guides/3.0-overview.html.markdown +++ b/website/docs/guides/3.0-overview.html.markdown @@ -66,4 +66,4 @@ More information about the new Data Sources and Resources for App Service coming --- -Since version 3.0 of the Azure Provider is being iteratively developed, more information will be added to this page over time - since this documentation is versioned, we recommend checking [the latest version of this document](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/3.0-overview). \ No newline at end of file +Since version 3.0 of the Azure Provider is being iteratively developed, more information will be added to this page over time - since this documentation is versioned, we recommend checking [the latest version of this document](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/3.0-overview). diff --git a/website/docs/r/application_insights_smart_detection_rule.html.markdown b/website/docs/r/application_insights_smart_detection_rule.html.markdown index 3b6ddd924a8ae..7b2179cce94ec 100644 --- a/website/docs/r/application_insights_smart_detection_rule.html.markdown +++ b/website/docs/r/application_insights_smart_detection_rule.html.markdown @@ -71,4 +71,4 @@ Application Insights Smart Detection Rules can be imported using the `resource i ```shell terraform import azurerm_application_insights_smart_detection_rule.rule1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/microsoft.insights/components/mycomponent1/SmartDetectionRule/myrule1 -``` \ No newline at end of file +``` diff --git a/website/docs/r/data_factory_linked_service_cosmosdb.html.markdown b/website/docs/r/data_factory_linked_service_cosmosdb.html.markdown index 3c2767b029269..efd5d8d7d55fa 100644 --- a/website/docs/r/data_factory_linked_service_cosmosdb.html.markdown +++ b/website/docs/r/data_factory_linked_service_cosmosdb.html.markdown @@ -3,12 +3,12 @@ subcategory: "Data Factory" layout: "azurerm" page_title: "Azure Resource Manager: azurerm_data_factory_linked_service_cosmosdb" description: |- - Manages a Linked Service (connection) between an SFTP Server and Azure Data Factory. + Manages a Linked Service (connection) between a CosmosDB and Azure Data Factory using SQL API. --- # azurerm_data_factory_linked_service_cosmosdb -Manages a Linked Service (connection) between a SFTP Server and Azure Data Factory. +Manages a Linked Service (connection) between a CosmosDB and Azure Data Factory using SQL API. ~> **Note:** All arguments including the client secret will be stored in the raw state as plain-text. [Read more about sensitive data in state](/docs/state/sensitive-data.html). diff --git a/website/docs/r/data_factory_linked_service_cosmosdb_mongoapi.html.markdown b/website/docs/r/data_factory_linked_service_cosmosdb_mongoapi.html.markdown new file mode 100644 index 0000000000000..29a5b0ceb6238 --- /dev/null +++ b/website/docs/r/data_factory_linked_service_cosmosdb_mongoapi.html.markdown @@ -0,0 +1,92 @@ +--- +subcategory: "Data Factory" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_data_factory_linked_service_cosmosdb_mongoapi" +description: |- +Manages a Linked Service (connection) between a CosmosDB and Azure Data Factory using Mongo API. +--- + +# azurerm_data_factory_linked_service_cosmosdb_mongoapi + +Manages a Linked Service (connection) between a CosmosDB and Azure Data Factory using Mongo API. + +~> **Note:** All arguments including the client secret will be stored in the raw state as plain-text. [Read more about sensitive data in state](/docs/state/sensitive-data.html). + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +data "azurerm_cosmosdb_account" "example" { + name = "tfex-cosmosdb-account" + resource_group_name = "tfex-cosmosdb-account-rg" +} + +resource "azurerm_data_factory" "example" { + name = "example" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name +} + +resource "azurerm_data_factory_linked_service_cosmosdb_mongoapi" "example" { + name = "example" + resource_group_name = azurerm_resource_group.example.name + data_factory_name = azurerm_data_factory.example.name + connection_string = "mongodb://testinstance:testkey@testinstance.documents.azure.com:10255/?ssl=true" + database = "foo" + +} +``` + +## Argument Reference + +The following supported arguments are common across all Azure Data Factory Linked Services: + +* `name` - (Required) Specifies the name of the Data Factory Linked Service. Changing this forces a new resource to be created. Must be unique within a data + factory. See the [Microsoft documentation](https://docs.microsoft.com/en-us/azure/data-factory/naming-rules) for all restrictions. + +* `resource_group_name` - (Required) The name of the resource group in which to create the Data Factory Linked Service. Changing this forces a new resource + +* `data_factory_name` - (Required) The Data Factory name in which to associate the Linked Service with. Changing this forces a new resource. + +* `description` - (Optional) The description for the Data Factory Linked Service. + +* `integration_runtime_name` - (Optional) The integration runtime reference to associate with the Data Factory Linked Service. + +* `annotations` - (Optional) List of tags that can be used for describing the Data Factory Linked Service. + +* `parameters` - (Optional) A map of parameters to associate with the Data Factory Linked Service. + +* `additional_properties` - (Optional) A map of additional properties to associate with the Data Factory Linked Service. + +The following supported arguments are specific to CosmosDB Linked Service: + +* `database` - (Optional) The name of the database. + +* `connection_string` - (Required) The connection string. + +## Attributes Reference + +The following attributes are exported: + +* `id` - The ID of the Data Factory Linked Service. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the Data Factory Linked Service. +* `update` - (Defaults to 30 minutes) Used when updating the Data Factory Linked Service. +* `read` - (Defaults to 5 minutes) Used when retrieving the Data Factory Linked Service. +* `delete` - (Defaults to 30 minutes) Used when deleting the Data Factory Linked Service. + +## Import + +Data Factory Linked Service's can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_data_factory_linked_service_cosmosdb_mongoapi.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example/providers/Microsoft.DataFactory/factories/example/linkedservices/example +```