def create(trace_id, check_result_item_id, check_history_id, check_result_id, check_item_code, organization_id, organization_name, project_id, project_name, aws_account_coop_id, aws_account, sort_code, check_result, result_json_path, result_csv_path, executed_date_time, time_to_live, aws_account_name, assessment_flag, exclusion_flag): common_utils.begin_logger(trace_id, __name__, inspect.currentframe()) # 不要なクラムを作成することを避けるため date_now = common_utils.get_current_date() data_create = { 'CheckResultItemID': check_result_item_id, 'CheckHistoryID': check_history_id, 'CheckResultID': check_result_id, 'CheckItemCode': check_item_code, 'OrganizationID': organization_id, 'OrganizationName': organization_name, 'ProjectID': project_id, 'ProjectName': project_name, 'AWSAccountCoopID': aws_account_coop_id, 'AWSAccount': aws_account, 'SortCode': sort_code, 'CheckResult': check_result, 'ResultJsonPath': result_json_path, 'ResultCsvPath': result_csv_path, 'ExecutedDateTime': executed_date_time, 'TimeToLive': time_to_live, 'AssessmentFlag': assessment_flag, 'ExclusionFlag': exclusion_flag, 'CreatedAt': date_now, 'UpdatedAt': date_now, "AWSAccountName": aws_account_name } condition_expression = Attr("CheckResultItemID").not_exists() DB_utils.create(trace_id, Tables.PM_CHECK_RESULT_ITEMS, data_create, condition_expression)
def create(trace_id, organization_id, notify_code, webhook_url, mentions, is_cw_logger=False): if (is_cw_logger): common_utils.begin_cw_logger(trace_id, __name__, inspect.currentframe()) else: common_utils.begin_logger(trace_id, __name__, inspect.currentframe()) if common_utils.is_null(mentions): mentions = None date_now = common_utils.get_current_date() org_notify_slack = { "OrganizationID": organization_id, "NotifyCode": notify_code, "WebhookURL": webhook_url, "Mentions": mentions, "CreatedAt": date_now, "UpdatedAt": date_now } DB_utils.create(trace_id, Tables.PM_ORG_NOTIFY_SLACK, org_notify_slack, is_cw_logger=is_cw_logger)
def create_report(trace_id, report_id, report_name, generate_user, aws_accounts, status, resource_info_path, json_output_path, json_output_time, html_output_status, html_path, html_output_time, excel_output_status, excel_path, excel_output_time, schema_version, organization_id, project_id): common_utils.begin_logger(trace_id, __name__, inspect.currentframe()) # 不要なクラムを作成することを避けるため date_now = common_utils.get_current_date() create_report = { 'ReportID': report_id, 'ReportName': report_name, 'GenerateUser': generate_user, 'AWSAccounts': aws_accounts, 'ReportStatus': status, 'ResourceInfoPath': resource_info_path, 'JsonOutputPath': json_output_path, 'JsonOutputTime': json_output_time, 'HTMLOutputStatus': html_output_status, 'HTMLPath': html_path, 'HTMLOutputTime': html_output_time, 'ExcelOutputStatus': excel_output_status, 'ExcelPath': excel_path, 'ExcelOutputTime': excel_output_time, 'SchemaVersion': schema_version, 'OrganizationID': organization_id, 'ProjectID': project_id, 'CreatedAt': date_now, 'UpdatedAt': date_now } condition_expression = Attr("ReportID").not_exists() DB_utils.create(trace_id, Tables.PM_REPORTS, create_report, condition_expression)
def create(user_id, exclusion_resource_id, organization_id, project_id, aws_account, check_item_code, region_name, resource_type, resource_name, exclusion_comment, email, account_refine_code, check_item_refine_code, time_to_live): common_utils.begin_logger(user_id, __name__, inspect.currentframe()) date_now = common_utils.get_current_date() if len(exclusion_comment) == 0: exclusion_comment = None create_exclusion_resources = { 'ExclusionResourceID': exclusion_resource_id, 'OrganizationID': organization_id, 'ProjectID': project_id, 'AWSAccount': aws_account, 'CheckItemCode': check_item_code, 'RegionName': region_name, 'ResourceType': resource_type, 'ResourceName': resource_name, 'ExclusionComment': exclusion_comment, 'UserID': user_id, 'MailAddress': email, 'AccountRefineCode': account_refine_code, 'CheckItemRefineCode': check_item_refine_code, 'TimeToLive': time_to_live, 'CreatedAt': date_now, 'UpdatedAt': date_now } DB_utils.create(user_id, Tables.PM_EXCLUSION_RESOURCES, create_exclusion_resources)
def create(trace_id, organization_id, notify_code, destinations): common_utils.begin_logger(trace_id, __name__, inspect.currentframe()) date_now = common_utils.get_current_date() create_notify = { 'OrganizationID': organization_id, 'NotifyCode': notify_code, 'Destinations': destinations, 'CreatedAt': date_now, 'UpdatedAt': date_now } DB_utils.create(trace_id, Tables.PM_ORG_NOTIFY_MAIL_DESTINATIONS, create_notify)
def create(trace_id, security_check_webhook_id, executed_status): common_utils.begin_logger(trace_id, __name__, inspect.currentframe()) date_now = common_utils.get_current_date() data_create = { 'SecurityCheckWebhookID': security_check_webhook_id, 'CreatedAt': date_now, 'ExecutedStatus': executed_status } condition_expression = Attr('SecurityCheckWebhookID').not_exists().__and__( Attr('CreatedAt').not_exists()) DB_utils.create(trace_id, Tables.PM_SECURITY_CHECK_WEBHOOK_CALL_HISTORY, data_create, condition_expression)
def create(trace_id, check_result_id, check_history_id, check_rule_code, organization_id, organization_name, project_id, project_name, aws_account_coop_id, aws_account, sort_code, ok_count, critical_count, ng_count, executed_date_time, time_to_live, aws_account_name, is_cw_logger=False): if (is_cw_logger): common_utils.begin_cw_logger(trace_id, __name__, inspect.currentframe()) else: common_utils.begin_logger(trace_id, __name__, inspect.currentframe()) # 不要なクラムを作成することを避けるため date_now = common_utils.get_current_date() data_create = { 'CheckResultID': check_result_id, 'CheckHistoryID': check_history_id, 'CheckRuleCode': check_rule_code, 'OrganizationID': organization_id, 'OrganizationName': organization_name, 'ProjectID': project_id, 'ProjectName': project_name, 'AWSAccountCoopID': aws_account_coop_id, 'AWSAccount': aws_account, 'SortCode': sort_code, 'OKCount': ok_count, 'CriticalCount': critical_count, 'NGCount': ng_count, 'ExecutedDateTime': executed_date_time, 'TimeToLive': time_to_live, 'CreatedAt': date_now, 'UpdatedAt': date_now, 'AWSAccountName': aws_account_name } condition_expression = Attr("CheckResultID").not_exists() DB_utils.create(trace_id, Tables.PM_CHECK_RESULTS, data_create, condition_expression, is_cw_logger=is_cw_logger)
def create_daily_check(trace_id, awsaccount): common_utils.begin_logger(trace_id, __name__, inspect.currentframe()) now_utc = datetime.utcnow() date_format = now_utc.strftime("%Y-%m-%d") unixtime = calendar.timegm(now_utc.utctimetuple()) ttl = 60 * 60 * 24 * 3 create_daily_check = { "AWSAccount": awsaccount, 'ExecutedDate': date_format, 'TTL': unixtime + ttl } condition_expression = Attr("AWSAccountID").not_exists().__and__( Attr("ExecutedDate").not_exists()) DB_utils.create(trace_id, Tables.PM_DAILY_CHECK_EXECUTED_AWSACCOUNTS, create_daily_check, condition_expression)
def create_organization(trace_id, organization_id, organization_name, contract, contract_status): common_utils.begin_logger(trace_id, __name__, inspect.currentframe()) # 不要なクラムを作成することを避けるため date_now = common_utils.get_current_date() create_organization = { 'OrganizationID': organization_id, 'OrganizationName': organization_name, 'Contract': contract, 'ContractStatus': contract_status, 'CreatedAt': date_now, 'UpdatedAt': date_now } condition_expression = Attr("OrganizationID").not_exists() DB_utils.create(trace_id, Tables.PM_ORGANIZATIONS, create_organization, condition_expression)
def create_projects(trace_id, project_id, project_name, description, organization_id): common_utils.begin_logger(trace_id, __name__, inspect.currentframe()) date_now = common_utils.get_current_date() # 不要なクラムを作成することを避けるため create_projects = { 'ProjectID': project_id, 'ProjectName': project_name, 'Description': description, 'OrganizationID': organization_id, 'CreatedAt': date_now, 'UpdatedAt': date_now } condition_expression = Attr("ProjectID").not_exists() DB_utils.create(trace_id, Tables.PM_PROJECTS, create_projects, condition_expression)
def create(trace_id, apply_id, before_mail_address, after_mail_address, time_to_live, caller_service_name): common_utils.begin_logger(trace_id, __name__, inspect.currentframe()) # 不要なカラムを作成することを避けるため date_now = common_utils.get_current_date() create_email_change_apply = { 'ApplyID': apply_id, 'UserID': trace_id, 'BeforeMailAddress': before_mail_address, 'AfterMailAddress': after_mail_address, 'TimeToLive': time_to_live, 'CallerServiceName': caller_service_name, 'CreatedAt': date_now, 'UpdatedAt': date_now } DB_utils.create(trace_id, Tables.PM_EMAIL_CHANGE_APPLY, create_email_change_apply)
def create_affiliation(trace_id, email, user_id, organization_id, authority, invitation_status): common_utils.begin_logger(trace_id, __name__, inspect.currentframe()) # 不要なクラムを作成することを避けるため date_now = common_utils.get_current_date() create_affiliation = { "MailAddress": email, "UserID": user_id, "OrganizationID": organization_id, "Authority": authority, "InvitationStatus": invitation_status, 'CreatedAt': date_now, 'UpdatedAt': date_now } condition_expression = Attr("UserID").not_exists().__and__( Attr("OrganizationID").not_exists()) DB_utils.create(trace_id, Tables.PM_AFFILIATION, create_affiliation, condition_expression)
def create_report_job_def(trace_id, code, job_definition, job_queue, max_retry, environment): common_utils.begin_logger(trace_id, __name__, inspect.currentframe()) # 不要なクラムを作成することを避けるため date_now = common_utils.get_current_date() create_report_job_def = { 'Code': code, 'JobDefinition': job_definition, 'JobQueue': job_queue, 'MaxRetry': max_retry, 'Environment': environment, 'CreatedAt': date_now, 'UpdatedAt': date_now } condition_expression = Attr("Code").not_exists() DB_utils.create(trace_id, Tables.PM_BATCH_JOB_DEFS, create_report_job_def, condition_expression)
def create(trace_id, organization_id, project_id, check_history_id, is_cw_logger=False): if (is_cw_logger): common_utils.begin_cw_logger(trace_id, __name__, inspect.currentframe()) else: common_utils.begin_logger(trace_id, __name__, inspect.currentframe()) # 不要なクラムを作成することを避けるため date_now = common_utils.get_current_date() data_create = { 'OrganizationID': organization_id, 'ProjectID': project_id, 'CheckHistoryID': check_history_id, 'CreatedAt': date_now, } DB_utils.create(trace_id, Tables.PM_LATEST_CHECK_RESULT, data_create, is_cw_logger=is_cw_logger)
def create(trace_id, assessment_item_id, organization_id, project_id, aws_account, check_item_code, time_to_live, assessment_comment, user_id, email, account_refine_code): common_utils.begin_logger(trace_id, __name__, inspect.currentframe()) date_now = common_utils.get_current_date() if len(assessment_comment) == 0: assessment_comment = None create_assessment = { 'AssessmentItemID': assessment_item_id, 'OrganizationID': organization_id, 'ProjectID': project_id, 'AWSAccount': aws_account, 'CheckItemCode': check_item_code, 'AssessmentComment': assessment_comment, 'UserID': user_id, 'MailAddress': email, 'AccountRefineCode': account_refine_code, 'TimeToLive': time_to_live, 'CreatedAt': date_now, 'UpdatedAt': date_now } DB_utils.create(trace_id, Tables.PM_ASSESSMENT_ITEMS, create_assessment)
def create(trace_id, security_check_webhook_id, webhook_path, user_id, mail_address, organization_id, project_id, max_daily_executed_count): common_utils.begin_logger(trace_id, __name__, inspect.currentframe()) date_now = common_utils.get_current_date() data_create = { 'SecurityCheckWebhookID': security_check_webhook_id, 'WebhookPath': webhook_path, 'UserID': user_id, 'MailAddress': mail_address, 'OrganizationID': organization_id, 'ProjectID': project_id, 'MaxDailyExecutedCount': max_daily_executed_count, 'Enabled': True, 'CreatedAt': date_now, 'UpdatedAt': date_now } condition_expression = Attr('SecurityCheckWebhookID').not_exists().__and__( Attr('WebhookPath').not_exists()) DB_utils.create(trace_id, Tables.PM_SECURITY_CHECK_WEBHOOK, data_create, condition_expression)
def create(user_id, user_name, company_name, department_name, mail_status, company_flg, country_code, caller_service_name): common_utils.begin_logger(user_id, __name__, inspect.currentframe()) date_now = common_utils.get_current_date() create_user = { 'UserID': user_id, 'UserName': user_name, 'CompanyName': company_name, 'DepartmentName': department_name, 'MailStatus': mail_status, 'CreatedAt': date_now, 'UpdatedAt': date_now } if company_flg is not None: create_user['CompanyFlg'] = company_flg if country_code is not None: create_user['CountryCode'] = country_code if caller_service_name is not None: create_user['CallerServiceName'] = caller_service_name condition_expression = Attr("UserID").not_exists() DB_utils.create(user_id, Tables.PM_USER_ATTRIBUTE, create_user, condition_expression)
def create_awscoops(trace_id, coop_id, aws_account, aws_account_name, role_name, external_id, description, effective, organization_id, project_id): common_utils.begin_logger(trace_id, __name__, inspect.currentframe()) date_now = common_utils.get_current_date() # 不要なクラムを作成することを避けるため create_awscoops = { 'CoopID': coop_id, 'AWSAccount': aws_account, 'AWSAccountName': aws_account_name, 'RoleName': role_name, 'ExternalID': external_id, 'Description': description, 'Effective': effective, 'OrganizationID': organization_id, 'ProjectID': project_id, 'CreatedAt': date_now, 'UpdatedAt': date_now } condition_expression = Attr("CoopID").not_exists() DB_utils.create(trace_id, Tables.PM_AWSACCOUNTCOOPS, create_awscoops, condition_expression)
def create(trace_id, check_history_id, organization_id, project_id, check_code, check_status, error_code, executed_type, report_file_path, executed_date_time, time_to_live, execute_user_id): common_utils.begin_logger(trace_id, __name__, inspect.currentframe()) date_now = common_utils.get_current_date() create_check_history = { 'CheckHistoryID': check_history_id, 'OrganizationID': organization_id, 'ProjectID': project_id, 'CheckCode': check_code, 'CheckStatus': check_status, 'ErrorCode': error_code, 'ExecutedType': executed_type, 'ReportFilePath': report_file_path, 'ExecutedDateTime': executed_date_time, 'ExecuteUserID': execute_user_id, 'TimeToLive': time_to_live, 'CreatedAt': date_now, 'UpdatedAt': date_now } condition_expression = Attr("CheckHistoryID").not_exists() DB_utils.create(trace_id, Tables.PM_CHECK_HISTORY, create_check_history, condition_expression)
def create_organizationTask(trace_id, task_id, code, target, user_id, email, status, retry_count, max_retry, is_cw_logger=False): if (is_cw_logger): common_utils.begin_cw_logger(trace_id, __name__, inspect.currentframe()) else: common_utils.begin_logger(trace_id, __name__, inspect.currentframe()) # 不要なクラムを作成することを避けるため date_now = common_utils.get_current_date() create_organization_task = { "TaskID": task_id, "Code": code, "Target": target, "UserID": user_id, "MailAddress": email, "TaskStatus": status, "RetryCount": retry_count, "MaxRetry": max_retry, "MessageID": None, 'CreatedAt': date_now, 'UpdatedAt': date_now } condition_expression = Attr("TaskID").not_exists() DB_utils.create(trace_id, Tables.PM_ORGANIZATION_TASKS, create_organization_task, condition_expression, is_cw_logger=is_cw_logger)