# -*- coding: utf-8 -*-
import boto3


def create_session(profile_name):
    if not profile_name:
        return boto3
    else:
        return boto3.Session(profile_name=profile_name)

# -*- coding: utf-8 -*-
import sys

import boto3
import botocore
import click


def create_session(profile_name):
    if profile_name is None:
        return boto3
    else:
        try:
            session = boto3.Session(profile_name=profile_name)
            return session
        except botocore.exceptions.ProfileNotFound as e:
            click.echo("Invalid profile name: {0}".format(profile_name, e), err=True)
            sys.exit(2)

Add error message when wrong AWS Profile Name is given