Skip to content

Commit

Permalink
#1302: add missing cleanup job for launchtemplates
Browse files Browse the repository at this point in the history
  • Loading branch information
achantavy committed Jun 17, 2024
1 parent 098d8ca commit 2b10062
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cartography/intel/aws/ec2/launch_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import boto3
import neo4j

from cartography.graph.job import GraphJob
from .util import get_botocore_config
from cartography.client.core.tx import load
from cartography.models.aws.ec2.launch_template_versions import LaunchTemplateVersionSchema
Expand Down Expand Up @@ -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,
Expand All @@ -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)

0 comments on commit 2b10062

Please sign in to comment.