class IAMAccessGrantForNonAdminAccountRule extends BaseRule {

    public RuleResult execute(final Map<String, String> ruleParam,
            Map<String, String> resourceAttributes) {

        logger.debug("========IAMAccessGrantForNonAdminAccountRule started=========");
        Map<String, String> ruleParamforIAM = new HashMap<>();
        ruleParamforIAM.putAll(ruleParam);
        ruleParamforIAM.put("region", "us-west-2");

        Map<String, Object> map = null;
        AmazonIdentityManagementClient iamClient = null;
        String roleIdentifyingString = ruleParamforIAM
                .get(PacmanSdkConstants.Role_IDENTIFYING_STRING);
        String roleName = resourceAttributes.get(PacmanRuleConstants.ROLE_NAME);
        String adminRolesToCompare = ruleParamforIAM
                .get(PacmanRuleConstants.ADMIN_ROLES_TO_COMPARE);

        String severity = ruleParamforIAM.get(PacmanRuleConstants.SEVERITY);
        String category = ruleParamforIAM.get(PacmanRuleConstants.CATEGORY);

        MDC.put("executionId", ruleParam.get("executionId")); 
        MDC.put("ruleId", ruleParam.get(PacmanSdkConstants.RULE_ID)); 

        List<LinkedHashMap<String, Object>> issueList = new ArrayList<>();
        LinkedHashMap<String, Object> issue = new LinkedHashMap<>();

        if (!PacmanUtils.doesAllHaveValue(adminRolesToCompare, severity,
                category)) {
            logger.info(PacmanRuleConstants.MISSING_CONFIGURATION);
            throw new InvalidInputException(PacmanRuleConstants.MISSING_CONFIGURATION);
        }

        Annotation annotation = null;

        List<AttachedPolicy> attachedRolePolicies = new ArrayList<>();
        String message = null;
        List<String> adminRoleListToCompare = PacmanUtils.splitStringToAList(
                adminRolesToCompare, ",");

        try {
            map = getClientFor(AWSService.IAM, roleIdentifyingString,
                    ruleParamforIAM);
            iamClient = (AmazonIdentityManagementClient) map
                    .get(PacmanSdkConstants.CLIENT);
        } catch (UnableToCreateClientException e) {
            logger.error("unable to get client for following input", e);
            throw new InvalidInputException(e.toString());
        }

        if (!adminRoleListToCompare.contains(roleName)) {
            ListAttachedRolePoliciesRequest request = new ListAttachedRolePoliciesRequest();
            ListAttachedRolePoliciesResult result = null;
            request.setRoleName(roleName);

            // Disabling pagination. Otherwise it fetches only the first 100
            // records.
            do {
                result = iamClient.listAttachedRolePolicies(request);
                attachedRolePolicies.addAll(result.getAttachedPolicies());
                request.setMarker(result.getMarker());
            } while (result.isTruncated());

            if (!CollectionUtils.isNullOrEmpty(attachedRolePolicies)) {
                if (isValidPoliciesForNonAdminRole(attachedRolePolicies)
                        || isIAMFullAccessFoundAfterThoroughCheck(iamClient,
                                attachedRolePolicies)) {
                    message = "Role " + roleName + " has IAM full access";
                    logger.warn(message);
                    annotation = Annotation.buildAnnotation(ruleParam,
                            Annotation.Type.ISSUE);
                    annotation.put(PacmanSdkConstants.DESCRIPTION,
                            "Non-admin roles with IAMFullAccess found");
                    annotation.put(PacmanRuleConstants.SEVERITY, severity);
                    annotation.put(PacmanRuleConstants.CATEGORY, category);

                    issue.put(PacmanRuleConstants.VIOLATION_REASON,
                            "Non-admin roles with IAMFullAccess found");
                    issueList.add(issue);
                    annotation.put("issueDetails", issueList.toString());

                    return new RuleResult(PacmanSdkConstants.STATUS_FAILURE,
                            PacmanRuleConstants.FAILURE_MESSAGE, annotation);
                }
            } else {
                logger.info(roleName , "This Role has no policies attached");
            }
        } else {
            logger.info("Admin role found");
        }

        return new RuleResult(PacmanSdkConstants.STATUS_SUCCESS,
                PacmanRuleConstants.SUCCESS_MESSAGE);
    }

}