diff --git a/core/operation/baseoperation.py b/core/operation/baseoperation.py index b01961d..7912361 100644 --- a/core/operation/baseoperation.py +++ b/core/operation/baseoperation.py @@ -38,10 +38,13 @@ def _create_or_update_template(self, template_data: dict) -> TemplateResponse: :return: Template ARN, Template Version ARN, and the Template ID """ + template_id = template_data["TemplateId"] try: + self._log.info(f"ready to delete template ({template_id}) if exists.") + self._qs_client.delete_template( **{ - "TemplateId": template_data["TemplateId"], + "TemplateId": template_id, "AwsAccountId": template_data["AwsAccountId"], } ) @@ -49,21 +52,26 @@ def _create_or_update_template(self, template_data: dict) -> TemplateResponse: # there can be some latency between the completion of the deletion command # and the complete backend deletion operation. time.sleep(3) + self._log.info(f"template ({template_id}) deletion complete.") except self._qs_client.exceptions.ResourceNotFoundException as e: - pass + self._log.info(f"template ({template_id}) not found: no deletion needed.") response = self._qs_client.create_template(**template_data) http_status = response["ResponseMetadata"]["HTTPStatusCode"] if http_status != 202: self._log.error( - f"Unexpected response from create_template request: {http_status} " + f"Unexpected response from create_template request: " + f"template_id = {template_id}, http_status = {http_status}" ) raise Exception( f"Unexpected response from trying to create/update template : {json.dumps(response, indent=4)} " ) else: + self._log.info( + f"Template ({template_id}) created successfully: http_status = {http_status}" + ) return TemplateResponse( response["Arn"], response["VersionArn"], response["TemplateId"] ) diff --git a/core/operation/import_from_json_operation.py b/core/operation/import_from_json_operation.py index 30c592a..e296975 100644 --- a/core/operation/import_from_json_operation.py +++ b/core/operation/import_from_json_operation.py @@ -99,10 +99,12 @@ def _create_or_update_data_set(self, dataset_definition: dict): :return: DataSet ARN and DataSet Id """ + data_set_id = dataset_definition["DataSetId"] try: + self._log.info(f"ready to delete data set ({data_set_id}) if exists.") self._qs_client.delete_data_set( **{ - "DataSetId": dataset_definition["DataSetId"], + "DataSetId": data_set_id, "AwsAccountId": dataset_definition["AwsAccountId"], } ) @@ -110,18 +112,26 @@ def _create_or_update_data_set(self, dataset_definition: dict): # there can be some latency between the completion of the deletion command # and the complete backend deletion operation. time.sleep(3) + self._log.info(f"Deletion complete for {data_set_id}.") except self._qs_client.exceptions.ResourceNotFoundException as e: - pass + self._log.info( + f"No deletion necessary: data set {data_set_id} does not exist." + ) response = self._qs_client.create_data_set(**dataset_definition) http_status = response["ResponseMetadata"]["HTTPStatusCode"] if http_status != 201 and http_status != 200: self._log.error( - f"Unexpected response from create_dataset request: {http_status} " + f"Unexpected response from create_dataset request: " + f"data_set_id = {data_set_id}, http_status = {http_status}" ) raise Exception( f"Unexpected response from trying to create/update dataset : {json.dumps(response, indent=4)} " ) else: + self._log.info( + f"Data set ({data_set_id}) created successfully: http_status = {http_status}" + ) + return DataSetResponse(response["Arn"], response["DataSetId"])