File tree Expand file tree Collapse file tree
101-azapi-eventhub-network-rules Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # AzAPI update resource is used to enable Network Rule sets on Event Hub namespace
2+ resource "azapi_update_resource" "qs101" {
3+ type = " Microsoft.EventHub/namespaces/networkRuleSets@2021-11-01"
4+ name = " default"
5+ parent_id = azurerm_eventhub_namespace. qs101 . id
6+
7+ body = jsonencode ({
8+ properties = {
9+ defaultAction = " Deny"
10+ publicNetworkAccess = " Enabled"
11+ virtualNetworkRules = [
12+ {
13+ ignoreMissingVnetServiceEndpoint = false
14+ subnet = {
15+ # API bug, returned id replaced `resourceGroups` with `resourcegroups`
16+ id = replace (azurerm_subnet. qs101 . id , " resourceGroups" , " resourcegroups" )
17+ }
18+ }
19+ ]
20+ ipRules = [
21+ {
22+ action = " Allow"
23+ ipMask = " 1.1.1.1"
24+ }
25+ ]
26+ }
27+ })
28+ }
Original file line number Diff line number Diff line change 1+ resource "azurerm_resource_group" "qs101" {
2+ name = " rg-qs101-eh-rules"
3+ location = " westus2"
4+ }
5+
6+ resource "azurerm_virtual_network" "qs101" {
7+ name = " myvnet"
8+ location = azurerm_resource_group. qs101 . location
9+ resource_group_name = azurerm_resource_group. qs101 . name
10+ address_space = [" 172.17.0.0/16" ]
11+ dns_servers = [" 10.0.0.4" , " 10.0.0.5" ]
12+ }
13+
14+ resource "azurerm_subnet" "qs101" {
15+ name = " default"
16+ resource_group_name = azurerm_resource_group. qs101 . name
17+ virtual_network_name = azurerm_virtual_network. qs101 . name
18+ address_prefixes = [" 172.17.0.0/24" ]
19+
20+ service_endpoints = [" Microsoft.EventHub" ]
21+ }
22+
23+ resource "random_pet" "qs101_namespace" {
24+ length = 3
25+ separator = " "
26+ }
27+
28+ resource "azurerm_eventhub_namespace" "qs101" {
29+ name = random_pet. qs101_namespace . id
30+ location = azurerm_resource_group. qs101 . location
31+ resource_group_name = azurerm_resource_group. qs101 . name
32+ sku = " Standard"
33+ capacity = 2
34+ }
Original file line number Diff line number Diff line change 1+ terraform {
2+ required_providers {
3+ azapi = {
4+ source = " azure/azapi"
5+ version = " =0.1.0"
6+ }
7+
8+ azurerm = {
9+ source = " hashicorp/azurerm"
10+ version = " =3.0.2"
11+ }
12+
13+ random = {
14+ source = " hashicorp/random"
15+ version = " =3.1.2"
16+ }
17+ }
18+ }
19+
20+ provider "azapi" {
21+ }
22+
23+ provider "azurerm" {
24+ features {}
25+ }
26+
27+ provider "random" {
28+ }
Original file line number Diff line number Diff line change 1+ # Provision a Lab Service Account and a Lab that are in public preview
2+ resource "azapi_resource" "qs101-account" {
3+ type = " Microsoft.LabServices/labaccounts@2018-10-15"
4+ name = " qs101LabAccount"
5+ parent_id = azurerm_resource_group. qs101 . id
6+
7+ body = jsonencode ({
8+ properties = {
9+ enabledRegionSelection = false
10+ }
11+ })
12+ }
13+
14+ resource "azapi_resource" "qs101-lab" {
15+ type = " Microsoft.LabServices/labaccounts/labs@2018-10-15"
16+ name = " qs101Lab"
17+ parent_id = azapi_resource. qs101-account . id
18+
19+ body = jsonencode ({
20+ properties = {
21+ maxUsersInLab = 10
22+ userAccessMode = " Restricted"
23+ }
24+ })
25+ }
Original file line number Diff line number Diff line change 1+ resource "azurerm_resource_group" "qs101" {
2+ name = " rg-qs101"
3+ location = " westus2"
4+
5+ depends_on = [
6+ azurerm_resource_provider_registration . qs101
7+ ]
8+ }
9+
10+ #
11+ resource "azurerm_resource_provider_registration" "qs101" {
12+ name = " Microsoft.LabServices"
13+ }
Original file line number Diff line number Diff line change 1+ terraform {
2+ required_providers {
3+ azapi = {
4+ source = " azure/azapi"
5+ version = " =0.1.0"
6+ }
7+ azurerm = {
8+ source = " hashicorp/azurerm"
9+ version = " =3.0.2"
10+ }
11+ }
12+ }
13+
14+ provider "azapi" {
15+ default_location = " eastus"
16+ default_tags = {
17+ team = " Azure deployments"
18+ }
19+ }
20+
21+ provider "azurerm" {
22+ features {}
23+ }
You can’t perform that action at this time.
0 commit comments