3 D\@s@dZddlZddlmZddlmZddlZGdddeZdS)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. N)CloudFormationLintRule) RuleMatchcsHeZdZdZdZdZdZdZddgZfdd Z d d Z d d Z Z S)GetAttz"Check if GetAtt values are correctZE1010zGetAtt validation of parameterszYValidates that GetAtt parameters are to valid resources and properties of those resourceszghttps://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.htmlZ functionsgetattcstt|jg|_g|_dS)zInit N)superr__init__ propertytypes resourcetypes)self) __class__x/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/cfn-lint/cfnlint/rules/functions/GetAtt.pyrszGetAtt.__init__cCs*tjj|jd}|d|_|d|_dS)NrZ ResourceTypesZ PropertyTypes)cfnlintZhelpersZRESOURCE_SPECSZregionsr r)r cfnZ resourcespecsr r r initialize%s zGetAtt.initializec Cs`g}|jd}|j}dg}x<|D]2}t|ddkrjd}|jt||jdjtt|ddq$t |dt j r|dj d\}} nFd}d} t |ddt j r|dd }dj|ddd} nt |ddt r|dd }|dd} t| dkrhx| jD]L} | |krd }|jt||jd jtt|djtt|ddqWn4d }|jt||j|ddjtt|ddd} n4d }|jt||j|ddjtt|dd|r$||kr6| dk rX| ||krXd ||krXd}|jt|dd|j|| |dq$d}|jt||j|| |dq$W|S)zCheck CloudFormation GetAttz Fn::GetAttZRefzInvalid GetAtt for {0}/N.rz:GetAtt only supports functions "{0}" for attributes at {1}z, z#Invalid GetAtt structure {0} at {1}*z'Invalid GetAtt {0}.{1} for resource {2}rrrrrrrrrrrrrrr)Zsearch_deep_keysZget_valid_getattslenappendrformatjoinmapstr isinstancesix string_typessplitdictkeys) r rmatchesZgetattsZ valid_getattsZvalid_attribute_functionsrmessageresnamerestypekr r r match*sX *    &00  ""z GetAtt.match) __name__ __module__ __qualname____doc__idZ shortdesc descriptionZ source_urltagsrrr( __classcell__r r )r r rs r)r,rrrrZcfnlint.helpersrr r r r s