New sample (converted from Bicep via OpenAI)

This commit is contained in:
Tom Archer 2023-03-18 13:34:12 -07:00
parent 35b3afaf63
commit 566ede9f1e
5 changed files with 82 additions and 0 deletions

View File

@ -0,0 +1,24 @@
resource "random_pet" "rg_name" {
prefix = var.resource_group_name_prefix
}
resource "azurerm_resource_group" "rg" {
name = random_pet.rg_name.id
location = var.resource_group_location
}
resource "random_string" "azurerm_cognitive_account_name" {
length = 13
lower = true
numeric = false
special = false
upper = false
}
resource "azurerm_cognitive_account" "cognitive_service" {
name = "CognitiveService-${random_string.azurerm_cognitive_account_name.result}"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
sku_name = var.sku
kind = "CognitiveServices"
}

View File

@ -0,0 +1,7 @@
output "resource_group_name" {
value = azurerm_resource_group.rg.name
}
output "azurerm_cognitive_account_name" {
value = azurerm_cognitive_account.cognitive_service.name
}

View File

@ -0,0 +1,16 @@
terraform {
required_version = ">=1.0"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>3.0"
}
random = {
source = "hashicorp/random"
version = "~>3.0"
}
}
}
provider "azurerm" {
features {}
}

View File

@ -0,0 +1,18 @@
# Azure Cognitive Services account
This template deploys an Azure Cognitive Services account.
## Terraform resource types
- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet)
- [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group)
- [random_string](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string)
- [azurerm_cognitive_account](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cognitive_account)
## Variables
| Name | Description | Default |
|-|-|-|
| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg |
| `resource_group_location` | Location of the resource group. | eastus |
| `sku` | The sku name of the Azure Analysis Services server to create. | S0 |

View File

@ -0,0 +1,17 @@
variable "resource_group_location" {
type = string
description = "Location for all resources."
default = "eastus"
}
variable "resource_group_name_prefix" {
type = string
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
default = "rg"
}
variable "sku" {
type = string
description = "The sku name of the Azure Analysis Services server to create. Choose from: B1, B2, D1, S0, S1, S2, S3, S4, S8, S9. Some skus are region specific. See https://docs.microsoft.com/en-us/azure/analysis-services/analysis-services-overview#availability-by-region"
default = "S0"
}