Skip to content

Commit

Permalink
add output for all resources
Browse files Browse the repository at this point in the history
  • Loading branch information
movinalot committed Aug 22, 2023
1 parent c816f2a commit 3ba5940
Show file tree
Hide file tree
Showing 32 changed files with 152 additions and 36 deletions.
26 changes: 13 additions & 13 deletions terraform/azure/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions terraform/azure/azurerm_automation_account.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ resource "azurerm_automation_account" "automation_account" {
type = each.value.identity_type
}
}

output "automation_accounts" {
value = var.enable_output ? azurerm_automation_account.automation_account[*] : null
sensitive = true
}
4 changes: 4 additions & 0 deletions terraform/azure/azurerm_automation_runbook.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ resource "azurerm_automation_runbook" "automation_runbook" {
uri = each.value.publish_content_link_uri
}
}

output "automation_runbooks" {
value = var.enable_output ? azurerm_automation_runbook.automation_runbook[*] : null
}
5 changes: 5 additions & 0 deletions terraform/azure/azurerm_automation_webhook.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ resource "azurerm_automation_webhook" "automation_webhook" {
]
}
}

output "automation_webhooks" {
value = var.enable_output ? azurerm_automation_webhook.automation_webhook[*] : null
sensitive = true
}
5 changes: 5 additions & 0 deletions terraform/azure/azurerm_linux_virtual_machine.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,8 @@ resource "azurerm_linux_virtual_machine" "linux_virtual_machine" {
ComputeType = each.value.tags_ComputeType
}
}

output "linux_virtual_machines" {
value = var.enable_output ? azurerm_linux_virtual_machine.linux_virtual_machine[*] : null
sensitive = true
}
4 changes: 4 additions & 0 deletions terraform/azure/azurerm_public_ip.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ resource "azurerm_public_ip" "public_ip" {
allocation_method = each.value.allocation_method
sku = each.value.sku
}

output "public_ips" {
value = var.enable_output ? azurerm_public_ip.public_ip[*] : null
}
4 changes: 4 additions & 0 deletions terraform/azure/azurerm_resource_group.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ data "azurerm_resource_group" "resource_group" {
count = local.resource_group_exists ? 1 : 0
name = local.resource_group_name_combined
}

output "resource_group" {
value = var.enable_output ? azurerm_resource_group.resource_group[*] : null
}
4 changes: 4 additions & 0 deletions terraform/azure/azurerm_role_assignment.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ resource "azurerm_role_assignment" "role_assignment" {
role_definition_name = each.value.role_definition_name
principal_id = each.value.principal_id
}

output "role_assignments" {
value = var.enable_output ? azurerm_role_assignment.role_assignment[*] : null
}
4 changes: 4 additions & 0 deletions terraform/azure/azurerm_route.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ resource "azurerm_route" "route" {
next_hop_type = each.value.next_hop_type
next_hop_in_ip_address = each.value.next_hop_in_ip_address
}

output "routes" {
value = var.enable_output ? azurerm_route.route[*] : null
}
4 changes: 4 additions & 0 deletions terraform/azure/azurerm_route_table.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ resource "azurerm_route_table" "route_table" {

name = each.value.name
}

output "route_tables" {
value = var.enable_output ? azurerm_route_table.route_table[*] : null
}
4 changes: 4 additions & 0 deletions terraform/azure/azurerm_subnet.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ resource "azurerm_subnet" "subnet" {
virtual_network_name = each.value.virtual_network_name
address_prefixes = each.value.address_prefixes
}

output "subnets" {
value = var.enable_output ? azurerm_subnet.subnet[*] : null
}
4 changes: 4 additions & 0 deletions terraform/azure/azurerm_subnet_route_table_association.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ resource "azurerm_subnet_route_table_association" "subnet_route_table_associatio
subnet_id = each.value.subnet_id
route_table_id = each.value.route_table_id
}

output "subnet_route_table_associations" {
value = var.enable_output ? azurerm_subnet_route_table_association.subnet_route_table_association[*] : null
}
13 changes: 3 additions & 10 deletions terraform/azure/azurerm_virtual_machine.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,7 @@ resource "azurerm_virtual_machine" "virtual_machine" {
}
}

resource "local_sensitive_file" "tempalte_file" {
for_each = local.virtual_machines
filename = format("../fortios/fortios_%s.cfg", each.value.name)
content = templatefile("${each.value.os_profile_custom_data}", {
hostname = each.value.name
api_key = each.value.os_profile_custom_data_api_key
license_type = each.value.os_profile_custom_data_license_type
license_file = each.value.os_profile_custom_data_license_file
license_token = each.value.os_profile_custom_data_license_token
})
output "virtual_machines" {
value = var.enable_output ? azurerm_virtual_machine.virtual_machine[*] : null
sensitive = true
}
4 changes: 4 additions & 0 deletions terraform/azure/azurerm_virtual_network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ resource "azurerm_virtual_network" "virtual_network" {
name = each.value.name
address_space = each.value.address_space
}

output "virtual_networks" {
value = var.enable_output ? azurerm_virtual_network.virtual_network[*] : null
}
4 changes: 4 additions & 0 deletions terraform/azure/azurerm_virtual_network_interface.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ resource "azurerm_network_interface" "network_interface" {
}
}
}

output "network_interfaces" {
value = var.enable_output ? azurerm_network_interface.network_interface[*] : null
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ resource "azurerm_network_interface_security_group_association" "port1nsg" {
network_interface_id = each.value.network_interface_id
network_security_group_id = each.value.network_security_group_id
}

output "network_interface_security_group_associations" {
value = var.enable_output ? azurerm_network_interface_security_group_association.port1nsg[*] : null
}
4 changes: 4 additions & 0 deletions terraform/azure/azurerm_virtual_network_security_group.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ resource "azurerm_network_security_group" "network_security_group" {

name = each.value.name
}

output "network_security_groups" {
value = var.enable_output ? azurerm_network_security_group.network_security_group[*] : null
}
4 changes: 4 additions & 0 deletions terraform/azure/azurerm_virtual_network_security_rule.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ resource "azurerm_network_security_rule" "network_security_rule" {
source_address_prefix = each.value.source_address_prefix
destination_address_prefix = each.value.destination_address_prefix
}

output "network_security_rules" {
value = var.enable_output ? azurerm_network_security_rule.network_security_rule[*] : null
}
12 changes: 12 additions & 0 deletions terraform/azure/local_sensitive_file.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,16 @@ config system automation-action
next
end
EOT
}

resource "local_sensitive_file" "tempalte_file" {
for_each = local.virtual_machines
filename = format("../fortios/fortios_%s.cfg", each.value.name)
content = templatefile("${each.value.os_profile_custom_data}", {
hostname = each.value.name
api_key = each.value.os_profile_custom_data_api_key
license_type = each.value.os_profile_custom_data_license_type
license_file = each.value.os_profile_custom_data_license_file
license_token = each.value.os_profile_custom_data_license_token
})
}
10 changes: 6 additions & 4 deletions terraform/azure/locals_single_fgt.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
locals {
resource_group_exists = true
resource_group_name_combined = "${local.username}-${var.resource_group_name_suffix}"
resource_group_exists = false
resource_group_name_suffix = "fgt-as-workshop"

resource_group_name_combined = "${local.username}-${local.resource_group_name_suffix}"

location = "eastus"

Expand All @@ -11,9 +13,9 @@ locals {
username = var.username
password = "Fortinet123#"

license_type = "payg" # can be byol|flex - fortinet_fg-vm or payg - "fortinet_fg-vm_payg_2022"
license_type = "flex" # can be byol|flex - fortinet_fg-vm or payg - "fortinet_fg-vm_payg_2022"
license_file = ""
license_token = ""
license_token = "DC411A1810904A2F8CB7"

environment_tag = "Terraform Single FortiGate"

Expand Down
2 changes: 1 addition & 1 deletion terraform/azure/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ output "credentials" {
output "webhook" {
value = azurerm_automation_webhook.automation_webhook["Update-RouteTable_webhook"].uri
sensitive = true
}
}
4 changes: 4 additions & 0 deletions terraform/azure/random_id.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ resource "random_id" "id" {

byte_length = 4
}

output "id" {
value = var.enable_output ? random_id.id.hex : null
}
4 changes: 4 additions & 0 deletions terraform/azure/random_string.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ resource "random_string" "string" {
length = 30
special = false
}

output "string" {
value = var.enable_output ? random_string.string.result : null
}
9 changes: 5 additions & 4 deletions terraform/azure/variables.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
variable "resource_group_name_suffix" {
variable "username" {
default = "user01"
type = string
default = "fgt-as-workshop"
}

variable "username" {
type = string
variable "enable_output" {
default = true
type = bool
}
4 changes: 4 additions & 0 deletions terraform/fortios/fortigate_firewall_policy.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ resource "fortios_firewall_policy" "firewall_policy" {
}
}
}

output "firewall_policys" {
value = var.enable_output ? fortios_firewall_policy.firewall_policy[*] : null
}
6 changes: 5 additions & 1 deletion terraform/fortios/fortios_firewall_address.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ resource "fortios_firewall_address" "firewall_address" {
type = each.value.type
sdn = each.value.sdn
filter = each.value.filter
}
}

output "firewall_addresses" {
value = var.enable_output ? fortios_firewall_address.firewall_address[*] : null
}
6 changes: 5 additions & 1 deletion terraform/fortios/fortios_router_static.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ resource "fortios_router_static" "router_static" {
dst = each.value.dst
gateway = each.value.gateway
status = each.value.status
}
}

output "router_statics" {
value = var.enable_output ? fortios_router_static.router_static[*] : null
}
6 changes: 5 additions & 1 deletion terraform/fortios/fortios_system_automationaction.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ resource "fortios_system_automationaction" "system_automationaction" {
}

verify_host_cert = each.value.verify_host_cert
}
}

output "system_automationactions" {
value = var.enable_output ? fortios_system_automationaction.system_automationaction[*] : null
}
4 changes: 4 additions & 0 deletions terraform/fortios/fortios_system_automationstitch.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ resource "fortios_system_automationstitch" "system_automationstitch" {
}
}
}

output "system_automationstitches" {
value = var.enable_output ? fortios_system_automationstitch.system_automationstitch[*] : null
}
4 changes: 4 additions & 0 deletions terraform/fortios/fortios_system_automationtrigger.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ resource "fortios_system_automationtrigger" "system_automationtrigger" {
}
}
}

output "system_automationtriggers" {
value = var.enable_output ? fortios_system_automationtrigger.system_automationtrigger[*] : null
}
4 changes: 4 additions & 0 deletions terraform/fortios/fortios_system_sdnconnector.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ resource "fortios_system_sdnconnector" "system_sdnconnector" {
use_metadata_iam = each.value.use_metadata_iam
subscription_id = each.value.subscription_id
resource_group = each.value.resource_group
}

output "system_sdnconnectors" {
value = var.enable_output ? fortios_system_sdnconnector.system_sdnconnector[*] : null
}
7 changes: 6 additions & 1 deletion terraform/fortios/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ variable "webhook" {
variable "static_routes" {
type = map(any)
default = {}
}
}

variable "enable_output" {
default = true
type = bool
}

0 comments on commit 3ba5940

Please sign in to comment.