Skip to content

Commit

Permalink
add example for Microsoft.Network/networkManagers's nested resources (
Browse files Browse the repository at this point in the history
#667)

* add example for `Microsoft.Network/networkManagers`'s nested resources

* make terrafmt
  • Loading branch information
ms-henglu authored Nov 12, 2024
1 parent 22c2cb6 commit 0ae936b
Show file tree
Hide file tree
Showing 6 changed files with 686 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
terraform {
required_providers {
azapi = {
source = "Azure/azapi"
}
}
}

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
}

resource "azapi_resource" "networkManager" {
type = "Microsoft.Network/networkManagers@2022-09-01"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
body = {
properties = {
description = ""
networkManagerScopeAccesses = [
"SecurityAdmin",
]
networkManagerScopes = {
managementGroups = [
]
subscriptions = [
"/subscriptions/${data.azapi_client_config.current.subscription_id}",
]
}
}
}
retry = {
error_message_regex = ["CannotDeleteResource"]
}
}

resource "azapi_resource" "ipamPool" {
type = "Microsoft.Network/networkManagers/ipamPools@2024-01-01-preview"
parent_id = azapi_resource.networkManager.id
name = var.resource_name
location = var.location
body = {
properties = {
addressPrefixes = [
"10.0.0.0/24",
]
description = "Test description."
parentPoolName = ""
displayName = "testDisplayName"
}
}

tags = {
myTag = "testTag"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
terraform {
required_providers {
azapi = {
source = "Azure/azapi"
}
}
}

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
}

resource "azapi_resource" "networkManager" {
type = "Microsoft.Network/networkManagers@2022-09-01"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
body = {
properties = {
description = ""
networkManagerScopeAccesses = [
"SecurityAdmin",
]
networkManagerScopes = {
managementGroups = [
]
subscriptions = [
"/subscriptions/${data.azapi_client_config.current.subscription_id}",
]
}
}
}
retry = {
error_message_regex = ["CannotDeleteResource"]
}
}

resource "azapi_resource" "ipamPool" {
type = "Microsoft.Network/networkManagers/ipamPools@2024-01-01-preview"
parent_id = azapi_resource.networkManager.id
name = var.resource_name
location = var.location
body = {
properties = {
addressPrefixes = [
"10.0.0.0/24",
]
description = "Test description."
parentPoolName = ""
displayName = "testDisplayName"
}
}

tags = {
myTag = "testTag"
}
}

resource "azapi_resource" "staticCidr" {
type = "Microsoft.Network/networkManagers/ipamPools/staticCidrs@2024-01-01-preview"
parent_id = azapi_resource.ipamPool.id
name = var.resource_name
body = {
properties = {
addressPrefixes = [
"10.0.0.0/25",
]
numberOfIPAddressesToAllocate = ""
description = "test description"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
terraform {
required_providers {
azapi = {
source = "Azure/azapi"
}
}
}

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
}

resource "azapi_resource" "networkManager" {
type = "Microsoft.Network/networkManagers@2022-09-01"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
body = {
properties = {
description = ""
networkManagerScopeAccesses = [
"SecurityAdmin",
]
networkManagerScopes = {
managementGroups = [
]
subscriptions = [
"/subscriptions/${data.azapi_client_config.current.subscription_id}",
]
}
}
}
retry = {
error_message_regex = ["CannotDeleteResource"]
}
}

resource "azapi_resource" "verifierWorkspace" {
type = "Microsoft.Network/networkManagers/verifierWorkspaces@2024-01-01-preview"
parent_id = azapi_resource.networkManager.id
name = var.resource_name
location = var.location
body = {
properties = {
description = "A sample workspace"
}
}

tags = {
myTag = "testTag"
}
}
Loading

0 comments on commit 0ae936b

Please sign in to comment.