def create_if_not_exists_groups()

in src/pkg/qs_user_gov.py [0:0]


def create_if_not_exists_groups(user):
    """
    check to see if a group exists in a QuickSight namespace.
    If not, create it. (only create if prefixed appropriately)
    ex. dlp_qs_dev_
    """

    for grp in user.qs_groups:
        try:
            QS_CLIENT.describe_group(
                GroupName=grp, AwsAccountId=user.account_id, Namespace=user.namespace
            )
        except ClientError:

            QS_CLIENT.create_group(
                GroupName=grp, AwsAccountId=user.account_id, Namespace=user.namespace
            )
            time.sleep(3) # let group be created
            LOGGER.info(f"Group [{grp}] added to namespace [{user.namespace}]")