예제 #1
0
def download_config_from_s3(app_name, cfg_name):
    bucket = elasticbeanstalk.get_storage_location()
    body = s3.get_object(bucket,
                         _get_s3_keyname_for_template(app_name, cfg_name))

    location = write_to_local_config(cfg_name, body)
    fileoperations.set_user_only_permissions(location)
    io.echo()
    io.echo('Configuration saved at: ' + location)
예제 #2
0
def download_config_from_s3(app_name, cfg_name):
    bucket = elasticbeanstalk.get_storage_location()
    body = s3.get_object(bucket,
                         _get_s3_keyname_for_template(app_name, cfg_name))

    location = write_to_local_config(cfg_name, body)
    fileoperations.set_user_only_permissions(location)
    io.echo()
    io.echo('Configuration saved at: ' + location)
예제 #3
0
def download_source_bundle(app_name, env_name):
    env = elasticbeanstalk.get_environment(app_name=app_name,
                                           env_name=env_name)
    if env.version_label and env.version_label != 'Sample Application':
        app_version = elasticbeanstalk.get_application_versions(
            app_name,
            version_labels=[env.version_label])['ApplicationVersions'][0]

        source_bundle = app_version['SourceBundle']
        bucket_name = source_bundle['S3Bucket']
        key_name = source_bundle['S3Key']
        io.echo('Downloading application version...')
        data = s3.get_object(bucket_name, key_name)
        filename = get_filename(key_name)
    else:
        # sample app
        template = cloudformation.get_template('awseb-' + env.id + '-stack')
        try:
            url = template['TemplateBody']['Parameters']['AppSource'][
                'Default']
        except KeyError:
            raise NotFoundError('Can not find app source for environment')
        utils.get_data_from_url(url)
        io.echo('Downloading application version...')
        data = utils.get_data_from_url(url, timeout=30)
        filename = 'sample.zip'

    fileoperations.make_eb_dir('downloads/')
    location = fileoperations.get_eb_file_full_location('downloads/' +
                                                        filename)
    fileoperations.write_to_data_file(location, data)
    io.echo('Application version downloaded to:', location)

    cwd = os.getcwd()
    try:
        fileoperations._traverse_to_project_root()
        if heuristics.directory_is_empty():
            # If we dont have any project code, unzip as current project
            io.echo('Unzipping application version as project files.')
            fileoperations.unzip_folder(location, os.getcwd())
            io.echo('Done.')
    finally:
        os.chdir(cwd)