<s> from . import AWSHelperFn , AWSObject , AWSProperty , If , FindInMap , Ref <EOL> from . validators import boolean , integer <EOL> from . import cloudformation <EOL> EC2_INSTANCE_LAUNCH = "<STR_LIT>" <EOL> EC2_INSTANCE_LAUNCH_ERROR = "<STR_LIT>" <EOL> EC2_INSTANCE_TERMINATE = "<STR_LIT>" <EOL> EC2_INSTANCE_TERMINATE_ERROR = "<STR_LIT>" <EOL> TEST_NOTIFICATION = "<STR_LIT>" <EOL> Default = '<STR_LIT>' <EOL> OldestInstance = '<STR_LIT>' <EOL> NewestInstance = '<STR_LIT>' <EOL> OldestLaunchConfiguration = '<STR_LIT>' <EOL> ClosestToNextInstanceHour = '<STR_LIT>' <EOL> class Tag ( AWSHelperFn ) : <EOL> def __init__ ( self , key , value , propogate ) : <EOL> self . data = { <EOL> '<STR_LIT>' : key , <EOL> '<STR_LIT>' : value , <EOL> '<STR_LIT>' : propogate , <EOL> } <EOL> def JSONrepr ( self ) : <EOL> return self . data <EOL> class Tags ( AWSHelperFn ) : <EOL> defaultPropagateAtLaunch = True <EOL> manyType = [ type ( [ ] ) , type ( ( ) ) ] <EOL> def __init__ ( self , ** kwargs ) : <EOL> self . tags = [ ] <EOL> for k , v in sorted ( kwargs . iteritems ( ) ) : <EOL> if type ( v ) in self . manyType : <EOL> propagate = str ( v [ <NUM_LIT:1> ] ) . lower ( ) <EOL> v = v [ <NUM_LIT:0> ] <EOL> else : <EOL> propagate = str ( self . defaultPropagateAtLaunch ) . lower ( ) <EOL> self . tags . append ( { <EOL> '<STR_LIT>' : k , <EOL> '<STR_LIT>' : v , <EOL> '<STR_LIT>' : propagate , <EOL> } ) <EOL> def __add__ ( self , newtags ) : <EOL> newtags . tags = self . tags + newtags . tags <EOL> return newtags <EOL> def JSONrepr ( self ) : <EOL> return self . tags <EOL> class NotificationConfigurations ( AWSProperty ) : <EOL> props = { <EOL> '<STR_LIT>' : ( basestring , True ) , <EOL> '<STR_LIT>' : ( list , True ) , <EOL> } <EOL> class MetricsCollection ( AWSProperty ) : <EOL> props = { <EOL> '<STR_LIT>' : ( basestring , True ) , <EOL> '<STR_LIT>' : ( list , False ) , <EOL> } <EOL> class Metadata ( AWSHelperFn ) : <EOL> def __init__ ( self , init , authentication = None ) : <EOL> self . validate ( init , authentication ) <EOL> if len ( init . data ) == <NUM_LIT:1> : <EOL> initKey , initValue = init . data . popitem ( ) <EOL> self . data = { initKey : initValue } <EOL> else : <EOL> self . data = init . data <EOL> if authentication : <EOL> authKey , authValue = authentication . data . popitem ( ) <EOL> self . data [ authKey ] = authValue <EOL> def validate ( self , init , authentication ) : <EOL> if not isinstance ( init , cloudformation . Init ) : <EOL> raise ValueError ( <EOL> '<STR_LIT>' <EOL> ) <EOL> is_instance = isinstance ( authentication , cloudformation . Authentication ) <EOL> if authentication and not is_instance : <EOL> raise ValueError ( <EOL> '<STR_LIT>' <EOL> ) <EOL> def JSONrepr ( self ) : <EOL> return self . data <EOL> class AutoScalingGroup ( AWSObject ) : <EOL> resource_type = "<STR_LIT>" <EOL> props = { <EOL> '<STR_LIT>' : ( list , False ) , <EOL> '<STR_LIT>' : ( integer , False ) , <EOL> '<STR_LIT>' : ( integer , False ) , <EOL> '<STR_LIT>' : ( integer , False ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> '<STR_LIT>' : ( list , False ) , <EOL> '<STR_LIT>' : ( integer , True ) , <EOL> '<STR_LIT>' : ( [ MetricsCollection ] , False ) , <EOL> '<STR_LIT>' : ( integer , True ) , <EOL> '<STR_LIT>' : ( [ NotificationConfigurations ] , False ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> '<STR_LIT>' : ( list , False ) , <EOL> '<STR_LIT>' : ( [ basestring ] , False ) , <EOL> '<STR_LIT>' : ( list , False ) , <EOL> } <EOL> def validate ( self ) : <EOL> if '<STR_LIT>' in self . resource : <EOL> update_policy = self . resource [ '<STR_LIT>' ] <EOL> if '<STR_LIT>' in update_policy . properties : <EOL> rolling_update = update_policy . AutoScalingRollingUpdate <EOL> isMinNoCheck = isinstance ( <EOL> rolling_update . MinInstancesInService , <EOL> ( FindInMap , Ref ) <EOL> ) <EOL> isMaxNoCheck = isinstance ( self . MaxSize , ( If , FindInMap , Ref ) ) <EOL> if not ( isMinNoCheck or isMaxNoCheck ) : <EOL> maxCount = int ( self . MaxSize ) <EOL> minCount = int ( rolling_update . MinInstancesInService ) <EOL> if minCount >= maxCount : <EOL> raise ValueError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> launch_config = self . properties . get ( '<STR_LIT>' ) <EOL> instance_id = self . properties . get ( '<STR_LIT>' ) <EOL> if launch_config and instance_id : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> if not launch_config and not instance_id : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> availability_zones = self . properties . get ( '<STR_LIT>' ) <EOL> vpc_zone_identifier = self . properties . get ( '<STR_LIT>' ) <EOL> if not availability_zones and not vpc_zone_identifier : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> return True <EOL> class LaunchConfiguration ( AWSObject ) : <EOL> resource_type = "<STR_LIT>" <EOL> props = { <EOL> '<STR_LIT>' : ( boolean , False ) , <EOL> '<STR_LIT>' : ( list , False ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> '<STR_LIT>' : ( [ basestring ] , False ) , <EOL> '<STR_LIT>' : ( boolean , False ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> '<STR_LIT>' : ( basestring , True ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> '<STR_LIT>' : ( boolean , False ) , <EOL> '<STR_LIT>' : ( basestring , True ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> '<STR_LIT>' : ( Metadata , False ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> '<STR_LIT>' : ( list , False ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> } <EOL> class StepAdjustments ( AWSProperty ) : <EOL> props = { <EOL> '<STR_LIT>' : ( integer , False ) , <EOL> '<STR_LIT>' : ( integer , False ) , <EOL> '<STR_LIT>' : ( integer , True ) , <EOL> } <EOL> class ScalingPolicy ( AWSObject ) : <EOL> resource_type = "<STR_LIT>" <EOL> props = { <EOL> '<STR_LIT>' : ( basestring , True ) , <EOL> '<STR_LIT>' : ( basestring , True ) , <EOL> '<STR_LIT>' : ( integer , False ) , <EOL> '<STR_LIT>' : ( integer , False ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> '<STR_LIT>' : ( integer , False ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> '<STR_LIT>' : ( integer , False ) , <EOL> '<STR_LIT>' : ( [ StepAdjustments ] , False ) , <EOL> } <EOL> class ScheduledAction ( AWSObject ) : <EOL> resource_type = "<STR_LIT>" <EOL> props = { <EOL> '<STR_LIT>' : ( basestring , True ) , <EOL> '<STR_LIT>' : ( integer , False ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> '<STR_LIT>' : ( integer , False ) , <EOL> '<STR_LIT>' : ( integer , False ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> } <EOL> class LifecycleHook ( AWSObject ) : <EOL> resource_type = "<STR_LIT>" <EOL> props = { <EOL> '<STR_LIT>' : ( basestring , True ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> '<STR_LIT>' : ( integer , False ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> '<STR_LIT>' : ( basestring , True ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> '<STR_LIT>' : ( basestring , True ) , <EOL> '<STR_LIT>' : ( basestring , True ) , <EOL> } <EOL> class Trigger ( AWSObject ) : <EOL> resource_type = "<STR_LIT>" <EOL> props = { <EOL> '<STR_LIT>' : ( basestring , True ) , <EOL> '<STR_LIT>' : ( integer , True ) , <EOL> '<STR_LIT>' : ( list , True ) , <EOL> '<STR_LIT>' : ( integer , False ) , <EOL> '<STR_LIT>' : ( integer , True ) , <EOL> '<STR_LIT>' : ( basestring , True ) , <EOL> '<STR_LIT>' : ( basestring , True ) , <EOL> '<STR_LIT>' : ( integer , True ) , <EOL> '<STR_LIT>' : ( basestring , True ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> '<STR_LIT>' : ( integer , False ) , <EOL> '<STR_LIT>' : ( integer , True ) , <EOL> } <EOL> class EBSBlockDevice ( AWSProperty ) : <EOL> props = { <EOL> '<STR_LIT>' : ( boolean , False ) , <EOL> '<STR_LIT>' : ( boolean , False ) , <EOL> '<STR_LIT>' : ( integer , False ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> '<STR_LIT>' : ( integer , False ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> } <EOL> class BlockDeviceMapping ( AWSProperty ) : <EOL> props = { <EOL> '<STR_LIT>' : ( basestring , True ) , <EOL> '<STR_LIT>' : ( EBSBlockDevice , False ) , <EOL> '<STR_LIT>' : ( boolean , False ) , <EOL> '<STR_LIT>' : ( basestring , False ) , <EOL> } </s>
