-
Notifications
You must be signed in to change notification settings - Fork 827
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
757ad97
commit 2f17431
Showing
8 changed files
with
198 additions
and
174 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" { | ||
} |
Oops, something went wrong.