3 D\k@s@dZddlZddlZddlmZddlmZGdddeZdS)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@s:eZdZdZdZdZdZdZdddgZd d Z d d Z d S)Ebsz$Check if Ec2 Ebs Resource PropertiesZE2504zCheck Ec2 Ebs Propertiesz#See if Ec2 Eb2 Properties are validzhhttps://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-blockdev-template.html propertiesZec2ebsc Csg}t|tr|j|d}|j|d}|dk rx|D]}|jd}t|tjr4|dkr|dkr|dddg} d} |jt| | jdj t t | q4|r4|dk r4|dddg} d} |jt| | j|dj t t | q4W|S)NZ VolumeTypeZIopsValueZio1z4VolumeType io1 requires Iops to be specified for {0}/z.Iops shouldn't be defined for type {0} for {1}) isinstancedictZ get_valuesgetsix string_typesappendrformatjoinmapstr) selfcfnrpathmatchesZvolume_types_objZiops_objZvolume_type_objZ volume_type pathmessagemessager{/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/cfn-lint/cfnlint/rules/resources/ectwo/Ebs.py _checkEbss.        z Ebs._checkEbsc Csg}|jddg}|j|jddgx|D]}|d}xt|dD]\}}|jd}|jd} |rtjd|s|d d |dg} d } |jt| | jd j t t | qF| rF|j|j || |d d |dgqFWq,W|S) z!Check Ec2 Ebs Resource ParameterszAWS::EC2::InstanceZBlockDeviceMappingsz%AWS::AutoScaling::LaunchConfigurationPathrZ VirtualNamerz^ephemeral[0-9]$Nz;Property VirtualName should be of type ephemeral(n) for {0}r) Zget_resource_propertiesextend enumerater rematchrrrrrrr) rrrresultsresultrindexrZ virtual_namerrrrrrr :s"     ,z Ebs.matchN) __name__ __module__ __qualname____doc__idZ shortdesc descriptionZ source_urltagsrr rrrrrs r)r'rr Zcfnlintrrrrrrrs