Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Azure Open AI Service module #48

Merged
merged 3 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions modules/azurerm/Azure-OpenAI-Service/azure_openai_service.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -------------------------------------------------------------------------------------
#
# Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). All Rights Reserved.
#
# This software is the property of WSO2 LLC. and its suppliers, if any.
# Dissemination of any information or reproduction of any material contained
# herein in any form is strictly forbidden, unless permitted by WSO2 expressly.
# You may not alter or remove any copyright or other notice from copies of this content.
#
# --------------------------------------------------------------------------------------

resource "azurerm_cognitive_account" "azure_openai_account" {
kind = var.kind
location = var.location
resource_group_name = var.resource_group_name
name = join("-", [var.cognitive_account_abbreviation, var.cognitive_account_name])
sku_name = var.account_sku_name
dynamic_throttling_enabled = var.dynamic_throttling_enabled
outbound_network_access_restricted = var.outbound_network_access_restricted
public_network_access_enabled = var.public_network_access_enabled
tags = var.tags
}

resource "azurerm_cognitive_deployment" "azure_openai_deployment" {
cognitive_account_id = azurerm_cognitive_account.azure_openai_account.id
name = join("-", [var.cognitive_deployment_abbreviation, var.cognitive_deployment_name])
rai_policy_name = var.rai_policy_name
version_upgrade_option = var.version_upgrade_option

model {
format = var.cognitive_model_format
name = var.cognitive_model_name
version = var.cognitive_model_version
}
scale {
type = var.deployment_sku_scale_type
capacity = var.deployment_sku_scale_capacity
}
}
35 changes: 35 additions & 0 deletions modules/azurerm/Azure-OpenAI-Service/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -------------------------------------------------------------------------------------
#
# Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). All Rights Reserved.
#
# This software is the property of WSO2 LLC. and its suppliers, if any.
# Dissemination of any information or reproduction of any material contained
# herein in any form is strictly forbidden, unless permitted by WSO2 expressly.
# You may not alter or remove any copyright or other notice from copies of this content.
#
# --------------------------------------------------------------------------------------

output "azure_openai_account_id" {
depends_on = [azurerm_cognitive_account.azure_openai_account]
value = azurerm_cognitive_account.azure_openai_account.id
}

output "azure_openai_account_endpoint" {
depends_on = [azurerm_cognitive_account.azure_openai_account]
value = azurerm_cognitive_account.azure_openai_account.endpoint
}

output "azure_openai_account_primary_access_key" {
depends_on = [azurerm_cognitive_account.azure_openai_account]
value = azurerm_cognitive_account.azure_openai_account.primary_access_key
}

output "azure_openai_account_secondary_access_key" {
depends_on = [azurerm_cognitive_account.azure_openai_account]
value = azurerm_cognitive_account.azure_openai_account.secondary_access_key
}

output "azure_openai_deployment_id" {
depends_on = [azurerm_cognitive_deployment.azure_openai_deployment]
value = azurerm_cognitive_deployment.azure_openai_deployment.id
}
114 changes: 114 additions & 0 deletions modules/azurerm/Azure-OpenAI-Service/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# -------------------------------------------------------------------------------------
#
# Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). All Rights Reserved.
#
# This software is the property of WSO2 LLC. and its suppliers, if any.
# Dissemination of any information or reproduction of any material contained
# herein in any form is strictly forbidden, unless permitted by WSO2 expressly.
# You may not alter or remove any copyright or other notice from copies of this content.
#
# --------------------------------------------------------------------------------------

variable "kind" {
description = "Specifies the type of Cognitive Service Account that should be created."
type = string
default = "OpenAI"
}

variable "location" {
description = "Azure region"
type = string
}

variable "resource_group_name" {
description = "Resource group name"
type = string
}

variable "cognitive_account_abbreviation" {
description = "The abbreviation for the name of the Azure Cognitive account."
type = string
default = "oai"
}

variable "cognitive_account_name" {
description = "The name of the Azure Cognitive account."
type = string
}

variable "account_sku_name" {
description = "The SKU name of the Azure Cognitive account."
type = string
}

variable "dynamic_throttling_enabled" {
description = "Specifies whether to enable the dynamic throttling for this Cognitive Service Account."
type = bool
default = false
}

variable "outbound_network_access_restricted" {
description = "Specifies whether outbound network access is restricted for the Cognitive Account"
type = bool
default = true
}

variable "public_network_access_enabled" {
description = "Specifies whether public network access is allowed for the Cognitive Account."
type = bool
default = false
}

variable "cognitive_deployment_abbreviation" {
description = "The abbreviation for the name of the Azure Cognitive Deployment."
type = string
default = "oai"
}

variable "cognitive_deployment_name" {
description = "The name of the Cognitive Services Account Deployment."
type = string
}

variable "rai_policy_name" {
description = "Optional Parameter for the name of the RAI policy."
type = string
default = null
}

variable "version_upgrade_option" {
description = "Deployment model version upgrade option."
type = string
default = "NoAutoUpgrade"
}

variable "cognitive_model_format" {
description = "The format of the Cognitive Services Account Deployment model."
type = string
default = "OpenAI"
}

variable "cognitive_model_name" {
description = "The name of the Cognitive Services Account Deployment model."
type = string
}

variable "cognitive_model_version" {
description = "The version of Cognitive Services Account Deployment model."
type = string
}

variable "deployment_sku_scale_type" {
description = "The name of the SKU. Ex - Standard or P3."
type = string
}

variable "deployment_sku_scale_capacity" {
description = " Tokens-per-Minute (TPM). The unit of measure for this field is in the thousands of Tokens-per-Minute."
type = string
}

variable "tags" {
description = "Default tag list"
type = map(string)
}
20 changes: 20 additions & 0 deletions modules/azurerm/Azure-OpenAI-Service/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -------------------------------------------------------------------------------------
#
# Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). All Rights Reserved.
#
# This software is the property of WSO2 LLC. and its suppliers, if any.
# Dissemination of any information or reproduction of any material contained
# herein in any form is strictly forbidden, unless permitted by WSO2 expressly.
# You may not alter or remove any copyright or other notice from copies of this content.
#
# --------------------------------------------------------------------------------------

terraform {
required_version = ">= 0.13"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.52.0"
}
}
}
Loading