This Commit change the resources to be auto generated from a json file (#2)
* Adding auto generation * Correcting terraform fmt * Adding resource definitions * Correcting review * Correcting append Co-authored-by: Gabriel Nepomuceno <ganepomu@microsoft.com>
This commit is contained in:
Родитель
6708b0c850
Коммит
c2c2e30c74
244
README.md
244
README.md
|
@ -1,3 +1,46 @@
|
|||
# Azure Naming
|
||||
|
||||
This module helps you to keep consistency on your resources names for terraform The goal of this module it is that for each resource that requires a name in terraform you would be easialy able to compose this name using this module and this will keep the consistency in your repositories.
|
||||
|
||||
# Usage
|
||||
|
||||
For every resource in `terraform_azurerm` just remove the `azurerm` part of the module and use the `name` property of this output.
|
||||
|
||||
example for `azurerm_resource_group` you can use :
|
||||
|
||||
```tf
|
||||
module "naming" "main" {
|
||||
suffix = [ "test" ]
|
||||
}
|
||||
resource "azurerm_resource_group" "example" {
|
||||
name = module.naming.main.resource_group.name
|
||||
location = "West Europe"
|
||||
}
|
||||
```
|
||||
|
||||
if you want this to be unique for this module and not shared with other instances of this module you can use `name_unique`
|
||||
|
||||
```tf
|
||||
module "naming" "main" {
|
||||
suffix = [ "test" ]
|
||||
}
|
||||
resource "azurerm_resource_group" "example" {
|
||||
name = module.naming.main.resource_group.name
|
||||
location = "West Europe"
|
||||
}
|
||||
```
|
||||
There are other advances usages that will be explained in the [Advanced usages](#advancedusages) part og this docs.
|
||||
|
||||
# Internals
|
||||
|
||||
## Modifying resources
|
||||
|
||||
The resources are automatically generated using `go` to change the generation please change the file on the `templates` folder. To add a new resource, include their definition at `resourceDefinition.jsonc` file it will be automatically generated.
|
||||
|
||||
# Current implementation
|
||||
|
||||
You can find a list bellow of all the resources that are currently implemented. To get a list of the ones that are missing implementation you can check at [Missing resources](docs/missing_ressources.md) the resources that have no documentation about their limitation on naming currently on Microsoft docs are on the [Not defined](docs/not_defined.md) list.
|
||||
|
||||
|
||||
|
||||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
|
||||
|
@ -19,98 +62,175 @@
|
|||
|------|-------------|------|---------|:--------:|
|
||||
| prefix | It is not recommended that you use prefix by azure you should be using a suffix for your resources. | `list(string)` | `[]` | no |
|
||||
| suffix | It is recommended that you specify a suffix for consistency. please use only lowercase charactes when possible | `list(string)` | `[]` | no |
|
||||
| unique-include-numbers | n/a | `bool` | `true` | no |
|
||||
| unique-length | n/a | `number` | `4` | no |
|
||||
| unique-seed | n/a | `string` | `""` | no |
|
||||
| unique-include-numbers | If you want to iunclude numbers in the unique generation | `bool` | `true` | no |
|
||||
| unique-length | Max length of the uniquiness suffix to be added | `number` | `4` | no |
|
||||
| unique-seed | Custom value for the randon charecters to be used | `string` | `""` | no |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| aks\_cluster | n/a |
|
||||
| analysis\_services\_server | n/a |
|
||||
| api\_management | n/a |
|
||||
| app\_service\_environment | n/a |
|
||||
| app\_service\_plan | n/a |
|
||||
| api\_managment\_service | n/a |
|
||||
| app\_configuration | n/a |
|
||||
| application\_gateway | n/a |
|
||||
| application\_insights | n/a |
|
||||
| application\_security\_group | n/a |
|
||||
| automation\_account | n/a |
|
||||
| automation\_certificate | n/a |
|
||||
| automation\_credential | n/a |
|
||||
| automation\_runbook | n/a |
|
||||
| automation\_schedule | n/a |
|
||||
| automation\_variable | n/a |
|
||||
| availability\_set | n/a |
|
||||
| azure\_arc\_connected\_machine | n/a |
|
||||
| blueprint | n/a |
|
||||
| cloud\_service | n/a |
|
||||
| cognitive\_search | n/a |
|
||||
| cognitive\_services | n/a |
|
||||
| container\_instance | n/a |
|
||||
| cosmos\_db | n/a |
|
||||
| bastion\_host | n/a |
|
||||
| batch\_account | n/a |
|
||||
| batch\_application | n/a |
|
||||
| batch\_certificate | n/a |
|
||||
| batch\_pool | n/a |
|
||||
| bot\_channel\_Email | n/a |
|
||||
| bot\_channel\_directline | n/a |
|
||||
| bot\_channel\_ms\_teams | n/a |
|
||||
| bot\_channel\_slack | n/a |
|
||||
| bot\_channels\_registration | n/a |
|
||||
| bot\_connection | n/a |
|
||||
| bot\_web\_app | n/a |
|
||||
| cdn\_endpoint | n/a |
|
||||
| cdn\_profile | n/a |
|
||||
| cognitive\_account | n/a |
|
||||
| containerGroups | n/a |
|
||||
| container\_registry | n/a |
|
||||
| container\_registry\_webhook | n/a |
|
||||
| cosmosdb\_account | n/a |
|
||||
| custom\_provider | n/a |
|
||||
| data\_factory | n/a |
|
||||
| data\_factory\_dataset\_mysql | n/a |
|
||||
| data\_factory\_dataset\_postgresql | n/a |
|
||||
| data\_factory\_dataset\_sql\_server\_table | n/a |
|
||||
| data\_factory\_integration\_runtime\_managed | n/a |
|
||||
| data\_factory\_linked\_service\_data\_lake\_storage\_gen2 | n/a |
|
||||
| data\_factory\_linked\_service\_key\_vault | n/a |
|
||||
| data\_factory\_linked\_service\_mysql | n/a |
|
||||
| data\_factory\_linked\_service\_postgresql | n/a |
|
||||
| data\_factory\_linked\_service\_sql\_server | n/a |
|
||||
| data\_factory\_pipeline | n/a |
|
||||
| data\_factory\_trigger\_schedule | n/a |
|
||||
| data\_lake\_analytics\_account | n/a |
|
||||
| data\_lake\_file\_system | n/a |
|
||||
| data\_lake\_store\_account | n/a |
|
||||
| data\_warehouse | n/a |
|
||||
| database\_migration\_service\_instance | n/a |
|
||||
| data\_lake\_analytics\_firewall\_rule | n/a |
|
||||
| data\_lake\_store | n/a |
|
||||
| data\_lake\_store\_firewall\_rule | n/a |
|
||||
| database\_migration\_project | n/a |
|
||||
| database\_migration\_service | n/a |
|
||||
| databricks\_workspace | n/a |
|
||||
| event\_hub | n/a |
|
||||
| event\_hub\_authorization\_rule | n/a |
|
||||
| event\_hub\_namespace | n/a |
|
||||
| event\_hub\_namespace\_authorization\_rule | n/a |
|
||||
| dev\_test\_lab | n/a |
|
||||
| dev\_test\_linux\_virtual\_machine | n/a |
|
||||
| dev\_test\_windows\_virtual\_machine | n/a |
|
||||
| disk\_encryption\_set | n/a |
|
||||
| eventhub | n/a |
|
||||
| eventhub\_authorization\_rule | n/a |
|
||||
| eventhub\_consumer\_group | n/a |
|
||||
| eventhub\_namespace | n/a |
|
||||
| eventhub\_namespace\_authorization\_rule | n/a |
|
||||
| eventhub\_namespace\_disaster\_recovery\_config | n/a |
|
||||
| express\_route\_circuit | n/a |
|
||||
| express\_route\_gateway | n/a |
|
||||
| firewall | n/a |
|
||||
| firewall\_ip\_configuration | n/a |
|
||||
| function\_app | n/a |
|
||||
| hdinsights\_hadoop\_cluster | n/a |
|
||||
| hdinsights\_hbase\_cluster | n/a |
|
||||
| hdinsights\_kafka\_cluster | n/a |
|
||||
| hdinsights\_ml\_services\_cluster | n/a |
|
||||
| hdinsights\_spark\_cluster | n/a |
|
||||
| hdinsights\_storm\_cluster | n/a |
|
||||
| iot\_hub | n/a |
|
||||
| frontdoor | n/a |
|
||||
| frontdoor\_firewall\_policy | n/a |
|
||||
| hdinsight\_hadoop\_cluster | n/a |
|
||||
| hdinsight\_hbase\_cluster | n/a |
|
||||
| hdinsight\_interactive\_query\_cluster | n/a |
|
||||
| hdinsight\_kafka\_cluster | n/a |
|
||||
| hdinsight\_ml\_services\_cluster | n/a |
|
||||
| hdinsight\_rserver\_cluster | n/a |
|
||||
| hdinsight\_spark\_cluster | n/a |
|
||||
| hdinsight\_storm\_cluster | n/a |
|
||||
| image | n/a |
|
||||
| iotcentral\_application | n/a |
|
||||
| iothub | n/a |
|
||||
| iothub\_consumer\_group | n/a |
|
||||
| iothub\_dps | n/a |
|
||||
| iothub\_dps\_certificate | n/a |
|
||||
| key\_vault | n/a |
|
||||
| key\_vault\_certificate | n/a |
|
||||
| key\_vault\_key | n/a |
|
||||
| load\_balancer\_external | n/a |
|
||||
| load\_balancer\_internal | n/a |
|
||||
| key\_vault\_secret | n/a |
|
||||
| kubernetes\_cluster | n/a |
|
||||
| kusto\_cluster | n/a |
|
||||
| kusto\_database | n/a |
|
||||
| kusto\_eventhub\_data\_connection | n/a |
|
||||
| lb | n/a |
|
||||
| lb\_nat\_rule | n/a |
|
||||
| linux\_virtual\_machine | n/a |
|
||||
| linux\_virtual\_machine\_scale\_set | n/a |
|
||||
| local\_network\_gateway | n/a |
|
||||
| log\_analytics\_workspace | n/a |
|
||||
| logic\_apps | n/a |
|
||||
| machine\_learning\_workspace | n/a |
|
||||
| migrate\_project | n/a |
|
||||
| mysql | n/a |
|
||||
| managed\_disk | n/a |
|
||||
| maps\_account | n/a |
|
||||
| mariadb\_database | n/a |
|
||||
| mariadb\_firewall\_rule | n/a |
|
||||
| mariadb\_server | n/a |
|
||||
| mariadb\_virtual\_network\_rule | n/a |
|
||||
| mssql\_database | n/a |
|
||||
| mssql\_elasticpool | n/a |
|
||||
| mssql\_server | n/a |
|
||||
| mysql\_database | n/a |
|
||||
| mysql\_firewall\_rule | n/a |
|
||||
| mysql\_server | n/a |
|
||||
| mysql\_virtual\_network\_rule | n/a |
|
||||
| network\_interface | n/a |
|
||||
| network\_security\_group | n/a |
|
||||
| notification\_hubs | n/a |
|
||||
| notification\_hubs\_namespace | n/a |
|
||||
| policy | n/a |
|
||||
| postgre | n/a |
|
||||
| private\_endpoint | n/a |
|
||||
| private\_service\_connection | n/a |
|
||||
| network\_watcher | n/a |
|
||||
| point\_to\_site\_vpn\_gateway | n/a |
|
||||
| postgresql\_database | n/a |
|
||||
| postgresql\_firewall\_rule | n/a |
|
||||
| postgresql\_server | n/a |
|
||||
| postgresql\_virtual\_network\_rule | n/a |
|
||||
| public\_ip | n/a |
|
||||
| recovery\_services\_vault | n/a |
|
||||
| public\_ip\_prefix | n/a |
|
||||
| redis\_cache | n/a |
|
||||
| resource\_group | n/a |
|
||||
| service\_bus | n/a |
|
||||
| service\_bus\_queue | n/a |
|
||||
| service\_bus\_topic | n/a |
|
||||
| service\_fabric | n/a |
|
||||
| sql\_database | n/a |
|
||||
| redis\_firewall\_rule | n/a |
|
||||
| role\_assignment | n/a |
|
||||
| role\_definition | n/a |
|
||||
| route | n/a |
|
||||
| route\_table | n/a |
|
||||
| service\_fabric\_cluster | n/a |
|
||||
| shared\_image | n/a |
|
||||
| shared\_image\_gallery | n/a |
|
||||
| snapshots | n/a |
|
||||
| sql\_elasticpool | n/a |
|
||||
| sql\_failover\_group | n/a |
|
||||
| sql\_firewall\_rule | n/a |
|
||||
| sql\_server | n/a |
|
||||
| sql\_server\_strech\_database | n/a |
|
||||
| storage\_account | n/a |
|
||||
| storage\_managed\_encryption\_key | n/a |
|
||||
| storagesimple | n/a |
|
||||
| stream\_analytics | n/a |
|
||||
| storage\_blob | n/a |
|
||||
| storage\_container | n/a |
|
||||
| storage\_data\_lake\_gen2\_filesystem | n/a |
|
||||
| storage\_queue | n/a |
|
||||
| storage\_share | n/a |
|
||||
| storage\_share\_directory | n/a |
|
||||
| storage\_table | n/a |
|
||||
| stream\_analytics\_function\_javascript\_udf | n/a |
|
||||
| stream\_analytics\_job | n/a |
|
||||
| stream\_analytics\_output\_blob | n/a |
|
||||
| stream\_analytics\_output\_eventhub | n/a |
|
||||
| stream\_analytics\_output\_mssql | n/a |
|
||||
| stream\_analytics\_output\_servicebus\_queue | n/a |
|
||||
| stream\_analytics\_output\_servicebus\_topic | n/a |
|
||||
| stream\_analytics\_reference\_input\_blob | n/a |
|
||||
| stream\_analytics\_stream\_input\_blob | n/a |
|
||||
| stream\_analytics\_stream\_input\_eventhub | n/a |
|
||||
| stream\_analytics\_stream\_input\_iothub | n/a |
|
||||
| subnet | n/a |
|
||||
| synapse | n/a |
|
||||
| template\_deployment | n/a |
|
||||
| traffic\_manager\_profile | n/a |
|
||||
| unique-seed | n/a |
|
||||
| virtual\_machine | n/a |
|
||||
| virtual\_machine\_linux | n/a |
|
||||
| virtual\_machine\_scale\_set | n/a |
|
||||
| virtual\_machine\_scale\_set\_linux | n/a |
|
||||
| virtual\_network | n/a |
|
||||
| virtual\_network\_gateway | n/a |
|
||||
| vm\_storage\_account | n/a |
|
||||
| vpn\_connection | n/a |
|
||||
| web\_app | n/a |
|
||||
| virtual\_network\_peering | n/a |
|
||||
| virtual\_wan | n/a |
|
||||
| windows\_virtual\_machine | n/a |
|
||||
| windows\_virtual\_machine\_scale\_set | n/a |
|
||||
|
||||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
|
||||
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
az = {
|
||||
// General
|
||||
resource_group = "rg"
|
||||
policy = "policy"
|
||||
api_management = "apim"
|
||||
|
||||
// Networking
|
||||
virtual_network = "vnet"
|
||||
subnet = "snet"
|
||||
network_interface = "nic"
|
||||
public_ip = "pip"
|
||||
load_balancer_internal = "lbi"
|
||||
load_balancer_external = "lbe"
|
||||
network_security_group = "nsg"
|
||||
application_security_group = "asg"
|
||||
local_network_gateway = "lgw"
|
||||
virtual_network_gateway = "vgw"
|
||||
vpn_connection = "cn"
|
||||
application_gateway = "agw"
|
||||
route_table = "route"
|
||||
traffic_manager_profile = "traf"
|
||||
private_endpoint = "pe" // Not in the specs
|
||||
private_service_connection = "psc" // Not in the specs
|
||||
firewall = "fw" // Not in the specs
|
||||
firewall_ip_configuration = "fwipc" // Not in the specs
|
||||
|
||||
// Compute and Web
|
||||
virtual_machine = "vm"
|
||||
virtual_machine_scale_set = "vmss"
|
||||
availability_set = "avail"
|
||||
vm_storage_account = "stvm"
|
||||
azure_arc_connected_machine = "arcm"
|
||||
container_instance = "aci"
|
||||
aks_cluster = "aks"
|
||||
service_fabric = "sf"
|
||||
app_service_environment = "ase"
|
||||
app_service_plan = "plan"
|
||||
web_app = "app"
|
||||
function_app = "func"
|
||||
cloud_service = "cld"
|
||||
notification_hubs = "ntf"
|
||||
notification_hubs_namespace = "ntfns"
|
||||
|
||||
// Databases
|
||||
azure_sql_database_server = "sql"
|
||||
azure_sql_database = "sqldb"
|
||||
cosmos_db = "cosmos"
|
||||
azure_cache_redis = "redis"
|
||||
mysql_database = "mysql"
|
||||
postgre_database = "psql"
|
||||
azure_data_warehouse = "sqldw"
|
||||
azure_synapse_analytics = "syn"
|
||||
sql_server_strech_database = "sqlstrdb"
|
||||
|
||||
// Storage
|
||||
storage_account = "st"
|
||||
azure_storsimple = "ssimp"
|
||||
storage_managed_encryption_key = "smek" # Not in the specs
|
||||
|
||||
// AI + Machine Learning
|
||||
azure_cognitive_search = "srch"
|
||||
azure_cognitive_services = "cog"
|
||||
azure_machine_learning_workspace = "mlw"
|
||||
|
||||
// Analytics and IoT
|
||||
azure_analysis_services_server = "as"
|
||||
azure_databricks_workspace = "dbw"
|
||||
azure_stream_analytics = "asa"
|
||||
azure_data_factory = "adf"
|
||||
data_lake_store_account = "dls"
|
||||
data_lake_file_system = "dlfs" // Not in the specs
|
||||
data_lake_analytics_account = "dla"
|
||||
event_hub = "evh"
|
||||
event_hub_namespace = "ehn" // Not in the specs
|
||||
event_hub_namespace_authorization_rule = "ehnar" // Not in the specs
|
||||
event_hub_authorization_rule = "ehar" // Not in the specs
|
||||
hdinsights_hadoop_cluster = "hadoop"
|
||||
hdinsights_hbase_cluster = "hbase"
|
||||
hdinsights_kafka_cluster = "kafka"
|
||||
hdinsights_spark_cluster = "spark"
|
||||
hdinsights_storm_cluster = "storm"
|
||||
hdinsights_ml_services_cluster = "mls"
|
||||
iot_hub = "iot"
|
||||
|
||||
// Integration
|
||||
logic_apps = "logic"
|
||||
service_bus = "sb"
|
||||
service_bus_queue = "sbq"
|
||||
service_bus_topic = "sbt"
|
||||
automation_account = "aa" // Not in the specs
|
||||
|
||||
// Managment and governance
|
||||
blueprint = "bp"
|
||||
key_vault = "kv"
|
||||
key_vault_key = "kvk"
|
||||
log_analytics_workspace = "log"
|
||||
application_insights = "appi"
|
||||
recovery_services_vault = "rsv"
|
||||
|
||||
//Migration
|
||||
azure_migrate_project = "migr"
|
||||
database_migration_service_instance = "dms"
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
managed_application_definition
|
||||
managed_application
|
||||
proximity_placement_group
|
||||
shared_image_version
|
||||
virtual_machine_extension
|
||||
virtual_machine_scale_set_extension
|
||||
orchestrated_virtual_machine_scale_set / preview
|
||||
sql_virtual_network_rule
|
||||
dns_a_record
|
||||
dns_aaaa_record
|
||||
dns_caa_record
|
||||
dns_cname_record
|
||||
dns_mx_record
|
||||
dns_ns_record
|
||||
dns_ptr_record
|
||||
dns_srv_record
|
||||
dns_txt_record
|
||||
dns_zone
|
||||
private_dns_a_record
|
||||
private_dns_a_record
|
||||
private_dns_aaaa_record
|
||||
private_dns_cname_record
|
||||
private_dns_mx_record
|
||||
private_dns_ptr_record
|
||||
private_dns_srv_record
|
||||
private_dns_txt_record
|
||||
private_dns_zone
|
||||
private_dns_zone_virtual_network_link
|
||||
iot_time_series_insights_access_policy
|
||||
iot_time_series_insights_standard_environment
|
||||
iot_time_series_insights_reference_data_set
|
||||
log_analytics_datasource_windows_event
|
||||
log_analytics_datasource_windows_performance_counter
|
||||
log_analytics_linked_service
|
||||
log_analytics_solution
|
||||
logic_app_action_custom
|
||||
logic_app_action_http
|
||||
logic_app_integration_account
|
||||
logic_app_trigger_custom
|
||||
logic_app_trigger_http_request
|
||||
logic_app_trigger_recurrence
|
||||
logic_app_workflow
|
||||
maintenance_configuration
|
||||
management_lock
|
||||
management_group
|
||||
media_services_account
|
||||
spatial_anchors_account
|
||||
eventgrid_domain
|
||||
eventgrid_domain_topic
|
||||
eventgrid_event_subscription
|
||||
eventgrid_topic
|
||||
notification_hub
|
||||
notification_hub_authorization_rule
|
||||
notification_hub_namespace
|
||||
relay_hybrid_connection
|
||||
relay_namespace
|
||||
servicebus_namespace
|
||||
servicebus_namespace_authorization_rule
|
||||
servicebus_queue
|
||||
servicebus_queue_authorization_rule
|
||||
servicebus_subscription
|
||||
servicebus_subscription_rule
|
||||
servicebus_topic
|
||||
servicebus_topic_authorization_rule
|
||||
signalr_service
|
||||
scheduled_query_rule_log
|
||||
application_security_group
|
||||
network_ddos_protection_plan
|
||||
express_route_circuit_authorization
|
||||
nat_gateway
|
||||
network_packet_capture
|
||||
network_profile
|
||||
network_security_group
|
||||
network_security_rule
|
||||
packet_capture //deprecated
|
||||
private_link_service
|
||||
web_application_firewall_policy
|
||||
netapp_account
|
||||
netapp_pool
|
||||
netapp_volume
|
||||
netapp_snapshot
|
||||
dashboard
|
||||
powerbi_embedded
|
||||
recovery_services_vault
|
||||
site_recovery_fabric
|
||||
site_recovery_network_mapping
|
||||
site_recovery_protection_container_mapping
|
||||
site_recovery_protection_container
|
||||
site_recovery_replicated_vm
|
||||
site_recovery_replication_policy
|
||||
hpc_cache
|
||||
hpc_cache_nfs_target
|
||||
hpc_cache_blob_target
|
|
@ -0,0 +1,61 @@
|
|||
# Not Difined limits
|
||||
|
||||
// https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules#microsoftdocumentdb
|
||||
kubernetes_cluster_node_pool
|
||||
cosmosdb_cassandra_keyspace
|
||||
cosmosdb_gremlin_database
|
||||
cosmosdb_gremlin_graph
|
||||
cosmosdb_mongo_collection
|
||||
cosmosdb_mongo_database
|
||||
cosmosdb_sql_container
|
||||
cosmosdb_sql_database
|
||||
cosmosdb_table
|
||||
cost_management_export_resource_group
|
||||
mariadb_configuration
|
||||
mysql_configuration
|
||||
postgresql_configuration
|
||||
policy_assignment
|
||||
policy_definition
|
||||
policy_remediation
|
||||
policy_set_definition
|
||||
data_share
|
||||
data_share_account
|
||||
devspace_controller
|
||||
dev_test_policy
|
||||
dev_test_schedule
|
||||
dev_test_virtual_network
|
||||
healthcare_service
|
||||
iothub_dps_shared_access_policy
|
||||
iothub_endpoint_eventhub
|
||||
iothub_endpoint_servicebus_queue
|
||||
iothub_endpoint_servicebus_topic
|
||||
iothub_endpoint_storage_container
|
||||
iothub_route
|
||||
iothub_shared_access_policy
|
||||
lb_backend_address_pool
|
||||
lb_rule
|
||||
lb_outbound_rule
|
||||
lb_nat_pool
|
||||
lb_probe
|
||||
traffic_manager_endpoint
|
||||
virtual_hub
|
||||
virtual_hub_connection
|
||||
virtual_network_gateway_connection
|
||||
vpn_server_configuration
|
||||
firewall_ip_configuration
|
||||
firewall_application_rule_collection
|
||||
firewall_nat_rule_collection
|
||||
firewall_network_rule_collection
|
||||
monitor_action_group
|
||||
monitor_action_rule_action_group
|
||||
monitor_action_rule_suppression
|
||||
monitor_activity_log_alert
|
||||
monitor_autoscale_setting
|
||||
monitor_diagnostic_setting
|
||||
monitor_log_profile
|
||||
monitor_metric_alert
|
||||
monitor_scheduled_query_rules_alert
|
||||
storage_table_entity
|
||||
search_service
|
||||
sentinel_alert_rule_ms_security_incident
|
||||
sentinel_alert_rule_scheduled
|
|
@ -0,0 +1,5 @@
|
|||
module github.com/azure/terraform-azurerm-naming
|
||||
|
||||
go 1.13
|
||||
|
||||
require muzzammil.xyz/jsonc v0.0.0-20200303171503-1e787b591db7
|
|
@ -0,0 +1,2 @@
|
|||
muzzammil.xyz/jsonc v0.0.0-20200303171503-1e787b591db7 h1:3CowZIBYWC4gEerMAHeKy4jF2fHoS45Q27yqsU/BsX0=
|
||||
muzzammil.xyz/jsonc v0.0.0-20200303171503-1e787b591db7/go.mod h1:rFv8tUUKe+QLh7v02BhfxXEf4ZHhYD7unR93HL/1Uvo=
|
|
@ -0,0 +1,64 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"text/template"
|
||||
|
||||
"muzzammil.xyz/jsonc"
|
||||
)
|
||||
|
||||
// Resource definityion for the package
|
||||
type Resource struct {
|
||||
Name string `json:"name"`
|
||||
Length *Length `json:"length,omitempty"`
|
||||
Regex *string `json:"regex,omitempty"`
|
||||
Scope *string `json:"scope,omitempty"`
|
||||
Slug *string `json:"slug,omitempty"`
|
||||
Dashes bool `json:"dashes"`
|
||||
}
|
||||
|
||||
// Length allowed for that resorce
|
||||
type Length struct {
|
||||
Min int `json:"min"`
|
||||
Max int `json:"max"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
files, err := ioutil.ReadDir("templates")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
var fileNames = make([]string, len(files))
|
||||
for i, file := range files {
|
||||
fileNames[i] = "templates/" + file.Name()
|
||||
}
|
||||
parsedTemplate, err := template.ParseFiles(fileNames...)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
sourceDefinitions, err := ioutil.ReadFile("resourceDefinition.jsonc")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
var data []Resource
|
||||
jc := jsonc.ToJSON(sourceDefinitions)
|
||||
err = json.Unmarshal(jc, &data)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
mainFile, err := os.OpenFile("main.tf", os.O_TRUNC|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
parsedTemplate.ExecuteTemplate(mainFile, "main", data)
|
||||
outputsFile, err := os.OpenFile("outputs.tf", os.O_TRUNC|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
parsedTemplate.ExecuteTemplate(outputsFile, "outputs", data)
|
||||
}
|
1704
main.tf
1704
main.tf
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
1458
outputs.tf
1458
outputs.tf
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,18 +0,0 @@
|
|||
[
|
||||
{
|
||||
"name": "key_vault_vault",
|
||||
"min_length": 3,
|
||||
"max_length": 24,
|
||||
"regex": "^(?=.{3,24}$)(?!.*--)[a-zA-Z][a-zA-Z0-9\\-]+$",
|
||||
"scope": "global",
|
||||
"slug": "kv"
|
||||
},
|
||||
{
|
||||
"name": "key_vault_secret",
|
||||
"min_length": 1,
|
||||
"max_length": 127,
|
||||
"regex": "^(?=.{1,127}$)[a-zA-Z0-9\\-]+$",
|
||||
"scope": "parent",
|
||||
"slug": "kvk"
|
||||
}
|
||||
]
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,14 @@
|
|||
[
|
||||
{
|
||||
"name": "private_endpoint",
|
||||
"length": {
|
||||
"min": 1,
|
||||
"max": 80
|
||||
},
|
||||
"regex": "^(?=.{1,80}$)[a-zA-Z0-9][a-zA-Z0-9\\-\\._]+[a-zA-Z0-9_]$",
|
||||
"scope": "resourceGroup",
|
||||
"slug": "pe", // Not in the specs
|
||||
"dashes": true
|
||||
},
|
||||
{}
|
||||
]
|
|
@ -0,0 +1,54 @@
|
|||
{{- define "resources" -}}
|
||||
{{- .Name }} = {
|
||||
name = substr(join("{{if .Dashes}}-{{ end }}", compact([local.prefix{{if not .Dashes}}_safe{{ end }}, "{{ .Slug }}", local.suffix{{if not .Dashes}}_safe{{ end }}])), 0, {{ .Length.Max }})
|
||||
name_unique = substr(join("{{if .Dashes}}-{{ end }}", compact([local.prefix{{if not .Dashes}}_safe{{ end }}, "{{ .Slug }}", local.suffix_unique{{if not .Dashes}}_safe{{ end }}])), 0, {{ .Length.Max }})
|
||||
dashes = {{ .Dashes }}
|
||||
slug = "{{ .Slug }}"
|
||||
min_length = {{ .Length.Min }}
|
||||
max_length = {{ .Length.Max }}
|
||||
scope = "{{ .Scope }}"
|
||||
regex = "/{{ .Regex }}/"
|
||||
}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
{{- define "main" -}}
|
||||
provider "random" {
|
||||
version = "~>2.2"
|
||||
}
|
||||
|
||||
resource "random_string" "main" {
|
||||
length = 60
|
||||
special = false
|
||||
upper = false
|
||||
number = var.unique-include-numbers
|
||||
}
|
||||
|
||||
resource "random_string" "first_letter" {
|
||||
length = 1
|
||||
special = false
|
||||
upper = false
|
||||
number = false
|
||||
}
|
||||
|
||||
|
||||
|
||||
locals {
|
||||
// adding a first letter to guarantee that you always start with a letter
|
||||
random_safe_generation = join("", [random_string.first_letter.result, random_string.main.result])
|
||||
random = substr(coalesce(var.unique-seed, local.random_safe_generation), 0, var.unique-length)
|
||||
prefix = join("-", var.prefix)
|
||||
prefix_safe = lower(join("", var.prefix))
|
||||
suffix = join("-", var.suffix)
|
||||
suffix_unique = join("-", concat(var.suffix, [local.random]))
|
||||
suffix_safe = lower(join("", var.suffix))
|
||||
suffix_unique_safe = lower(join("", concat(var.suffix, [local.random])))
|
||||
// Names based in the recomendations of
|
||||
// https://docs.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/naming-and-tagging
|
||||
az = {
|
||||
{{- range . }}
|
||||
{{ template "resources" .}}
|
||||
{{- end }}
|
||||
}
|
||||
}
|
||||
{{ end }}
|
|
@ -0,0 +1,16 @@
|
|||
{{ define "output" }}
|
||||
output "{{ .Name }}" {
|
||||
value = local.az.{{ .Name }}
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
{{ define "outputs" }}
|
||||
output "unique-seed" {
|
||||
value = coalesce(var.unique-seed, local.random_safe_generation)
|
||||
}
|
||||
|
||||
{{- range . }}
|
||||
{{- template "output" .}}
|
||||
{{- end }}
|
||||
|
||||
{{ end }}
|
|
@ -11,16 +11,19 @@ variable "suffix" {
|
|||
}
|
||||
|
||||
variable "unique-seed" {
|
||||
description = "Custom value for the randon charecters to be used"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "unique-length" {
|
||||
description = "Max length of the uniquiness suffix to be added"
|
||||
type = number
|
||||
default = 4
|
||||
}
|
||||
|
||||
variable "unique-include-numbers" {
|
||||
description = "If you want to iunclude numbers in the unique generation"
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче