Skip to content

Commit

Permalink
matching contributor guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
andyaviles121 committed Jun 21, 2024
1 parent 757ad97 commit 2f17431
Show file tree
Hide file tree
Showing 8 changed files with 198 additions and 174 deletions.
20 changes: 0 additions & 20 deletions quickstart/101-ai-studio/connections.tf

This file was deleted.

66 changes: 0 additions & 66 deletions quickstart/101-ai-studio/dependent.tf

This file was deleted.

36 changes: 0 additions & 36 deletions quickstart/101-ai-studio/hub.tf

This file was deleted.

170 changes: 149 additions & 21 deletions quickstart/101-ai-studio/main.tf
Original file line number Diff line number Diff line change
@@ -1,32 +1,160 @@
terraform {
required_version = ">= 1.0"
resource "random_pet" "rg_name" {
prefix = var.resource_group_name_prefix
}

// RESOURCE GROUP
resource "azurerm_resource_group" "rg" {
location = var.resource_group_location
name = random_pet.rg_name.id
}

data "azurerm_client_config" "current" {
}

// STORAGE ACCOUNT
resource "azurerm_storage_account" "default" {
name = "${var.prefix}storage${random_string.suffix.result}"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
account_tier = "Standard"
account_replication_type = "GRS"
allow_nested_items_to_be_public = false
}

required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.0, < 4.0"
// KEY VAULT
resource "azurerm_key_vault" "default" {
name = "${var.prefix}keyvault${random_string.suffix.result}"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
tenant_id = data.azurerm_client_config.current.tenant_id
sku_name = "standard"
purge_protection_enabled = false
}

// AzAPI AIServices
resource "azapi_resource" "AIServicesResource"{
type = "Microsoft.CognitiveServices/accounts@2023-10-01-preview"
name = "AIServicesResource${random_string.suffix.result}"
location = azurerm_resource_group.rg.location
parent_id = azurerm_resource_group.rg.id

identity {
type = "SystemAssigned"
}

body = jsonencode({
name = "AIServicesResource${random_string.suffix.result}"
properties = {
//restore = true
customSubDomainName = "${random_string.suffix.result}domain"
apiProperties = {
statisticsEnabled = false
}
}
azapi = {
source = "azure/azapi"
kind = "AIServices"
sku = {
name = var.sku
}
}
})

response_export_values = ["*"]
}

provider "azurerm" {
features {
key_vault {
recover_soft_deleted_key_vaults = false
purge_soft_delete_on_destroy = false
purge_soft_deleted_keys_on_destroy = false
}
resource_group {
prevent_deletion_if_contains_resources = false
// Azure AI Hub
resource "azapi_resource" "hub" {
type = "Microsoft.MachineLearningServices/workspaces@2024-04-01-preview"
name = "${random_pet.rg_name.id}-aih"
location = azurerm_resource_group.rg.location
parent_id = azurerm_resource_group.rg.id

identity {
type = "SystemAssigned"
}

body = jsonencode({
properties = {
description = "This is my Azure AI hub"
friendlyName = "My Hub"
storageAccount = azurerm_storage_account.default.id
keyVault = azurerm_key_vault.default.id

/* Optional: To enable these field, the corresponding dependent resources need to be uncommented.
applicationInsight = azurerm_application_insights.default.id
containerRegistry = azurerm_container_registry.default.id
*/

/*Optional: To enable Customer Managed Keys, the corresponding
encryption = {
status = var.encryption_status
keyVaultProperties = {
keyVaultArmId = azurerm_key_vault.default.id
keyIdentifier = var.cmk_keyvault_key_uri
}
}
*/

}
kind = "hub"
})
}

// Azure AI Project
resource "azapi_resource" "project" {
type = "Microsoft.MachineLearningServices/workspaces@2024-04-01-preview"
name = "my-ai-project${random_string.suffix.result}"
location = azurerm_resource_group.rg.location
parent_id = azurerm_resource_group.rg.id

identity {
type = "SystemAssigned"
}

body = jsonencode({
properties = {
description = "This is my Azure AI PROJECT"
friendlyName = "My Project"
hubResourceId = azapi_resource.hub.id
}
kind = "project"
})
}

provider "azapi" {
// AzAPI AI Services Connection
resource "azapi_resource" "AIServicesConnection" {
type = "Microsoft.MachineLearningServices/workspaces/connections@2024-04-01-preview"
name = "Default_AIServices${random_string.suffix.result}"
parent_id = azapi_resource.hub.id

body = jsonencode({
properties = {
category = "AIServices",
target = jsondecode(azapi_resource.AIServicesResource.output).properties.endpoint,
authType = "AAD",
isSharedToAll = true,
metadata = {
ApiType = "Azure",
ResourceId = azapi_resource.AIServicesResource.id
}
}
})
response_export_values = ["*"]
}

data "azurerm_client_config" "current" {
}
/* The following resources are OPTIONAL.
// APPLICATION INSIGHTS
resource "azurerm_application_insights" "default" {
name = "${var.prefix}appinsights${random_string.suffix.result}"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
application_type = "web"
}
// CONTAINER REGISTRY
resource "azurerm_container_registry" "default" {
name = "${var.prefix}contreg${random_string.suffix.result}"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
sku = "premium"
admin_enabled = true
}
*/
5 changes: 2 additions & 3 deletions quickstart/101-ai-studio/output.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
output "ResourceGroup" {
value = azurerm_resource_group.default.id
value = azurerm_resource_group.rg.id
}

output "HubId" {
Expand All @@ -12,5 +12,4 @@ output "ProjectId" {

output "endpoint" {
value = jsondecode(azapi_resource.AIServicesResource.output).properties.endpoint
}

}
19 changes: 0 additions & 19 deletions quickstart/101-ai-studio/project.tf

This file was deleted.

33 changes: 33 additions & 0 deletions quickstart/101-ai-studio/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
terraform {
required_version = ">= 1.0"

required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>3.0"
}
azapi = {
source = "azure/azapi"
}
random = {
source = "hashicorp/random"
version = "~>3.0"
}
}
}

provider "azurerm" {
features {
key_vault {
recover_soft_deleted_key_vaults = false
purge_soft_delete_on_destroy = false
purge_soft_deleted_keys_on_destroy = false
}
resource_group {
prevent_deletion_if_contains_resources = false
}
}
}

provider "azapi" {
}
Loading

0 comments on commit 2f17431

Please sign in to comment.