states.azurerm.network.virtual_network

Azure Resource Manager (ARM) Virtual Network State Module

New in version 1.0.0.

Changed in version 4.0.0,: 5.0.0

maintainer:

<devops@eitr.tech>

configuration:

This module requires Azure Resource Manager credentials to be passed via acct. Note that the authentication parameters are case sensitive.

Required provider parameters:

if using username and password:
  • subscription_id
  • username
  • password
if using a service principal:
  • subscription_id
  • tenant
  • client_id
  • secret

Optional provider parameters:

cloud_environment: Used to point the cloud driver to different API endpoints, such as Azure GovCloud. Possible values:

  • AZURE_PUBLIC_CLOUD (default)
  • AZURE_CHINA_CLOUD
  • AZURE_US_GOV_CLOUD
  • AZURE_GERMAN_CLOUD

Example acct setup for Azure Resource Manager authentication:

azurerm:
    default:
        subscription_id: 3287abc8-f98a-c678-3bde-326766fd3617
        tenant: ABCDEFAB-1234-ABCD-1234-ABCDEFABCDEF
        client_id: ABCDEFAB-1234-ABCD-1234-ABCDEFABCDEF
        secret: XXXXXXXXXXXXXXXXXXXXXXXX
        cloud_environment: AZURE_PUBLIC_CLOUD
    user_pass_auth:
        subscription_id: 3287abc8-f98a-c678-3bde-326766fd3617
        username: fletch
        password: 123pass

The authentication parameters can also be passed as a dictionary of keyword arguments to the connection_auth parameter of each state, but this is not preferred and could be deprecated in the future.

idem_azurerm.states.azurerm.network.virtual_network.absent(hub, ctx, name, resource_group, connection_auth=None, **kwargs)

New in version 1.0.0.

Ensure a virtual network does not exist in the resource group.

Parameters:
  • name – Name of the virtual network.
  • resource_group – The resource group assigned to the virtual network.
  • connection_auth – A dict with subscription and authentication parameters to be used in connecting to the Azure Resource Manager API.

Example usage:

Ensure virtual network absent:
    azurerm.network.virtual_network.absent:
      - name: test_vnet
      - resource_group: test_group
idem_azurerm.states.azurerm.network.virtual_network.present(hub, ctx, name, address_prefixes, resource_group, dns_servers=None, enable_ddos_protection=False, ddos_protection_plan=None, tags=None, connection_auth=None, **kwargs)

New in version 1.0.0.

Changed in version 4.0.0,: 5.0.0

Ensure a virtual network exists.

Parameters:
  • name – Name of the virtual network.
  • resource_group – The resource group assigned to the virtual network.
  • address_prefixes – A list of CIDR blocks which can be used by subnets within the virtual network.
  • dns_servers – A list of DNS server addresses.
  • enable_ddos_protection – A boolean value indicating whether a DDoS protection is enabled for all the protected resources in the virtual network. It requires a DDoS protection plan associated with the resource. Default to False.
  • ddos_protection_plan – The resource ID of the DDoS protection plan associated with the virtual network. This parameter is required when the enable_ddos_protection parameter is set to True.
  • tags – A dictionary of strings can be passed as tag metadata to the virtual network object.
  • connection_auth – A dict with subscription and authentication parameters to be used in connecting to the Azure Resource Manager API.

Example usage:

Ensure virtual network exists:
    azurerm.network.virtual_network.present:
        - name: vnet1
        - resource_group: group1
        - address_prefixes:
            - '10.0.0.0/8'
            - '192.168.0.0/16'
        - dns_servers:
            - '8.8.8.8'
        - tags:
            contact_name: Elmer Fudd Gantry
idem_azurerm.states.azurerm.network.virtual_network.subnet_absent(hub, ctx, name, virtual_network, resource_group, connection_auth=None, **kwargs)

New in version 1.0.0.

Ensure a virtual network does not exist in the virtual network.

Parameters:
  • name – Name of the subnet.
  • virtual_network – Name of the existing virtual network containing the subnet.
  • resource_group – The resource group assigned to the virtual network.
  • connection_auth – A dict with subscription and authentication parameters to be used in connecting to the Azure Resource Manager API.

Example usage:

Ensure subnet absent:
    azurerm.network.virtual_network.subnet_absent:
      - name: test_subnet
      - resource_group: test_group
idem_azurerm.states.azurerm.network.virtual_network.subnet_present(hub, ctx, name, address_prefix, virtual_network, resource_group, security_group=None, route_table=None, service_endpoints=None, connection_auth=None, **kwargs)

New in version 1.0.0.

Changed in version 4.0.0.

Ensure a subnet exists.

Parameters:
  • name – Name of the subnet.
  • address_prefix – A CIDR block used by the subnet within the virtual network.
  • virtual_network – Name of the existing virtual network to contain the subnet.
  • resource_group – The resource group assigned to the virtual network.
  • security_group – The name of the existing network security group to assign to the subnet.
  • route_table – The name of the existing route table to assign to the subnet.
  • service_endpoints – A list of service endpoints. More information about service endpoints and valid values can be found here.
  • connection_auth – A dict with subscription and authentication parameters to be used in connecting to the Azure Resource Manager API.

Example usage:

Ensure subnet exists:
    azurerm.network.virtual_network.subnet_present:
        - name: vnet1_sn1
        - virtual_network: vnet1
        - resource_group: group1
        - address_prefix: '192.168.1.0/24'
        - security_group: nsg1
        - route_table: rt1