Skip to content

azurermCosmosdbSqlStoredProcedure

Manages a SQL Stored Procedure within a Cosmos DB Account SQL Database.

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 azurermCosmosdbSqlStoredProcedureExample =
  new azurerm.cosmosdbSqlStoredProcedure.CosmosdbSqlStoredProcedure(
    this,
    "example_3",
    {
      account_name: dataAzurermCosmosdbAccountExample.name,
      body: "   function () { var context = getContext(); var response = context.getResponse(); response.setBody('Hello, World'); }\n",
      container_name: azurermCosmosdbSqlContainerExample.name,
      database_name: azurermCosmosdbSqlDatabaseExample.name,
      name: "test-stored-proc",
      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.*/
azurermCosmosdbSqlStoredProcedureExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • name - (Required) Specifies the name of the Cosmos DB SQL Stored Procedure. Changing this forces a new resource to be created.

  • resourceGroupName - (Required) The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.

  • accountName - (Required) The name of the Cosmos DB Account to create the stored procedure within. Changing this forces a new resource to be created.

  • databaseName - (Required) The name of the Cosmos DB SQL Database to create the stored procedure within. Changing this forces a new resource to be created.

  • containerName - (Required) The name of the Cosmos DB SQL Container to create the stored procedure within. Changing this forces a new resource to be created.

  • body - (Required) The body of the stored procedure.

Attributes Reference

The following attributes are exported:

  • id - The ID of the Cosmos DB SQL Stored Procedure.

Timeouts

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

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

Import

CosmosDB SQL Stored Procedures can be imported using the resourceId, e.g.

terraform import azurerm_cosmosdb_sql_stored_procedure.db1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/db1/containers/c1/storedProcedures/sp1