Skip to content

azurermStreamAnalyticsOutputCosmosdb

Manages a Stream Analytics Output to CosmosDB.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "rg-example",
  }
);
const dataAzurermStreamAnalyticsJobExample =
  new azurerm.dataAzurermStreamAnalyticsJob.DataAzurermStreamAnalyticsJob(
    this,
    "example_1",
    {
      name: "example-job",
      resource_group_name: azurermResourceGroupExample.name,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
dataAzurermStreamAnalyticsJobExample.overrideLogicalId("example");
const azurermCosmosdbAccountExample =
  new azurerm.cosmosdbAccount.CosmosdbAccount(this, "example_2", {
    consistency_policy: [
      {
        consistency_level: "BoundedStaleness",
        max_interval_in_seconds: 10,
        max_staleness_prefix: 200,
      },
    ],
    geo_location: [
      {
        failover_priority: 0,
        location: azurermResourceGroupExample.location,
      },
    ],
    kind: "GlobalDocumentDB",
    location: azurermResourceGroupExample.location,
    name: "exampledb",
    offer_type: "Standard",
    resource_group_name: azurermResourceGroupExample.name,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermCosmosdbAccountExample.overrideLogicalId("example");
const azurermCosmosdbSqlDatabaseExample =
  new azurerm.cosmosdbSqlDatabase.CosmosdbSqlDatabase(this, "example_3", {
    account_name: azurermCosmosdbAccountExample.name,
    name: "cosmos-sql-db",
    resource_group_name: azurermCosmosdbAccountExample.resourceGroupName,
    throughput: 400,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermCosmosdbSqlDatabaseExample.overrideLogicalId("example");
const azurermCosmosdbSqlContainerExample =
  new azurerm.cosmosdbSqlContainer.CosmosdbSqlContainer(this, "example_4", {
    account_name: azurermCosmosdbAccountExample.name,
    database_name: azurermCosmosdbSqlDatabaseExample.name,
    name: "examplecontainer",
    partition_key_path: "foo",
    resource_group_name: azurermCosmosdbAccountExample.resourceGroupName,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermCosmosdbSqlContainerExample.overrideLogicalId("example");
const azurermStreamAnalyticsOutputCosmosdbExample =
  new azurerm.streamAnalyticsOutputCosmosdb.StreamAnalyticsOutputCosmosdb(
    this,
    "example_5",
    {
      container_name: azurermCosmosdbSqlContainerExample.name,
      cosmosdb_account_key: azurermCosmosdbAccountExample.primaryKey,
      cosmosdb_sql_database_id: azurermCosmosdbSqlDatabaseExample.id,
      document_id: "exampledocumentid",
      name: "output-to-cosmosdb",
      stream_analytics_job_id: dataAzurermStreamAnalyticsJobExample.id,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermStreamAnalyticsOutputCosmosdbExample.overrideLogicalId("example");

Arguments Reference

The following arguments are supported:

  • name - (Required) The name of the Stream Analytics Output. Changing this forces a new resource to be created.

  • streamAnalyticsJobId - (Required) The ID of the Stream Analytics Job. Changing this forces a new resource to be created.

  • cosmosdbAccountKey - (Required) The account key for the CosmosDB database.

  • cosmosdbSqlDatabaseId - (Required) The ID of the CosmosDB database.

  • containerName - (Required) The name of the CosmosDB container.

  • documentId - (Optional) The name of the field in output events used to specify the primary key which insert or update operations are based on.

  • partitionKey - (Optional) The name of the field in output events used to specify the key for partitioning output across collections. If containerName contains {partition} token, this property is required to be specified.

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

  • id - The ID of the Stream Analytics Output for CosmosDB.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the Stream Analytics Output for CosmosDB.
  • read - (Defaults to 5 minutes) Used when retrieving the Stream Analytics Output for CosmosDB.
  • update - (Defaults to 30 minutes) Used when updating the Stream Analytics Output for CosmosDB.
  • delete - (Defaults to 30 minutes) Used when deleting the Stream Analytics Output for CosmosDB.

Import

Stream Analytics Outputs for CosmosDB can be imported using the resourceId, e.g.

terraform import azurerm_stream_analytics_output_cosmosdb.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.StreamAnalytics/streamingJobs/job1/outputs/output1