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 2 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,11 +76,15 @@ 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

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_cloudfoundation"></a> [cloudfoundation](#input\_cloudfoundation) | Name of your cloud foundation | `string` | n/a | yes |
| <a name="input_connectivity"></a> [connectivity](#input\_connectivity) | n/a | `string` | `"lv-connectivity"` | no |
| <a name="input_identity"></a> [identity](#input\_identity) | n/a | `string` | `"lv-identity"` | no |
| <a name="input_landingzones"></a> [landingzones](#input\_landingzones) | n/a | `string` | `"lv-landingzones"` | 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.cloudfoundation}-management"
}

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,19 @@ 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"
cloudfoundation = "${local.management_group_prefix}"
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 "cloudfoundation" {
type = string
nullable = false
description = "Name of your cloud foundation"
}

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