#!/usr/bin/env python3 import json import sys from deepdiff import DeepDiff tf_plan_json = json.loads(sys.stdin.read()) resources_to_change = [] resources = tf_plan_json['resource_changes'] state_before = {} state_after = {} for resource in resources: if 'change' in resource: if 'actions' in resource['change']: if set(resource['change']['actions']).issubset(['create', 'delete', 'update']): if 'type' in resource and resource['type'] == 'aws_ecs_task_definition': resources_to_change.append({ "before": resource['change']['before'], "after": resource['change']['after'] }) for resource in resources_to_change: before = resource['before'] after = resource['after'] container_definition_before = json.loads(before['container_definitions']) container_definition_after = json.loads(after['container_definitions']) print(DeepDiff(container_definition_before,container_definition_after))