You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.7 KiB

  1. terraform {
  2. required_version = "~> 0.12.21"
  3. required_providers {
  4. azurerm = "~> 1.44"
  5. }
  6. }
  7. resource "azurerm_network_security_group" "aznsg" {
  8. count = length(var.nsgs)
  9. name = var.nsgs[count.index].name
  10. resource_group_name = var.nsgs[count.index].resource_group_name
  11. location = var.nsgs[count.index].location
  12. tags = var.nsgs[count.index].tags
  13. dynamic "security_rule" {
  14. for_each = var.nsgs[count.index].security_rules
  15. content {
  16. name = security_rule.key
  17. description = security_rule.value.description
  18. protocol = security_rule.value.protocol #Tcp, Udp, Icmp, or *
  19. source_port_range = security_rule.value.source_port_range # [Integer or range between 0 and 65535 or *]
  20. destination_port_range = security_rule.value.destination_port_range # [Integer or range between 0 and 65535 or *]
  21. source_address_prefix = security_rule.value.source_address_prefix # [CIDR or destination IP range or * or tags such as ‘VirtualNetwork’, ‘AzureLoadBalancer’ and ‘Internet’ ]
  22. destination_address_prefix = security_rule.value.destination_address_prefix # [CIDR or destination IP range or * or tags such as ‘VirtualNetwork’, ‘AzureLoadBalancer’ and ‘Internet’ ]
  23. access = security_rule.value.access #Allow or Deny
  24. priority = security_rule.value.priority
  25. direction = security_rule.value.direction #Inbound or Outbound.
  26. }
  27. }
  28. depends_on = [var.aznsg_depends_on]
  29. }