Source:
public void processEvent(final CloudTrailEvent event) { List<String> instances = CloudTrailEventSupport.getInstances(event); String region = getRegionAsString(event); String amiId = null; AmazonEC2Client amazonEC2Client = cachingClientProvider .getClient( AmazonEC2Client.class, event.getEventData().getAccountId(), Region.getRegion(Regions.fromName(event.getEventData().getAwsRegion()))); for (String instance : instances) { try { amiId = getAmi(instance); } catch (PathNotFoundException e){ LOG.warn("no amiId found"); } DateTime eventDate = getLifecycleDate(event, instance); LifecycleEntity lifecycleEntity = new LifecycleEntity(); if (amiId != null) { String amiName = getAmiName(amazonEC2Client, amiId); lifecycleEntity.setImageId(getAmi(instance)); lifecycleEntity.setImageName(amiName); } lifecycleEntity.setEventType(event.getEventData().getEventName()); lifecycleEntity.setEventDate(eventDate); lifecycleEntity.setAccountId(getAccountId(event)); lifecycleEntity.setRegion(region); lifecycleEntity.setInstanceId(CloudTrailEventSupport.getInstanceId(instance)); ApplicationEntity applicationEntity; VersionEntity versionEntity; try { String versionName = getVersionName(event, instance); versionEntity = new VersionEntity(versionName); String applicationName = getApplicationName(event, instance); applicationEntity = new ApplicationEntity(applicationName); } catch (AmazonServiceException e) { LOG.warn("Could not get version/application for lifecycle event."); return; } if (versionEntity.getName() == null || applicationEntity.getName() == null) { LOG.warn("Lifecycle: UserData does not contain application name or version!"); return; } applicationLifecycleService.saveLifecycle(applicationEntity, versionEntity, lifecycleEntity); } }

Target:
public void processEvent(final CloudTrailEvent event) { List<String> instances = CloudTrailEventSupport.getInstances(event); String region = getRegionAsString(event); AmazonEC2Client amazonEC2Client = clientProvider .getClient( AmazonEC2Client.class, event.getEventData().getAccountId(),CloudTrailEventSupport.getRegion(event)); for (String instance : instances) { String amiId = null; try { amiId = getAmi(instance); } catch (PathNotFoundException e){ LOG.warn("no amiId found for instance {}", instance); } DateTime eventDate = getLifecycleDate(event, instance); LifecycleEntity lifecycleEntity = new LifecycleEntity(); if (amiId != null) { String amiName = getAmiName(amazonEC2Client, amiId); lifecycleEntity.setImageId(amiId); lifecycleEntity.setImageName(amiName); } lifecycleEntity.setEventType(event.getEventData().getEventName()); lifecycleEntity.setEventDate(eventDate); lifecycleEntity.setAccountId(getAccountId(event)); lifecycleEntity.setRegion(region); lifecycleEntity.setInstanceId(CloudTrailEventSupport.getInstanceId(instance)); ApplicationEntity applicationEntity; VersionEntity versionEntity; try { String versionName = getVersionName(event, instance); versionEntity = new VersionEntity(versionName); String applicationName = getApplicationName(event, instance); applicationEntity = new ApplicationEntity(applicationName); } catch (AmazonServiceException e) { LOG.warn("Could not get version/application for lifecycle event."); return; } if (versionEntity.getName() == null || applicationEntity.getName() == null) { LOG.warn("Lifecycle: UserData does not contain application name or version!"); return; } applicationLifecycleService.saveLifecycle(applicationEntity, versionEntity, lifecycleEntity); } }