Ejemplo n.º 1
0
    def test_list__application_workspace__non_verbose_mode(
            self,
            echo_mock,
            list_custom_platform_versions_mock,
            get_all_solution_stacks_mock
    ):
        self.setup_application_workspace()

        get_all_solution_stacks_mock.return_value = [
            SolutionStack('64bit Amazon Linux 2017.09 v4.4.0 running Node.js'),
            SolutionStack('64bit Amazon Linux 2017.09 v2.6.0 running PHP 5.4')

        ]
        list_custom_platform_versions_mock.return_value = [
            'arn:aws:elasticbeanstalk:us-west-2:123123123:platform/custom-platform-4/1.0.3',
            'arn:aws:elasticbeanstalk:us-west-2:123123123:platform/custom-platform-5/1.3.6'
        ]

        app = EB(argv=['platform', 'list'])
        app.setup()
        app.run()

        echo_mock.assert_called_once_with(
            'node.js', 'php-5.4', 'custom-platform-4', 'custom-platform-5', sep='{linesep}'.format(linesep=os.linesep)
        )
Ejemplo n.º 2
0
def _api_to_environment(api_dict, want_solution_stack = False):
    # Convert solution_stack and tier to objects
    try:
        if want_solution_stack:
            solution_stack_name = api_dict['SolutionStackName']
            platform = SolutionStack(solution_stack_name)
        else:
            platform_arn = api_dict['PlatformArn']
            platform = PlatformVersion(platform_arn)
    except KeyError:
        platform = SolutionStack(api_dict['SolutionStackName'])

    tier = api_dict['Tier']
    tier = Tier(tier['Name'], tier['Type'], tier['Version'])

    env = Environment(
        version_label=api_dict.get('VersionLabel'),
        status=api_dict.get('Status'),
        app_name=api_dict.get('ApplicationName'),
        health=api_dict.get('Health'),
        id=api_dict.get('EnvironmentId'),
        date_updated=api_dict.get('DateUpdated'),
        platform=platform,
        description=api_dict.get('Description'),
        name=api_dict.get('EnvironmentName'),
        date_created=api_dict.get('DateCreated'),
        tier=tier,
        cname=api_dict.get('CNAME', 'UNKNOWN'),
        option_settings=api_dict.get('OptionSettings'),
        is_abortable=api_dict.get('AbortableOperationInProgress', False),
        environment_links=api_dict.get('EnvironmentLinks'),
        environment_arn=api_dict.get('EnvironmentArn')
    )
    return env
Ejemplo n.º 3
0
def get_solution_stack_from_customer(module_name=None):
	"""
	Method prompts customer for a platform name, and if applicable, a platform version name

	:param module_name: An `module_name` to choose a platform corresponding to a
		particular module in the EB application. This is applicable if the directory
		is being `eb init`-ed with the `--modules` argument.

	:return: A SolutionStack object representing the the customers choice of platform
	"""
	solution_stacks = elasticbeanstalk.get_available_solution_stacks()
	solution_stacks_grouped_by_language_name = SolutionStack.group_solution_stacks_by_language_name(solution_stacks)
	language_names_to_display = [solution_stack['LanguageName'] for solution_stack in solution_stacks_grouped_by_language_name]

	custom_platforms = platformops.list_custom_platform_versions()

	if custom_platforms:
		language_names_to_display.append(CUSTOM_PLATFORM_OPTION)

	chosen_language_name = prompt_for_language_name(language_names_to_display, module_name)

	if chosen_language_name == CUSTOM_PLATFORM_OPTION:
		return platformops.get_custom_platform_from_customer(custom_platforms)

	return SolutionStack(resolve_language_version(chosen_language_name, solution_stacks))
Ejemplo n.º 4
0
    def __get_platform_name(cls, environment, want_solution_stack=False):
        try:
            if want_solution_stack or environment['SolutionStackName'] == 'custom':
                solution_stack_name = environment['SolutionStackName']
                platform_name = SolutionStack(solution_stack_name)
            else:
                platform_arn = environment['PlatformArn']
                platform_name = PlatformVersion(platform_arn)
        except KeyError:
            platform_name = SolutionStack(environment['SolutionStackName'])

        return platform_name
    def test_find_solution_stack_from_string__retrieves_latest(
            self, solution_stacks_retriever_mock):
        solution_stacks = [
            SolutionStack('64bit Amazon Linux 2017.03 v4.2.1 running Node.js'),
            SolutionStack('64bit Amazon Linux 2017.03 v4.2.0 running Node.js')
        ]
        solution_stacks_retriever_mock.return_value = solution_stacks

        self.assertEqual(
            SolutionStack('64bit Amazon Linux 2017.03 v4.2.1 running Node.js'),
            solution_stack_ops.find_solution_stack_from_string(
                '64bit Amazon Linux 2017.03 v4.2.0 running Node.js',
                find_newer=True))
    def test_find_solution_stack_from_string__retrieves_latest_python_solution_Stack(
            self, solution_stacks_retriever_mock):
        solution_stacks = [
            SolutionStack(
                '64bit Amazon Linux 2014.09 v1.1.0 running Python 2.7'),
            SolutionStack(
                '64bit Amazon Linux 2014.09 v1.1.0 running Python 3.6')
        ]
        solution_stacks_retriever_mock.return_value = solution_stacks

        self.assertEqual(
            SolutionStack(
                '64bit Amazon Linux 2014.09 v1.1.0 running Python 2.7'),
            solution_stack_ops.find_solution_stack_from_string(
                'Python 2.7', find_newer=True))
    def test_get_solution_stack_from_customer__custom_platforms_absent__customer_chooses_platform_without_multiple_versions(
            self, platforms_lister_mock, input_prompter_mock,
            solution_stacks_lister_mock, boolean_response_mock):
        available_solution_stacks = [
            SolutionStack('64bit Amazon Linux 2017.09 v4.4.0 running Node.js'),
        ]

        solution_stacks_lister_mock.return_value = available_solution_stacks
        platforms_lister_mock.return_value = []
        boolean_response_mock.return_value = False
        input_prompter_mock.side_effect = [0]

        self.assertEqual(
            SolutionStack('64bit Amazon Linux 2017.09 v4.4.0 running Node.js'),
            solution_stack_ops.get_solution_stack_from_customer())
    def test_find_solution_stack_from_string__eb_managed_platform(
            self, platform_arn_to_solution_stack_mock,
            solution_stack_lister_mock):
        solution_stack_lister_mock.return_value = [
            '64bit Amazon Linux 2017.09 v2.7.1 running Tomcat 8 Java 8'
        ]
        platform_arn_to_solution_stack_mock.return_value = SolutionStack(
            '64bit Amazon Linux 2017.09 v2.7.1 running Tomcat 8 Java 8')

        self.assertEqual(
            SolutionStack(
                '64bit Amazon Linux 2017.09 v2.7.1 running Tomcat 8 Java 8'),
            solution_stack_ops.find_solution_stack_from_string(
                'arn:aws:elasticbeanstalk:us-west-2::platform/Tomcat 8 with Java 8 running on 64bit Amazon Linux/2.7.1'
            ))
    def test_resolve_roles__interactive_mode__service_role_could_not_be_found__simulate_customer_viewing_policies(
            self, get_managed_policy_document_mock, get_input_mock,
            create_default_service_role_mock, get_service_role_mock,
            create_default_instance_profile_mock):
        get_managed_policy_document_mock.side_effect = [
            {
                "PolicyVersion": {
                    "Document": {}
                }
            },
            {
                "PolicyVersion": {
                    "Document": {}
                }
            },
        ]
        get_input_mock.side_effect = ['view', '\n']
        create_default_instance_profile_mock.return_value = 'default-profile'
        get_service_role_mock.return_value = None
        create_default_service_role_mock.return_value = 'aws-elasticbeanstalk-service-role'
        env_request = CreateEnvironmentRequest(
            app_name='my-application',
            env_name='environment-1',
            cname='cname-1',
            platform=SolutionStack(
                '64bit Amazon Linux 2015.09 v2.0.6 running Multi-container Docker 1.7.1 (Generic)'
            ),
            elb_type='network',
            group_name='dev',
        )

        createops.resolve_roles(env_request, True)
        self.assertEqual('aws-elasticbeanstalk-service-role',
                         env_request.service_role)
Ejemplo n.º 10
0
def resolve_language_version(chosen_language_name, solution_stacks):
	"""
	Method determines the list of platform versions matching a platform name and
	returns a SolutionStack object representing the platform version the customer
	would like to use.

	:param chosen_language_name: Name of language the customer would like to use
	:param solution_stacks: A list of SolutionStack objects to assemble the list
	of related platform versions from.

	:return: A SolutionStack object representing customer's choice of language
	version.
	"""
	matching_language_versions = SolutionStack.group_solution_stacks_by_platform_shorthand(
		solution_stacks,
		language_name=chosen_language_name
	)

	if len(matching_language_versions) > 1:
		version = prompt_for_solution_stack_version(matching_language_versions)
	else:
		version = matching_language_versions[0]['PlatformShorthand']

	for language_version in matching_language_versions:
		if language_version['PlatformShorthand'] == version:
			return language_version['SolutionStack']
Ejemplo n.º 11
0
    def draw_banner_info_lines(self, lines, data):
        if lines > 2:
            tier_type = self.env_data['Tier']['Name']
            tier = '{}'.format(tier_type)
            solutionstack = SolutionStack(self.env_data['SolutionStackName'])
            platform = ' {}'.format(solutionstack.version)
            term.echo_line('{tier}{pad}{platform} '.format(
                tier=tier,
                platform=platform,
                pad=' '*(term.width() - len(tier) - len(platform))
            ))

            lines -= 1
        if lines > 3:
            # Get instance health count
            instance_counts = OrderedDict([
                ('total', data.get('Total', 0)),
                ('ok', data.get('Ok', 0)),
                ('warning', data.get('Warning', 0)),
                ('degraded', data.get('Degraded', 0)),
                ('severe', data.get('Severe', 0)),
                ('info', data.get('Info', 0)),
                ('pending', data.get('Pending', 0)),
                ('unknown', data.get('Unknown', 0) + data.get('NoData', 0)),
            ])
            column_size = max(len(k) for k in instance_counts) + 1
            term.echo_line(
                ''.join((s.center(column_size)
                          for s in instance_counts)))
            term.echo_line(
                ''.join((io.bold((str(v).center(column_size)))
                                 for k, v in six.iteritems(instance_counts))))
            lines -= 2

        return lines
Ejemplo n.º 12
0
class ListTest(unittest.TestCase):
    platform = PlatformVersion(
        'arn:aws:elasticbeanstalk:us-west-2::platform/PHP 7.1 running on 64bit Amazon Linux/2.6.5'
    )
    solution_stack = SolutionStack(
        '64bit Amazon Linux 2017.09 v4.4.0 running Node.js')

    def setUp(self):
        self.root_dir = os.getcwd()
        if not os.path.exists('testDir'):
            os.mkdir('testDir')

        os.chdir('testDir')

    def tearDown(self):
        os.chdir(self.root_dir)
        shutil.rmtree('testDir')
        aws.set_region(None)

    def setup_platform_workspace(self):
        fileoperations.create_config_file('my-platform',
                                          'us-west-2',
                                          self.platform.name,
                                          workspace_type='Platform')

    def setup_application_workspace(self):
        fileoperations.create_config_file('my-application',
                                          'us-west-2',
                                          self.solution_stack.name,
                                          workspace_type='Application')
    def test_make_new_env_from_code_in_directory__use_source__process_app_version(
            self, wait_for_processed_app_versions_mock,
            create_app_version_mock, upload_keypair_if_needed_mock,
            wait_for_success_events_mock, get_current_branch_environment_mock,
            create_env_mock, create_app_version_from_source_mock, echo_mock,
            log_info_mock, git_management_enabled_mock, build_spec_exists_mock,
            resolve_roles_mock):
        build_spec_exists_mock.return_value = False
        git_management_enabled_mock.return_value = False
        create_environment_result_mock = mock.MagicMock()
        create_environment_result_mock.name = 'result'
        create_env_mock.return_value = (create_environment_result_mock,
                                        'request-id')
        get_current_branch_environment_mock.return_value = 'environment-1'
        env_request = CreateEnvironmentRequest(
            app_name='my-application',
            env_name='environment-1',
            cname='cname-1',
            platform=SolutionStack(
                '64bit Amazon Linux 2015.09 v2.0.6 running Multi-container Docker 1.7.1 (Generic)'
            ),
            elb_type='network',
            group_name='dev',
            key_name='aws-eb-us-west-2')
        create_app_version_mock.return_value = 'version-label-1'
        wait_for_processed_app_versions_mock.return_value = True
        create_app_version_from_source_mock.return_value = 'version-label-1'

        createops.make_new_env(env_request,
                               source='codecommit/my-repository/my-branch')

        create_app_version_from_source_mock.assert_called_once_with(
            'my-application',
            'codecommit/my-repository/my-branch',
            build_config=None,
            label=None,
            process=False)
        create_environment_result_mock.print_env_details.assert_called_once_with(
            createops.io.echo,
            createops.elasticbeanstalk.get_environments,
            createops.elasticbeanstalk.get_environment_resources,
            health=False)
        wait_for_success_events_mock.assert_called_once_with(
            'request-id', timeout_in_minutes=None)
        create_env_mock.assert_called_once_with(env_request, interactive=True)
        upload_keypair_if_needed_mock.assert_called_once_with(
            'aws-eb-us-west-2')
        wait_for_processed_app_versions_mock.assert_called_once_with(
            'my-application', ['version-label-1'], timeout=5)
        log_info_mock.assert_has_calls([
            mock.call('Creating new application version using remote source'),
            mock.call('Creating new environment')
        ])
        echo_mock.assert_has_calls([
            mock.call('Starting environment deployment via remote source'),
            mock.call('Printing Status:')
        ])
    def test_make_new_env_from_code_in_directory__non_interactive_mode__buildspec_present__using_application_code_in_directory_to_create_app_version(
            self, download_and_extract_sample_app_mock,
            stream_build_configuration_app_version_creation_mock,
            create_app_version_mock, upload_keypair_if_needed_mock,
            wait_for_success_events_mock, get_current_branch_environment_mock,
            create_env_mock, log_info_mock, git_management_enabled_mock,
            build_spec_exists_mock, get_build_configuration_mock,
            resolve_roles_mock):
        resolve_roles_mock.side_effect = None
        build_spec_exists_mock.return_value = True
        build_config = BuildConfiguration(
            compute_type='t2.micro',
            image='java-ami',
            service_role='codebuild-service-role',
            timeout=10)
        get_build_configuration_mock.return_value = build_config
        git_management_enabled_mock.return_value = False
        create_environment_result_mock = mock.MagicMock()
        create_environment_result_mock.name = 'result'
        create_env_mock.return_value = (create_environment_result_mock,
                                        'request-id')
        get_current_branch_environment_mock.return_value = 'environment-1'
        env_request = CreateEnvironmentRequest(
            app_name='my-application',
            env_name='environment-1',
            cname='cname-1',
            platform=SolutionStack(
                '64bit Amazon Linux 2015.09 v2.0.6 running Multi-container Docker 1.7.1 (Generic)'
            ),
            elb_type='network',
            group_name='dev',
            key_name='aws-eb-us-west-2')
        create_app_version_mock.return_value = 'version-label-1'

        createops.make_new_env(env_request, interactive=True)

        stream_build_configuration_app_version_creation_mock.assert_called_once_with(
            'my-application', 'version-label-1', build_config)
        create_environment_result_mock.print_env_details.assert_called_once_with(
            createops.io.echo,
            createops.elasticbeanstalk.get_environments,
            createops.elasticbeanstalk.get_environment_resources,
            health=False)
        wait_for_success_events_mock.assert_called_once_with(
            'request-id', timeout_in_minutes=None)
        create_env_mock.assert_called_once_with(env_request, interactive=True)
        upload_keypair_if_needed_mock.assert_called_once_with(
            'aws-eb-us-west-2')
        create_app_version_mock.assert_called_once_with(
            'my-application', build_config=build_config, process=False)
        log_info_mock.assert_has_calls([
            mock.call('Creating new application version using project code'),
            mock.call('Creating new environment')
        ])
        download_and_extract_sample_app_mock.assert_not_called()
    def test_get_solution_stack_from_customer__choose_custom_platform_option(
            self, solution_stack_detector_mock,
            custom_platform_versions_retriever_mock, index_prompter_mock,
            solution_stack_retriever_mock):
        solution_stack_retriever_mock.return_value = [
            SolutionStack('64bit Amazon Linux 2017.03 v2.5.3 running Java 8'),
            SolutionStack('64bit Amazon Linux 2017.03 v2.5.3 running Java 7'),
            SolutionStack('64bit Amazon Linux 2017.03 v4.2.1 running Node.js')
        ]
        custom_platform_versions_retriever_mock.return_value = [
            'arn:aws:elasticbeanstalk:us-west-2:123123123:platform/custom-platform-1/1.0.3',
            'arn:aws:elasticbeanstalk:us-west-2:123123123:platform/custom-platform-2/1.0.3',
            'arn:aws:elasticbeanstalk:us-west-2:123123123:platform/custom-platform-2/1.0.0',
            'arn:aws:elasticbeanstalk:us-west-2:123123123:platform/custom-platform-2/1.0.2'
        ]
        solution_stack_detector_mock.return_value = False
        index_prompter_mock.side_effect = [2, 1, 2]

        self.assertEqual(
            PlatformVersion(
                'arn:aws:elasticbeanstalk:us-west-2:123123123:platform/custom-platform-2/1.0.3'
            ), solution_stack_ops.get_solution_stack_from_customer())
Ejemplo n.º 16
0
def platform_arn_to_solution_stack(platform_arn):
	"""
	Method determines the EB-managed solution stack represented by a PlatformArn

	:param platform_arn: PlatformArn of a solution stack
	:return: SolutionStack representing the PlatformArn if it an EB-managed platform, otherwise None
	"""
	if not PlatformVersion.is_eb_managed_platform_arn(platform_arn):
		return

	platform_description = elasticbeanstalk.describe_platform_version(platform_arn)

	return SolutionStack(platform_description['SolutionStackName'])
Ejemplo n.º 17
0
def get_available_solution_stacks(fail_on_empty_response=True):
    LOG.debug('Inside get_available_solution_stacks api wrapper')
    result = _make_api_call('list_available_solution_stacks')
    stack_strings = result['SolutionStacks']

    LOG.debug('Solution Stack result size = ' + str(len(stack_strings)))

    if fail_on_empty_response and len(stack_strings) == 0:
        raise NotFoundError(strings['sstacks.notfound'])

    solution_stacks = [SolutionStack(s) for s in stack_strings]

    return solution_stacks
    def test_resolve_roles__non_interactive_mode__no_healthd_support_for_platform__service_role_cannot_determined(
            self, get_service_role_mock, create_default_instance_profile_mock):
        env_request = CreateEnvironmentRequest(
            app_name='my-application',
            env_name='environment-1',
            cname='cname-1',
            platform=SolutionStack(
                '64bit Windows Server Core 2016 v1.2.0 running IIS 10.0'),
            elb_type='network',
            group_name='dev',
            instance_profile='developer')

        createops.resolve_roles(env_request, False)

        get_service_role_mock.assert_not_called()
        create_default_instance_profile_mock.assert_not_called()
        self.assertIsNone(env_request.service_role)
    def test_resolve_roles__non_interactive_mode__profile_passed_is_other_role_name_other_than_service_role__existing_role_retrieved_from_service(
            self, get_service_role_mock, create_default_instance_profile_mock):
        get_service_role_mock.return_value = 'service-role'
        env_request = CreateEnvironmentRequest(
            app_name='my-application',
            env_name='environment-1',
            cname='cname-1',
            platform=SolutionStack(
                '64bit Amazon Linux 2015.09 v2.0.6 running Multi-container Docker 1.7.1 (Generic)'
            ),
            elb_type='network',
            group_name='dev',
            instance_profile='developer')

        createops.resolve_roles(env_request, False)

        create_default_instance_profile_mock.assert_not_called()
    def test_make_new_env_from_code_in_directory__process_app_version_failed(
            self, wait_for_processed_app_versions_mock,
            create_app_version_mock, upload_keypair_if_needed_mock,
            wait_for_success_events_mock, get_current_branch_environment_mock,
            create_env_mock, log_info_mock, git_management_enabled_mock,
            build_spec_exists_mock, resolve_roles_mock):
        resolve_roles_mock.side_effect = None
        build_spec_exists_mock.return_value = False
        git_management_enabled_mock.return_value = False
        create_environment_result_mock = mock.MagicMock()
        create_environment_result_mock.name = 'result'
        create_env_mock.return_value = (create_environment_result_mock,
                                        'request-id')
        get_current_branch_environment_mock.return_value = 'environment-1'
        wait_for_processed_app_versions_mock.return_value = False
        env_request = CreateEnvironmentRequest(
            app_name='my-application',
            env_name='environment-1',
            cname='cname-1',
            platform=SolutionStack(
                '64bit Amazon Linux 2015.09 v2.0.6 running Multi-container Docker 1.7.1 (Generic)'
            ),
            elb_type='network',
            group_name='dev',
            key_name='aws-eb-us-west-2')
        create_app_version_mock.return_value = 'version-label-1'

        createops.make_new_env(env_request,
                               process_app_version=True,
                               timeout=5)

        wait_for_processed_app_versions_mock.assert_called_once_with(
            'my-application', ['version-label-1'], timeout=5)
        create_app_version_mock.assert_called_once_with('my-application',
                                                        build_config=None,
                                                        process=True)
        log_info_mock.assert_has_calls([
            mock.call('Creating new application version using project code'),
        ])
        create_environment_result_mock.print_env_details.assert_not_called()
        wait_for_success_events_mock.assert_not_called()
        create_env_mock.assert_not_called()
        upload_keypair_if_needed_mock.assert_not_called()
Ejemplo n.º 21
0
class TestCodeSource(unittest.TestCase):
    solution = SolutionStack(
        '64bit Amazon Linux 2015.03 v2.0.6 running PHP 5.5')
    app_name = 'ebcli-intTest-app'

    def setUp(self):
        self.patcher_io = mock.patch('ebcli.controllers.codesource.io')
        self.mock_io = self.patcher_io.start()

    def tearDown(self):
        self.patcher_io.stop()

    @mock.patch('ebcli.controllers.codesource.gitops')
    def test_case_insensative_input(self, mock_gitops):
        EB.Meta.exit_on_close = False
        self.app = EB(argv=['codesource', 'LoCaL'])
        self.app.setup()
        self.app.run()
        self.app.close()

        self.mock_io.echo.assert_called_once_with(
            strings['codesource.localmsg'])

    @mock.patch('ebcli.controllers.codesource.gitops')
    @mock.patch('ebcli.controllers.codesource.utils.io')
    def test_interactive_choices_codecommit(self, mock_utils_io, mock_gitops):
        mock_utils_io.prompt.side_effect = [
            '1',  # select CodeCommit
        ]

        EB.Meta.exit_on_close = False
        self.app = EB(argv=['codesource'])
        self.app.setup()
        self.app.run()
        self.app.close()

        self.mock_io.echo.assert_called_with(
            prompts['codesource.codesourceprompt'])

        io_calls = [mock.call('2)', 'Local'), mock.call('1)', 'CodeCommit')]
        mock_utils_io.echo.assert_has_calls(io_calls, any_order=True)
    def test_platform_arn_to_solution_stack__preconfigured_solution_stack_arns(
            self):
        platform_arns = [
            'arn:aws:elasticbeanstalk:us-west-2::platform/Docker running on 64bit Amazon Linux/2.8.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/Elastic Beanstalk Packer Builder/2.4.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/Go 1 running on 64bit Amazon Linux/2.7.1',
            'arn:aws:elasticbeanstalk:us-west-2::platform/IIS 10.0 running on 64bit Windows Server 2016/1.2.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/IIS 10.0 running on 64bit Windows Server Core 2016/1.2.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/IIS 7.5 running on 64bit Windows Server 2008 R2/1.2.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/IIS 7.5 running on 64bit Windows Server 2008 R2/0.1.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/IIS 8 running on 64bit Windows Server 2012/1.2.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/IIS 8 running on 64bit Windows Server 2012/0.1.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/IIS 8.5 running on 64bit Windows Server 2012 R2/1.2.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/IIS 8.5 running on 64bit Windows Server 2012 R2/0.1.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/IIS 8.5 running on 64bit Windows Server Core 2012 R2/1.2.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/IIS 8.5 running on 64bit Windows Server Core 2012 R2/0.1.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/Java 8 running on 64bit Amazon Linux/2.6.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/Multi-container Docker running on 64bit Amazon Linux/2.8.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/Node.js running on 32bit Amazon Linux/1.2.1',
            'arn:aws:elasticbeanstalk:us-west-2::platform/Node.js running on 32bit Amazon Linux 2014.03/1.1.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/Passenger with Ruby 1.9.3 running on 32bit Amazon Linux/1.2.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/Passenger with Ruby 1.9.3 running on 32bit Amazon Linux 2014.03/1.1.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/Passenger with Ruby 2.4 running on 64bit Amazon Linux/2.6.1',
            'arn:aws:elasticbeanstalk:us-west-2::platform/Passenger with Ruby 2.4 running on 64bit Amazon Linux/2.6.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/PHP 7.1 running on 64bit Amazon Linux/2.5.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/Preconfigured Docker - GlassFish 4.0 with Java 7 running on 64bit Debian/2.8.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/Preconfigured Docker - Python 3.4 running on 64bit Debian/2.8.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/Puma with Ruby 2.4 running on 64bit Amazon Linux/2.6.1',
            'arn:aws:elasticbeanstalk:us-west-2::platform/Python 2.7 running on 64bit Amazon Linux 2014.03/1.1.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/Python 3.4 running on 64bit Amazon Linux/2.6.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/Tomcat 7 with Java 7 running on 32bit Amazon Linux 2014.03/1.1.0',
            'arn:aws:elasticbeanstalk:us-west-2::platform/Tomcat 8 with Java 8 running on 64bit Amazon Linux/2.7.1',
        ]

        platform_descriptions = [
            {
                'SolutionStackName':
                '64bit Amazon Linux 2017.09 v2.8.0 running Docker 17.06.2-ce'
            },
            {
                'SolutionStackName':
                '64bit Amazon Linux 2017.09 v2.4.0 running Packer 1.0.3'
            },
            {
                'SolutionStackName':
                '64bit Amazon Linux 2017.09 v2.7.1 running Go 1.9'
            },
            {
                'SolutionStackName':
                '64bit Windows Server 2016 v1.2.0 running IIS 10.0'
            },
            {
                'SolutionStackName':
                '64bit Windows Server Core 2016 v1.2.0 running IIS 10.0'
            },
            {
                'SolutionStackName':
                '64bit Windows Server 2008 R2 v1.2.0 running IIS 7.5'
            },
            {
                'SolutionStackName':
                '64bit Windows Server 2008 R2 running IIS 7.5'
            },
            {
                'SolutionStackName':
                '64bit Windows Server 2012 v1.2.0 running IIS 8'
            },
            {
                'SolutionStackName': '64bit Windows Server 2012 running IIS 8'
            },
            {
                'SolutionStackName':
                '64bit Windows Server 2012 R2 v1.2.0 running IIS 8.5'
            },
            {
                'SolutionStackName':
                '64bit Windows Server 2012 R2 running IIS 8.5'
            },
            {
                'SolutionStackName':
                '64bit Windows Server Core 2012 R2 v1.2.0 running IIS 8.5'
            },
            {
                'SolutionStackName':
                '64bit Windows Server Core 2012 R2 running IIS 8.5'
            },
            {
                'SolutionStackName':
                '64bit Amazon Linux 2017.09 v2.6.0 running Java 8'
            },
            {
                'SolutionStackName':
                '64bit Amazon Linux 2017.09 v2.8.0 running Multi-container Docker 17.06.2-ce (Generic)'
            },
            {
                'SolutionStackName':
                '32bit Amazon Linux 2014.09 v1.2.1 running Node.js'
            },
            {
                'SolutionStackName':
                '32bit Amazon Linux 2014.03 v1.1.0 running Node.js'
            },
            {
                'SolutionStackName':
                '32bit Amazon Linux 2014.09 v1.2.0 running Ruby 1.9.3'
            },
            {
                'SolutionStackName':
                '32bit Amazon Linux 2014.03 v1.1.0 running Ruby 1.9.3'
            },
            {
                'SolutionStackName':
                '64bit Amazon Linux 2017.09 v2.6.1 running Ruby 2.4 (Passenger Standalone)'
            },
            {
                'SolutionStackName':
                '64bit Amazon Linux 2017.09 v2.6.0 running Ruby 2.4 (Passenger Standalone)'
            },
            {
                'SolutionStackName':
                '64bit Amazon Linux 2017.03 v2.5.0 running PHP 7.1'
            },
            {
                'SolutionStackName':
                '64bit Debian jessie v2.8.0 running GlassFish 4.0 Java 7 (Preconfigured - Docker)'
            },
            {
                'SolutionStackName':
                '64bit Debian jessie v2.8.0 running Python 3.4 (Preconfigured - Docker)'
            },
            {
                'SolutionStackName':
                '64bit Amazon Linux 2017.09 v2.6.1 running Ruby 2.4 (Puma)'
            },
            {
                'SolutionStackName':
                '64bit Amazon Linux 2014.03 v1.1.0 running Python 2.7'
            },
            {
                'SolutionStackName':
                '64bit Amazon Linux 2017.09 v2.6.0 running Python 3.4'
            },
            {
                'SolutionStackName':
                '32bit Amazon Linux 2014.03 v1.1.0 running Tomcat 7 Java 7'
            },
            {
                'SolutionStackName':
                '64bit Amazon Linux 2017.09 v2.7.1 running Tomcat 8 Java 8'
            },
        ]

        for index in range(0, len(platform_arns)):
            with mock.patch(
                    'ebcli.lib.elasticbeanstalk.describe_platform_version'
            ) as describe_platform_version_mock:
                describe_platform_version_mock.return_value = platform_descriptions[
                    index]

                self.assertEqual(
                    SolutionStack(
                        platform_descriptions[index]['SolutionStackName']),
                    solution_stack_ops.platform_arn_to_solution_stack(
                        platform_arns[index]))
Ejemplo n.º 23
0
def find_solution_stack_from_string(solution_string, find_newer=False):
	"""
	Method returns a SolutionStack object representing the given `solution_string`.

	If the `solution_string` matches ARNs and complete names of solution stacks, the exact
	match is returned. In the event when there are multiple matches, the latest version is
	returned.

	:param solution_string: A string in one of the following (case-insensitive) forms:
		- PlatformArn:
			- EB-managed: 'arn:aws:elasticbeanstalk:us-west-2::platform/Multi-container Docker running on 64bit Amazon Linux/2.8.0'
			- Custom: arn:aws:elasticbeanstalk:us-west-2:123412341234:platform/custom_platform/1.0.0
		- complete name: '64bit Amazon Linux 2017.03 v2.7.5 running Multi-container Docker 17.03.2-ce (Generic)'
		- shorthand: 'Multi-container Docker 17.03.2-ce (Generic)'
		- language name: 'Multi-container Docker'
		- pythonified shorthand: 'multi-container-docker-17.03.2-ce-(generic)'
	:param find_newer: If solution_string is a complete name or a PlatformArn that uniquely matches a
			solution stack or platform, find the newest version of the solution stack.

	:return: A SolutionStack object representing the latest version of the `solution_string`. In case of a custom
		platform, the return value is a PlatformVersion object.
	"""

	# Compare input with PlatformARNs
	match = None
	if PlatformVersion.is_eb_managed_platform_arn(solution_string):
		if find_newer:
			match = platformops.get_latest_eb_managed_platform(solution_string)
		else:
			match = platform_arn_to_solution_stack(solution_string)
	elif PlatformVersion.is_custom_platform_arn(solution_string):
		if find_newer:
			match = platformops.get_latest_custom_platform(solution_string)
		else:
			match = platformops.find_custom_platform_from_string(solution_string)

	# Compare input with complete SolutionStack name and retrieve latest SolutionStack
	# in the series if `find_newer` is set to True
	if not match:
		available_solution_stacks = elasticbeanstalk.get_available_solution_stacks()

		match = SolutionStack.match_with_complete_solution_string(available_solution_stacks, solution_string)
		if match and find_newer:
			language_name = SolutionStack(solution_string).language_name
			match = SolutionStack.match_with_solution_string_language_name(available_solution_stacks, language_name)

	# Compare input with other forms
	for solution_string_matcher in [
		SolutionStack.match_with_solution_string_shorthand,
		SolutionStack.match_with_solution_string_language_name,
		SolutionStack.match_with_pythonified_solution_string,
	]:
		if not match:
			match = solution_string_matcher(available_solution_stacks, solution_string)

	# Compare input with custom platform names
	if not match:
		match = platformops.find_custom_platform_from_string(solution_string)

	if not match:
		raise NotFoundError('Platform "{}" does not appear to be valid'.format(solution_string))

	return match
    def test_find_solution_stack_from_string(self,
                                             custom_platforms_lister_mock,
                                             solution_stack_lister_mock):
        solution_strings = [
            'docker-1.11.2',
            'docker-1.12.6',
            'docker-1.6.2',
            'docker-1.7.1',
            'docker-1.9.1',
            'docker-17.03.1-ce',
            'glassfish-4.0-java-7-(preconfigured-docker)',
            'glassfish-4.1-java-8-(preconfigured-docker)',
            'go-1.3-(preconfigured-docker)',
            'go-1.4',
            'go-1.4-(preconfigured-docker)',
            'go-1.5',
            'go-1.6',
            'go-1.8',
            'iis-10.0',
            'iis-7.5',
            'iis-8',
            'iis-8.5',
            'java-7',
            'java-8',
            'multi-container-docker-1.11.2-(generic)',
            'multi-container-docker-1.6.2-(generic)',
            'multi-container-docker-1.9.1-(generic)',
            'multi-container-docker-17.03.1-ce-(generic)',
            'node.js',
            'packer-1.0.0',
            'packer-1.0.3',
            'php-5.3',
            'php-5.4',
            'php-5.5',
            'php-5.6',
            'php-7.0',
            'python',
            'python-2.7',
            'python-3.4',
            'python-3.4-(preconfigured-docker)',
            'ruby-1.9.3',
            'ruby-2.0-(passenger-standalone)',
            'ruby-2.0-(puma)',
            'ruby-2.1-(passenger-standalone)',
            'ruby-2.1-(puma)',
            'ruby-2.2-(passenger-standalone)',
            'ruby-2.2-(puma)',
            'ruby-2.3-(passenger-standalone)',
            'ruby-2.3-(puma)',
            'tomcat-6',
            'tomcat-7',
            'tomcat-7-java-6',
            'tomcat-7-java-7',
            'tomcat-8-java-8',
            'Node.js',
            'PHP',
            'Python',
            'Ruby',
            'Tomcat',
            'IIS',
            'Docker',
            'Multi-container Docker',
            'Glassfish',
            'Go',
            'Java',
            'Packer',
            '64bit Windows Server Core 2016 v1.2.0 running IIS 10.0',
            '64bit Windows Server 2016 v1.2.0 running IIS 10.0',
            '64bit Windows Server Core 2012 R2 v1.2.0 running IIS 8.5',
            '64bit Windows Server 2012 R2 v1.2.0 running IIS 8.5',
            '64bit Windows Server 2012 v1.2.0 running IIS 8',
            '64bit Windows Server 2008 R2 v1.2.0 running IIS 7.5',
            '64bit Amazon Linux 2017.03 v2.5.3 running Java 8',
            '64bit Amazon Linux 2017.03 v2.5.3 running Java 7',
            '64bit Amazon Linux 2017.03 v4.2.1 running Node.js',
            '64bit Amazon Linux 2017.03 v4.2.0 running Node.js',
            '64bit Amazon Linux 2017.03 v4.1.1 running Node.js',
            '64bit Amazon Linux 2015.09 v2.0.8 running Node.js',
            '64bit Amazon Linux 2015.03 v1.4.6 running Node.js',
            '64bit Amazon Linux 2014.03 v1.1.0 running Node.js',
            '32bit Amazon Linux 2014.03 v1.1.0 running Node.js',
            '64bit Amazon Linux 2017.03 v2.4.3 running PHP 5.4',
            '64bit Amazon Linux 2017.03 v2.4.3 running PHP 5.5',
            '64bit Amazon Linux 2017.03 v2.4.3 running PHP 5.6',
            '64bit Amazon Linux 2017.03 v2.4.3 running PHP 7.0',
            '64bit Amazon Linux 2017.03 v2.4.2 running PHP 5.4',
            '64bit Amazon Linux 2017.03 v2.4.2 running PHP 5.6',
            '64bit Amazon Linux 2017.03 v2.4.2 running PHP 7.0',
            '64bit Amazon Linux 2017.03 v2.4.1 running PHP 5.6',
            '64bit Amazon Linux 2016.03 v2.1.6 running PHP 5.4',
            '64bit Amazon Linux 2016.03 v2.1.6 running PHP 5.5',
            '64bit Amazon Linux 2016.03 v2.1.6 running PHP 5.6',
            '64bit Amazon Linux 2016.03 v2.1.6 running PHP 7.0',
            '64bit Amazon Linux 2015.03 v1.4.6 running PHP 5.6',
            '64bit Amazon Linux 2015.03 v1.4.6 running PHP 5.5',
            '64bit Amazon Linux 2015.03 v1.4.6 running PHP 5.4',
            '64bit Amazon Linux 2014.03 v1.1.0 running PHP 5.5',
            '64bit Amazon Linux 2014.03 v1.1.0 running PHP 5.4',
            '32bit Amazon Linux 2014.03 v1.1.0 running PHP 5.5',
            '32bit Amazon Linux 2014.03 v1.1.0 running PHP 5.4',
            '64bit Amazon Linux running PHP 5.3',
            '32bit Amazon Linux running PHP 5.3',
            '64bit Amazon Linux 2017.03 v2.5.0 running Python 3.4',
            '64bit Amazon Linux 2017.03 v2.5.0 running Python',
            '64bit Amazon Linux 2017.03 v2.5.0 running Python 2.7',
            '64bit Amazon Linux 2015.03 v1.4.6 running Python 3.4',
            '64bit Amazon Linux 2015.03 v1.4.6 running Python 2.7',
            '64bit Amazon Linux 2015.03 v1.4.6 running Python',
            '64bit Amazon Linux 2014.03 v1.1.0 running Python 2.7',
            '64bit Amazon Linux 2014.03 v1.1.0 running Python',
            '32bit Amazon Linux 2014.03 v1.1.0 running Python 2.7',
            '32bit Amazon Linux 2014.03 v1.1.0 running Python',
            '64bit Amazon Linux running Python',
            '32bit Amazon Linux running Python',
            '64bit Amazon Linux 2017.03 v2.4.3 running Ruby 2.3 (Puma)',
            '64bit Amazon Linux 2017.03 v2.4.3 running Ruby 2.2 (Puma)',
            '64bit Amazon Linux 2017.03 v2.4.3 running Ruby 2.1 (Puma)',
            '64bit Amazon Linux 2017.03 v2.4.3 running Ruby 2.0 (Puma)',
            '64bit Amazon Linux 2017.03 v2.4.3 running Ruby 2.3 (Passenger Standalone)',
            '64bit Amazon Linux 2017.03 v2.4.3 running Ruby 2.2 (Passenger Standalone)',
            '64bit Amazon Linux 2017.03 v2.4.3 running Ruby 2.1 (Passenger Standalone)',
            '64bit Amazon Linux 2017.03 v2.4.3 running Ruby 2.0 (Passenger Standalone)',
            '64bit Amazon Linux 2017.03 v2.4.3 running Ruby 1.9.3',
            '64bit Amazon Linux 2015.03 v1.4.6 running Ruby 2.2 (Puma)',
            '64bit Amazon Linux 2015.03 v1.4.6 running Ruby 2.2 (Passenger Standalone)',
            '64bit Amazon Linux 2015.03 v1.4.6 running Ruby 2.1 (Puma)',
            '64bit Amazon Linux 2015.03 v1.4.6 running Ruby 2.1 (Passenger Standalone)',
            '64bit Amazon Linux 2015.03 v1.4.6 running Ruby 2.0 (Puma)',
            '64bit Amazon Linux 2015.03 v1.4.6 running Ruby 2.0 (Passenger Standalone)',
            '64bit Amazon Linux 2015.03 v1.4.6 running Ruby 1.9.3',
            '64bit Amazon Linux 2014.03 v1.1.0 running Ruby 2.1 (Puma)',
            '64bit Amazon Linux 2014.03 v1.1.0 running Ruby 2.1 (Passenger Standalone)',
            '64bit Amazon Linux 2014.03 v1.1.0 running Ruby 2.0 (Puma)',
            '64bit Amazon Linux 2014.03 v1.1.0 running Ruby 2.0 (Passenger Standalone)',
            '64bit Amazon Linux 2014.03 v1.1.0 running Ruby 1.9.3',
            '32bit Amazon Linux 2014.03 v1.1.0 running Ruby 1.9.3',
            '64bit Amazon Linux 2017.03 v2.6.3 running Tomcat 8 Java 8',
            '64bit Amazon Linux 2017.03 v2.6.3 running Tomcat 7 Java 7',
            '64bit Amazon Linux 2017.03 v2.6.3 running Tomcat 7 Java 6',
            '64bit Amazon Linux 2017.03 v2.6.1 running Tomcat 8 Java 8',
            '64bit Amazon Linux 2015.03 v1.4.5 running Tomcat 8 Java 8',
            '64bit Amazon Linux 2015.03 v1.4.5 running Tomcat 7 Java 7',
            '64bit Amazon Linux 2015.03 v1.4.5 running Tomcat 7 Java 6',
            '64bit Amazon Linux 2015.03 v1.4.4 running Tomcat 7 Java 7',
            '64bit Amazon Linux 2014.03 v1.1.0 running Tomcat 7 Java 7',
            '64bit Amazon Linux 2014.03 v1.1.0 running Tomcat 7 Java 6',
            '32bit Amazon Linux 2014.03 v1.1.0 running Tomcat 7 Java 7',
            '32bit Amazon Linux 2014.03 v1.1.0 running Tomcat 7 Java 6',
            '64bit Amazon Linux running Tomcat 7',
            '64bit Amazon Linux running Tomcat 6',
            '32bit Amazon Linux running Tomcat 7',
            '32bit Amazon Linux running Tomcat 6',
            '64bit Windows Server Core 2012 R2 running IIS 8.5',
            '64bit Windows Server 2012 R2 running IIS 8.5',
            '64bit Windows Server 2012 running IIS 8',
            '64bit Windows Server 2008 R2 running IIS 7.5',
            '64bit Amazon Linux 2017.03 v2.7.2 running Docker 17.03.1-ce',
            '64bit Amazon Linux 2017.03 v2.7.1 running Docker 17.03.1-ce',
            '64bit Amazon Linux 2017.03 v2.6.0 running Docker 1.12.6',
            '64bit Amazon Linux 2016.09 v2.3.0 running Docker 1.11.2',
            '64bit Amazon Linux 2016.03 v2.1.6 running Docker 1.11.2',
            '64bit Amazon Linux 2016.03 v2.1.0 running Docker 1.9.1',
            '64bit Amazon Linux 2015.09 v2.0.6 running Docker 1.7.1',
            '64bit Amazon Linux 2015.03 v1.4.6 running Docker 1.6.2',
            '64bit Amazon Linux 2017.03 v2.7.3 running Multi-container Docker 17.03.1-ce (Generic)',
            '64bit Amazon Linux 2016.03 v2.1.6 running Multi-container Docker 1.11.2 (Generic)',
            '64bit Amazon Linux 2016.03 v2.1.0 running Multi-container Docker 1.9.1 (Generic)',
            '64bit Amazon Linux 2015.03 v1.4.6 running Multi-container Docker 1.6.2 (Generic)',
            '64bit Debian jessie v2.7.2 running GlassFish 4.1 Java 8 (Preconfigured - Docker)',
            '64bit Debian jessie v2.7.2 running GlassFish 4.0 Java 7 (Preconfigured - Docker)',
            '64bit Debian jessie v1.4.6 running GlassFish 4.1 Java 8 (Preconfigured - Docker)',
            '64bit Debian jessie v1.4.6 running GlassFish 4.0 Java 7 (Preconfigured - Docker)',
            '64bit Debian jessie v2.7.2 running Go 1.4 (Preconfigured - Docker)',
            '64bit Debian jessie v2.7.2 running Go 1.3 (Preconfigured - Docker)',
            '64bit Debian jessie v1.4.6 running Go 1.4 (Preconfigured - Docker)',
            '64bit Debian jessie v1.4.6 running Go 1.3 (Preconfigured - Docker)',
            '64bit Debian jessie v2.7.2 running Python 3.4 (Preconfigured - Docker)',
            '64bit Debian jessie v1.4.6 running Python 3.4 (Preconfigured - Docker)',
            '64bit Amazon Linux 2017.03 v2.5.1 running Go 1.8',
            '64bit Amazon Linux 2016.09 v2.3.3 running Go 1.6',
            '64bit Amazon Linux 2016.09 v2.3.0 running Go 1.5',
            '64bit Amazon Linux 2016.03 v2.1.0 running Go 1.4',
            '64bit Amazon Linux 2017.03 v2.3.1 running Packer 1.0.3',
            '64bit Amazon Linux 2017.03 v2.2.2 running Packer 1.0.0',
            'Node.js',
            'PHP 5.6',
            'PHP 5.3',
            'Python 3.4',
            'Python',
            'Ruby 2.3 (Puma)',
            'Ruby 2.3 (Passenger Standalone)',
            'Tomcat 8 Java 8',
            'Tomcat 7',
            'IIS 8.5',
            'IIS 8.5',
            'IIS 8',
            'Docker 1.12.6',
            'Multi-container Docker 17.03.1-ce (Generic)',
            'Multi-container Docker 1.11.2 (Generic)',
            'GlassFish 4.1 Java 8 (Preconfigured - Docker)',
            'Go 1.4 (Preconfigured - Docker)',
            'Python 3.4 (Preconfigured - Docker)',
            'Java 8',
            'Java 7',
            'Go 1.8',
            'Go 1.6',
            'Go 1.5',
            'Go 1.4',
            'Packer 1.0.0',
        ]
        solution_stacks = [
            '64bit Windows Server Core 2016 v1.2.0 running IIS 10.0',
            '64bit Windows Server 2016 v1.2.0 running IIS 10.0',
            '64bit Windows Server Core 2012 R2 v1.2.0 running IIS 8.5',
            '64bit Windows Server 2012 R2 v1.2.0 running IIS 8.5',
            '64bit Windows Server 2012 v1.2.0 running IIS 8',
            '64bit Windows Server 2008 R2 v1.2.0 running IIS 7.5',
            '64bit Amazon Linux 2017.03 v2.5.3 running Java 8',
            '64bit Amazon Linux 2017.03 v2.5.3 running Java 7',
            '64bit Amazon Linux 2017.03 v4.2.1 running Node.js',
            '64bit Amazon Linux 2017.03 v4.2.0 running Node.js',
            '64bit Amazon Linux 2017.03 v4.1.1 running Node.js',
            '64bit Amazon Linux 2015.09 v2.0.8 running Node.js',
            '64bit Amazon Linux 2015.03 v1.4.6 running Node.js',
            '64bit Amazon Linux 2014.03 v1.1.0 running Node.js',
            '32bit Amazon Linux 2014.03 v1.1.0 running Node.js',
            '64bit Amazon Linux 2017.03 v2.4.3 running PHP 5.4',
            '64bit Amazon Linux 2017.03 v2.4.3 running PHP 5.5',
            '64bit Amazon Linux 2017.03 v2.4.3 running PHP 5.6',
            '64bit Amazon Linux 2017.03 v2.4.3 running PHP 7.0',
            '64bit Amazon Linux 2017.03 v2.4.2 running PHP 5.4',
            '64bit Amazon Linux 2017.03 v2.4.2 running PHP 5.6',
            '64bit Amazon Linux 2017.03 v2.4.2 running PHP 7.0',
            '64bit Amazon Linux 2017.03 v2.4.1 running PHP 5.6',
            '64bit Amazon Linux 2016.03 v2.1.6 running PHP 5.4',
            '64bit Amazon Linux 2016.03 v2.1.6 running PHP 5.5',
            '64bit Amazon Linux 2016.03 v2.1.6 running PHP 5.6',
            '64bit Amazon Linux 2016.03 v2.1.6 running PHP 7.0',
            '64bit Amazon Linux 2015.03 v1.4.6 running PHP 5.6',
            '64bit Amazon Linux 2015.03 v1.4.6 running PHP 5.5',
            '64bit Amazon Linux 2015.03 v1.4.6 running PHP 5.4',
            '64bit Amazon Linux 2014.03 v1.1.0 running PHP 5.5',
            '64bit Amazon Linux 2014.03 v1.1.0 running PHP 5.4',
            '32bit Amazon Linux 2014.03 v1.1.0 running PHP 5.5',
            '32bit Amazon Linux 2014.03 v1.1.0 running PHP 5.4',
            '64bit Amazon Linux running PHP 5.3',
            '32bit Amazon Linux running PHP 5.3',
            '64bit Amazon Linux 2017.03 v2.5.0 running Python 3.4',
            '64bit Amazon Linux 2017.03 v2.5.0 running Python',
            '64bit Amazon Linux 2017.03 v2.5.0 running Python 2.7',
            '64bit Amazon Linux 2015.03 v1.4.6 running Python 3.4',
            '64bit Amazon Linux 2015.03 v1.4.6 running Python 2.7',
            '64bit Amazon Linux 2015.03 v1.4.6 running Python',
            '64bit Amazon Linux 2014.03 v1.1.0 running Python 2.7',
            '64bit Amazon Linux 2014.03 v1.1.0 running Python',
            '32bit Amazon Linux 2014.03 v1.1.0 running Python 2.7',
            '32bit Amazon Linux 2014.03 v1.1.0 running Python',
            '64bit Amazon Linux running Python',
            '32bit Amazon Linux running Python',
            '64bit Amazon Linux 2017.03 v2.4.3 running Ruby 2.3 (Puma)',
            '64bit Amazon Linux 2017.03 v2.4.3 running Ruby 2.2 (Puma)',
            '64bit Amazon Linux 2017.03 v2.4.3 running Ruby 2.1 (Puma)',
            '64bit Amazon Linux 2017.03 v2.4.3 running Ruby 2.0 (Puma)',
            '64bit Amazon Linux 2017.03 v2.4.3 running Ruby 2.3 (Passenger Standalone)',
            '64bit Amazon Linux 2017.03 v2.4.3 running Ruby 2.2 (Passenger Standalone)',
            '64bit Amazon Linux 2017.03 v2.4.3 running Ruby 2.1 (Passenger Standalone)',
            '64bit Amazon Linux 2017.03 v2.4.3 running Ruby 2.0 (Passenger Standalone)',
            '64bit Amazon Linux 2017.03 v2.4.3 running Ruby 1.9.3',
            '64bit Amazon Linux 2015.03 v1.4.6 running Ruby 2.2 (Puma)',
            '64bit Amazon Linux 2015.03 v1.4.6 running Ruby 2.2 (Passenger Standalone)',
            '64bit Amazon Linux 2015.03 v1.4.6 running Ruby 2.1 (Puma)',
            '64bit Amazon Linux 2015.03 v1.4.6 running Ruby 2.1 (Passenger Standalone)',
            '64bit Amazon Linux 2015.03 v1.4.6 running Ruby 2.0 (Puma)',
            '64bit Amazon Linux 2015.03 v1.4.6 running Ruby 2.0 (Passenger Standalone)',
            '64bit Amazon Linux 2015.03 v1.4.6 running Ruby 1.9.3',
            '64bit Amazon Linux 2014.03 v1.1.0 running Ruby 2.1 (Puma)',
            '64bit Amazon Linux 2014.03 v1.1.0 running Ruby 2.1 (Passenger Standalone)',
            '64bit Amazon Linux 2014.03 v1.1.0 running Ruby 2.0 (Puma)',
            '64bit Amazon Linux 2014.03 v1.1.0 running Ruby 2.0 (Passenger Standalone)',
            '64bit Amazon Linux 2014.03 v1.1.0 running Ruby 1.9.3',
            '32bit Amazon Linux 2014.03 v1.1.0 running Ruby 1.9.3',
            '64bit Amazon Linux 2017.03 v2.6.3 running Tomcat 8 Java 8',
            '64bit Amazon Linux 2017.03 v2.6.3 running Tomcat 7 Java 7',
            '64bit Amazon Linux 2017.03 v2.6.3 running Tomcat 7 Java 6',
            '64bit Amazon Linux 2017.03 v2.6.1 running Tomcat 8 Java 8',
            '64bit Amazon Linux 2015.03 v1.4.5 running Tomcat 8 Java 8',
            '64bit Amazon Linux 2015.03 v1.4.5 running Tomcat 7 Java 7',
            '64bit Amazon Linux 2015.03 v1.4.5 running Tomcat 7 Java 6',
            '64bit Amazon Linux 2015.03 v1.4.4 running Tomcat 7 Java 7',
            '64bit Amazon Linux 2014.03 v1.1.0 running Tomcat 7 Java 7',
            '64bit Amazon Linux 2014.03 v1.1.0 running Tomcat 7 Java 6',
            '32bit Amazon Linux 2014.03 v1.1.0 running Tomcat 7 Java 7',
            '32bit Amazon Linux 2014.03 v1.1.0 running Tomcat 7 Java 6',
            '64bit Amazon Linux running Tomcat 7',
            '64bit Amazon Linux running Tomcat 6',
            '32bit Amazon Linux running Tomcat 7',
            '32bit Amazon Linux running Tomcat 6',
            '64bit Windows Server Core 2012 R2 running IIS 8.5',
            '64bit Windows Server 2012 R2 running IIS 8.5',
            '64bit Windows Server 2012 running IIS 8',
            '64bit Windows Server 2008 R2 running IIS 7.5',
            '64bit Amazon Linux 2017.03 v2.7.2 running Docker 17.03.1-ce',
            '64bit Amazon Linux 2017.03 v2.7.1 running Docker 17.03.1-ce',
            '64bit Amazon Linux 2017.03 v2.6.0 running Docker 1.12.6',
            '64bit Amazon Linux 2016.09 v2.3.0 running Docker 1.11.2',
            '64bit Amazon Linux 2016.03 v2.1.6 running Docker 1.11.2',
            '64bit Amazon Linux 2016.03 v2.1.0 running Docker 1.9.1',
            '64bit Amazon Linux 2015.09 v2.0.6 running Docker 1.7.1',
            '64bit Amazon Linux 2015.03 v1.4.6 running Docker 1.6.2',
            '64bit Amazon Linux 2017.03 v2.7.3 running Multi-container Docker 17.03.1-ce (Generic)',
            '64bit Amazon Linux 2016.03 v2.1.6 running Multi-container Docker 1.11.2 (Generic)',
            '64bit Amazon Linux 2016.03 v2.1.0 running Multi-container Docker 1.9.1 (Generic)',
            '64bit Amazon Linux 2015.03 v1.4.6 running Multi-container Docker 1.6.2 (Generic)',
            '64bit Debian jessie v2.7.2 running GlassFish 4.1 Java 8 (Preconfigured - Docker)',
            '64bit Debian jessie v2.7.2 running GlassFish 4.0 Java 7 (Preconfigured - Docker)',
            '64bit Debian jessie v1.4.6 running GlassFish 4.1 Java 8 (Preconfigured - Docker)',
            '64bit Debian jessie v1.4.6 running GlassFish 4.0 Java 7 (Preconfigured - Docker)',
            '64bit Debian jessie v2.7.2 running Go 1.4 (Preconfigured - Docker)',
            '64bit Debian jessie v2.7.2 running Go 1.3 (Preconfigured - Docker)',
            '64bit Debian jessie v1.4.6 running Go 1.4 (Preconfigured - Docker)',
            '64bit Debian jessie v1.4.6 running Go 1.3 (Preconfigured - Docker)',
            '64bit Debian jessie v2.7.2 running Python 3.4 (Preconfigured - Docker)',
            '64bit Debian jessie v1.4.6 running Python 3.4 (Preconfigured - Docker)',
            '64bit Amazon Linux 2017.03 v2.5.1 running Go 1.8',
            '64bit Amazon Linux 2016.09 v2.3.3 running Go 1.6',
            '64bit Amazon Linux 2016.09 v2.3.0 running Go 1.5',
            '64bit Amazon Linux 2016.03 v2.1.0 running Go 1.4',
            '64bit Amazon Linux 2017.03 v2.3.1 running Packer 1.0.3',
            '64bit Amazon Linux 2017.03 v2.2.2 running Packer 1.0.0',
        ]

        solution_stacks = [
            SolutionStack(solution_stack) for solution_stack in solution_stacks
        ]
        custom_platforms = [
            'arn:aws:elasticbeanstalk:us-west-2:12345678:platform/custom-platform-1/1.0.0',
        ]
        solution_stack_lister_mock.return_value = solution_stacks
        custom_platforms_lister_mock.return_value = custom_platforms

        for solution_string in solution_strings:
            solution_stack_ops.find_solution_stack_from_string(solution_string)