Set the default region for the Resource Mapping Tool when no region is configured via AWS CLI (#2856)

Ensure a valid region is always present when generating resource mapping files.
This commit is contained in:
Junbo Liang
2021-08-12 10:05:13 -07:00
committed by GitHub
parent 538276c993
commit 6d5d042e40
4 changed files with 22 additions and 1 deletions
@@ -105,6 +105,8 @@ class ViewEditController(QObject):
def _create_new_config_file(self) -> None:
configuration: Configuration = self._configuration_manager.configuration
self._set_default_region(configuration)
try:
new_config_file_path: str = file_utils.join_path(
configuration.config_directory, constants.RESOURCE_MAPPING_DEFAULT_CONFIG_FILE_NAME)
@@ -117,6 +119,15 @@ class ViewEditController(QObject):
self._rescan_config_directory()
def _set_default_region(self, configuration: Configuration):
default_region = configuration.region
if not default_region or default_region == 'aws-global':
self.set_notification_frame_text_sender.emit(
notification_label_text.VIEW_EDIT_PAGE_CREATE_NEW_CONFIG_FILE_NO_DEFAULT_REGION_MESSAGE)
logger.warning(notification_label_text.VIEW_EDIT_PAGE_CREATE_NEW_CONFIG_FILE_NO_DEFAULT_REGION_MESSAGE)
configuration.region = constants.RESOURCE_MAPPING_DEFAULT_CONFIG_FILE_REGION
def _delete_table_row(self) -> None:
indices: List[QModelIndex] = self._table_view.selectedIndexes()
self._proxy_model.remove_resources(indices)