Skip to content

[AVM Module Issue]: type subnetType is causing issues icw bicep-docs #6223

@mikebijl

Description

@mikebijl

Check for previous/existing GitHub issues

  • I have checked for previous/existing GitHub issues

Issue Type?

Bug

Module Name

avm/res/network/virtual-network

(Optional) Module Version

0.7.0, 0.7.1

Description

Since I guess the module is bumped to version 0.7 the IPAM support is added to the module 'br/public:avm/res/network/virtual-network:0.7.1'.

The problem with this module is not that deployments are failing... however the type subnetType is not fully correct. The way I experienced this is by trying to document my internal bicep "wrapper" modules by using bicep-docs.

Once I do that, it fails with the following:

error processing C:\Users\....\bicep\res\network\virtual-network_0.7.1.1.bicep: failed to parse ARM template: DataTypes: unmarshalerDecoder: Alias: Items: readObjectStart: expect { or n, but found
f, error found in #10 byte of ...|"items": false,
    |..., bigger context ...|"array",
      "prefixItems": [],
      "items": false,
      "metadata": {
        "__bicep_importe|..., error found in #10 byte of ...|   }
    },
    "_1.|..., bigger context ...|ommon-types_0.1.0.0.bicep"
        }
      }
    },
    "_1.supportedResourceTypes": {
      "type":|...

After troubleshooting I found the issue and it lies within the way ipamPoolPrefixAllocations is defined.

IMHO it should have been done this way

type ipamPoolPrefixAllocationsType = {
      @description('Required. The IPAM pool.')
      pool: {
        @description('Required. The Resource ID of the IPAM pool.')
        id: string
      }
      @description('Required. Number of IP addresses allocated from the pool.')
      numberOfIpAddresses: string
}

@export()
type subnetType = {
  @description('Required. The Name of the subnet resource.')
  name: string

  @description('Conditional. The address prefix for the subnet. Required if `addressPrefixes` is empty.')
  addressPrefix: string?

  @description('Conditional. List of address prefixes for the subnet. Required if `addressPrefix` is empty.')
  addressPrefixes: string[]?

  @description('Conditional. The address space for the subnet, deployed from IPAM Pool. Required if `addressPrefixes` and `addressPrefix` is empty and the VNet address space configured to use IPAM Pool.')
  ipamPoolPrefixAllocations: ipamPoolPrefixAllocationsType[]?

Since the resource 'Microsoft.Network virtualNetworks/subnets' says the following... it is an array of objects

ipamPoolPrefixAllocations A list of IPAM Pools for allocating IP address prefixes. IpamPoolPrefixAllocation[]

The current virtual-network module dictates that there is "array" with a single object in it. My approach makes it an array of typed objects...

After I included my own "type" in the module file, the bicep-docs is working as expected...

(Optional) Correlation Id

No response

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Needs: Triage

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions