def set_aws_configs(params: set, configs: dict): """Sets AWS configuration Args: params (set): List of aws configuration attributes configs (dict): Configuration map for a particular component """ for k, v in configs.items(): if k not in params: continue cmd = ["aws", "configure", "set", k, v] proc_inst = run_command(cmd) if proc_inst.returncode != 0: print_error_msg(f"Failed configuring aws with {k}")
def get_aws_configs(): """Gets AWS configuration from environment""" env_params_cfg_map = ( ('AWS_ACCESS_KEY_ID', 'aws_access_key_id'), ('AWS_SECRET_ACCESS_KEY', 'aws_secret_access_key'), ('AWS_DEFAULT_REGION', 'region'), ) configs = {} for env_param, cfg_key in env_params_cfg_map: cmd = ["aws", "configure", "get", cfg_key] proc_inst = run_command(cmd) val = None if proc_inst.returncode == 0: val = proc_inst.stdout.strip() if not val: val = os.environ.get(env_param) configs[cfg_key] = val return configs
def run(self): run_command(self.cmd, get_return_value=False) while self.flag: self.my_loop()
def _run_cmd(cmd): logging.debug(f'start cmd : {cmd}') common.run_command(cmd) logging.debug(f'end cmd : {cmd}')
def my_loop(self): run_command(self.cmd)