Esempio n. 1
0
def test_can_create_botocore_session_debug():
    log_name = 'botocore.endpoint'
    assert_has_no_request_body_filter(log_name)

    utils.create_botocore_session(debug=True)

    assert_request_body_filter_in_log(log_name)
    assert logging.getLogger('').level == logging.DEBUG
Esempio n. 2
0
def show_lambda_logs(config, max_entries, include_lambda_messages):
    # type: (Config, int, bool) -> None
    lambda_arn = config.lambda_arn
    profile = config.profile
    client = create_botocore_session(profile).create_client('logs')
    retriever = LogRetriever.create_from_arn(client, lambda_arn)
    events = retriever.retrieve_logs(
        include_lambda_messages=include_lambda_messages,
        max_entries=max_entries)
    for event in events:
        print event['timestamp'], event['logShortId'], event['message'].strip()
Esempio n. 3
0
def url(ctx):
    # type: (click.Context) -> None
    config = create_config_obj(ctx)
    session = create_botocore_session(profile=config.profile,
                                      debug=ctx.obj['debug'])
    c = TypedAWSClient(session)
    rest_api_id = c.get_rest_api_id(config.app_name)
    stage_name = config.stage
    region_name = c.region_name
    click.echo(
        "https://{api_id}.execute-api.{region}.amazonaws.com/{stage}/".format(
            api_id=rest_api_id, region=region_name, stage=stage_name))
Esempio n. 4
0
def generate_sdk(ctx, sdk_type, outdir):
    # type: (click.Context, str, str) -> None
    config = create_config_obj(ctx)
    session = create_botocore_session(profile=config.profile,
                                      debug=ctx.obj['debug'])
    client = TypedAWSClient(session)
    rest_api_id = client.get_rest_api_id(config.app_name)
    stage_name = config.stage
    if rest_api_id is None:
        click.echo("Could not find API ID, has this application "
                   "been deployed?")
        raise click.Abort()
    client.download_sdk(rest_api_id,
                        outdir,
                        stage=stage_name,
                        sdk_type=sdk_type)
Esempio n. 5
0
def deploy(ctx, autogen_policy, profile, stage):
    # type: (click.Context, bool, str, str) -> None
    config = create_config_obj(ctx,
                               stage_name=stage,
                               autogen_policy=autogen_policy,
                               profile=profile)
    session = create_botocore_session(profile=config.profile,
                                      debug=ctx.obj['debug'])
    d = deployer.create_default_deployer(session=session, prompter=click)
    try:
        d.deploy(config)
    except botocore.exceptions.NoRegionError:
        e = click.ClickException("No region configured. "
                                 "Either export the AWS_DEFAULT_REGION "
                                 "environment variable or set the "
                                 "region value in our ~/.aws/config file.")
        e.exit_code = 2
        raise e
Esempio n. 6
0
def test_can_create_botocore_session():
    session = utils.create_botocore_session()
    assert session.user_agent().startswith('aws-chalice/')