Skip to content

Commit

Permalink
Add tfsort to pre-commit hooks (#16)
Browse files Browse the repository at this point in the history
* Add `tfsort` to pre-commit hooks

Signed-off-by: Roman Schwarz <[email protected]>

* Sort outputs

Signed-off-by: Roman Schwarz <[email protected]>

---------

Signed-off-by: Roman Schwarz <[email protected]>
  • Loading branch information
rswrz authored Sep 20, 2024
1 parent ebd71a4 commit 897919f
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 53 deletions.
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
106 changes: 53 additions & 53 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand All @@ -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
}
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 897919f

Please sign in to comment.