-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Assignment multiple users or groups via aws_ssoadmin_account_assignment #18739
Comments
@daimon243 Thank you for letting us know about this! While I cannot guarantee when we'll have a chance to work on this, at first glance, your idea of changing |
Related #18812 |
Yes i think your idea is better, because anyone using "aws_ssoadmin_account_assignment" will not need to fix previously written infrastructure code. I totally agree. Therefore Potential Terraform Configuration some change: Potential Terraform Configuration # new resource assignment multiple users
resource aws_ssoadmin_account_assignments assignments {
instance_arn = tolist(data.aws_ssoadmin_instances.sso.arns)[0]
principal_type = "USER" /*or "GROUP"*/
target_id = var.target_account_id
target_type = "AWS_ACCOUNT"
permission_set_arn = var.permission_set_arn
principal_id = [principal_id1, principal_id2, principal_id3,...principal_idN]
} |
I would really love to see an array option for target_id as well. That way when we want to provide access to the same principal across multiple accounts, we can do it in the same resource. |
As an workaround, you can create a loop using resource "aws_ssoadmin_account_assignment" "this" {
for_each = toset(['group1','group2','group3','group4'])
instance_arn = tolist(data.aws_ssoadmin_instances.this.arns)[0]
permission_set_arn = var.permission_set_arn
principal_id = each.value
principal_type = "GROUP"
target_type = "AWS_ACCOUNT"
target_id = var.target_account_id
} |
I've raised a PR to implement an aws_ssoadmin_account_assignments resource as our iac would benefit from this. |
…icorp/terraform-provider-aws/blob/main/docs/contributing ---> <!--- Please keep this note for the community ---> * Please vote on this pull request by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original pull request comment to help the community and maintainers prioritize this request * Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request <!--- Thank you for keeping this note for the community ---> <!--- If your PR fully resolves and should automatically close the linked issue, use Closes. Otherwise, use Relates ---> Closes hashicorp#18739 Output from acceptance testing: <!-- Replace TestAccXXX with a pattern that matches the tests affected by this PR. Replace ec2 with the service package corresponding to your tests. For more information on the `-run` flag, see the `go test` documentation at https://tip.golang.org/cmd/go/#hdr-Testing_flags. --> ``` $ make testacc PKG=ssoadmin ==> Checking that code complies with gofmt requirements... TF_ACC=1 go test ./internal/service/ssoadmin/... -v -count 1 -parallel 20 -timeout 180m === RUN TestAccSSOAdminAccountAssignment_Basic_group === PAUSE TestAccSSOAdminAccountAssignment_Basic_group === RUN TestAccSSOAdminAccountAssignment_Basic_user === PAUSE TestAccSSOAdminAccountAssignment_Basic_user === RUN TestAccSSOAdminAccountAssignment_disappears === PAUSE TestAccSSOAdminAccountAssignment_disappears === RUN TestAccSSOAdminAccountAssignments_Basic_group === PAUSE TestAccSSOAdminAccountAssignments_Basic_group === RUN TestAccSSOAdminAccountAssignments_Basic_user === PAUSE TestAccSSOAdminAccountAssignments_Basic_user === RUN TestAccSSOAdminInstancesDataSource_basic === PAUSE TestAccSSOAdminInstancesDataSource_basic === RUN TestAccSSOAdminManagedPolicyAttachment_basic === PAUSE TestAccSSOAdminManagedPolicyAttachment_basic === RUN TestAccSSOAdminManagedPolicyAttachment_forceNew === PAUSE TestAccSSOAdminManagedPolicyAttachment_forceNew === RUN TestAccSSOAdminManagedPolicyAttachment_disappears --- PASS: TestAccSSOAdminManagedPolicyAttachment_disappears (27.91s) === RUN TestAccSSOAdminManagedPolicyAttachment_Disappears_permissionSet --- PASS: TestAccSSOAdminManagedPolicyAttachment_Disappears_permissionSet (18.53s) === RUN TestAccSSOAdminManagedPolicyAttachment_multipleManagedPolicies === PAUSE TestAccSSOAdminManagedPolicyAttachment_multipleManagedPolicies === RUN TestAccSSOAdminPermissionSetDataSource_arn === PAUSE TestAccSSOAdminPermissionSetDataSource_arn === RUN TestAccSSOAdminPermissionSetDataSource_name === PAUSE TestAccSSOAdminPermissionSetDataSource_name === RUN TestAccSSOAdminPermissionSetDataSource_nonExistent === PAUSE TestAccSSOAdminPermissionSetDataSource_nonExistent === RUN TestAccSSOAdminPermissionSetInlinePolicy_basic === PAUSE TestAccSSOAdminPermissionSetInlinePolicy_basic === RUN TestAccSSOAdminPermissionSetInlinePolicy_update === PAUSE TestAccSSOAdminPermissionSetInlinePolicy_update === RUN TestAccSSOAdminPermissionSetInlinePolicy_disappears --- PASS: TestAccSSOAdminPermissionSetInlinePolicy_disappears (20.30s) === RUN TestAccSSOAdminPermissionSetInlinePolicy_Disappears_permissionSet --- PASS: TestAccSSOAdminPermissionSetInlinePolicy_Disappears_permissionSet (20.05s) === RUN TestAccSSOAdminPermissionSet_basic === PAUSE TestAccSSOAdminPermissionSet_basic === RUN TestAccSSOAdminPermissionSet_tags --- PASS: TestAccSSOAdminPermissionSet_tags (55.21s) === RUN TestAccSSOAdminPermissionSet_updateDescription === PAUSE TestAccSSOAdminPermissionSet_updateDescription === RUN TestAccSSOAdminPermissionSet_updateRelayState === PAUSE TestAccSSOAdminPermissionSet_updateRelayState === RUN TestAccSSOAdminPermissionSet_updateSessionDuration === PAUSE TestAccSSOAdminPermissionSet_updateSessionDuration === RUN TestAccSSOAdminPermissionSet_RelayState_updateSessionDuration === PAUSE TestAccSSOAdminPermissionSet_RelayState_updateSessionDuration === RUN TestAccSSOAdminPermissionSet_mixedPolicyAttachments === PAUSE TestAccSSOAdminPermissionSet_mixedPolicyAttachments === CONT TestAccSSOAdminAccountAssignment_Basic_group === CONT TestAccSSOAdminPermissionSetDataSource_nonExistent === CONT TestAccSSOAdminPermissionSet_updateRelayState === CONT TestAccSSOAdminPermissionSet_basic === CONT TestAccSSOAdminPermissionSet_updateDescription === CONT TestAccSSOAdminManagedPolicyAttachment_basic === CONT TestAccSSOAdminPermissionSetDataSource_arn === CONT TestAccSSOAdminAccountAssignment_disappears === CONT TestAccSSOAdminAccountAssignments_Basic_group === CONT TestAccSSOAdminPermissionSetInlinePolicy_update === CONT TestAccSSOAdminManagedPolicyAttachment_multipleManagedPolicies === CONT TestAccSSOAdminAccountAssignment_Basic_user === CONT TestAccSSOAdminPermissionSetDataSource_name === CONT TestAccSSOAdminPermissionSetInlinePolicy_basic === CONT TestAccSSOAdminPermissionSet_mixedPolicyAttachments === CONT TestAccSSOAdminManagedPolicyAttachment_forceNew === CONT TestAccSSOAdminPermissionSet_updateSessionDuration === CONT TestAccSSOAdminAccountAssignments_Basic_user === CONT TestAccSSOAdminPermissionSet_RelayState_updateSessionDuration === CONT TestAccSSOAdminInstancesDataSource_basic --- PASS: TestAccSSOAdminPermissionSetDataSource_nonExistent (10.53s) --- PASS: TestAccSSOAdminInstancesDataSource_basic (22.39s) --- PASS: TestAccSSOAdminPermissionSetDataSource_arn (30.25s) --- PASS: TestAccSSOAdminPermissionSet_basic (33.43s) --- PASS: TestAccSSOAdminAccountAssignment_disappears (41.19s) --- PASS: TestAccSSOAdminPermissionSetDataSource_name (43.32s) --- PASS: TestAccSSOAdminPermissionSetInlinePolicy_basic (43.53s) --- PASS: TestAccSSOAdminAccountAssignments_Basic_group (46.83s) --- PASS: TestAccSSOAdminAccountAssignment_Basic_user (47.01s) --- PASS: TestAccSSOAdminManagedPolicyAttachment_basic (50.46s) --- PASS: TestAccSSOAdminPermissionSet_updateSessionDuration (54.33s) --- PASS: TestAccSSOAdminPermissionSet_updateDescription (54.34s) --- PASS: TestAccSSOAdminPermissionSet_updateRelayState (54.41s) --- PASS: TestAccSSOAdminPermissionSet_RelayState_updateSessionDuration (54.94s) --- PASS: TestAccSSOAdminPermissionSetInlinePolicy_update (60.59s) --- PASS: TestAccSSOAdminPermissionSet_mixedPolicyAttachments (61.51s) --- PASS: TestAccSSOAdminManagedPolicyAttachment_forceNew (70.69s) --- PASS: TestAccSSOAdminAccountAssignment_Basic_group (76.75s) --- PASS: TestAccSSOAdminAccountAssignments_Basic_user (76.81s) --- PASS: TestAccSSOAdminManagedPolicyAttachment_multipleManagedPolicies (91.68s) PASS ok github.com/hashicorp/terraform-provider-aws/internal/service/ssoadmin 237.127s ```
HI @daimon243 and everyone else. I've been trying to reproduce this issue, and have not seen similar long times. This is not to say that we don't want to fix this resource, since it can still take a long time. I want to better understand the origin of the problem. With 1,200 existing users, a Are you still seeing much longer times as reported above? If so, what version of the provider and terraform are you using? How many users do you have in SSO? Some things that may be related to the lower times I'm seeing:
|
Hi @gingersnapz. One option you have is to use |
@gdavison I'm having a similar issue. I've tried using setproduct, but I get
I was going to create a new issue so here is my: Reproduction Code [Required]
Additional contextIf I use -target as suggested elsewhere (4149) to provision the permission set first, then the assignments works. However, the explanations I've seen for this error is that Terraform is unable to determine the number of resources to provision at plan so it fails. But in my case, while the arns of the permission sets would be unknown, Terraform can determine the number of assignments to create. |
Hi @jsimoni. Unfortunately, this is a limitation of |
Hi @gdavison. I rewrote the infrastructure and instead of one folder with permission sets assigned, I created many folders, divided into small groups. Now, with a total number of users in SSO of about 1000 and assigning rights to 20 employees, I get the maximum execution time from 1 to 6 minutes. In this particular case, there is no problem. With this approach, the request rate limit is not exceeded. But using a list of users as a parameter instead of using for_each seems to be preferable because we can run queries to api in batch. |
Community Note
Description
I use aws_ssoadmin_account_assignment resource like this:
When apply multiple user assignments via use "for_each" for resource "aws_ssoadmin_account_assignment", created send-receive request for every "principal_id" .
The every request contain all assignment for permission_set in target_account. In my case for 1000+ users one request have above 300Kbytes and paginator splitting one request to 20 pages. For all users traffic more then 300 Mbytes and approximately 20k pagination token for any assignments change and more than 5 hours in progress.
terraform apply failed with some error message like:
After splitting all users by blocks for 100 users on some time receive error: "Error: error reading SSO Account Assignment for Principal ...: ValidationException: Invalid pagination token"
According to https://docs.aws.amazon.com/sdk-for-go/api/service/ssoadmin/#ListAccountAssignmentsInput do not have filter by "principal_id". Therefore need join multiple assignments to one aws_ssoadmin_account_assignment resource.
New or Affected Resource(s)
Potential Terraform Configuration
References
The text was updated successfully, but these errors were encountered: