Skip to content

Commit

Permalink
cartography-cncf#1302: add missing cleanup job for launchtemplates (c…
Browse files Browse the repository at this point in the history
…artography-cncf#1315)

Adds missing cleanup job. 

(Sorry for the mistake)
  • Loading branch information
achantavy authored and tmsteere committed Aug 8, 2024
1 parent 7d658d9 commit 492a432
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 @@ -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
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 492a432

Please sign in to comment.