def match()

in cfn-lint-custom-rules/rules/AMSRequiredAttributes.py [0:0]


    def match(self, cfn):
        """Check CloudFormation Resources"""

        matches = []
        required_attributes = {"AWS::Elasticsearch::Domain": ["VPCOptions"]}

        for resource_name, resource_values in cfn.template.get("Resources", {}).items():

            self.logger.debug("Validating Properties for %s resource", resource_name)

            matched = False
            resource_type = resource_values.get("Type", "")

            if resource_type in required_attributes.keys():
                check_attributes = required_attributes[resource_type]
                resource_attributes = set(
                    [attribute for attribute, _ in resource_values["Properties"].items()]
                )

                for attribute in check_attributes:
                    if attribute not in resource_attributes:
                        matched = True
                        break

                if matched:
                    message = "AMS - Resource {} missing one of required property attributes: {}."
                    matches.append(
                        RuleMatch(
                            ["Resources", resource_name],
                            message.format(resource_type, check_attributes),
                        )
                    )

        return matches