Skip to content

azurermCosmosdbSqlTrigger

Manages an SQL Trigger.

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 dataAzurermCosmosdbAccountExample =
  new azurerm.dataAzurermCosmosdbAccount.DataAzurermCosmosdbAccount(
    this,
    "example",
    {
      name: "tfex-cosmosdb-account",
      resource_group_name: "tfex-cosmosdb-account-rg",
    }
  );
const azurermCosmosdbSqlDatabaseExample =
  new azurerm.cosmosdbSqlDatabase.CosmosdbSqlDatabase(this, "example_1", {
    account_name: dataAzurermCosmosdbAccountExample.name,
    name: "tfex-cosmos-db",
    resource_group_name: dataAzurermCosmosdbAccountExample.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_2", {
    account_name: dataAzurermCosmosdbAccountExample.name,
    database_name: azurermCosmosdbSqlDatabaseExample.name,
    name: "example-container",
    partition_key_path: "/id",
    resource_group_name: dataAzurermCosmosdbAccountExample.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 azurermCosmosdbSqlTriggerExample =
  new azurerm.cosmosdbSqlTrigger.CosmosdbSqlTrigger(this, "example_3", {
    body: "function trigger(){}",
    container_id: azurermCosmosdbSqlContainerExample.id,
    name: "test-trigger",
    operation: "Delete",
    type: "Post",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermCosmosdbSqlTriggerExample.overrideLogicalId("example");

Arguments Reference

The following arguments are supported:

  • name - (Required) The name which should be used for this SQL Trigger. Changing this forces a new SQL Trigger to be created.

  • containerId - (Required) The id of the Cosmos DB SQL Container to create the SQL Trigger within. Changing this forces a new SQL Trigger to be created.

  • body - (Required) Body of the Trigger.

  • operation - (Required) The operation the trigger is associated with. Possible values are all, create, update, delete and replace.

  • type - (Required) Type of the Trigger. Possible values are pre and post.

Attributes Reference

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

  • id - The ID of the SQL Trigger.

Timeouts

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

  • create - (Defaults to 30 minutes) Used when creating the SQL Trigger.
  • read - (Defaults to 5 minutes) Used when retrieving the SQL Trigger.
  • update - (Defaults to 30 minutes) Used when updating the SQL Trigger.
  • delete - (Defaults to 30 minutes) Used when deleting the SQL Trigger.

Import

SQL Triggers can be imported using the resourceId, e.g.

terraform import azurerm_cosmosdb_sql_trigger.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/triggers/trigger1