def _add_database_options(link, option_settings): namespace = 'aws:rds:dbinstance' allocated_storage = elasticbeanstalk.get_option_setting( option_settings, namespace, 'DBAllocatedStorage') deletion_policy = elasticbeanstalk.get_option_setting( option_settings, namespace, 'DBDeletionPolicy') engine = elasticbeanstalk.get_option_setting(option_settings, namespace, 'DBEngine') instance_class = elasticbeanstalk.get_option_setting( option_settings, namespace, 'DBInstanceClass') multi_az = elasticbeanstalk.get_option_setting(option_settings, namespace, 'MultiAZDatabase') if allocated_storage: link += '&rdsDBAllocatedStorage=' + allocated_storage if deletion_policy: link += '&rdsDBDeletionPolicy=' + deletion_policy if engine: link += '&rdsDBEngine=' + engine if instance_class: link += '&rdsDBInstanceClass=' + instance_class if multi_az: link += '&rdsMultiAZDatabase=' + multi_az return link
def _is_single_instance(app_name, env_name): env = elasticbeanstalk.describe_configuration_settings(app_name, env_name) option_settings = env['OptionSettings'] env_type = elasticbeanstalk.get_option_setting( option_settings, namespaces.ENVIRONMENT, option_names.ENVIRONMENT_TYPE) if env_type == 'SingleInstance': return True
def _raise_if_environment_is_not_using_enhanced_health(configuration_settings): option_settings = configuration_settings.get('OptionSettings') health_type = elasticbeanstalk.get_option_setting( option_settings, namespaces.HEALTH_SYSTEM, option_names.SYSTEM_TYPE ) if health_type != 'enhanced': raise InvalidOptionsError(strings['cloudwatch_environment_health_log_streaming.enhanced_health_not_found'])
def get_quick_link(app_name, env_name): env = elasticbeanstalk.get_environment(app_name=app_name, env_name=env_name) settings = elasticbeanstalk.describe_configuration_settings( app_name, env_name) option_settings = settings['OptionSettings'] environment_type = elasticbeanstalk.get_option_setting( option_settings, 'aws:elasticbeanstalk:environment', 'EnvironmentType') instance_type = elasticbeanstalk.get_option_setting( option_settings, 'aws:autoscaling:launchconfiguration', 'InstanceType') link = 'https://console.aws.amazon.com/elasticbeanstalk/home?' # add region region = aws.get_region_name() link += 'region=' + urllib.parse.quote(region) # add quicklaunch flag link += '#/newApplication' # add application name link += '?applicationName=' + urllib.parse.quote(app_name) # add solution stack link += '&solutionStackName=' + urllib.parse.quote( env.platform.platform_shorthand) # add link += '&tierName=' + env.tier.name if environment_type: link += '&environmentType=' + environment_type if env.version_label: app_version = elasticbeanstalk.get_application_versions( app_name, version_labels=[env.version_label])['ApplicationVersions'][0] source_bundle = app_version['SourceBundle'] source_url = 'https://s3.amazonaws.com/' + source_bundle['S3Bucket'] + \ '/' + source_bundle['S3Key'] link += '&sourceBundleUrl=' + source_url if instance_type: link += '&instanceType=' + instance_type link = _add_database_options(link, option_settings) link = _add_vpc_options(link, option_settings) io.echo(link)
def upgrade_env(app_name, env_name, timeout, confirm, noroll): env = elasticbeanstalk.get_environment_settings(app_name, env_name) latest = solution_stack_ops.find_solution_stack_from_string( env.platform.name, find_newer=True) if latest.name == env.platform.name: io.echo(prompts['upgrade.alreadylatest']) return else: single = elasticbeanstalk.get_option_setting( env.option_settings, namespaces.ENVIRONMENT, 'EnvironmentType') == 'SingleInstance' rolling_enabled = elasticbeanstalk.get_option_setting( env.option_settings, namespaces.ROLLING_UPDATES, option_names.ROLLING_UPDATE_ENABLED) == 'true' webserver = env.tier.name.lower() == 'webserver' io.echo() io.echo(prompts['upgrade.infodialog'].format(env_name)) io.echo('Current platform:', env.platform) io.echo('Latest platform: ', latest.name) io.echo() warning = _get_warning_message(confirm, single, rolling_enabled, webserver, noroll) if warning: io.log_warning(warning) io.echo(prompts['upgrade.altmessage']) io.echo() if not confirm: io.validate_action(prompts['upgrade.validate'], env.name) add_rolling = _should_add_rolling(single, rolling_enabled, noroll) do_upgrade(env_name, add_rolling, timeout, latest.name, health_based=webserver, platform_arn=latest.name)
def open_app(app_name, env_name): env = elasticbeanstalk.get_environment(app_name=app_name, env_name=env_name) settings = elasticbeanstalk.describe_configuration_settings( app_name, env_name) option_settings = settings.get('OptionSettings', []) http_port = elasticbeanstalk.get_option_setting( option_settings, namespaces.LOAD_BALANCER, option_names.LOAD_BALANCER_HTTP_PORT) if http_port == 'OFF': ssl = True else: ssl = False commonops.open_webpage_in_browser(env.cname, ssl=ssl)
def _add_vpc_options(link, option_settings): vpc_id = elasticbeanstalk.get_option_setting(option_settings, 'aws:ec2:vpc', 'VPCId') if vpc_id: link += '&withVpc=true' return link