Skip to content

Commit

Permalink
Rewrite if-clause existing infra and resource for imported dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
dlpzx committed Sep 12, 2024
1 parent 5358677 commit 0eb4f73
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,9 @@ def get_database(self, database_name):
try:
database = self._client.get_database(Name=database_name)
return database
except self._client.exceptions.EntityNotFoundException:
return False
except ClientError as e:
raise Exception(f'Error checking if database {database_name} exists: {e}')
log.exception(f'Database not found, exception: {e}')
return False

def create_database(self, database_name, bucket):
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,14 @@ def persistent_imported_kms_s3_dataset1(
aws_client=persistent_env1_aws_client,
integration_role_arn=persistent_env1_integration_role_arn,
env=persistent_env1,
bucket_name=resource_name if existing_bucket is None else None,
kms_alias_name=resource_name if existing_kms_alias is None else None,
glue_database_name=resource_name if existing_database is None else None,
bucket_name=resource_name if not existing_bucket else None,
kms_alias_name=resource_name if not existing_kms_alias else None,
glue_database_name=resource_name if not existing_database else None,
)
if (
all(None in item for item in [bucket, existing_bucket])
or all(None in item for item in [kms_alias, existing_kms_alias])
or all(None in item for item in [database, existing_database])
(not bucket and not existing_bucket)
or (not kms_alias and not existing_kms_alias)
or (not database and not existing_database)
):
delete_aws_imported_resources(
aws_client=persistent_env1_aws_client,
Expand All @@ -465,7 +465,7 @@ def persistent_imported_kms_s3_dataset1(
client1,
group1,
persistent_env1,
bucket,
kms_alias,
database,
resource_name,
resource_name,
resource_name,
)

0 comments on commit 0eb4f73

Please sign in to comment.