101-cosmos-db-analyticalstore patch (#143)

* change azurerm version

* add default values
This commit is contained in:
Dingjia Chen 2023-02-09 21:06:33 -06:00 committed by GitHub
parent 9a4284c545
commit a522c44462
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 5 deletions

View File

@ -1,5 +1,5 @@
resource "azurerm_resource_group" "example" { resource "azurerm_resource_group" "example" {
name = var.resource_group_name name = "${random_pet.random_prefix.id}-rg"
location = var.location location = var.location
} }
@ -34,7 +34,7 @@ resource "azurerm_cosmosdb_sql_database" "example" {
throughput = var.throughput throughput = var.throughput
} }
resource "azurerm_cosmosdb_sql_container" "example" { resource "azurerm_cosmosdb_sql_container" "main" {
name = var.sql_container_name name = var.sql_container_name
resource_group_name = azurerm_resource_group.example.name resource_group_name = azurerm_resource_group.example.name
account_name = azurerm_cosmosdb_account.example.name account_name = azurerm_cosmosdb_account.example.name
@ -64,3 +64,7 @@ resource "azurerm_cosmosdb_sql_container" "example" {
paths = ["/definition/idlong", "/definition/idshort"] paths = ["/definition/idlong", "/definition/idshort"]
} }
} }
resource "random_pet" "random_prefix" {
prefix = var.name_prefix
}

View File

@ -2,7 +2,7 @@ terraform {
required_providers { required_providers {
azurerm = { azurerm = {
source = "hashicorp/azurerm" source = "hashicorp/azurerm"
version = ">=3.0.0" version = ">=3.0, < 4.0"
} }
} }
} }

View File

@ -1,30 +1,36 @@
variable "resource_group_name" { variable "name_prefix" {
type = string type = string
description = "Resource group name" default = "101-cosmos-db-analyticalstore"
description = "Prefix for resource group name"
} }
variable "location" { variable "location" {
type = string type = string
default = "westus"
description = "Resource group location" description = "Resource group location"
} }
variable "cosmosdb_account_name" { variable "cosmosdb_account_name" {
type = string type = string
default = "default-account-name"
description = "Cosmos db account name" description = "Cosmos db account name"
} }
variable "cosmosdb_account_location" { variable "cosmosdb_account_location" {
type = string type = string
default = "westus"
description = "Cosmos db account location" description = "Cosmos db account location"
} }
variable "cosmosdb_sqldb_name" { variable "cosmosdb_sqldb_name" {
type = string type = string
default = "default-sqldb-name"
description = "value" description = "value"
} }
variable "throughput" { variable "throughput" {
type = number type = number
default = 400
description = "Cosmos db database throughput" description = "Cosmos db database throughput"
validation { validation {
condition = var.throughput >= 400 && var.throughput <= 1000000 condition = var.throughput >= 400 && var.throughput <= 1000000
@ -38,10 +44,12 @@ variable "throughput" {
variable "sql_container_name" { variable "sql_container_name" {
type = string type = string
default = "default-sql-container-name"
description = "SQL API container name." description = "SQL API container name."
} }
variable "analytical_storage_ttl" { variable "analytical_storage_ttl" {
type = number type = number
default = 0
description = "Analytical Storage TTL in seconds." description = "Analytical Storage TTL in seconds."
} }