Ejemplo n.º 1
0
def _default_account_id(options):
    if options.assume_role:
        try:
            options.account_id = options.assume_role.split(':')[4]
            return
        except IndexError:
            pass
    try:
        session = utils.get_profile_session(options)
        options.account_id = get_account_id_from_sts(session)
    except:
        options.account_id = None
Ejemplo n.º 2
0
def _default_account_id(options):
    if options.assume_role:
        try:
            options.account_id = options.assume_role.split(':')[4]
            return
        except IndexError:
            pass
    try:
        session = utils.get_profile_session(options)
        options.account_id = get_account_id_from_sts(session)
    except:
        options.account_id = None
Ejemplo n.º 3
0
def _default_region(options):
    marker = object()
    value = getattr(options, 'regions', marker)
    if value is marker:
        return

    if len(value) > 0:
        return

    try:
        options.regions = [utils.get_profile_session(options).region_name]
        log.debug("using default region:%s from boto" % options.regions[0])
    except:
        return
Ejemplo n.º 4
0
def _default_region(options):
    marker = object()
    value = getattr(options, 'regions', marker)
    if value is marker:
        return

    if len(value) > 0:
        return

    try:
        options.regions = [utils.get_profile_session(options).region_name]
        log.debug("using default region:%s from boto" % options.regions[0])
    except:
        return
Ejemplo n.º 5
0
def _default_region(options):
    marker = object()
    value = getattr(options, 'regions', marker)
    if value is marker:
        return

    if len(value) > 0:
        return

    try:
        options.regions = [utils.get_profile_session(options).region_name]
    except:
        log.warning('Could not determine default region')
        options.regions = [None]

    if options.regions[0] is None:
        log.error('No default region set. Specify a default via AWS_DEFAULT_REGION '
                  'or setting a region in ~/.aws/config')
        sys.exit(1)

    log.debug("using default region:%s from boto" % options.regions[0])