dependency/azapi_examples/Microsoft.MachineLearningServices_workspaces_codes_versions@2024-10-01/main.tf (210 lines of code) (raw):

terraform { required_providers { azapi = { source = "Azure/azapi" } azurerm = { source = "hashicorp/azurerm" } } } provider "azurerm" { features { } } provider "azapi" { skip_provider_registration = false } variable "resource_name" { type = string default = "acctest0001" } variable "location" { type = string default = "westeurope" } data "azapi_client_config" "current" { } resource "azapi_resource" "resourceGroup" { type = "Microsoft.Resources/resourceGroups@2020-06-01" name = var.resource_name location = var.location body = {} schema_validation_enabled = false response_export_values = ["*"] } resource "azapi_resource" "storageAccount" { type = "Microsoft.Storage/storageAccounts@2021-09-01" parent_id = azapi_resource.resourceGroup.id name = var.resource_name location = var.location body = { kind = "StorageV2" properties = { accessTier = "Hot" allowBlobPublicAccess = true allowCrossTenantReplication = true allowSharedKeyAccess = true defaultToOAuthAuthentication = false encryption = { keySource = "Microsoft.Storage" services = { queue = { keyType = "Service" } table = { keyType = "Service" } } } isHnsEnabled = false isNfsV3Enabled = false isSftpEnabled = false minimumTlsVersion = "TLS1_2" networkAcls = { defaultAction = "Allow" } publicNetworkAccess = "Enabled" supportsHttpsTrafficOnly = true } sku = { name = "Standard_LRS" } } } data "azapi_resource" "blobService" { type = "Microsoft.Storage/storageAccounts/blobServices@2022-09-01" parent_id = azapi_resource.storageAccount.id name = "default" } resource "azapi_resource" "container" { type = "Microsoft.Storage/storageAccounts/blobServices/containers@2022-09-01" name = var.resource_name parent_id = data.azapi_resource.blobService.id body = { properties = { metadata = { key = "value" } } } } resource "azurerm_storage_blob" "example" { name = "codes.py" storage_account_name = azapi_resource.storageAccount.name storage_container_name = azapi_resource.container.name type = "Block" source = "/Users/luheng/go/playground/issues/icm/azapi_ml_code/output.md" } resource "azapi_resource" "component" { type = "Microsoft.Insights/components@2020-02-02" parent_id = azapi_resource.resourceGroup.id name = var.resource_name location = var.location body = { kind = "web" properties = { Application_Type = "web" DisableIpMasking = false DisableLocalAuth = false ForceCustomerStorageForProfiler = false RetentionInDays = 90 SamplingPercentage = 100 publicNetworkAccessForIngestion = "Enabled" publicNetworkAccessForQuery = "Enabled" } } } resource "azapi_resource" "vault" { type = "Microsoft.KeyVault/vaults@2021-10-01" parent_id = azapi_resource.resourceGroup.id name = var.resource_name location = var.location body = { properties = { accessPolicies = [ { objectId = "45a2d1ea-488a-44b0-bb2e-3cd8e485ebef" permissions = { certificates = [ "all", ] keys = [ "all", ] secrets = [ "all", ] storage = [] } tenantId = data.azapi_client_config.current.tenant_id } ] createMode = "default" enablePurgeProtection = true enableRbacAuthorization = false enableSoftDelete = true enabledForDeployment = false enabledForDiskEncryption = false enabledForTemplateDeployment = false publicNetworkAccess = "Enabled" sku = { family = "A" name = "standard" } tenantId = data.azapi_client_config.current.tenant_id } } lifecycle { ignore_changes = [body.properties.accessPolicies] } } resource "azapi_resource" "workspace" { type = "Microsoft.MachineLearningServices/workspaces@2022-05-01" parent_id = azapi_resource.resourceGroup.id name = var.resource_name location = var.location identity { type = "SystemAssigned" identity_ids = [] } body = { properties = { applicationInsights = azapi_resource.component.id keyVault = azapi_resource.vault.id publicNetworkAccess = "Disabled" storageAccount = azapi_resource.storageAccount.id v1LegacyMode = false } sku = { name = "Basic" tier = "Basic" } } ignore_casing = true schema_validation_enabled = false response_export_values = ["*"] } data "azapi_resource_id" "code" { type = "Microsoft.MachineLearningServices/workspaces/codes@2024-10-01" parent_id = azapi_resource.workspace.id name = "mycode" } resource "azapi_resource" "codeVersion" { type = "Microsoft.MachineLearningServices/workspaces/codes/versions@2024-10-01" parent_id = data.azapi_resource_id.code.id name = "1" body = { properties = { codeUri = "${azapi_resource.storageAccount.output.properties.primaryEndpoints.blob}${azapi_resource.container.name}" description = "this is a test code version" isArchived = false tags = { env = "prod" } properties = { } } } depends_on = [azurerm_storage_blob.example] }