Resource Name Mapper#
There are two modules:
namingbatch
The root module#
The root module only demonstrates the use of naming and batch. These examples are in main.tf.
naming#
The module naming accepts a base_name and resource_type input.
base_namecan be anystring.resource_typeis astringand must be one ofvirtual_machine,key_vault, orstorage_account.
An output, resource_name is returned. Its value is the reformatted base_name based on its resource_type.
The following transformations are applied to base_name based on resource_type:
virtual_machineprependsvm-and appends-00.base_nameis limited to 15 characters.key_vaultprependskv-.base_namecharacters are lower-cased.storage_accountprependssa.base_nameremoves hyphens, and is lower-cased.
Here are examples of this module’s output for the resource_name.
|
|
|
|---|---|---|
|
|
|
|
|
|
|
|
|
batch#
The module batch accepts an input resources that is a map of { "base_name" = "resource_type" }. This allows the creation of several resource_name``s without invoking the ``naming module directly.
In the map, the key is base_name and the value is resource_type. The inputs follow the same rules as the naming module.
base_namecan be anystring.resource_typeis astringand must be one ofvirtual_machine,key_vault, orstorage_account.
An output, resource_names is returned. Its value is a map of { "base_name" = "resource_name" } where resource_name is the transformed base_name value from the naming module.
Here are examples of this module’s output for the resource_names.
|
|
|---|---|
|
|
|
|
|
|
Tests#
Run terraform test to execute automated tests for these modules.