def initialize_codecommit(): source_control = SourceControl.get_source_control() try: source_control_setup = source_control.is_setup() except CommandError: source_control_setup = False if not source_control_setup: io.log_error("Cannot setup CodeCommit because there is no Source Control setup") return if codecommit.region_supported(commonops.get_default_region()): # Show the current setup if there is one and ask if they want to continue codecommit_setup = print_current_codecommit_settings() if codecommit_setup: try: io.validate_action("Do you wish to continue (y/n)", "y") except ValidationError: return # Setup git config settings for code commit credentials source_control.setup_codecommit_cred_config() # Get user desired repository from ebcli.controllers import initialize repository = initialize.get_repository_interactive() branch = initialize.get_branch_interactive(repository) # set defaults for current environment set_repo_default_for_current_environment(repository) set_branch_default_for_current_environment(branch) else: io.log_error("The region {0} is not supported by CodeCommit".format(commonops.get_default_region()))
def enable_cloudwatch_logs(env_name): # Add option settings needed for log streaming """ Enables cloudwatch log streaming for the given environment :param env_name: environment name """ option_settings = [ elasticbeanstalk.create_option_setting(namespaces.CLOUDWATCH_LOGS, option_names.STREAM_LOGS, 'true'), ] io.echo(strings['cloudwatch-logs.enable']) # echo link to cloudwatch console, BJS console link is different region = commonops.get_default_region() if region == 'cn-north-1': cw_link_regionalized = strings['cloudwatch-logs.bjslink'] else: cw_link_regionalized = strings['cloudwatch-logs.link'] io.echo( cw_link_regionalized.replace('{region}', region).replace('{env_name}', env_name)) commonops.update_environment(env_name, changes=option_settings, nohang=False)
def _echo_link_to_cloudwatch_console(env_name): region = commonops.get_default_region() if region in ['cn-north-1', 'cn-northwest-1']: cw_link_regionalized = strings['cloudwatch-logs.bjslink'] else: cw_link_regionalized = strings['cloudwatch-logs.link'] io.echo(cw_link_regionalized.replace('{region}', region).replace('{env_name}', env_name))
def get_region_from_inputs(region): # Get region from config file if not region: try: region = commonops.get_default_region() except NotInitializedError: region = None return region
def get_region_from_inputs(self): # Get region from command line arguments region = self.app.pargs.region # Get region from config file if not region: try: region = commonops.get_default_region() except NotInitializedError: region = None return region
def __init__(self): args = self._parse_args() # environment_name may be None self.environment_name = args.environment_name or get_current_branch_environment( ) self.profile = self._raise_if_none( args.profile, get_default_profile(), "Please specify a specific profile in the command or eb configuration.", ) self.region = self._raise_if_none( args.region, get_default_region(), "Please specify a specific region in the command or eb configuration.", )
def elb_types(region): """ Returns the list of Load Balancer types that a customer can use in the given region. :param region: Name of region of create environment in :return: list of Load Balancer types """ types = [elb_names.CLASSIC_VERSION, elb_names.APPLICATION_VERSION] if not region: region = commonops.get_default_region() if region not in ['cn-north-1', 'us-gov-west-1']: types.append(elb_names.NETWORK_VERSION) return types
def set_region(region_name): if not region_name: region_name = commonops.get_default_region() aws.set_region(region_name)