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

custom_landing_zones Keys cannot contain periods #855

Closed
cloudchristoph opened this issue Nov 8, 2023 · 3 comments · Fixed by #857
Closed

custom_landing_zones Keys cannot contain periods #855

cloudchristoph opened this issue Nov 8, 2023 · 3 comments · Fixed by #857
Assignees

Comments

@cloudchristoph
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Versions

terraform: 1.6.3

azure provider: 1.10.0

module: 5.0.0

Description

Describe the bug

When I try to add a management group with a period in the ID, it fails the validation.
Periods are allowed for Management Group IDs.

Steps to Reproduce

  1. Add a custom_landing_zone like this:
  custom_landing_zones = {
    "com.mycompany" = {
      display_name               = "My Company"
      parent_management_group_id = "${data.azurerm_client_config.core.tenant_id}"
      subscription_ids           = []
      archetype_config = {
        archetype_id   = "mycompany_root"
        parameters     = {}
        access_control = {}
      }
    }
  1. terraform plan
  2. You'll get an validation error:
│     │ var.custom_landing_zones is object with 1 attribute "com.mycompany"
│
│ The custom_landing_zones keys must be between 2 to 89 characters long and can only contain lowercase letters, numbers and hyphens.
│
│ This was checked by the validation rule at .terraform/modules/enterprise_scale/variables.tf:605,3-13.

Possible fix:

I've changed the validation rule in

condition = can([for k in keys(var.custom_landing_zones) : regex("^[a-zA-Z0-9-]{2,89}$", k)]) || length(keys(var.custom_landing_zones)) == 0
error_message = "The custom_landing_zones keys must be between 2 to 89 characters long and can only contain lowercase letters, numbers and hyphens."

...to:

    condition     = can([for k in keys(var.custom_landing_zones) : regex("^[a-zA-Z0-9-.]{2,89}$", k)]) || length(keys(var.custom_landing_zones)) == 0
    error_message = "The custom_landing_zones keys must be between 2 to 89 characters long and can only contain lowercase letters, numbers, periods and hyphens."

Screenshots

Additional context

I'm still creating the environment where this issue has hit me. So I'm not sure, if there are side effects with Management Groups containing a period in the ID. So far I have not observed any problems.

I would also like to point out that I don't think it's a good idea. I follow customer specifications here and see no technical reason not to allow it.

@matt-FFFFFF matt-FFFFFF self-assigned this Nov 8, 2023
@matt-FFFFFF
Copy link
Member

Hi I agree - we will fix

matt-FFFFFF added a commit that referenced this issue Nov 9, 2023
@matt-FFFFFF matt-FFFFFF mentioned this issue Nov 9, 2023
5 tasks
@cloudchristoph
Copy link
Author

Wow that was fast Matt. 😲

Didn't have the chance to test all components. Just using this for Policy deployments tbh.
I'll let you know, if I see issues with those Management Groups.

@matt-FFFFFF
Copy link
Member

I need to get this reviewed but should be able to merge and release tomorrow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants