From 0772dfdca787c0d2e5958963337107a97da203cb Mon Sep 17 00:00:00 2001 From: Roman Schwarz Date: Thu, 19 Sep 2024 15:42:04 +0200 Subject: [PATCH 1/2] Add `tfsort` to pre-commit hooks Signed-off-by: Roman Schwarz --- .pre-commit-config.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9d7deda..de7db89 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,6 +10,14 @@ repos: hooks: - id: terraform-docs-system args: ["."] + - repo: local + hooks: + - id: tfsort + name: Sort Terraform variables + language: system + types: [terraform] + entry: bash -c 'for f in $@; do tfsort "$f"; done' -- + files: ^variables|outputs\.tf$ - repo: https://github.com/antonbabenko/pre-commit-terraform rev: "v1.92.0" hooks: From 66748351dbc9318feddac05dde1cbc78079b48ff Mon Sep 17 00:00:00 2001 From: Roman Schwarz Date: Thu, 19 Sep 2024 15:50:15 +0200 Subject: [PATCH 2/2] Sort outputs Signed-off-by: Roman Schwarz --- outputs.tf | 106 ++++++++++++++++++++++++++--------------------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/outputs.tf b/outputs.tf index cf2f4cc..140afc7 100644 --- a/outputs.tf +++ b/outputs.tf @@ -1,8 +1,3 @@ -output "admin_username" { - description = "The admin username of the virtual machine." - value = local.virtual_machine.admin_username -} - output "admin_password" { description = "The admin password of the virtual machine." value = local.admin_password @@ -20,6 +15,11 @@ output "admin_ssh_public_key" { value = local.admin_ssh_public_key } +output "admin_username" { + description = "The admin username of the virtual machine." + value = local.virtual_machine.admin_username +} + output "data_disks" { description = <<-EOT A list of data disks attached to the virtual machine. Each list element is an map with the following keys: @@ -45,54 +45,6 @@ output "id" { description = "The ID of the virtual machine." } -output "user_assigned_identity" { - description = <<-EOT - The primary user assigned identity of the virtual machine - - Attributes: - - Attribute | Description - -- | -- - `client_id` | The client id in uuid format of the user assigned identity. - `id` | The resource id of the user assgined identity. - `name` | The name of the user assigned identity. - `principal_id` | The Principal ID of the user assigned identity. - `tenant_id` | The Tenant ID of the user assigned identity. - EOT - - value = one([for resource in azurerm_user_assigned_identity.this : { - client_id = resource.client_id - id = resource.id - name = resource.name - principal_id = resource.principal_id - tenant_id = resource.tenant_id - }]) -} - -output "user_assigned_identity_ids" { - description = "A list of all user assigned identities of the virtual machine." - - value = local.virtual_machine.identity[*].identity_ids -} - -output "system_assigned_identity" { - description = <<-EOT - The primary user assigned identity of the virtual machine - - Attributes: - - Attribute | Description - -- | -- - `principal_id` | The Principal ID of the system assigned identity. - `tenant_id` | The Tenant ID of the system assigned identity. - EOT - - value = one([for identity in local.virtual_machine.identity : { - principal_id = identity.principal_id - tenant_id = identity.tenant_id - }]) -} - output "image" { value = local.image } @@ -141,6 +93,54 @@ output "public_ip_addresses" { value = local.virtual_machine.public_ip_addresses } +output "system_assigned_identity" { + description = <<-EOT + The primary user assigned identity of the virtual machine + + Attributes: + + Attribute | Description + -- | -- + `principal_id` | The Principal ID of the system assigned identity. + `tenant_id` | The Tenant ID of the system assigned identity. + EOT + + value = one([for identity in local.virtual_machine.identity : { + principal_id = identity.principal_id + tenant_id = identity.tenant_id + }]) +} + +output "user_assigned_identity" { + description = <<-EOT + The primary user assigned identity of the virtual machine + + Attributes: + + Attribute | Description + -- | -- + `client_id` | The client id in uuid format of the user assigned identity. + `id` | The resource id of the user assgined identity. + `name` | The name of the user assigned identity. + `principal_id` | The Principal ID of the user assigned identity. + `tenant_id` | The Tenant ID of the user assigned identity. + EOT + + value = one([for resource in azurerm_user_assigned_identity.this : { + client_id = resource.client_id + id = resource.id + name = resource.name + principal_id = resource.principal_id + tenant_id = resource.tenant_id + }]) +} + +output "user_assigned_identity_ids" { + description = "A list of all user assigned identities of the virtual machine." + + value = local.virtual_machine.identity[*].identity_ids +} + output "virtual_machine_extensions" { description = <<-EOT A list of virtual machine extensions installed on this virtual machine by this module. Each list element is a map with the following attributes: