diff --git a/modules/azure-customrole/.terraform-docs.yml b/modules/azure-customrole/.terraform-docs.yml new file mode 100644 index 000000000..bce3ca3a9 --- /dev/null +++ b/modules/azure-customrole/.terraform-docs.yml @@ -0,0 +1,48 @@ +formatter: "markdown" # this is required + +version: "" + +header-from: docs/header.md +footer-from: docs/footer.md + +recursive: + enabled: false + path: modules + include-main: true + +sections: + hide: [] + show: [] + +content: "" + +output: + file: "README.md" + mode: inject + template: |- + + {{ .Content }} + + +output-values: + enabled: false + from: "" + +sort: + enabled: true + by: name + +settings: + anchor: true + color: true + default: true + description: false + escape: true + hide-empty: false + html: true + indent: 2 + lockfile: true + read-comments: true + required: true + sensitive: true + type: true \ No newline at end of file diff --git a/modules/azure-customrole/README.md b/modules/azure-customrole/README.md index c3d7bfd02..e74394cb1 100644 --- a/modules/azure-customrole/README.md +++ b/modules/azure-customrole/README.md @@ -1,66 +1,86 @@ + +# Azure Custom Role Terraform Module + +## Overview + +This Terraform module allows you to create a custom role in Azure, specifying actions, data actions, and the assignable scopes. + +## Main features +- Create custom roles in Azure. +- Flexible definition of actions, data actions, not actions, and not data actions. +- Support for multiple assignable scopes. + +## Ejemplo completo + +Puedes encontrar un ejemplo completo en [`_examples/basic/values.yaml`](_examples/basic/values.yaml). + +## File structure + +``` +. +├── main.tf +├── variables.tf +├── outputs.tf +├── versions.tf +├── README.md +├── CHANGELOG.md +└── docs/ + ├── header.md + └── footer.md +``` + ## Requirements | Name | Version | |------|---------| -| [terraform](#requirement\_terraform) | >= 1.7.5 | +| [terraform](#requirement\_terraform) | >= 1.7.0 | +| [azurerm](#requirement\_azurerm) | ~> 4.16.0 | ## Providers | Name | Version | |------|---------| -| [azurerm](#provider\_azurerm) | ~= 4.16.0 | +| [azurerm](#provider\_azurerm) | ~> 4.16.0 | + +## Modules + +No modules. ## Resources | Name | Type | |------|------| -| [azurerm_role_definition](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_definition) | source | +| [azurerm_role_definition.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_definition) | resource | ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| name | The name of the Role Definition | `string` | n/a | yes | -| assignable_scopes | One or more assignable scopes for this Role Definition. The first one will become de scope at which the Role Definition applies to. | `list(string)` | n/a | yes | -| permissions | A permissions block with possible 'actions', 'data_actions', 'not_actions' and/or 'not_data_actions'. |
object({
actions = list(string) (optional)
data_actions = list(string) (optional)
not_actions = list(string) (optional)
not_data_actions = list(string) (optional)
}) | n/a | yes |
+| [assignable\_scopes](#input\_assignable\_scopes) | One or more assignable scopes for this Role Definition. The first one will become de scope at which the Role Definition applies to. | `list(string)` | n/a | yes |
+| [name](#input\_name) | The name of the Role Definition | `string` | n/a | yes |
+| [permissions](#input\_permissions) | A permissions block with possible 'actions', 'data\_actions', 'not\_actions' and/or 'not\_data\_actions'. | object({
actions = optional(list(string), [])
data_actions = optional(list(string), [])
not_actions = optional(list(string), [])
not_data_actions = optional(list(string), [])
}) | n/a | yes |
## Outputs
| Name | Description |
|------|-------------|
-| [role_definition_id](#output\_role\_definition\_id">) | The ID of the Role Definition. |
-
-## Example
-
-### HCL
-```hcl
-{
- name: "Custom Role"
- assignable_scopes: ["yyy", "zzz"]
- permissions: {
- actions = [
- "Microsoft.Compute/disks/read",
- "Microsoft.Compute/disks/write",
- ]
- not_actions = [
- "Microsoft.Compute/disks/read",
- "Microsoft.Compute/disks/write",
- ]
- }
-}
-```
+| [id](#output\_id) | # OUTPUTS SECTION Role Definition Id |
-### Yaml
-```yaml
-name: "Custom Role"
-assignable_scopes:
- - "yyy"
- - "zzz"
-permissions:
- actions:
- - "Microsoft.Compute/disks/read"
- - "Microsoft.Compute/disks/write"
- notActions:
- - "Microsoft.Authorization/*/Delete"
- - "Microsoft.Authorization/*/Write"
-```
+---
+
+## Examples
+
+For detailed examples, refer to the [module examples](https://github.com/prefapp/tfm/tree/main/modules/azure-customrole/_examples):
+
+- [basic](https://github.com/prefapp/tfm/tree/main/modules/azure-customrole/_examples/basic) - Basic custom role definition with assignable scopes and permissions.
+
+## Additional resources
+
+- [Azure Custom Roles](https://learn.microsoft.com/en-us/azure/role-based-access-control/custom-roles)
+- [Terraform AzureRM Provider - azurerm\_role\_definition](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_definition)
+- [Official Terraform documentation](https://www.terraform.io/docs)
+
+## Support
+
+For issues, questions, or contributions related to this module, please visit the [repository's issue tracker](https://github.com/prefapp/tfm/issues).
+
\ No newline at end of file
diff --git a/modules/azure-customrole/_examples/basic/main.tf b/modules/azure-customrole/_examples/basic/main.tf
new file mode 100644
index 000000000..ff2c4dc6b
--- /dev/null
+++ b/modules/azure-customrole/_examples/basic/main.tf
@@ -0,0 +1,6 @@
+module "custom_role" {
+ source = "../../"
+ name = var.name
+ assignable_scopes = var.assignable_scopes
+ permissions = var.permissions
+}
\ No newline at end of file
diff --git a/modules/azure-customrole/_examples/basic/values.yaml b/modules/azure-customrole/_examples/basic/values.yaml
new file mode 100644
index 000000000..67aacad83
--- /dev/null
+++ b/modules/azure-customrole/_examples/basic/values.yaml
@@ -0,0 +1,11 @@
+name: "Custom Role"
+assignable_scopes:
+ - "/subscriptions/xxx"
+ - "/subscriptions/yyy"
+permissions:
+ actions:
+ - "Microsoft.Compute/disks/read"
+ - "Microsoft.Compute/disks/write"
+ not_actions:
+ - "Microsoft.Authorization/*/Delete"
+ - "Microsoft.Authorization/*/Write"
\ No newline at end of file
diff --git a/modules/azure-customrole/docs/footer.md b/modules/azure-customrole/docs/footer.md
new file mode 100644
index 000000000..8fb7437fc
--- /dev/null
+++ b/modules/azure-customrole/docs/footer.md
@@ -0,0 +1,17 @@
+---
+
+## Examples
+
+For detailed examples, refer to the [module examples](https://github.com/prefapp/tfm/tree/main/modules/azure-customrole/_examples):
+
+- [basic](https://github.com/prefapp/tfm/tree/main/modules/azure-customrole/_examples/basic) - Basic custom role definition with assignable scopes and permissions.
+
+## Additional resources
+
+- [Azure Custom Roles](https://learn.microsoft.com/en-us/azure/role-based-access-control/custom-roles)
+- [Terraform AzureRM Provider - azurerm_role_definition](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_definition)
+- [Official Terraform documentation](https://www.terraform.io/docs)
+
+## Support
+
+For issues, questions, or contributions related to this module, please visit the [repository's issue tracker](https://github.com/prefapp/tfm/issues).
\ No newline at end of file
diff --git a/modules/azure-customrole/docs/header.md b/modules/azure-customrole/docs/header.md
new file mode 100644
index 000000000..e19868866
--- /dev/null
+++ b/modules/azure-customrole/docs/header.md
@@ -0,0 +1,29 @@
+# Azure Custom Role Terraform Module
+
+## Overview
+
+This Terraform module allows you to create a custom role in Azure, specifying actions, data actions, and the assignable scopes.
+
+## Main features
+- Create custom roles in Azure.
+- Flexible definition of actions, data actions, not actions, and not data actions.
+- Support for multiple assignable scopes.
+
+## Full example
+
+You can find a full example in [`_examples/basic/values.yaml`](../_examples/basic/values.yaml).
+
+## File structure
+
+```
+.
+├── main.tf
+├── variables.tf
+├── outputs.tf
+├── versions.tf
+├── README.md
+├── CHANGELOG.md
+└── docs/
+ ├── header.md
+ └── footer.md
+```