From 492a43287141a411b5619b75c596fda528604130 Mon Sep 17 00:00:00 2001 From: Alex Chantavy Date: Mon, 17 Jun 2024 14:25:28 -0700 Subject: [PATCH] #1302: add missing cleanup job for launchtemplates (#1315) Adds missing cleanup job. (Sorry for the mistake) --- cartography/intel/aws/ec2/launch_templates.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cartography/intel/aws/ec2/launch_templates.py b/cartography/intel/aws/ec2/launch_templates.py index a78404bc74..59aee54119 100644 --- a/cartography/intel/aws/ec2/launch_templates.py +++ b/cartography/intel/aws/ec2/launch_templates.py @@ -6,6 +6,7 @@ from .util import get_botocore_config from cartography.client.core.tx import load +from cartography.graph.job import GraphJob from cartography.models.aws.ec2.launch_template_versions import LaunchTemplateVersionSchema from cartography.models.aws.ec2.launch_templates import LaunchTemplateSchema from cartography.util import aws_handle_regions @@ -114,6 +115,16 @@ def load_launch_template_versions( ) +@timeit +def cleanup(neo4j_session: neo4j.Session, common_job_parameters: dict[str, Any]) -> None: + logger.info("Running launch template cleanup job.") + cleanup_job = GraphJob.from_node_schema(LaunchTemplateSchema(), common_job_parameters) + cleanup_job.run(neo4j_session) + + cleanup_job = GraphJob.from_node_schema(LaunchTemplateVersionSchema(), common_job_parameters) + cleanup_job.run(neo4j_session) + + @timeit def sync_ec2_launch_templates( neo4j_session: neo4j.Session, @@ -132,3 +143,5 @@ def sync_ec2_launch_templates( versions = get_launch_template_versions(boto3_session, templates, region) versions = transform_launch_template_versions(versions) load_launch_template_versions(neo4j_session, versions, region, current_aws_account_id, update_tag) + + cleanup(neo4j_session, common_job_parameters)