3 Dã\ã@s8dZddlZddlmZddlmZGdd„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. éN)ÚCloudFormationLintRule)Ú RuleMatchc@s8eZdZdZdZdZdZdZddgZdd „Z d d „Z d S) ÚUpdateReplacePolicyz!Check Base Resource ConfigurationZE3036z.Check UpdateReplacePolicy values for Resourcesz3Check that the UpdateReplacePolicy values are validzehttps://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatereplacepolicy.htmlÚ resourcesZupdatereplacepolicyc CsÔg}dddg}dddddd d g}t|tjtjfƒs\d }|jt||jd jtt |ƒƒƒƒƒ|S||kr˜d }|jt||jdjtt |ƒƒd jtt |ƒƒƒƒƒ|dkrÐ||krÐd}|jt||j|d jtt |ƒƒƒƒƒ|S)z,Check resource names for UpdateReplacePolicyÚDeleteZRetainZSnapshotzAWS::EC2::VolumezAWS::ElastiCache::CacheClusterz"AWS::ElastiCache::ReplicationGroupzAWS::Neptune::DBClusterzAWS::RDS::DBClusterzAWS::RDS::DBInstancezAWS::Redshift::Clusterz5UpdateReplacePolicy values should be of string at {0}ú/z4UpdateReplacePolicy should be only one of {0} at {1}z, zGUpdateReplacePolicy cannot be Snapshot for resources of type {0} at {1}) Ú isinstanceÚsixÚ text_typeÚ string_typesÚappendrÚformatÚjoinÚmapÚstr)ÚselfÚkeyÚpathÚres_typeÚmatchesZ valid_valuesZvalid_snapshot_typesÚmessage©rú…/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/cfn-lint/cfnlint/rules/resources/UpdateReplacePolicy.pyÚ check_values8"zUpdateReplacePolicy.check_valuec Csœg}|jƒ}xŠ|jƒD]~\}}|jdƒ}|rd|dg}|jdƒ}|jjd|ƒt|tƒr€d} |jt|| j dj t t |ƒƒƒƒƒq|j |j|||ƒƒqW|S)zCheck CloudFormation ResourcesrZ ResourcesÚTypez8Validating UpdateReplacePolicy for %s base configurationz8Only one UpdateReplacePolicy allowed per resource at {0}r)Ú get_resourcesÚitemsÚgetÚloggerÚdebugrÚlistr rr rrrÚextendr) rZcfnrrÚ resource_nameZresource_valuesZupdatereplace_policiesrrrrrrÚmatchDs    $zUpdateReplacePolicy.matchN) Ú__name__Ú __module__Ú __qualname__Ú__doc__ÚidZ shortdescÚ descriptionZ source_urlÚtagsrr#rrrrrs&r)r'r ZcfnlintrrrrrrrÚs