Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/108 management subscription #128

Merged
merged 3 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions kit/azure/organization-hierarchy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ After deploying this module, you should probably deploy the following kit module
| [azurerm_management_group.management](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/management_group) | resource |
| [azurerm_management_group.parent](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/management_group) | resource |
| [azurerm_management_group.platform](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/management_group) | resource |
| [azurerm_management_group_subscription_association.management](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/management_group_subscription_association) | resource |
| [azurerm_subscription.management](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subscription) | resource |
| [azurerm_subscription.current](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subscription) | data source |

## Inputs

Expand All @@ -86,6 +89,7 @@ After deploying this module, you should probably deploy the following kit module
| <a name="input_landingzones"></a> [landingzones](#input\_landingzones) | n/a | `string` | `"lv-landingzones"` | no |
| <a name="input_locations"></a> [locations](#input\_locations) | This is for the Azure Allowed locations. Additionally, we use the first added locations where this policy assignment should exist, which is required when an identity is assigned. | `list(string)` | <pre>[<br> "germanywestcentral"<br>]</pre> | no |
| <a name="input_management"></a> [management](#input\_management) | n/a | `string` | `"lv-management"` | no |
| <a name="input_management_subscription_name"></a> [management\_subscription\_name](#input\_management\_subscription\_name) | Name of your management subscription | `string` | `"management"` | no |
| <a name="input_parentManagementGroup"></a> [parentManagementGroup](#input\_parentManagementGroup) | n/a | `string` | `"lv-foundation"` | no |
| <a name="input_platform"></a> [platform](#input\_platform) | n/a | `string` | `"lv-platform"` | no |

Expand Down
22 changes: 13 additions & 9 deletions kit/azure/organization-hierarchy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ resource "azurerm_management_group" "management" {
parent_management_group_id = azurerm_management_group.platform.id
}

# Move management subscription into the new organization hierarchy
# add this if moving the management group under the created hierardhy is desired
# data "azurerm_subscription" "current" {
# }

# resource "azurerm_management_group_subscription_association" "management" {
# management_group_id = azurerm_management_group.management.id
# subscription_id = data.azurerm_subscription.current.id
# }
# moves the management subscription into the new organization hierarchy
data "azurerm_subscription" "current" {
}

resource "azurerm_subscription" "management" {
subscription_id = data.azurerm_subscription.current.subscription_id
subscription_name = var.management_subscription_name
}

resource "azurerm_management_group_subscription_association" "management" {
management_group_id = azurerm_management_group.management.id
subscription_id = data.azurerm_subscription.current.id
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@ provider "azurerm" {
EOF
}

locals {
# the prefix used the name of your cloudfoundation
management_group_prefix = "${include.platform.locals.cloudfoundation.name}"
}

inputs = {
# todo: set input variables
connectivity = "lv-connectivity"
identity = "lv-identity"
landingzones = "lv-landingzones"
connectivity = "${local.management_group_prefix}-connectivity"
identity = "${local.management_group_prefix}-identity"
landingzones = "${local.management_group_prefix}-landingzones"
locations = ["germanywestcentral"]
management = "lv-management"
parentManagementGroup = "lv-foundation"
platform = "lv-platform"

management = "${local.management_group_prefix}-management"
parentManagementGroup = "${local.management_group_prefix}-foundation"
platform = "${local.management_group_prefix}-platform"
}
5 changes: 5 additions & 0 deletions kit/azure/organization-hierarchy/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
variable "management_subscription_name" {
type = string
default = "management"
description = "Name of your management subscription"
}

variable "parentManagementGroup" {
default = "lv-foundation"
Expand Down
Loading