3 Dã\ù ã@s0dZddlmZddlmZGdd„deƒZdS)a¼ Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. é)ÚCloudFormationLintRule)Ú RuleMatchc@s0eZdZdZdZdZdZdZdd gZd d „Z d S)ÚImageIdzCheck if Parameters are usedZW2506z1Check if ImageId Parameters have the correct typez5See if there are any refs for ImageId to a parameter z-of inappropriate type. Appropriate Types are zF[AWS::EC2::Image::Id, AWS::SSM::Parameter::Value]z\https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/best-practices.html#parmtypesÚ parametersZimageidc Csøg}|jdƒ}|jƒ}ddg}dd„|Dƒ}xÆ|D]¾}|d}t|tƒr2t|ƒdkr¼xš|jƒD]X\}} |dkr^| |kr^|| d|kr^d | d jtt|ƒƒf} d | g} |j t | | ƒƒq^Wq2d d jtt|dd…ƒƒ} |j t |dd…| ƒƒq2W|S)z'Check CloudFormation ImageId ParametersrzAWS::EC2::Image::Idz/AWS::SSM::Parameter::ValuecSsg|]}|ddkr|‘qS)rZ Resources©)Ú.0Úxrrú„/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/cfn-lint/cfnlint/rules/resources/properties/ImageId.pyú ,sz!ImageId.match..éZRefÚTypez#Parameter %s should be of type [%s]z, Z Parametersz)Inappropriate map found for ImageId on %sú/Néÿÿÿÿrr) Zsearch_deep_keysZget_valid_refsÚ isinstanceÚdictÚlenÚitemsÚjoinÚmapÚstrÚappendr) ÚselfZcfnÚmatchesZ imageidtreesZ valid_refsZ allowed_typesZ imageidtreeZ imageidobjÚkeyZ paramnameÚmessageÚtreerrr Úmatchs,    z ImageId.matchNzbSee if there are any refs for ImageId to a parameter of inappropriate type. Appropriate Types are z¨See if there are any refs for ImageId to a parameter of inappropriate type. Appropriate Types are [AWS::EC2::Image::Id, AWS::SSM::Parameter::Value]) Ú__name__Ú __module__Ú __qualname__Ú__doc__ÚidZ shortdescÚ descriptionZ source_urlÚtagsrrrrr rsrN)r Zcfnlintrrrrrrr Ús