def apply_instance_profile(parameter_pool, option_settings, option_to_remove): app_name = parameter_pool.get_value(ParameterName.ApplicationName, False) solution_stack = parameter_pool.get_value(ParameterName.SolutionStack, False) eb_client = api_wrapper.create_eb_client(parameter_pool) optionDef = eb_utils.get_option_def( eb_client=eb_client, app_name=app_name, namespace=OptionSettingIAMProfile.Namespace, option_name=OptionSettingIAMProfile.OptionName, solution_stack=solution_stack) if optionDef: # Solution stack supports instance profile profile_name = parameter_pool.get_value( ParameterName.InstanceProfileName) if OptionSettingIAMProfile.Namespace in option_settings\ and OptionSettingIAMProfile.OptionName in option_settings[OptionSettingIAMProfile.Namespace]: # skip reset IAM profile name if option settings already have it return else: eb_utils.add_option_setting( option_settings=option_settings, option_remove=option_to_remove, namespace=OptionSettingIAMProfile.Namespace, option=OptionSettingIAMProfile.OptionName, value=profile_name) else: eb_utils.remove_option_setting( option_settings=option_settings, option_remove=option_to_remove, namespace=OptionSettingIAMProfile.Namespace, option=OptionSettingIAMProfile.OptionName, add_to_remove=False)
def apply_instance_profile(parameter_pool, option_settings, option_to_remove): app_name = parameter_pool.get_value(ParameterName.ApplicationName, False) solution_stack = parameter_pool.get_value(ParameterName.SolutionStack, False) eb_client = api_wrapper.create_eb_client(parameter_pool) optionDef = eb_utils.get_option_def(eb_client = eb_client, app_name = app_name, namespace = OptionSettingIAMProfile.Namespace, option_name = OptionSettingIAMProfile.OptionName, solution_stack = solution_stack) if optionDef: # Solution stack supports instance profile profile_name = parameter_pool.get_value(ParameterName.InstanceProfileName) if OptionSettingIAMProfile.Namespace in option_settings\ and OptionSettingIAMProfile.OptionName in option_settings[OptionSettingIAMProfile.Namespace]: # skip reset IAM profile name if option settings already have it return else: eb_utils.add_option_setting(option_settings = option_settings, option_remove = option_to_remove, namespace = OptionSettingIAMProfile.Namespace, option = OptionSettingIAMProfile.OptionName, value = profile_name) else: eb_utils.remove_option_setting(option_settings = option_settings, option_remove = option_to_remove, namespace = OptionSettingIAMProfile.Namespace, option = OptionSettingIAMProfile.OptionName, add_to_remove = False)
def ask_environment_type(cls, parameter_pool): # Ensure application existence eb_client = api_wrapper.create_eb_client(parameter_pool) app_name = parameter_pool.get_value(ParameterName.ApplicationName, False) api_wrapper.create_application(parameter_pool, app_name, eb_client = eb_client) # Get available environment types solution_stack = parameter_pool.get_value(ParameterName.SolutionStack, False) optionDef = eb_utils.get_option_def(eb_client = eb_client, app_name = app_name, namespace = OptionSettingEnvironmentType.Namespace, option_name = OptionSettingEnvironmentType.OptionName, solution_stack = solution_stack) if optionDef and len(optionDef.value_options) > 0: # Ask for environment type is option is available original_value = parameter_pool.get_value(ParameterName.EnvironmentType) append_message = u'' if original_value is None \ else TerminalMessage.CurrentValue.format(original_value) print(TerminalPromptAskingMessage[ParameterName.EnvironmentType].\ format(append_message)) availableTypes = optionDef.value_options type_index = cls.single_choice(choice_list = availableTypes, title = TerminalMessage.AvailableEnvironmentType, message = None, can_return_none = original_value is not None) value = availableTypes[type_index] if type_index is not None else original_value envtype = Parameter(ParameterName.EnvironmentType, value, ParameterSource.Terminal) parameter_pool.put(envtype, True) else: # Remove environment type parameter_pool.remove(ParameterName.EnvironmentType)
def ask_environment_type(cls, parameter_pool): # Ensure application existence eb_client = api_wrapper.create_eb_client(parameter_pool) app_name = parameter_pool.get_value(ParameterName.ApplicationName, False) api_wrapper.create_application(parameter_pool, app_name, eb_client = eb_client) # Get available environment types solution_stack = parameter_pool.get_value(ParameterName.SolutionStack, False) optionDef = eb_utils.get_option_def(eb_client = eb_client, app_name = app_name, namespace = OptionSettingEnvironmentType.Namespace, option_name = OptionSettingEnvironmentType.OptionName, solution_stack = solution_stack) if optionDef and len(optionDef.value_options) > 0: # Ask for environment type is option is available original_value = parameter_pool.get_value(ParameterName.EnvironmentType) append_message = '' if original_value is None \ else TerminalMessage.CurrentValue.format(original_value) print((TerminalPromptAskingMessage[ParameterName.EnvironmentType].\ format(append_message))) availableTypes = optionDef.value_options type_index = cls.single_choice(choice_list = availableTypes, title = TerminalMessage.AvailableEnvironmentType, message = None, can_return_none = original_value is not None) value = availableTypes[type_index] if type_index is not None else original_value envtype = Parameter(ParameterName.EnvironmentType, value, ParameterSource.Terminal) parameter_pool.put(envtype, True) else: # Remove environment type parameter_pool.remove(ParameterName.EnvironmentType)