# Buggy code
def get_asg_templates(self, asgs):
    templates = {}
    for a in asgs:
        t = None
        if "LaunchTemplate" in a:
            t = a["LaunchTemplate"]
        elif "MixedInstancesPolicy" in a:
            t = a["MixedInstancesPolicy"]["LaunchTemplate"][
                "LaunchTemplateSpecification"
            ]
        if t is None:
            continue
        templates.setdefault(
            (t["LaunchTemplateId"], t.get("Version", None)), []
        ).append(a["AutoScalingGroupName"])
    return templates


# Traceback (KeyError)
Traceback (most recent call last):
File "/home/cloudcustodian/custodian/bin/c7n-org", line 11, in <module>
sys.exit(cli())
File "/home/cloudcustodian/custodian/lib/python3.6/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/cloudcustodian/custodian/lib/python3.6/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/cloudcustodian/custodian/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/cloudcustodian/custodian/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/cloudcustodian/custodian/lib/python3.6/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/cloudcustodian/custodian/lib/python3.6/site-packages/c7n_org/cli.py", line 649, in run
debug)] = (a, r)
File "/home/cloudcustodian/custodian/lib/python3.6/site-packages/c7n/executor.py", line 63, in submit
return MainThreadFuture(func(*args, **kw))
File "/home/cloudcustodian/custodian/lib/python3.6/site-packages/c7n_org/cli.py", line 560, in run_account
resources = p.run()
File "/home/cloudcustodian/custodian/lib/python3.6/site-packages/c7n/policy.py", line 1045, in __call__
resources = PullMode(self).run()
File "/home/cloudcustodian/custodian/lib/python3.6/site-packages/c7n/policy.py", line 288, in run
resources = self.policy.resource_manager.resources()
File "/home/cloudcustodian/custodian/lib/python3.6/site-packages/c7n/query.py", line 467, in resources
resources = self.filter_resources(resources)
File "/home/cloudcustodian/custodian/lib/python3.6/site-packages/c7n/manager.py", line 108, in filter_resources
resources = f.process(resources, event)
File "/home/cloudcustodian/custodian/lib/python3.6/site-packages/c7n/resources/asg.py", line 832, in process
launch_info = LaunchInfo(self.manager).initialize(asgs)
File "/home/cloudcustodian/custodian/lib/python3.6/site-packages/c7n/resources/asg.py", line 85, in initialize
self.templates = self.get_launch_templates(asgs)
File "/home/cloudcustodian/custodian/lib/python3.6/site-packages/c7n/resources/asg.py", line 92, in get_launch_templates
template_ids = list(tmpl_mgr.get_asg_templates(asgs))
File "/home/cloudcustodian/custodian/lib/python3.6/site-packages/c7n/resources/ec2.py", line 1956, in get_asg_templates
t['Version']), []).append(a['AutoScalingGroupName'])
KeyError: 'Version'

# Fixed code
def get_asg_templates(self, asgs):
    templates = {}
    for a in asgs:
        t = None
        if "LaunchTemplate" in a:
            t = a["LaunchTemplate"]
        elif "MixedInstancesPolicy" in a:
            t = a["MixedInstancesPolicy"]["LaunchTemplate"][
                "LaunchTemplateSpecification"
            ]
        if t is None:
            continue
        templates.setdefault(
            (t["LaunchTemplateId"], t.get("Version", "$Default")), []
        ).append(a["AutoScalingGroupName"])
    return templates