refactor: レビュー指摘対応

https://nds-tyo.backlog.com/git/NEWDWH2021/newsdwh2021/pullRequests/37#comment-1247185
This commit is contained in:
shimoda.m@nds-tyo.co.jp 2022-07-08 15:12:52 +09:00
parent c52e936a76
commit fc8ecccf21

View File

@ -29,24 +29,26 @@ logger = MeDaCaLogger.get_logger()
def handler(event, context):
try:
# ① 処理開始ログを出力する
logger.info('I-01-01', '処理開始 Viewセキュリティオプション付与チェック')
# ② 設定ファイル[チェック対象スキーマ名ファイル]を読み込む
logger.info('I-02-01', 'チェック対象スキーマ名ファイルを読み込み 開始')
check_target_schemas = read_check_target_schemas()
logger.info('I-02-02', f'チェック対象スキーマ名ファイルを読み込み 終了 チェック対象スキーマ名:{check_target_schemas}')
# print(check_target_schemas)
# ③ データベースに接続する
logger.info('I-03-01', 'データベースへの接続開始 開始')
# DB接続のためのパラメータ取得
db_host, db_user_name, db_user_password = read_db_param_from_parameter_store()
connection = connection_database(db_host, db_user_name, db_user_password)
logger.info('I-03-02', 'データベースへの接続開始 成功')
# ④ Viewのオプションを確認するため、データを取得する
logger.info('I-04-01', 'Viewセキュリティオプション チェック開始')
check_result = fetch_view_security_options(connection, check_target_schemas)
if len(check_result) == 0:
logger.info('I-04-02', 'Viewセキュリティオプション 未設定のViewはありません。処理を終了します。')
return
logger.info('I-05-01', 'Viewセキュリティオプション 未設定のViewがあるため、メール送信処理を開始します。')
# ⑤ 取得できたデータをもとに、メール通知する文言を作成する
no_security_option_views = [NoSecurityOptionView(*row) for row in check_result]
logger.info(
'I-05-02', f'通知メール(タイトル)テンプレートファイル読込 読込元:{CONFIG_BUCKET_NAME}/{NOTICE_MAIL_TITLE_TEMPLATE_PATH}')
@ -75,6 +77,7 @@ def handler(event, context):
notice_to_nds('E-99', e)
raise e
finally:
# ⑥ 処理終了ログを出力する
logger.info('I-06-01', '処理終了 Viewセキュリティオプション付与チェック')