class AwsIamService {

    public InstanceProfile getInstanceProfile(AmazonIdentityManagement iam, String instanceProfileArn,
            ValidationResultBuilder validationResultBuilder) {
        InstanceProfile instanceProfile = null;
        if (instanceProfileArn != null && instanceProfileArn.contains("/")) {
            String instanceProfileName = instanceProfileArn.split("/", 2)[1];
            GetInstanceProfileRequest instanceProfileRequest = new GetInstanceProfileRequest()
                    .withInstanceProfileName(instanceProfileName);
            try {
                instanceProfile = iam.getInstanceProfile(instanceProfileRequest).getInstanceProfile();
            } catch (NoSuchEntityException | ServiceFailureException e) {
                String msg = String.format("Instance profile (%s) doesn't exist.", instanceProfileArn);
                LOGGER.error(msg, e);
                validationResultBuilder.error(msg);
            }
        }
        return instanceProfile;
    }

}