We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
AutoScalingRollingUpdate with 'If' Aws Helper Condition fail during validate
Hi, in autoscalinggroup  UpdatePolicy if i have a AutoScalingRollingUpdate with a IF AWS Helper Condition it fails during validate with:
##
AttributeError: 'If' object has no attribute 'MinInstancesInService'
##

Example code:
##
                AutoScalingRollingUpdate=If(
                    'RollingUpdate',
                    pol.AutoScalingRollingUpdate(
                        MaxBatchSize=get_mapped_value('RollingUpdateMaxBatchSize'),
                        MinInstancesInService=get_mapped_value('RollingUpdateMinInstancesInService'),
                        MinSuccessfulInstancesPercent=get_mapped_value('RollingUpdateMinSuccessfulInstancesPercent'),
                        PauseTime=get_mapped_value('RollingUpdatePauseTime'),
                        SuspendProcesses=[
                            'HealthCheck',
                            'ReplaceUnhealthy',
                            'AlarmNotification',
                            'ScheduledActions'
                        ],
                        WaitOnResourceSignals=True
                    ),
                    Ref('AWS::NoValue')
                ),
##

To solve issue, in troposphere/autoscaling.py function validate should be:
```
diff --git a/troposphere/autoscaling.py b/troposphere/autoscaling.py
index cc5873f..8f7a43d 100644
--- a/troposphere/autoscaling.py
+++ b/troposphere/autoscaling.py
@@ -136,7 +136,8 @@ class AutoScalingGroup(AWSObject):
             update_policy = self.resource['UpdatePolicy']
 
             if (not isinstance(update_policy, AWSHelperFn) and
-                    'AutoScalingRollingUpdate' in update_policy.properties):
+                    'AutoScalingRollingUpdate' in update_policy.properties and
+                    not isinstance(update_policy.AutoScalingRollingUpdate, AWSHelperFn)):
                 rolling_update = update_policy.AutoScalingRollingUpdate
 
                 isMinNoCheck = isinstance(
```
##

Regards, Alberto.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `troposphere/autoscaling.py`
Content:
```
1 # Copyright (c) 2012-2013, Mark Peek <mark@peek.org>
2 # All rights reserved.
3 #
4 # See LICENSE file for full license.
5 
6 from . import AWSHelperFn, AWSObject, AWSProperty, If, FindInMap, Ref
7 from .validators import boolean, integer
8 from . import cloudformation
9 
10 
11 EC2_INSTANCE_LAUNCH = "autoscaling:EC2_INSTANCE_LAUNCH"
12 EC2_INSTANCE_LAUNCH_ERROR = "autoscaling:EC2_INSTANCE_LAUNCH_ERROR"
13 EC2_INSTANCE_TERMINATE = "autoscaling:EC2_INSTANCE_TERMINATE"
14 EC2_INSTANCE_TERMINATE_ERROR = "autoscaling:EC2_INSTANCE_TERMINATE_ERROR"
15 TEST_NOTIFICATION = "autoscaling:TEST_NOTIFICATION"
16 
17 # Termination Policy constants
18 Default = 'Default'
19 OldestInstance = 'OldestInstance'
20 NewestInstance = 'NewestInstance'
21 OldestLaunchConfiguration = 'OldestLaunchConfiguration'
22 ClosestToNextInstanceHour = 'ClosestToNextInstanceHour'
23 
24 
25 class Tag(AWSHelperFn):
26     def __init__(self, key, value, propogate):
27         self.data = {
28             'Key': key,
29             'Value': value,
30             'PropagateAtLaunch': propogate,
31         }
32 
33     def JSONrepr(self):
34         return self.data
35 
36 
37 class Tags(AWSHelperFn):
38     defaultPropagateAtLaunch = True
39     manyType = [type([]), type(())]
40 
41     def __init__(self, **kwargs):
42         self.tags = []
43         for k, v in sorted(kwargs.iteritems()):
44             if type(v) in self.manyType:
45                 propagate = str(v[1]).lower()
46                 v = v[0]
47             else:
48                 propagate = str(self.defaultPropagateAtLaunch).lower()
49             self.tags.append({
50                 'Key': k,
51                 'Value': v,
52                 'PropagateAtLaunch': propagate,
53             })
54 
55     # append tags to list
56     def __add__(self, newtags):
57         newtags.tags = self.tags + newtags.tags
58         return newtags
59 
60     def JSONrepr(self):
61         return self.tags
62 
63 
64 class NotificationConfigurations(AWSProperty):
65     props = {
66         'TopicARN': (basestring, True),
67         'NotificationTypes': (list, True),
68     }
69 
70 
71 class MetricsCollection(AWSProperty):
72     props = {
73         'Granularity': (basestring, True),
74         'Metrics': (list, False),
75     }
76 
77 
78 class Metadata(AWSHelperFn):
79     def __init__(self, init, authentication=None):
80         self.validate(init, authentication)
81         # get keys and values from init and authentication
82 
83         # if there's only one data point, then we know its the default
84         # cfn-init; where the key is 'config'
85         if len(init.data) == 1:
86             initKey, initValue = init.data.popitem()
87             self.data = {initKey: initValue}
88         else:
89             self.data = init.data
90 
91         if authentication:
92             authKey, authValue = authentication.data.popitem()
93             self.data[authKey] = authValue
94 
95     def validate(self, init, authentication):
96         if not isinstance(init, cloudformation.Init):
97             raise ValueError(
98                 'init must be of type cloudformation.Init'
99             )
100 
101         is_instance = isinstance(authentication, cloudformation.Authentication)
102         if authentication and not is_instance:
103             raise ValueError(
104                 'authentication must be of type cloudformation.Authentication'
105             )
106 
107     def JSONrepr(self):
108         return self.data
109 
110 
111 class AutoScalingGroup(AWSObject):
112     resource_type = "AWS::AutoScaling::AutoScalingGroup"
113 
114     props = {
115         'AvailabilityZones': (list, False),
116         'Cooldown': (integer, False),
117         'DesiredCapacity': (integer, False),
118         'HealthCheckGracePeriod': (integer, False),
119         'HealthCheckType': (basestring, False),
120         'InstanceId': (basestring, False),
121         'LaunchConfigurationName': (basestring, False),
122         'LoadBalancerNames': (list, False),
123         'MaxSize': (integer, True),
124         'MetricsCollection': ([MetricsCollection], False),
125         'MinSize': (integer, True),
126         'NotificationConfigurations': ([NotificationConfigurations], False),
127         'PlacementGroup': (basestring, False),
128         'Tags': (list, False),
129         'TargetGroupARNs': ([basestring], False),
130         'TerminationPolicies': ([basestring], False),
131         'VPCZoneIdentifier': (list, False),
132     }
133 
134     def validate(self):
135         if 'UpdatePolicy' in self.resource:
136             update_policy = self.resource['UpdatePolicy']
137 
138             if (not isinstance(update_policy, AWSHelperFn) and
139                     'AutoScalingRollingUpdate' in update_policy.properties):
140                 rolling_update = update_policy.AutoScalingRollingUpdate
141 
142                 isMinNoCheck = isinstance(
143                     rolling_update.MinInstancesInService,
144                     (FindInMap, Ref)
145                 )
146                 isMaxNoCheck = isinstance(self.MaxSize, (If, FindInMap, Ref))
147 
148                 if not (isMinNoCheck or isMaxNoCheck):
149                     maxCount = int(self.MaxSize)
150                     minCount = int(rolling_update.MinInstancesInService)
151 
152                     if minCount >= maxCount:
153                         raise ValueError(
154                             "The UpdatePolicy attribute "
155                             "MinInstancesInService must be less than the "
156                             "autoscaling group's MaxSize")
157 
158         launch_config = self.properties.get('LaunchConfigurationName')
159         instance_id = self.properties.get('InstanceId')
160         if launch_config and instance_id:
161             raise ValueError("LaunchConfigurationName and InstanceId "
162                              "are mutually exclusive.")
163         if not launch_config and not instance_id:
164             raise ValueError("Must specify either LaunchConfigurationName or "
165                              "InstanceId: http://docs.aws.amazon.com/AWSCloud"
166                              "Formation/latest/UserGuide/aws-properties-as-gr"
167                              "oup.html#cfn-as-group-instanceid")
168 
169         availability_zones = self.properties.get('AvailabilityZones')
170         vpc_zone_identifier = self.properties.get('VPCZoneIdentifier')
171         if not availability_zones and not vpc_zone_identifier:
172             raise ValueError("Must specify AvailabilityZones and/or "
173                              "VPCZoneIdentifier: http://docs.aws.amazon.com/A"
174                              "WSCloudFormation/latest/UserGuide/aws-propertie"
175                              "s-as-group.html#cfn-as-group-vpczoneidentifier")
176         return True
177 
178 
179 class LaunchConfiguration(AWSObject):
180     resource_type = "AWS::AutoScaling::LaunchConfiguration"
181 
182     props = {
183         'AssociatePublicIpAddress': (boolean, False),
184         'BlockDeviceMappings': (list, False),
185         'ClassicLinkVPCId': (basestring, False),
186         'ClassicLinkVPCSecurityGroups': ([basestring], False),
187         'EbsOptimized': (boolean, False),
188         'IamInstanceProfile': (basestring, False),
189         'ImageId': (basestring, True),
190         'InstanceId': (basestring, False),
191         'InstanceMonitoring': (boolean, False),
192         'InstanceType': (basestring, True),
193         'KernelId': (basestring, False),
194         'KeyName': (basestring, False),
195         'Metadata': (Metadata, False),
196         'PlacementTenancy': (basestring, False),
197         'RamDiskId': (basestring, False),
198         'SecurityGroups': (list, False),
199         'SpotPrice': (basestring, False),
200         'UserData': (basestring, False),
201     }
202 
203 
204 class StepAdjustments(AWSProperty):
205     props = {
206         'MetricIntervalLowerBound': (integer, False),
207         'MetricIntervalUpperBound': (integer, False),
208         'ScalingAdjustment': (integer, True),
209     }
210 
211 
212 class ScalingPolicy(AWSObject):
213     resource_type = "AWS::AutoScaling::ScalingPolicy"
214 
215     props = {
216         'AdjustmentType': (basestring, True),
217         'AutoScalingGroupName': (basestring, True),
218         'Cooldown': (integer, False),
219         'EstimatedInstanceWarmup': (integer, False),
220         'MetricAggregationType': (basestring, False),
221         'MinAdjustmentMagnitude': (integer, False),
222         'PolicyType': (basestring, False),
223         'ScalingAdjustment': (integer, False),
224         'StepAdjustments': ([StepAdjustments], False),
225     }
226 
227 
228 class ScheduledAction(AWSObject):
229     resource_type = "AWS::AutoScaling::ScheduledAction"
230 
231     props = {
232         'AutoScalingGroupName': (basestring, True),
233         'DesiredCapacity': (integer, False),
234         'EndTime': (basestring, False),
235         'MaxSize': (integer, False),
236         'MinSize': (integer, False),
237         'Recurrence': (basestring, False),
238         'StartTime': (basestring, False),
239     }
240 
241 
242 class LifecycleHook(AWSObject):
243     resource_type = "AWS::AutoScaling::LifecycleHook"
244 
245     props = {
246         'AutoScalingGroupName': (basestring, True),
247         'DefaultResult': (basestring, False),
248         'HeartbeatTimeout': (integer, False),
249         'LifecycleHookName': (basestring, False),
250         'LifecycleTransition': (basestring, True),
251         'NotificationMetadata': (basestring, False),
252         'NotificationTargetARN': (basestring, True),
253         'RoleARN': (basestring, True),
254     }
255 
256 
257 class Trigger(AWSObject):
258     resource_type = "AWS::AutoScaling::Trigger"
259 
260     props = {
261         'AutoScalingGroupName': (basestring, True),
262         'BreachDuration': (integer, True),
263         'Dimensions': (list, True),
264         'LowerBreachScaleIncrement': (integer, False),
265         'LowerThreshold': (integer, True),
266         'MetricName': (basestring, True),
267         'Namespace': (basestring, True),
268         'Period': (integer, True),
269         'Statistic': (basestring, True),
270         'Unit': (basestring, False),
271         'UpperBreachScaleIncrement': (integer, False),
272         'UpperThreshold': (integer, True),
273     }
274 
275 
276 class EBSBlockDevice(AWSProperty):
277     # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-launchconfig-blockdev-template.html
278     props = {
279         'DeleteOnTermination': (boolean, False),
280         'Encrypted': (boolean, False),
281         'Iops': (integer, False),
282         'SnapshotId': (basestring, False),
283         'VolumeSize': (integer, False),
284         'VolumeType': (basestring, False),
285     }
286 
287 
288 class BlockDeviceMapping(AWSProperty):
289     # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-launchconfig-blockdev-mapping.html
290     props = {
291         'DeviceName': (basestring, True),
292         'Ebs': (EBSBlockDevice, False),
293         'NoDevice': (boolean, False),
294         'VirtualName': (basestring, False),
295     }
296
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/troposphere/autoscaling.py b/troposphere/autoscaling.py
--- a/troposphere/autoscaling.py
+++ b/troposphere/autoscaling.py
@@ -137,23 +137,26 @@
 
             if (not isinstance(update_policy, AWSHelperFn) and
                     'AutoScalingRollingUpdate' in update_policy.properties):
-                rolling_update = update_policy.AutoScalingRollingUpdate
-
-                isMinNoCheck = isinstance(
-                    rolling_update.MinInstancesInService,
-                    (FindInMap, Ref)
-                )
-                isMaxNoCheck = isinstance(self.MaxSize, (If, FindInMap, Ref))
-
-                if not (isMinNoCheck or isMaxNoCheck):
-                    maxCount = int(self.MaxSize)
-                    minCount = int(rolling_update.MinInstancesInService)
-
-                    if minCount >= maxCount:
-                        raise ValueError(
-                            "The UpdatePolicy attribute "
-                            "MinInstancesInService must be less than the "
-                            "autoscaling group's MaxSize")
+                if not isinstance(
+                        update_policy.AutoScalingRollingUpdate, AWSHelperFn):
+                    rolling_update = update_policy.AutoScalingRollingUpdate
+
+                    is_min_no_check = isinstance(
+                        rolling_update.MinInstancesInService,
+                        (FindInMap, Ref)
+                    )
+                    is_max_no_check = isinstance(self.MaxSize,
+                                                 (If, FindInMap, Ref))
+
+                    if not (is_min_no_check or is_max_no_check):
+                        max_count = int(self.MaxSize)
+                        min_count = int(rolling_update.MinInstancesInService)
+
+                        if min_count >= max_count:
+                            raise ValueError(
+                                "The UpdatePolicy attribute "
+                                "MinInstancesInService must be less than the "
+                                "autoscaling group's MaxSize")
 
         launch_config = self.properties.get('LaunchConfigurationName')
         instance_id = self.properties.get('InstanceId')

{"golden_diff": "diff --git a/troposphere/autoscaling.py b/troposphere/autoscaling.py\n--- a/troposphere/autoscaling.py\n+++ b/troposphere/autoscaling.py\n@@ -137,23 +137,26 @@\n \n             if (not isinstance(update_policy, AWSHelperFn) and\n                     'AutoScalingRollingUpdate' in update_policy.properties):\n-                rolling_update = update_policy.AutoScalingRollingUpdate\n-\n-                isMinNoCheck = isinstance(\n-                    rolling_update.MinInstancesInService,\n-                    (FindInMap, Ref)\n-                )\n-                isMaxNoCheck = isinstance(self.MaxSize, (If, FindInMap, Ref))\n-\n-                if not (isMinNoCheck or isMaxNoCheck):\n-                    maxCount = int(self.MaxSize)\n-                    minCount = int(rolling_update.MinInstancesInService)\n-\n-                    if minCount >= maxCount:\n-                        raise ValueError(\n-                            \"The UpdatePolicy attribute \"\n-                            \"MinInstancesInService must be less than the \"\n-                            \"autoscaling group's MaxSize\")\n+                if not isinstance(\n+                        update_policy.AutoScalingRollingUpdate, AWSHelperFn):\n+                    rolling_update = update_policy.AutoScalingRollingUpdate\n+\n+                    is_min_no_check = isinstance(\n+                        rolling_update.MinInstancesInService,\n+                        (FindInMap, Ref)\n+                    )\n+                    is_max_no_check = isinstance(self.MaxSize,\n+                                                 (If, FindInMap, Ref))\n+\n+                    if not (is_min_no_check or is_max_no_check):\n+                        max_count = int(self.MaxSize)\n+                        min_count = int(rolling_update.MinInstancesInService)\n+\n+                        if min_count >= max_count:\n+                            raise ValueError(\n+                                \"The UpdatePolicy attribute \"\n+                                \"MinInstancesInService must be less than the \"\n+                                \"autoscaling group's MaxSize\")\n \n         launch_config = self.properties.get('LaunchConfigurationName')\n         instance_id = self.properties.get('InstanceId')\n", "issue": "AutoScalingRollingUpdate with 'If' Aws Helper Condition fail during validate\nHi, in autoscalinggroup  UpdatePolicy if i have a AutoScalingRollingUpdate with a IF AWS Helper Condition it fails during validate with:\r\n##\r\nAttributeError: 'If' object has no attribute 'MinInstancesInService'\r\n##\r\n\r\nExample code:\r\n##\r\n                AutoScalingRollingUpdate=If(\r\n                    'RollingUpdate',\r\n                    pol.AutoScalingRollingUpdate(\r\n                        MaxBatchSize=get_mapped_value('RollingUpdateMaxBatchSize'),\r\n                        MinInstancesInService=get_mapped_value('RollingUpdateMinInstancesInService'),\r\n                        MinSuccessfulInstancesPercent=get_mapped_value('RollingUpdateMinSuccessfulInstancesPercent'),\r\n                        PauseTime=get_mapped_value('RollingUpdatePauseTime'),\r\n                        SuspendProcesses=[\r\n                            'HealthCheck',\r\n                            'ReplaceUnhealthy',\r\n                            'AlarmNotification',\r\n                            'ScheduledActions'\r\n                        ],\r\n                        WaitOnResourceSignals=True\r\n                    ),\r\n                    Ref('AWS::NoValue')\r\n                ),\r\n##\r\n\r\nTo solve issue, in troposphere/autoscaling.py function validate should be:\r\n```\r\ndiff --git a/troposphere/autoscaling.py b/troposphere/autoscaling.py\r\nindex cc5873f..8f7a43d 100644\r\n--- a/troposphere/autoscaling.py\r\n+++ b/troposphere/autoscaling.py\r\n@@ -136,7 +136,8 @@ class AutoScalingGroup(AWSObject):\r\n             update_policy = self.resource['UpdatePolicy']\r\n \r\n             if (not isinstance(update_policy, AWSHelperFn) and\r\n-                    'AutoScalingRollingUpdate' in update_policy.properties):\r\n+                    'AutoScalingRollingUpdate' in update_policy.properties and\r\n+                    not isinstance(update_policy.AutoScalingRollingUpdate, AWSHelperFn)):\r\n                 rolling_update = update_policy.AutoScalingRollingUpdate\r\n \r\n                 isMinNoCheck = isinstance(\r\n```\r\n##\r\n\r\nRegards, Alberto.\n", "before_files": [{"content": "# Copyright (c) 2012-2013, Mark Peek <mark@peek.org>\n# All rights reserved.\n#\n# See LICENSE file for full license.\n\nfrom . import AWSHelperFn, AWSObject, AWSProperty, If, FindInMap, Ref\nfrom .validators import boolean, integer\nfrom . import cloudformation\n\n\nEC2_INSTANCE_LAUNCH = \"autoscaling:EC2_INSTANCE_LAUNCH\"\nEC2_INSTANCE_LAUNCH_ERROR = \"autoscaling:EC2_INSTANCE_LAUNCH_ERROR\"\nEC2_INSTANCE_TERMINATE = \"autoscaling:EC2_INSTANCE_TERMINATE\"\nEC2_INSTANCE_TERMINATE_ERROR = \"autoscaling:EC2_INSTANCE_TERMINATE_ERROR\"\nTEST_NOTIFICATION = \"autoscaling:TEST_NOTIFICATION\"\n\n# Termination Policy constants\nDefault = 'Default'\nOldestInstance = 'OldestInstance'\nNewestInstance = 'NewestInstance'\nOldestLaunchConfiguration = 'OldestLaunchConfiguration'\nClosestToNextInstanceHour = 'ClosestToNextInstanceHour'\n\n\nclass Tag(AWSHelperFn):\n    def __init__(self, key, value, propogate):\n        self.data = {\n            'Key': key,\n            'Value': value,\n            'PropagateAtLaunch': propogate,\n        }\n\n    def JSONrepr(self):\n        return self.data\n\n\nclass Tags(AWSHelperFn):\n    defaultPropagateAtLaunch = True\n    manyType = [type([]), type(())]\n\n    def __init__(self, **kwargs):\n        self.tags = []\n        for k, v in sorted(kwargs.iteritems()):\n            if type(v) in self.manyType:\n                propagate = str(v[1]).lower()\n                v = v[0]\n            else:\n                propagate = str(self.defaultPropagateAtLaunch).lower()\n            self.tags.append({\n                'Key': k,\n                'Value': v,\n                'PropagateAtLaunch': propagate,\n            })\n\n    # append tags to list\n    def __add__(self, newtags):\n        newtags.tags = self.tags + newtags.tags\n        return newtags\n\n    def JSONrepr(self):\n        return self.tags\n\n\nclass NotificationConfigurations(AWSProperty):\n    props = {\n        'TopicARN': (basestring, True),\n        'NotificationTypes': (list, True),\n    }\n\n\nclass MetricsCollection(AWSProperty):\n    props = {\n        'Granularity': (basestring, True),\n        'Metrics': (list, False),\n    }\n\n\nclass Metadata(AWSHelperFn):\n    def __init__(self, init, authentication=None):\n        self.validate(init, authentication)\n        # get keys and values from init and authentication\n\n        # if there's only one data point, then we know its the default\n        # cfn-init; where the key is 'config'\n        if len(init.data) == 1:\n            initKey, initValue = init.data.popitem()\n            self.data = {initKey: initValue}\n        else:\n            self.data = init.data\n\n        if authentication:\n            authKey, authValue = authentication.data.popitem()\n            self.data[authKey] = authValue\n\n    def validate(self, init, authentication):\n        if not isinstance(init, cloudformation.Init):\n            raise ValueError(\n                'init must be of type cloudformation.Init'\n            )\n\n        is_instance = isinstance(authentication, cloudformation.Authentication)\n        if authentication and not is_instance:\n            raise ValueError(\n                'authentication must be of type cloudformation.Authentication'\n            )\n\n    def JSONrepr(self):\n        return self.data\n\n\nclass AutoScalingGroup(AWSObject):\n    resource_type = \"AWS::AutoScaling::AutoScalingGroup\"\n\n    props = {\n        'AvailabilityZones': (list, False),\n        'Cooldown': (integer, False),\n        'DesiredCapacity': (integer, False),\n        'HealthCheckGracePeriod': (integer, False),\n        'HealthCheckType': (basestring, False),\n        'InstanceId': (basestring, False),\n        'LaunchConfigurationName': (basestring, False),\n        'LoadBalancerNames': (list, False),\n        'MaxSize': (integer, True),\n        'MetricsCollection': ([MetricsCollection], False),\n        'MinSize': (integer, True),\n        'NotificationConfigurations': ([NotificationConfigurations], False),\n        'PlacementGroup': (basestring, False),\n        'Tags': (list, False),\n        'TargetGroupARNs': ([basestring], False),\n        'TerminationPolicies': ([basestring], False),\n        'VPCZoneIdentifier': (list, False),\n    }\n\n    def validate(self):\n        if 'UpdatePolicy' in self.resource:\n            update_policy = self.resource['UpdatePolicy']\n\n            if (not isinstance(update_policy, AWSHelperFn) and\n                    'AutoScalingRollingUpdate' in update_policy.properties):\n                rolling_update = update_policy.AutoScalingRollingUpdate\n\n                isMinNoCheck = isinstance(\n                    rolling_update.MinInstancesInService,\n                    (FindInMap, Ref)\n                )\n                isMaxNoCheck = isinstance(self.MaxSize, (If, FindInMap, Ref))\n\n                if not (isMinNoCheck or isMaxNoCheck):\n                    maxCount = int(self.MaxSize)\n                    minCount = int(rolling_update.MinInstancesInService)\n\n                    if minCount >= maxCount:\n                        raise ValueError(\n                            \"The UpdatePolicy attribute \"\n                            \"MinInstancesInService must be less than the \"\n                            \"autoscaling group's MaxSize\")\n\n        launch_config = self.properties.get('LaunchConfigurationName')\n        instance_id = self.properties.get('InstanceId')\n        if launch_config and instance_id:\n            raise ValueError(\"LaunchConfigurationName and InstanceId \"\n                             \"are mutually exclusive.\")\n        if not launch_config and not instance_id:\n            raise ValueError(\"Must specify either LaunchConfigurationName or \"\n                             \"InstanceId: http://docs.aws.amazon.com/AWSCloud\"\n                             \"Formation/latest/UserGuide/aws-properties-as-gr\"\n                             \"oup.html#cfn-as-group-instanceid\")\n\n        availability_zones = self.properties.get('AvailabilityZones')\n        vpc_zone_identifier = self.properties.get('VPCZoneIdentifier')\n        if not availability_zones and not vpc_zone_identifier:\n            raise ValueError(\"Must specify AvailabilityZones and/or \"\n                             \"VPCZoneIdentifier: http://docs.aws.amazon.com/A\"\n                             \"WSCloudFormation/latest/UserGuide/aws-propertie\"\n                             \"s-as-group.html#cfn-as-group-vpczoneidentifier\")\n        return True\n\n\nclass LaunchConfiguration(AWSObject):\n    resource_type = \"AWS::AutoScaling::LaunchConfiguration\"\n\n    props = {\n        'AssociatePublicIpAddress': (boolean, False),\n        'BlockDeviceMappings': (list, False),\n        'ClassicLinkVPCId': (basestring, False),\n        'ClassicLinkVPCSecurityGroups': ([basestring], False),\n        'EbsOptimized': (boolean, False),\n        'IamInstanceProfile': (basestring, False),\n        'ImageId': (basestring, True),\n        'InstanceId': (basestring, False),\n        'InstanceMonitoring': (boolean, False),\n        'InstanceType': (basestring, True),\n        'KernelId': (basestring, False),\n        'KeyName': (basestring, False),\n        'Metadata': (Metadata, False),\n        'PlacementTenancy': (basestring, False),\n        'RamDiskId': (basestring, False),\n        'SecurityGroups': (list, False),\n        'SpotPrice': (basestring, False),\n        'UserData': (basestring, False),\n    }\n\n\nclass StepAdjustments(AWSProperty):\n    props = {\n        'MetricIntervalLowerBound': (integer, False),\n        'MetricIntervalUpperBound': (integer, False),\n        'ScalingAdjustment': (integer, True),\n    }\n\n\nclass ScalingPolicy(AWSObject):\n    resource_type = \"AWS::AutoScaling::ScalingPolicy\"\n\n    props = {\n        'AdjustmentType': (basestring, True),\n        'AutoScalingGroupName': (basestring, True),\n        'Cooldown': (integer, False),\n        'EstimatedInstanceWarmup': (integer, False),\n        'MetricAggregationType': (basestring, False),\n        'MinAdjustmentMagnitude': (integer, False),\n        'PolicyType': (basestring, False),\n        'ScalingAdjustment': (integer, False),\n        'StepAdjustments': ([StepAdjustments], False),\n    }\n\n\nclass ScheduledAction(AWSObject):\n    resource_type = \"AWS::AutoScaling::ScheduledAction\"\n\n    props = {\n        'AutoScalingGroupName': (basestring, True),\n        'DesiredCapacity': (integer, False),\n        'EndTime': (basestring, False),\n        'MaxSize': (integer, False),\n        'MinSize': (integer, False),\n        'Recurrence': (basestring, False),\n        'StartTime': (basestring, False),\n    }\n\n\nclass LifecycleHook(AWSObject):\n    resource_type = \"AWS::AutoScaling::LifecycleHook\"\n\n    props = {\n        'AutoScalingGroupName': (basestring, True),\n        'DefaultResult': (basestring, False),\n        'HeartbeatTimeout': (integer, False),\n        'LifecycleHookName': (basestring, False),\n        'LifecycleTransition': (basestring, True),\n        'NotificationMetadata': (basestring, False),\n        'NotificationTargetARN': (basestring, True),\n        'RoleARN': (basestring, True),\n    }\n\n\nclass Trigger(AWSObject):\n    resource_type = \"AWS::AutoScaling::Trigger\"\n\n    props = {\n        'AutoScalingGroupName': (basestring, True),\n        'BreachDuration': (integer, True),\n        'Dimensions': (list, True),\n        'LowerBreachScaleIncrement': (integer, False),\n        'LowerThreshold': (integer, True),\n        'MetricName': (basestring, True),\n        'Namespace': (basestring, True),\n        'Period': (integer, True),\n        'Statistic': (basestring, True),\n        'Unit': (basestring, False),\n        'UpperBreachScaleIncrement': (integer, False),\n        'UpperThreshold': (integer, True),\n    }\n\n\nclass EBSBlockDevice(AWSProperty):\n    # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-launchconfig-blockdev-template.html\n    props = {\n        'DeleteOnTermination': (boolean, False),\n        'Encrypted': (boolean, False),\n        'Iops': (integer, False),\n        'SnapshotId': (basestring, False),\n        'VolumeSize': (integer, False),\n        'VolumeType': (basestring, False),\n    }\n\n\nclass BlockDeviceMapping(AWSProperty):\n    # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-launchconfig-blockdev-mapping.html\n    props = {\n        'DeviceName': (basestring, True),\n        'Ebs': (EBSBlockDevice, False),\n        'NoDevice': (boolean, False),\n        'VirtualName': (basestring, False),\n    }\n", "path": "troposphere/autoscaling.py"}], "after_files": [{"content": "# Copyright (c) 2012-2013, Mark Peek <mark@peek.org>\n# All rights reserved.\n#\n# See LICENSE file for full license.\n\nfrom . import AWSHelperFn, AWSObject, AWSProperty, If, FindInMap, Ref\nfrom .validators import boolean, integer\nfrom . import cloudformation\n\n\nEC2_INSTANCE_LAUNCH = \"autoscaling:EC2_INSTANCE_LAUNCH\"\nEC2_INSTANCE_LAUNCH_ERROR = \"autoscaling:EC2_INSTANCE_LAUNCH_ERROR\"\nEC2_INSTANCE_TERMINATE = \"autoscaling:EC2_INSTANCE_TERMINATE\"\nEC2_INSTANCE_TERMINATE_ERROR = \"autoscaling:EC2_INSTANCE_TERMINATE_ERROR\"\nTEST_NOTIFICATION = \"autoscaling:TEST_NOTIFICATION\"\n\n# Termination Policy constants\nDefault = 'Default'\nOldestInstance = 'OldestInstance'\nNewestInstance = 'NewestInstance'\nOldestLaunchConfiguration = 'OldestLaunchConfiguration'\nClosestToNextInstanceHour = 'ClosestToNextInstanceHour'\n\n\nclass Tag(AWSHelperFn):\n    def __init__(self, key, value, propogate):\n        self.data = {\n            'Key': key,\n            'Value': value,\n            'PropagateAtLaunch': propogate,\n        }\n\n    def JSONrepr(self):\n        return self.data\n\n\nclass Tags(AWSHelperFn):\n    defaultPropagateAtLaunch = True\n    manyType = [type([]), type(())]\n\n    def __init__(self, **kwargs):\n        self.tags = []\n        for k, v in sorted(kwargs.iteritems()):\n            if type(v) in self.manyType:\n                propagate = str(v[1]).lower()\n                v = v[0]\n            else:\n                propagate = str(self.defaultPropagateAtLaunch).lower()\n            self.tags.append({\n                'Key': k,\n                'Value': v,\n                'PropagateAtLaunch': propagate,\n            })\n\n    # append tags to list\n    def __add__(self, newtags):\n        newtags.tags = self.tags + newtags.tags\n        return newtags\n\n    def JSONrepr(self):\n        return self.tags\n\n\nclass NotificationConfigurations(AWSProperty):\n    props = {\n        'TopicARN': (basestring, True),\n        'NotificationTypes': (list, True),\n    }\n\n\nclass MetricsCollection(AWSProperty):\n    props = {\n        'Granularity': (basestring, True),\n        'Metrics': (list, False),\n    }\n\n\nclass Metadata(AWSHelperFn):\n    def __init__(self, init, authentication=None):\n        self.validate(init, authentication)\n        # get keys and values from init and authentication\n\n        # if there's only one data point, then we know its the default\n        # cfn-init; where the key is 'config'\n        if len(init.data) == 1:\n            initKey, initValue = init.data.popitem()\n            self.data = {initKey: initValue}\n        else:\n            self.data = init.data\n\n        if authentication:\n            authKey, authValue = authentication.data.popitem()\n            self.data[authKey] = authValue\n\n    def validate(self, init, authentication):\n        if not isinstance(init, cloudformation.Init):\n            raise ValueError(\n                'init must be of type cloudformation.Init'\n            )\n\n        is_instance = isinstance(authentication, cloudformation.Authentication)\n        if authentication and not is_instance:\n            raise ValueError(\n                'authentication must be of type cloudformation.Authentication'\n            )\n\n    def JSONrepr(self):\n        return self.data\n\n\nclass AutoScalingGroup(AWSObject):\n    resource_type = \"AWS::AutoScaling::AutoScalingGroup\"\n\n    props = {\n        'AvailabilityZones': (list, False),\n        'Cooldown': (integer, False),\n        'DesiredCapacity': (integer, False),\n        'HealthCheckGracePeriod': (integer, False),\n        'HealthCheckType': (basestring, False),\n        'InstanceId': (basestring, False),\n        'LaunchConfigurationName': (basestring, False),\n        'LoadBalancerNames': (list, False),\n        'MaxSize': (integer, True),\n        'MetricsCollection': ([MetricsCollection], False),\n        'MinSize': (integer, True),\n        'NotificationConfigurations': ([NotificationConfigurations], False),\n        'PlacementGroup': (basestring, False),\n        'Tags': (list, False),\n        'TargetGroupARNs': ([basestring], False),\n        'TerminationPolicies': ([basestring], False),\n        'VPCZoneIdentifier': (list, False),\n    }\n\n    def validate(self):\n        if 'UpdatePolicy' in self.resource:\n            update_policy = self.resource['UpdatePolicy']\n\n            if (not isinstance(update_policy, AWSHelperFn) and\n                    'AutoScalingRollingUpdate' in update_policy.properties):\n                if not isinstance(\n                        update_policy.AutoScalingRollingUpdate, AWSHelperFn):\n                    rolling_update = update_policy.AutoScalingRollingUpdate\n\n                    is_min_no_check = isinstance(\n                        rolling_update.MinInstancesInService,\n                        (FindInMap, Ref)\n                    )\n                    is_max_no_check = isinstance(self.MaxSize,\n                                                 (If, FindInMap, Ref))\n\n                    if not (is_min_no_check or is_max_no_check):\n                        max_count = int(self.MaxSize)\n                        min_count = int(rolling_update.MinInstancesInService)\n\n                        if min_count >= max_count:\n                            raise ValueError(\n                                \"The UpdatePolicy attribute \"\n                                \"MinInstancesInService must be less than the \"\n                                \"autoscaling group's MaxSize\")\n\n        launch_config = self.properties.get('LaunchConfigurationName')\n        instance_id = self.properties.get('InstanceId')\n        if launch_config and instance_id:\n            raise ValueError(\"LaunchConfigurationName and InstanceId \"\n                             \"are mutually exclusive.\")\n        if not launch_config and not instance_id:\n            raise ValueError(\"Must specify either LaunchConfigurationName or \"\n                             \"InstanceId: http://docs.aws.amazon.com/AWSCloud\"\n                             \"Formation/latest/UserGuide/aws-properties-as-gr\"\n                             \"oup.html#cfn-as-group-instanceid\")\n\n        availability_zones = self.properties.get('AvailabilityZones')\n        vpc_zone_identifier = self.properties.get('VPCZoneIdentifier')\n        if not availability_zones and not vpc_zone_identifier:\n            raise ValueError(\"Must specify AvailabilityZones and/or \"\n                             \"VPCZoneIdentifier: http://docs.aws.amazon.com/A\"\n                             \"WSCloudFormation/latest/UserGuide/aws-propertie\"\n                             \"s-as-group.html#cfn-as-group-vpczoneidentifier\")\n        return True\n\n\nclass LaunchConfiguration(AWSObject):\n    resource_type = \"AWS::AutoScaling::LaunchConfiguration\"\n\n    props = {\n        'AssociatePublicIpAddress': (boolean, False),\n        'BlockDeviceMappings': (list, False),\n        'ClassicLinkVPCId': (basestring, False),\n        'ClassicLinkVPCSecurityGroups': ([basestring], False),\n        'EbsOptimized': (boolean, False),\n        'IamInstanceProfile': (basestring, False),\n        'ImageId': (basestring, True),\n        'InstanceId': (basestring, False),\n        'InstanceMonitoring': (boolean, False),\n        'InstanceType': (basestring, True),\n        'KernelId': (basestring, False),\n        'KeyName': (basestring, False),\n        'Metadata': (Metadata, False),\n        'PlacementTenancy': (basestring, False),\n        'RamDiskId': (basestring, False),\n        'SecurityGroups': (list, False),\n        'SpotPrice': (basestring, False),\n        'UserData': (basestring, False),\n    }\n\n\nclass StepAdjustments(AWSProperty):\n    props = {\n        'MetricIntervalLowerBound': (integer, False),\n        'MetricIntervalUpperBound': (integer, False),\n        'ScalingAdjustment': (integer, True),\n    }\n\n\nclass ScalingPolicy(AWSObject):\n    resource_type = \"AWS::AutoScaling::ScalingPolicy\"\n\n    props = {\n        'AdjustmentType': (basestring, True),\n        'AutoScalingGroupName': (basestring, True),\n        'Cooldown': (integer, False),\n        'EstimatedInstanceWarmup': (integer, False),\n        'MetricAggregationType': (basestring, False),\n        'MinAdjustmentMagnitude': (integer, False),\n        'PolicyType': (basestring, False),\n        'ScalingAdjustment': (integer, False),\n        'StepAdjustments': ([StepAdjustments], False),\n    }\n\n\nclass ScheduledAction(AWSObject):\n    resource_type = \"AWS::AutoScaling::ScheduledAction\"\n\n    props = {\n        'AutoScalingGroupName': (basestring, True),\n        'DesiredCapacity': (integer, False),\n        'EndTime': (basestring, False),\n        'MaxSize': (integer, False),\n        'MinSize': (integer, False),\n        'Recurrence': (basestring, False),\n        'StartTime': (basestring, False),\n    }\n\n\nclass LifecycleHook(AWSObject):\n    resource_type = \"AWS::AutoScaling::LifecycleHook\"\n\n    props = {\n        'AutoScalingGroupName': (basestring, True),\n        'DefaultResult': (basestring, False),\n        'HeartbeatTimeout': (integer, False),\n        'LifecycleHookName': (basestring, False),\n        'LifecycleTransition': (basestring, True),\n        'NotificationMetadata': (basestring, False),\n        'NotificationTargetARN': (basestring, True),\n        'RoleARN': (basestring, True),\n    }\n\n\nclass Trigger(AWSObject):\n    resource_type = \"AWS::AutoScaling::Trigger\"\n\n    props = {\n        'AutoScalingGroupName': (basestring, True),\n        'BreachDuration': (integer, True),\n        'Dimensions': (list, True),\n        'LowerBreachScaleIncrement': (integer, False),\n        'LowerThreshold': (integer, True),\n        'MetricName': (basestring, True),\n        'Namespace': (basestring, True),\n        'Period': (integer, True),\n        'Statistic': (basestring, True),\n        'Unit': (basestring, False),\n        'UpperBreachScaleIncrement': (integer, False),\n        'UpperThreshold': (integer, True),\n    }\n\n\nclass EBSBlockDevice(AWSProperty):\n    # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-launchconfig-blockdev-template.html\n    props = {\n        'DeleteOnTermination': (boolean, False),\n        'Encrypted': (boolean, False),\n        'Iops': (integer, False),\n        'SnapshotId': (basestring, False),\n        'VolumeSize': (integer, False),\n        'VolumeType': (basestring, False),\n    }\n\n\nclass BlockDeviceMapping(AWSProperty):\n    # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-launchconfig-blockdev-mapping.html\n    props = {\n        'DeviceName': (basestring, True),\n        'Ebs': (EBSBlockDevice, False),\n        'NoDevice': (boolean, False),\n        'VirtualName': (basestring, False),\n    }\n", "path": "troposphere/autoscaling.py"}]}