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

Incorrect group regexp #27

Closed
jarrod-mg opened this issue Feb 26, 2024 · 6 comments · Fixed by #26
Closed

Incorrect group regexp #27

jarrod-mg opened this issue Feb 26, 2024 · 6 comments · Fixed by #26

Comments

@jarrod-mg
Copy link

regexache.MustCompile(`^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$`),

This insists that all group IDs must be UUIDs (8-4-4-4-12). However, if you are using federation, it is possible for group IDs to look different. In my case they are 8-8-4-4-4-12. I don't know if other federation systems would be different or not.

@jarrod-mg
Copy link
Author

Also

regexache.MustCompile(`^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$`),

@jarrod-mg
Copy link
Author

Just to add... If I add an approval policy via the TEAM UI, and then look in the dynamodb approvers table, I can see it has successfully added the 8-8-4-4-4-12 style ID; so TEAM itself is perfectly happy with non-UUID group IDs.

@brittandeyoung
Copy link
Owner

hmm with their being separate types allowed, I may need to remove the field validation altogether. The difficult part is that the API does not do any validation, which will be confusing for users if they input an id incorrectly. The api will accept it, but it will not function properly. I will work on getting this change in.

@jarrod-mg
Copy link
Author

It might help it if it is paired with some documentation. I use it like this, so I can never get an incorrect group id, as they came from a lookup. Maybe making the example like the below (or a simplified case of it) could help?

data "aws_ssoadmin_instances" "current" {}

locals {
  role1 = "NameOfRole1"
  role2 = "NameOfRole2"
  groups = ["group1", "group2", "group3"]
  approvers = {
    ou1 = [local.role1],
    ou2 = [local.role1, local.role2],
  }
  instance_arn      = tolist(data.aws_ssoadmin_instances.current.arns)[0]
  identity_store_id = tolist(data.aws_ssoadmin_instances.current.identity_store_ids)[0]
}


data "aws_identitystore_group" "group" {
  for_each          = toset(local.groups)
  identity_store_id = local.identity_store_id
  alternate_identifier {
    unique_attribute {
      attribute_path  = "DisplayName"
      attribute_value = each.key
    }
  }
}

data "aws_organizations_organization" "org" {}

data "aws_organizations_organizational_unit" "ou" {
    for_each = local.approvers

    name = each.key
    parent_id = data.aws_organizations_organization.org.roots[0].id
}

resource "awsteam_approvers_ou" "approval_policy" {
    for_each = local.approvers

    ou_id     = data.aws_organizations_organizational_unit.ou[each.key].id
    ou_name   = each.key
    approvers = each.value
    group_ids = [for approver in each.value : data.aws_identitystore_group.group[approver].id]
}

@brittandeyoung
Copy link
Owner

@jarrod-mg There is an api built into teams for reading aws accounts, users, and groups. I plan on implementing data sources for these in the provider. When I do, I will update the examples to use these dynamic methods.

@brittandeyoung
Copy link
Owner

This functionality has been released in v1.0.0.

For further feature requests or bug reports with this functionality, please create a new GitHub issue

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

Successfully merging a pull request may close this issue.

2 participants