Skip to content

Commit f981e21

Browse files
authored
Merge pull request #29 from stackitcloud/28-support-a-custom-parent-root-folder
feat(governance): support custom parent folder ID for resource manage…
2 parents 1173605 + 99c8b66 commit f981e21

6 files changed

Lines changed: 20 additions & 5 deletions

File tree

src/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
| Name | Version |
55
|------|---------|
66
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.10 |
7-
| <a name="requirement_stackit"></a> [stackit](#requirement\_stackit) | 0.93.0 |
8-
| <a name="requirement_time"></a> [time](#requirement\_time) | 0.13.1 |
9-
| <a name="requirement_vault"></a> [vault](#requirement\_vault) | 5.7.0 |
7+
| <a name="requirement_stackit"></a> [stackit](#requirement\_stackit) | 0.96.0 |
8+
| <a name="requirement_time"></a> [time](#requirement\_time) | 0.14.0 |
9+
| <a name="requirement_vault"></a> [vault](#requirement\_vault) | 5.9.0 |
1010

1111
## Providers
1212

@@ -43,7 +43,8 @@ No resources.
4343
| <a name="input_organization_owners"></a> [organization\_owners](#input\_organization\_owners) | List of organization owners. | `list(string)` | `[]` | no |
4444
| <a name="input_owner_email"></a> [owner\_email](#input\_owner\_email) | Email address of the owner. Required for STACKIT resource manager. | `string` | n/a | yes |
4545
| <a name="input_region"></a> [region](#input\_region) | STACKIT region for regional resources. | `string` | `"eu01"` | no |
46-
| <a name="input_rm_folders"></a> [rm\_folders](#input\_rm\_folders) | Map of resource manager folders to create under the root organization. | <pre>map(object({<br/> name = string<br/> description = optional(string, null)<br/> owner_emails = list(string)<br/> reader_emails = list(string)<br/> }))</pre> | <pre>{<br/> "landing_zones_corporate": {<br/> "name": "Landing Zones - Corporate 4",<br/> "owner_emails": [],<br/> "reader_emails": []<br/> },<br/> "landing_zones_public": {<br/> "name": "Landing Zones - Public 4",<br/> "owner_emails": [],<br/> "reader_emails": []<br/> },<br/> "platform": {<br/> "name": "Platform 4",<br/> "owner_emails": [],<br/> "reader_emails": []<br/> },<br/> "sandboxes": {<br/> "name": "Sandboxes 4",<br/> "owner_emails": [],<br/> "reader_emails": []<br/> }<br/>}</pre> | no |
46+
| <a name="input_rm_folder_parent_id"></a> [rm\_folder\_parent\_id](#input\_rm\_folder\_parent\_id) | ID of the parent folder under which the resource manager folders will be created. If not provided, the resource manager folders will be created under the organization. | `string` | `null` | no |
47+
| <a name="input_rm_folders"></a> [rm\_folders](#input\_rm\_folders) | Map of resource manager folders to create under the root organization. | <pre>map(object({<br/> name = string<br/> description = optional(string, null)<br/> owner_emails = list(string)<br/> reader_emails = list(string)<br/> }))</pre> | <pre>{<br/> "landing_zones_corporate": {<br/> "name": "Landing Zones - Corporate",<br/> "owner_emails": [],<br/> "reader_emails": []<br/> },<br/> "landing_zones_public": {<br/> "name": "Landing Zones - Public",<br/> "owner_emails": [],<br/> "reader_emails": []<br/> },<br/> "platform": {<br/> "name": "Platform",<br/> "owner_emails": [],<br/> "reader_emails": []<br/> },<br/> "sandboxes": {<br/> "name": "Sandboxes",<br/> "owner_emails": [],<br/> "reader_emails": []<br/> }<br/>}</pre> | no |
4748
| <a name="input_sandboxes"></a> [sandboxes](#input\_sandboxes) | List of sandboxes to create. | <pre>list(object({<br/> project_name = string<br/> owner_emails = optional(list(string))<br/> project_owner_email = string<br/> }))</pre> | `[]` | no |
4849

4950
## Outputs

src/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module "governance" {
77

88
owner_email = var.owner_email
99
organization_id = var.organization_id
10+
rm_folder_parent_id = var.rm_folder_parent_id
1011
labels = var.labels
1112
organization_owners = var.organization_owners
1213
organization_auditors = var.organization_auditors

src/modules/governance/1-rm-folders.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ resource "stackit_resourcemanager_folder" "this" {
3030
for_each = var.rm_folders
3131

3232
name = each.value.name
33-
parent_container_id = var.organization_id
33+
parent_container_id = var.rm_folder_parent_id != null ? var.rm_folder_parent_id : var.organization_id
3434
owner_email = var.owner_email
3535
# labels = length(var.labels) > 0 ? var.labels : null # provider bug: empty map becomes null after apply
3636

src/modules/governance/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ No modules.
3838
| <a name="input_organization_id"></a> [organization\_id](#input\_organization\_id) | Container ID of the root folder or organization under which the company folder will be created. | `string` | n/a | yes |
3939
| <a name="input_organization_owners"></a> [organization\_owners](#input\_organization\_owners) | List of organization role assignments for organization owners. | `list(string)` | `[]` | no |
4040
| <a name="input_owner_email"></a> [owner\_email](#input\_owner\_email) | Email address of the owner for the folders. Required for STACKIT resource manager. | `string` | n/a | yes |
41+
| <a name="input_rm_folder_parent_id"></a> [rm\_folder\_parent\_id](#input\_rm\_folder\_parent\_id) | ID of the parent folder under which the resource manager folders will be created. If not provided, the resource manager folders will be created under the organization. | `string` | `null` | no |
4142
| <a name="input_rm_folders"></a> [rm\_folders](#input\_rm\_folders) | Map of folder keys to folder configuration. Each folder has a display name and optional lists of owner and reader subjects. | <pre>map(object({<br/> name = string<br/> owner_emails = optional(list(string), [])<br/> reader_emails = optional(list(string), [])<br/> }))</pre> | <pre>{<br/> "landing_zones_corporate": {<br/> "name": "Landing Zones - Corporate",<br/> "owner_emails": [],<br/> "reader_emails": []<br/> },<br/> "landing_zones_public": {<br/> "name": "Landing Zones - Public",<br/> "owner_emails": [],<br/> "reader_emails": []<br/> },<br/> "platform": {<br/> "name": "Platform",<br/> "owner_emails": [],<br/> "reader_emails": []<br/> },<br/> "sandbox": {<br/> "name": "Sandboxes",<br/> "owner_emails": [],<br/> "reader_emails": []<br/> }<br/>}</pre> | no |
4243

4344
## Outputs

src/modules/governance/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ variable "rm_folders" {
3939
}
4040
}
4141

42+
variable "rm_folder_parent_id" {
43+
type = string
44+
description = "ID of the parent folder under which the resource manager folders will be created. If not provided, the resource manager folders will be created under the organization."
45+
default = null
46+
}
47+
4248
variable "labels" {
4349
type = map(string)
4450
description = "Additional labels to apply to all folders."

src/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ variable "organization_id" {
2222
description = "Container ID of the root organization."
2323
}
2424

25+
variable "rm_folder_parent_id" {
26+
type = string
27+
description = "ID of the parent folder under which the resource manager folders will be created. If not provided, the resource manager folders will be created under the organization."
28+
default = null
29+
}
30+
2531
variable "region" {
2632
type = string
2733
description = "STACKIT region for regional resources."

0 commit comments

Comments
 (0)