github.com/darmach/terratest@v0.34.8-0.20210517103231-80931f95e3ff/examples/azure/terraform-azure-cosmosdb-example/main.tf (about) 1 # --------------------------------------------------------------------------------------------------------------------- 2 # DEPLOY AN AZURE VIRTUAL MACHINE 3 # This is an example of how to deploy an Azure Virtual Machine with the minimum network resources. 4 # --------------------------------------------------------------------------------------------------------------------- 5 # See test/azure/terraform_azure_example_test.go for how to write automated tests for this code. 6 # --------------------------------------------------------------------------------------------------------------------- 7 8 provider "azurerm" { 9 version = "~> 2.29" 10 features {} 11 } 12 13 14 # --------------------------------------------------------------------------------------------------------------------- 15 # PIN TERRAFORM VERSION TO >= 0.12 16 # The examples have been upgraded to 0.12 syntax 17 # --------------------------------------------------------------------------------------------------------------------- 18 19 terraform { 20 # This module is now only being tested with Terraform 0.13.x. However, to make upgrading easier, we are setting 21 # 0.12.26 as the minimum version, as that version added support for required_providers with source URLs, making it 22 # forwards compatible with 0.13.x code. 23 required_version = ">= 0.12.26" 24 } 25 26 # --------------------------------------------------------------------------------------------------------------------- 27 # DEPLOY A RESOURCE GROUP 28 # --------------------------------------------------------------------------------------------------------------------- 29 30 resource "azurerm_resource_group" "rg" { 31 name = "terratest-cosmos-rg-${var.postfix}" 32 location = var.location 33 } 34 35 # --------------------------------------------------------------------------------------------------------------------- 36 # DEPLOY A COSMOSDB ACCOUNT 37 # --------------------------------------------------------------------------------------------------------------------- 38 39 resource "azurerm_cosmosdb_account" "test" { 40 name = "terratest-${var.postfix}" 41 location = azurerm_resource_group.rg.location 42 resource_group_name = azurerm_resource_group.rg.name 43 offer_type = "Standard" 44 kind = "GlobalDocumentDB" 45 46 consistency_policy { 47 consistency_level = "Session" 48 max_interval_in_seconds = 5 49 max_staleness_prefix = 100 50 } 51 52 geo_location { 53 location = azurerm_resource_group.rg.location 54 failover_priority = 0 55 } 56 } 57 58 resource "azurerm_cosmosdb_sql_database" "testdb" { 59 name = "testdb" 60 throughput = var.throughput 61 resource_group_name = azurerm_resource_group.rg.name 62 account_name = azurerm_cosmosdb_account.test.name 63 } 64 65 resource "azurerm_cosmosdb_sql_container" "container1" { 66 name = "test-container-1" 67 throughput = var.throughput 68 partition_key_path = "/key1" 69 resource_group_name = azurerm_cosmosdb_account.test.resource_group_name 70 account_name = azurerm_cosmosdb_account.test.name 71 database_name = azurerm_cosmosdb_sql_database.testdb.name 72 } 73 74 resource "azurerm_cosmosdb_sql_container" "container2" { 75 name = "test-container-2" 76 partition_key_path = "/key2" 77 resource_group_name = azurerm_cosmosdb_account.test.resource_group_name 78 account_name = azurerm_cosmosdb_account.test.name 79 database_name = azurerm_cosmosdb_sql_database.testdb.name 80 } 81 82 resource "azurerm_cosmosdb_sql_container" "container3" { 83 name = "test-container-3" 84 partition_key_path = "/key3" 85 resource_group_name = azurerm_cosmosdb_account.test.resource_group_name 86 account_name = azurerm_cosmosdb_account.test.name 87 database_name = azurerm_cosmosdb_sql_database.testdb.name 88 }