Skip to content

Commit d522740

Browse files
Deprecate legacy TF module variables for MGs (#83)
* Deprecate legacy TF module variables for MGs DEPRECATION NOTICE -------------------- Deprecating the following variables from all modules :- - management_group_ids With this breaking change, above legacy var will no longer be supported for Secure installs. Recommended Solutions ----------------------- - For new Foundational installs: Users can use the new vars only, for including and excluding management_groups and/or accounts. - For existing installs: - It is highly recommended to migrate to using new variables. Please work with Sysdig to migrate your Terraform installs to use new vars instead to achieve the same deployment outcome. - Pin and use older module version if you do not wish to migrate. * Disable TFLint rule for unused variable declarations --------- Co-authored-by: Ivan Besinovic <ivan.besinovic@sysdig.com>
1 parent 5404e98 commit d522740

49 files changed

Lines changed: 47 additions & 380 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.tflint.hcl

Whitespace-only changes.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ deps: $(TFLINT)
1616
go install github.com/hashicorp/terraform-config-inspect@latest
1717

1818
lint: $(TFLINT)
19-
$(MAKE) -C modules lint
19+
$(TFLINT) --recursive --chdir=modules --config=.tflint.hcl
2020

2121
fmt:
2222
terraform fmt -check -recursive modules

modules/.tflint.hcl

Whitespace-only changes.

modules/agentless-scanning/.tflint.hcl

Whitespace-only changes.

modules/agentless-scanning/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ No modules.
4444
| [azurerm_lighthouse_assignment.lighthouse_assignment_for_tenant](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/lighthouse_assignment) | resource |
4545
| [azurerm_lighthouse_definition.lighthouse_definition](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/lighthouse_definition) | resource |
4646
| [sysdig_secure_cloud_auth_account_component.azure_service_principal](https://registry.terraform.io/providers/sysdiglabs/sysdig/latest/docs/resources/secure_cloud_auth_account_component) | resource |
47-
| [azurerm_management_group.management_groups](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/management_group) | data source |
4847
| [azurerm_management_group.root_management_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/management_group) | data source |
4948
| [azurerm_subscription.primary](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subscription) | data source |
5049
| [sysdig_secure_agentless_scanning_assets.assets](https://registry.terraform.io/providers/sysdiglabs/sysdig/latest/docs/data-sources/secure_agentless_scanning_assets) | data source |
@@ -54,7 +53,6 @@ No modules.
5453
| Name | Description | Type | Default | Required |
5554
|------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|---------|:--------:|
5655
| <a name="input_is_organizational"></a> [is\_organizational](#input\_is\_organizational) | (Optional) Set this field to 'true' to deploy secure-for-cloud to an Azure Tenant. | `bool` | `false` | no |
57-
| <a name="input_management_group_ids"></a> [suffix](#input\_management\_group\_ids) | TO BE DEPRECATED on 30th November, 2025: Please work with Sysdig to migrate to using `include_management_groups` instead.<br> List of Azure Management Group IDs. secure-for-cloud will be deployed to all the subscriptions under these management groups. If not provided, set to empty by default | `set(string)` | `[]` | no |
5856
| <a name="input_subscription_id"></a> [subscription\_id](#input\_subscription\_id) | Subscription ID in which to create a trust relationship | `string` | n/a | yes |
5957
| <a name="input_sysdig_secure_account_id"></a> [sysdig\_secure\_account\_id](#input\_sysdig\_secure\_account\_id) | ID of the Sysdig Cloud Account to enable Agentless Scanning for (incase of organization, ID of the Sysdig management account) | `string` | n/a | yes |
6058
| <a name="input_include_management_groups"></a> [suffix](#input\_include\_management_groups) | management_groups to include for organization in the format '<management_group_idt>' i.e: management_group_id_1 | `set(string)` | `[]` | no |
Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,6 @@
11
locals {
2-
# check if both old and new include/exclude org parameters are used, we fail early
3-
both_org_configuration_params = var.is_organizational && length(var.management_group_ids) > 0 && (
4-
length(var.include_management_groups) > 0 ||
5-
length(var.exclude_management_groups) > 0 ||
6-
length(var.include_subscriptions) > 0 ||
7-
length(var.exclude_subscriptions) > 0
8-
)
9-
10-
# check if old management_group_ids parameter is provided, for backwards compatibility we will always give preference to it
11-
check_old_management_group_ids_param = var.is_organizational && length(var.management_group_ids) > 0
12-
13-
# legacy mode: use management_group_ids if provided
14-
selected_management_group = var.is_organizational && local.check_old_management_group_ids_param ? (length(data.azurerm_management_group.management_groups) > 0 ? values(data.azurerm_management_group.management_groups) : [data.azurerm_management_group.root_management_group[0]]) : []
15-
16-
# legacy mode: get all subscriptions from selected management groups
17-
legacy_all_mg_subscription_ids = flatten([
18-
for mg in local.selected_management_group : mg.all_subscription_ids
19-
])
20-
212
# unified recursive mode: get subscriptions from granular-subscriptions modules when include_management_groups or exclude_management_groups is provided
22-
discovered_subscription_ids = var.is_organizational && !local.check_old_management_group_ids_param && (length(var.include_management_groups) > 0 || length(var.exclude_management_groups) > 0) ? (
3+
discovered_subscription_ids = var.is_organizational && (length(var.include_management_groups) > 0 || length(var.exclude_management_groups) > 0) ? (
234
flatten([
245
module.level0[0].subscriptions,
256
module.level1[0].subscriptions,
@@ -32,15 +13,15 @@ locals {
3213
) : []
3314

3415
# include specific subscriptions that are not already discovered
35-
additional_subscription_ids = var.is_organizational && !local.check_old_management_group_ids_param && length(var.include_subscriptions) > 0 ? (
16+
additional_subscription_ids = var.is_organizational && length(var.include_subscriptions) > 0 ? (
3617
[for s in var.include_subscriptions : s if !(contains(local.discovered_subscription_ids, s))]
3718
) : []
3819

3920
# combine discovered and additional subscriptions
4021
new_all_subscription_ids = concat(local.discovered_subscription_ids, local.additional_subscription_ids)
4122

4223
# default mode: use root management group subscriptions when no include/exclude filters are provided
43-
default_all_mg_subscription_ids = var.is_organizational && !local.check_old_management_group_ids_param && length(var.include_management_groups) == 0 && length(var.exclude_management_groups) == 0 ? (
24+
default_all_mg_subscription_ids = var.is_organizational && length(var.include_management_groups) == 0 && length(var.exclude_management_groups) == 0 ? (
4425
length(var.exclude_subscriptions) > 0 ? (
4526
[for s in data.azurerm_management_group.root_management_group[0].all_subscription_ids : s if !(contains(var.exclude_subscriptions, s))]
4627
) : (
@@ -50,26 +31,7 @@ locals {
5031

5132
# combine all subscription ids based on mode
5233
all_mg_subscription_ids = concat(
53-
local.legacy_all_mg_subscription_ids,
5434
local.new_all_subscription_ids,
5535
local.default_all_mg_subscription_ids
5636
)
57-
}
58-
59-
check "validate_org_configuration_params" {
60-
assert {
61-
condition = length(var.management_group_ids) == 0 # if this condition is false we throw warning
62-
error_message = <<-EOT
63-
WARNING: 'management_group_ids' TO BE DEPRECATED on 30th November, 2025: Please work with Sysdig to migrate your Terraform installs to use 'include_management_groups' instead.
64-
EOT
65-
}
66-
67-
assert {
68-
condition = !local.both_org_configuration_params # if this condition is false we throw error
69-
error_message = <<-EOT
70-
ERROR: If both management_group_ids and include_management_groups/exclude_management_groups/include_subscriptions/exclude_subscriptions variables are populated,
71-
ONLY management_group_ids will be considered. Please use only one of the two methods.
72-
Note: management_group_ids is going to be DEPRECATED on 30th November, 2025. Please work with Sysdig to migrate your Terraform installs.
73-
EOT
74-
}
7537
}

modules/agentless-scanning/organizational.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ data "azurerm_management_group" "root_management_group" {
77
display_name = "Tenant Root Group"
88
}
99

10-
data "azurerm_management_group" "management_groups" {
11-
for_each = var.is_organizational && length(var.management_group_ids) > 0 ? var.management_group_ids : []
12-
name = each.value
13-
}
14-
1510
data "azurerm_subscription" "all_subscriptions" {
1611
for_each = toset(local.all_mg_subscription_ids)
1712
subscription_id = each.value

modules/agentless-scanning/variables.tf

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@ variable "is_organizational" {
99
default = false
1010
}
1111

12-
variable "management_group_ids" {
13-
description = <<-EOF
14-
TO BE DEPRECATED on 30th November, 2025: Please work with Sysdig to migrate to using `include_management_groups` instead.
15-
When set, restrict onboarding to a set of Azure Management Groups identifiers whose child management groups and subscriptions are to be onboarded.
16-
Default: onboard all management groups.
17-
EOF
18-
type = set(string)
19-
default = []
20-
}
21-
2212
variable "sysdig_secure_account_id" {
2313
type = string
2414
description = "ID of the Sysdig Cloud Account to enable Agentless Scanning for (incase of organization, ID of the Sysdig management account)"

modules/config-posture/.tflint.hcl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
rule "terraform_unused_declarations" {
2+
enabled = false
3+
}
4+

modules/config-posture/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ No modules.
7171
|------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|---------|:--------:|
7272
| <a name="input_agentless_aks_connection_enabled"></a> [agentless\_aks\_connection\_enabled](#input\_agentless\_aks\_connection\_enabled) | Enable the Agentless AKS connection to the K8s clusters within the cloud. This allows admin access. Read more about why this is needed in the official docs. | `bool` | `false` | no |
7373
| <a name="input_is_organizational"></a> [is\_organizational](#input\_is\_organizational) | (Optional) Set this field to 'true' to deploy secure-for-cloud to an Azure Tenant. | `bool` | `false` | no |
74-
| <a name="input_management_group_ids"></a> [suffix](#input\_management\_group\_ids) | TO BE DEPRECATED on 30th November, 2025: Please work with Sysdig to migrate to using `include_management_groups` instead.<br> List of Azure Management Group IDs. secure-for-cloud will be deployed to all the subscriptions under these management groups. If not provided, set to empty by default | `set(string)` | `[]` | no |
7574
| <a name="input_subscription_id"></a> [subscription\_id](#input\_subscription\_id) | Subscription ID in which to create resources for secure-for-cloud | `string` | n/a | yes |
7675
| <a name="input_sysdig_secure_account_id"></a> [sysdig\_secure\_account\_id](#input\_sysdig\_secure\_account\_id) | ID of the Sysdig Cloud Account to enable Config Posture for (incase of organization, ID of the Sysdig management account) | `string` | n/a | yes |
7776
| <a name="input_config_posture_service_principal"></a> [config\_posture\_service\_principal](#input\_config\_posture\_service\_principal) | (Optional) Service Principal to be used for CSPM, this SP needs to be associated to the Sysdig Config Posture Application ID. If not provided, a new one will be created. | `string` | `""` | no |

0 commit comments

Comments
 (0)