Skip to content

Commit bcae6d7

Browse files
committed
Add module files
0 parents  commit bcae6d7

File tree

13 files changed

+567
-0
lines changed

13 files changed

+567
-0
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## code changes will send PR to following users
2+
* @Think-Cube/think-cube

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: 'terraform'
4+
directory: '/'
5+
schedule:
6+
interval: 'daily'

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Local .terraform directories
2+
**/.terraform/*
3+
4+
# .tfstate files
5+
*.tfstate
6+
*.tfstate.*
7+
8+
# Crash log files
9+
crash.log
10+
11+
# Exclude all .tfvars files, which are likely to contain sentitive data, such as
12+
# password, private keys, and other secrets. These should not be part of version
13+
# control as they are data points which are potentially sensitive and subject
14+
# to change depending on the environment.
15+
#
16+
*.tfvars
17+
18+
# Ignore override files as they are usually used to override resources locally and so
19+
# are not checked in
20+
override.tf
21+
override.tf.json
22+
*_override.tf
23+
*_override.tf.json
24+
25+
# Include override files you do wish to add to version control using negated pattern
26+
#
27+
# !example_override.tf
28+
29+
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
30+
# example: *tfplan*
31+
32+
# Ignore CLI configuration files
33+
.terraformrc
34+
terraform.rc

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 ThinkCube
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
## Requirements
2+
3+
| Name | Version |
4+
|------|---------|
5+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.6.3 |
6+
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | 4.27.0 |
7+
8+
## Providers
9+
10+
| Name | Version |
11+
|------|---------|
12+
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | 4.27.0 |
13+
14+
## Modules
15+
16+
No modules.
17+
18+
## Resources
19+
20+
| Name | Type |
21+
|------|------|
22+
| [azurerm_cognitive_account.main](https://registry.terraform.io/providers/hashicorp/azurerm/4.27.0/docs/resources/cognitive_account) | resource |
23+
| [azurerm_cognitive_deployment.main](https://registry.terraform.io/providers/hashicorp/azurerm/4.27.0/docs/resources/cognitive_deployment) | resource |
24+
| [azurerm_client_config.current](https://registry.terraform.io/providers/hashicorp/azurerm/4.27.0/docs/data-sources/client_config) | data source |
25+
| [azurerm_resource_group.rg](https://registry.terraform.io/providers/hashicorp/azurerm/4.27.0/docs/data-sources/resource_group) | data source |
26+
27+
## Inputs
28+
29+
| Name | Description | Type | Default | Required |
30+
|------|-------------|------|---------|:--------:|
31+
| <a name="input_cognitive_account_custom_subdomain_name"></a> [cognitive\_account\_custom\_subdomain\_name](#input\_cognitive\_account\_custom\_subdomain\_name) | Custom subdomain name for the Azure OpenAI Service, if applicable. | `string` | n/a | yes |
32+
| <a name="input_cognitive_account_kind"></a> [cognitive\_account\_kind](#input\_cognitive\_account\_kind) | The type of Cognitive Service Account to create (e.g., OpenAI, ComputerVision). Changing this triggers resource recreation. | `string` | `"OpenAI"` | no |
33+
| <a name="input_cognitive_account_name"></a> [cognitive\_account\_name](#input\_cognitive\_account\_name) | The name of the Azure Cognitive Service Account. Changing this triggers resource recreation. | `string` | n/a | yes |
34+
| <a name="input_cognitive_account_public_network_access_enabled"></a> [cognitive\_account\_public\_network\_access\_enabled](#input\_cognitive\_account\_public\_network\_access\_enabled) | Controls whether public network access is enabled for the Azure OpenAI Service. | `bool` | `true` | no |
35+
| <a name="input_cognitive_account_sku_name"></a> [cognitive\_account\_sku\_name](#input\_cognitive\_account\_sku\_name) | The pricing tier (SKU) for the Azure OpenAI Service (e.g., S0). | `string` | `"S0"` | no |
36+
| <a name="input_default_tags"></a> [default\_tags](#input\_default\_tags) | A map of key-value pairs to tag resources for organization and management. | `map(any)` | n/a | yes |
37+
| <a name="input_deployment"></a> [deployment](#input\_deployment) | Configures Cognitive Services Account deployments with the following attributes:<br> - name: The deployment name. Changing this triggers resource recreation.<br> - model\_format: The model format (e.g., OpenAI). Changing this triggers resource recreation.<br> - model\_name: The name of the deployment model. Changing this triggers resource recreation.<br> - model\_version: The version of the deployment model.<br> - scale\_type: The deployment scale type (e.g., Standard). Changing this triggers resource recreation.<br> - rai\_policy\_name: Optional Responsible AI policy name. Changing this triggers resource recreation.<br> - capacity: Optional Tokens-per-Minute (TPM) capacity, defaults to 1 (1000 tokens/min).<br> - version\_upgrade\_option: Optional model version upgrade policy (e.g., OnceNewDefaultVersionAvailable, OnceCurrentVersionExpired, NoAutoUpgrade). | <pre>map(object({<br> name = string<br> model_format = string<br> model_name = string<br> model_version = string<br> scale_type = string<br> rai_policy_name = optional(string)<br> capacity = optional(number)<br> version_upgrade_option = optional(string)<br> }))</pre> | `{}` | no |
38+
| <a name="input_environment"></a> [environment](#input\_environment) | Defines the environment type for the backend container (e.g., dev, prod, staging). | `string` | `"dev"` | no |
39+
| <a name="input_identity_enabled"></a> [identity\_enabled](#input\_identity\_enabled) | Enables or disables managed identity for the Cognitive Service Account. | `bool` | `false` | no |
40+
| <a name="input_identity_type"></a> [identity\_type](#input\_identity\_type) | Specifies the managed identity type (e.g., SystemAssigned, UserAssigned). | `string` | `"SystemAssigned"` | no |
41+
| <a name="input_network_acls_default_action"></a> [network\_acls\_default\_action](#input\_network\_acls\_default\_action) | Sets the default action for network ACLs (e.g., Allow or Deny). | `string` | `"Deny"` | no |
42+
| <a name="input_network_acls_enabled"></a> [network\_acls\_enabled](#input\_network\_acls\_enabled) | Enables or disables network Access Control Lists (ACLs) for the Cognitive Service Account. | `bool` | `false` | no |
43+
| <a name="input_network_acls_ip_rules"></a> [network\_acls\_ip\_rules](#input\_network\_acls\_ip\_rules) | A list of IP addresses or CIDR blocks allowed in network ACLs. | `list(string)` | `[]` | no |
44+
| <a name="input_network_acls_virtual_network_rules"></a> [network\_acls\_virtual\_network\_rules](#input\_network\_acls\_virtual\_network\_rules) | A list of virtual network rules for network ACLs, specifying subnet ID and optional service endpoint settings. | <pre>list(object({<br> subnet_id = string<br> ignore_missing_vnet_service_endpoint = optional(bool)<br> }))</pre> | `[]` | no |
45+
| <a name="input_region"></a> [region](#input\_region) | The Azure region where resources will be deployed (e.g., 'weu' for West Europe). | `string` | `"weu"` | no |
46+
| <a name="input_resource_group_location"></a> [resource\_group\_location](#input\_resource\_group\_location) | The Azure region for creating the resource group. Changing this triggers resource recreation. | `string` | `"West Europe"` | no |
47+
| <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name) | The name of the Azure resource group where resources will be provisioned. | `string` | n/a | yes |
48+
49+
## Outputs
50+
51+
| Name | Description |
52+
|------|-------------|
53+
| <a name="output_cognitive_account_endpoint"></a> [cognitive\_account\_endpoint](#output\_cognitive\_account\_endpoint) | The endpoint URL of the Azure Cognitive Service Account. |
54+
| <a name="output_cognitive_account_id"></a> [cognitive\_account\_id](#output\_cognitive\_account\_id) | The resource ID of the Azure Cognitive Service Account. |
55+
| <a name="output_cognitive_account_location"></a> [cognitive\_account\_location](#output\_cognitive\_account\_location) | The Azure region where the Cognitive Service Account is deployed. |
56+
| <a name="output_cognitive_account_name"></a> [cognitive\_account\_name](#output\_cognitive\_account\_name) | The name of the Azure Cognitive Service Account. |
57+
| <a name="output_cognitive_account_primary_access_key"></a> [cognitive\_account\_primary\_access\_key](#output\_cognitive\_account\_primary\_access\_key) | The primary access key for the Azure Cognitive Service Account. |
58+
| <a name="output_cognitive_account_resource_group_name"></a> [cognitive\_account\_resource\_group\_name](#output\_cognitive\_account\_resource\_group\_name) | The name of the resource group containing the Cognitive Service Account. |
59+
| <a name="output_cognitive_account_secondary_access_key"></a> [cognitive\_account\_secondary\_access\_key](#output\_cognitive\_account\_secondary\_access\_key) | The secondary access key for the Azure Cognitive Service Account. |
60+
| <a name="output_cognitive_deployment_ids"></a> [cognitive\_deployment\_ids](#output\_cognitive\_deployment\_ids) | A map of deployment names to their respective resource IDs for the Cognitive Service Account deployments. |

backend.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
terraform {
2+
required_providers {
3+
azurerm = {
4+
source = "hashicorp/azurerm"
5+
version = "4.27.0"
6+
}
7+
}
8+
required_version = ">= 1.6.3"
9+
}

cognitive_account.tf

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
resource "azurerm_cognitive_account" "main" {
2+
name = "${var.environment}-${var.cognitive_account_name}-${var.region}-oai"
3+
location = data.azurerm_resource_group.rg.location
4+
resource_group_name = data.azurerm_resource_group.rg.name
5+
kind = var.cognitive_account_kind
6+
custom_subdomain_name = var.cognitive_account_custom_subdomain_name
7+
sku_name = var.cognitive_account_sku_name
8+
public_network_access_enabled = var.cognitive_account_public_network_access_enabled
9+
tags = var.default_tags
10+
11+
dynamic "identity" {
12+
for_each = var.identity_enabled ? [1] : []
13+
content {
14+
type = var.identity_type
15+
}
16+
}
17+
18+
dynamic "network_acls" {
19+
for_each = var.network_acls_enabled ? [1] : []
20+
content {
21+
default_action = var.network_acls_default_action
22+
ip_rules = var.network_acls_ip_rules
23+
24+
dynamic "virtual_network_rules" {
25+
for_each = var.network_acls_virtual_network_rules
26+
content {
27+
subnet_id = virtual_network_rules.value.subnet_id
28+
ignore_missing_vnet_service_endpoint = lookup(virtual_network_rules.value, "ignore_missing_vnet_service_endpoint", false)
29+
}
30+
}
31+
}
32+
}
33+
34+
lifecycle {
35+
ignore_changes = [
36+
tags
37+
]
38+
}
39+
}

cognitive_deployment.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
resource "azurerm_cognitive_deployment" "main" {
2+
for_each = var.deployment
3+
4+
cognitive_account_id = azurerm_cognitive_account.main.id
5+
name = each.value.name
6+
rai_policy_name = each.value.rai_policy_name
7+
version_upgrade_option = each.value.version_upgrade_option
8+
9+
sku {
10+
name = each.value.scale_type
11+
capacity = try(each.value.capacity, 1)
12+
}
13+
14+
model {
15+
format = each.value.model_format
16+
name = each.value.model_name
17+
version = each.value.model_version
18+
}
19+
}

main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
data "azurerm_client_config" "current" {}
2+
3+
data "azurerm_resource_group" "rg" {
4+
name = var.resource_group_name
5+
}

output.tf

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
output "cognitive_account_id" {
2+
value = azurerm_cognitive_account.main.id
3+
description = "The resource ID of the Azure Cognitive Service Account."
4+
sensitive = false
5+
}
6+
7+
output "cognitive_account_location" {
8+
value = azurerm_cognitive_account.main.location
9+
description = "The Azure region where the Cognitive Service Account is deployed."
10+
sensitive = false
11+
}
12+
13+
output "cognitive_account_name" {
14+
value = azurerm_cognitive_account.main.name
15+
description = "The name of the Azure Cognitive Service Account."
16+
sensitive = false
17+
}
18+
19+
output "cognitive_account_resource_group_name" {
20+
value = azurerm_cognitive_account.main.resource_group_name
21+
description = "The name of the resource group containing the Cognitive Service Account."
22+
sensitive = false
23+
}
24+
25+
output "cognitive_account_endpoint" {
26+
value = azurerm_cognitive_account.main.endpoint
27+
description = "The endpoint URL of the Azure Cognitive Service Account."
28+
sensitive = false
29+
}
30+
31+
output "cognitive_account_primary_access_key" {
32+
value = azurerm_cognitive_account.main.primary_access_key
33+
description = "The primary access key for the Azure Cognitive Service Account."
34+
sensitive = true
35+
}
36+
37+
output "cognitive_account_secondary_access_key" {
38+
value = azurerm_cognitive_account.main.secondary_access_key
39+
description = "The secondary access key for the Azure Cognitive Service Account."
40+
sensitive = true
41+
}
42+
43+
output "cognitive_deployment_ids" {
44+
value = { for k, v in azurerm_cognitive_deployment.main : k => v.id }
45+
description = "A map of deployment names to their respective resource IDs for the Cognitive Service Account deployments."
46+
sensitive = false
47+
}

0 commit comments

Comments
 (0)