New sample (converted from Bicep via OpenAI)

This commit is contained in:
Tom Archer 2023-04-12 09:30:19 -07:00
parent f90f330230
commit 67452c3289
5 changed files with 97 additions and 0 deletions

View File

@ -0,0 +1,37 @@
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_notification_hub_namespace_name" {
length = 25
upper = false
numeric = false
special = false
}
resource "azurerm_notification_hub_namespace" "namespace" {
name = "hubns-${random_string.azurerm_notification_hub_namespace_name.result}"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
namespace_type = "NotificationHub"
sku_name = "Free"
}
resource "random_string" "azurerm_notification_hub_name" {
length = 25
upper = false
numeric = false
special = false
}
resource "azurerm_notification_hub" "hub" {
name = "hub-${random_string.azurerm_notification_hub_name.result}"
resource_group_name = azurerm_resource_group.rg.name
namespace_name = azurerm_notification_hub_namespace.namespace.name
location = azurerm_resource_group.rg.location
}

View File

@ -0,0 +1,11 @@
output "resource_group_name" {
value = azurerm_resource_group.rg.name
}
output "notification_hub_namespace_name" {
value = azurerm_notification_hub_namespace.namespace.name
}
output "notification_hub__name" {
value = azurerm_notification_hub.hub.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,22 @@
# Azure Notification Hubs namespace and hub
This template creates an Azure Notification Hubs namespace and hub.
## 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_notification_hub_namespace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/notification_hub_namespace)
- [azurerm_notification_hub](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/notification_hub)
## 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 |
## Example
To see how to run this example, see [Create a notification hub using Terraform](https://learn.microsoft.com/azure/notification-hubs/create-notification-hub-terraform).

View File

@ -0,0 +1,11 @@
variable "resource_group_location" {
type = string
default = "eastus"
description = "Location for all resources."
}
variable "resource_group_name_prefix" {
type = string
default = "rg"
description = "Prefix of the resource group name that's combined with a random value so name is unique in your Azure subscription."
}