def get_aws_partition()

in src/stepfunctions/steps/utils.py [0:0]


def get_aws_partition():

    """
    Returns the aws partition for the current boto3 session.
    Defaults to 'aws' if the region could not be detected.
    """

    partitions = boto3.session.Session().get_available_partitions()
    cur_region = boto3.session.Session().region_name
    cur_partition = "aws"

    if cur_region is None:
        logger.warning("No region detected for the boto3 session. Using default partition: aws")
        return cur_partition

    for partition in partitions:
        regions = boto3.session.Session().get_available_regions("stepfunctions", partition)
        if cur_region in regions:
            cur_partition = partition
            return cur_partition

    return cur_partition