Skip to content

Commit

Permalink
fix: adds permission_set_arn
Browse files Browse the repository at this point in the history
  • Loading branch information
wanisfahmyDE committed Jan 9, 2025
1 parent 4eb4cc7 commit f79c938
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions internal/provider/resource_aws_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ func resourceAWSAccount() *schema.Resource {
Required: false,
Optional: true,
},
"permission_set_arn": {
Description: "ARN of the permission set to be removed, normally it's the arn of AWSAdministratorAccess permission set. Required if remove_account_assignment_on_update is enabled.",
Type: schema.TypeString,
Required: false,
Optional: true,
},
},
},
},
Expand Down Expand Up @@ -453,15 +459,17 @@ func updateAccountAssignment(ctx context.Context, d *schema.ResourceData, ssoadm
instanceArn := sso["instance_arn"].(string)
oldPrincipalId := oldSSOMap["principal_id"].(string)
newPrincipalId := newSSOMap["principal_id"].(string)
permissionSetArn := newSSOMap["permission_set_arn"].(string)

if oldEmail != newEmail && oldPrincipalId != newPrincipalId && oldPrincipalId != "" && instanceArn != "" {
if oldEmail != newEmail && oldPrincipalId != newPrincipalId && instanceArn != "" && permissionSetArn != "" {

_, err := ssoadmincon.DeleteAccountAssignment(ctx, &ssoadmin.DeleteAccountAssignmentInput{
InstanceArn: &instanceArn,
TargetId: &accountId,
TargetType: "AWS_ACCOUNT",
PrincipalType: "USER",
PrincipalId: &oldPrincipalId,
InstanceArn: &instanceArn,
TargetId: &accountId,
TargetType: "AWS_ACCOUNT",
PrincipalType: "USER",
PrincipalId: &oldPrincipalId,
PermissionSetArn: &permissionSetArn,
})
if err != nil {
return fmt.Errorf("error unassigning SSO user from account (%s): %v", accountId, err)
Expand Down

0 comments on commit f79c938

Please sign in to comment.