Azure / terraform-azurerm-avm-res-documentdb-databaseaccount

https://registry.terraform.io/modules/Azure/avm-res-documentdb-databaseaccount/azurerm/latest
MIT License
0 stars 0 forks source link

Terraform Azure Cosmos DB Module

This Terraform module is designed to create Azure Cosmos DB accounts, its related resources and APIs.

[!WARNING] Major version Zero (0.y.z) is for initial development. Anything MAY change at any time. A module SHOULD NOT be considered stable till at least it is major version one (1.0.0) or greater. Changes will always be via new versions being published and no changes will be made to existing published versions. For more details please go to https://semver.org/

Features

Limitations

Examples

Requirements

The following requirements are needed by this module:

Providers

The following providers are used by this module:

Resources

The following resources are used by this module:

Required Inputs

The following input variables are required:

location

Description: Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

Example Inputs: eastus
See more in CLI: az account list-locations -o table --query "[].name"

Type: string

name

Description: Specifies the name of the CosmosDB Account. Changing this forces a new resource to be created.
The name can contain only lowercase letters, numbers and the '-' character, must be between 3 and 44 characters long, and must not start or end with the character '-'.

Example Inputs: cosmos-sharepoint-prod-westus-001
See more: https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules#microsoftdocumentdb

Type: string

resource_group_name

Description: The name of the resource group in which to create this resource.
Changing this forces a new resource to be created.
Name must be less than 90 characters long and must only contain underscores, hyphens, periods, parentheses, letters, or digits.

Example Inputs: rg-sharepoint-prod-westus-001
See more: https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules#microsoftresources

Type: string

Optional Inputs

The following input variables are optional (have default values):

access_key_metadata_writes_enabled

Description: Defaults to false. Is write operations on metadata resources (databases, containers, throughput) via account keys enabled?

Type: bool

Default: false

analytical_storage_config

Description: Defaults to null. Configuration related to the analytical storage of this account

Type:

object({
    schema_type = string
  })

Default: null

analytical_storage_enabled

Description: Defaults to false. Enable Analytical Storage option for this Cosmos DB account. Enabling and then disabling analytical storage forces a new resource to be created.

Type: bool

Default: false

automatic_failover_enabled

Description: Defaults to true. Enable automatic failover for this Cosmos DB account.

Type: bool

Default: true

backup

Description: Defaults to {}. Configures the backup policy for this Cosmos DB account.

Type:

object({
    retention_in_hours  = optional(number, 8)
    interval_in_minutes = optional(number, 240)
    storage_redundancy  = optional(string, "Geo")
    type                = optional(string, "Continuous")
    tier                = optional(string, "Continuous30Days")
  })

Default: {}

capabilities

Description: Defaults to []. The capabilities which should be enabled for this Cosmos DB account.

Type:

set(object({
    name = string
  }))

Default: []

capacity

Description: Defaults to {}. Configures the throughput limit for this Cosmos DB account.

Type:

object({
    total_throughput_limit = optional(number, -1)
  })

Default: {}

consistency_policy

Description: Defaults to {}. Used to define the consistency policy for this CosmosDB account

Type:

object({
    max_interval_in_seconds = optional(number, 5)
    max_staleness_prefix    = optional(number, 100)
    consistency_level       = optional(string, "ConsistentPrefix")
  })

Default: {}

cors_rule

Description: Defaults to null. Configures the CORS rule for this Cosmos DB account.

Type:

object({
    allowed_headers    = set(string)
    allowed_methods    = set(string)
    allowed_origins    = set(string)
    exposed_headers    = set(string)
    max_age_in_seconds = optional(number, null)
  })

Default: null

customer_managed_key

Description: Defaults to null. Ignored for Basic and Standard. Defines a customer managed key to use for encryption.

Type:

object({
    key_name              = string
    key_vault_resource_id = string

    key_version = optional(string, null) # Not supported in CosmosDB

    user_assigned_identity = optional(object({
      resource_id = string
    }), null)
  })

Default: null

diagnostic_settings

Description: Defaults to {}. A map of diagnostic settings to create. The map key is deliberately arbitrary to avoid issues where map keys maybe unknown at plan time.

Type:

map(object({
    name                                     = optional(string, null)
    log_categories                           = optional(set(string), [])
    log_groups                               = optional(set(string), ["allLogs"])
    metric_categories                        = optional(set(string), ["AllMetrics"])
    log_analytics_destination_type           = optional(string, "Dedicated")
    workspace_resource_id                    = optional(string, null)
    storage_account_resource_id              = optional(string, null)
    event_hub_authorization_rule_resource_id = optional(string, null)
    event_hub_name                           = optional(string, null)
    marketplace_partner_resource_id          = optional(string, null)
  }))

Default: {}

enable_telemetry

Description: Defaults to true. This variable controls whether or not telemetry is enabled for the module.
For more information see https://aka.ms/avm/telemetryinfo.
If it is set to false, then no telemetry will be collected.

Type: bool

Default: true

free_tier_enabled

Description: Defaults to false. Enable the Free Tier pricing option for this Cosmos DB account. Defaults to false. Changing this forces a new resource to be created.

Type: bool

Default: false

geo_locations

Description: Default to the region where the account was deployed with zone redundant enabled. Specifies a geo_location resource, used to define where data should be replicated with the failover_priority 0 specifying the primary location.

Type:

set(object({
    location          = string
    failover_priority = number
    zone_redundant    = optional(bool, true)
  }))

Default: null

ip_range_filter

Description: Defaults to []. CosmosDB Firewall Support: This value specifies the set of IP addresses or IP address ranges in CIDR form to be included as the allowed list of client IPs for a given database account.

Note: To enable the "Allow access from the Azure portal" behavior, you should add the IP addresses provided by the documentation to this list. https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-configure-firewall#allow-requests-from-the-azure-portal Note: To enable the "Accept connections from within public Azure datacenters" behavior, you should add 0.0.0.0 to the list, see the documentation for more details. https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-configure-firewall#allow-requests-from-global-azure-datacenters-or-other-sources-within-azure

Type: set(string)

Default: []

local_authentication_disabled

Description: Defaults to false. Ignored for non SQL APIs accounts. Disable local authentication and ensure only MSI and AAD can be used exclusively for authentication. Can be set only when using the SQL API.

Type: bool

Default: false

lock

Description: Defaults to null. Controls the Resource Lock configuration for this resource.
If specified, it will be inherited by child resources unless overriden when creating those child resources.
The following properties can be specified:

Type:

object({
    kind = string
    name = optional(string, null)
  })

Default: null

managed_identities

Description: Defaults to {}. Controls the Managed Identity configuration on this resource. The following properties can be specified:

Type:

object({
    system_assigned            = optional(bool, false)
    user_assigned_resource_ids = optional(set(string), [])
  })

Default: {}

minimal_tls_version

Description: Defaults to Tls12. Specifies the minimal TLS version for the CosmosDB account. Possible values are: Tls, Tls11, and Tls12

Type: string

Default: "Tls12"

mongo_databases

Description: Defaults to {}. Manages SQL Databases within a Cosmos DB Account.

Type:

map(object({
    name = string

    throughput = optional(number, null)

    autoscale_settings = optional(object({
      max_throughput = number
    }), null)

    collections = optional(map(object({
      name = string

      default_ttl_seconds = optional(string, null)
      shard_key           = optional(string, null)
      throughput          = optional(number, null)

      autoscale_settings = optional(object({
        max_throughput = number
      }), null)

      index = optional(object({
        keys   = list(string)
        unique = optional(bool, false)
      }), null)

    })), {})
  }))

Default: {}

mongo_server_version

Description: The Server Version of a MongoDB account. Defaults to 3.6 Possible values are 4.2, 4.0, 3.6, and 3.2

Type: string

Default: "3.6"

multiple_write_locations_enabled

Description: Defaults to false. Ignored when backup.type is Continuous. Enable multi-region writes for this Cosmos DB account.

Type: bool

Default: false

network_acl_bypass_for_azure_services

Description: Defaults to false. If Azure services can bypass ACLs.

Type: bool

Default: false

network_acl_bypass_ids

Description: Defaults to []. The list of resource Ids for Network Acl Bypass for this Cosmos DB account.

Type: set(string)

Default: []

partition_merge_enabled

Description: Defaults to false. Is partition merge on the Cosmos DB account enabled?

Type: bool

Default: false

private_endpoints

Description: Default to {}. A map of private endpoints to create. The map key is deliberately arbitrary to avoid issues where map keys maybe unknown at plan time.

Type:

map(object({
    subnet_resource_id = string
    subresource_name   = string

    name                                    = optional(string, null)
    private_dns_zone_group_name             = optional(string, "default")
    private_dns_zone_resource_ids           = optional(set(string), [])
    application_security_group_associations = optional(map(string), {})
    private_service_connection_name         = optional(string, null)
    network_interface_name                  = optional(string, null)
    location                                = optional(string, null)
    resource_group_name                     = optional(string, null)

    ip_configurations = optional(map(object({
      name               = string
      private_ip_address = string
    })), {})

    tags = optional(map(string), null)

    lock = optional(object({
      kind = string
      name = optional(string, null)
    }), null)

    role_assignments = optional(map(object({
      role_definition_id_or_name = string
      principal_id               = string

      description                            = optional(string, null)
      skip_service_principal_aad_check       = optional(bool, false)
      delegated_managed_identity_resource_id = optional(string, null)

      principal_type    = optional(string, null) # forced to be here by lint, not supported
      condition         = optional(string, null) # forced to be here by lint, not supported
      condition_version = optional(string, null) # forced to be here by lint, not supported
    })), {})
  }))

Default: {}

private_endpoints_manage_dns_zone_group

Description: Default to true. Whether to manage private DNS zone groups with this module. If set to false, you must manage private DNS zone groups externally, e.g. using Azure Policy.

Type: bool

Default: true

public_network_access_enabled

Description: Defaults to true. Whether or not public network access is allowed for this CosmosDB account.

Type: bool

Default: true

role_assignments

Description: Defaults to {}. A map of role assignments to create. The map key is deliberately arbitrary to avoid issues where map keys maybe unknown at plan time.

Type:

map(object({
    role_definition_id_or_name             = string
    principal_id                           = string
    description                            = optional(string, null)
    skip_service_principal_aad_check       = optional(bool, false)
    delegated_managed_identity_resource_id = optional(string, null)

    principal_type    = optional(string, null) # forced to be here by lint, not supported
    condition         = optional(string, null) # forced to be here by lint, not supported
    condition_version = optional(string, null) # forced to be here by lint, not supported
  }))

Default: {}

sql_databases

Description: Defaults to {}. Manages SQL Databases within a Cosmos DB Account.

Type:

map(object({
    name = string

    throughput = optional(number, null)

    autoscale_settings = optional(object({
      max_throughput = number
    }), null)

    containers = optional(map(object({
      partition_key_path = string
      name               = string

      throughput             = optional(number, null)
      default_ttl            = optional(number, null)
      analytical_storage_ttl = optional(number, null)

      unique_keys = optional(list(object({
        paths = set(string)
      })), [])

      autoscale_settings = optional(object({
        max_throughput = number
      }), null)

      functions = optional(map(object({
        body = string
        name = string
      })), {})

      stored_procedures = optional(map(object({
        body = string
        name = string
      })), {})

      triggers = optional(map(object({
        body      = string
        type      = string
        operation = string
        name      = string
      })), {})

      conflict_resolution_policy = optional(object({
        mode                          = string
        conflict_resolution_path      = optional(string, null)
        conflict_resolution_procedure = optional(string, null)
      }), null)

      indexing_policy = optional(object({
        indexing_mode = string

        included_paths = optional(set(object({
          path = string
        })), [])

        excluded_paths = optional(set(object({
          path = string
        })), [])

        composite_indexes = optional(set(object({
          indexes = set(object({
            path  = string
            order = string
          }))
        })), [])

        spatial_indexes = optional(set(object({
          path = string
        })), [])
      }), null)

    })), {})
  }))

Default: {}

sql_dedicated_gateway

Description: Defaults to null. Manages a SQL Dedicated Gateway within a Cosmos DB Account.

Type:

object({
    instance_size  = string
    instance_count = optional(number, 1)
  })

Default: null

tags

Description: Defaults to {}. A mapping of tags to assign to the resource. These tags will propagate to any child resource unless overriden when creating the child resource

Example Inputs:

  tags = {
    environment = "testing"
  }

Type: map(string)

Default: null

virtual_network_rules

Description: Defaults to []. Used to define which subnets are allowed to access this CosmosDB account.

Type:

set(object({
    subnet_id = string
  }))

Default: []

Outputs

The following outputs are exported:

name

Description: The name of the cosmos db account created.

resource

Description: The cosmos db account created. More info: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cosmosdb_account#attributes-reference

resource_diagnostic_settings

Description: The diagnostic settings created. More info: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_diagnostic_setting#attributes-reference

resource_id

Description: The resource ID of the cosmos db account created.

resource_locks

Description: The management locks created. More info: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/management_lock#attributes-reference

resource_private_endpoints

Description: A map of the private endpoints created. More info: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_endpoint#attributes-reference

resource_private_endpoints_application_security_group_association

Description: The private endpoint application security group associations created

resource_role_assignments

Description: The role assignments created. More info: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment#attributes-reference

sql_containers

Description: The value of the sql containers created. More info: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cosmosdb_sql_container#attributes-reference

sql_databases

Description: The value of the sql databases created. More info: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cosmosdb_sql_database#attributes-reference

sql_dedicated_gateway

Description: The value of the sql dedicated gateway created. More info: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cosmosdb_sql_dedicated_gateway#attributes-reference

sql_functions

Description: The value of the sql functions created. More info: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cosmosdb_sql_function#attributes-reference

sql_stored_procedures

Description: The value of the sql stored procedures created. More info: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cosmosdb_sql_stored_procedure#attributes-reference

sql_triggers

Description: The value of the sql triggers created. More info: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cosmosdb_sql_trigger#attributes-reference

Modules

No modules.

Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.