We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Validation of AutoScalingGroup with UpdatePolicy fails when maxSize is an expression
Troposphere version: `troposphere==1.5.0`
Snippet example:

```
t.add_resource(AutoScalingGroup(
        "WebserverAutoScalingGroup",
        AvailabilityZones=GetAZs(Ref("AWS::Region")),
        LaunchConfigurationName=Ref(r['webserver_lc']),
        LoadBalancerNames=[Ref(r['webserver_elb'])],

        UpdatePolicy=UpdatePolicy(
            AutoScalingRollingUpdate=AutoScalingRollingUpdate(
                PauseTime='PT5M',
                MinInstancesInService="1",
                MaxBatchSize='1',
                WaitOnResourceSignals=True
            )
        ),
        CreationPolicy=CreationPolicy(
            ResourceSignal=ResourceSignal(
                Timeout='PT15M'
            )
        ),
        HealthCheckGracePeriod=300,
        HealthCheckType="EC2",

        DesiredCapacity=If(
            "IsStaging",
            '1',
            '3',
        ),
        MinSize=If(
            "IsStaging",
            '1',
            '3'
        ),
        MaxSize=If(
            "IsStaging",
            '1',
            '5'
        )
    ))
```

This gives the error:

```
Traceback (most recent call last):
<-- snip -->
packages/troposphere/__init__.py", line 367, in default
    return obj.JSONrepr()
  File "venv/lib/python2.7/site-packages/troposphere/__init__.py", line 176, in JSONrepr
    self.validate()
  File "venv/lib/python2.7/site-packages/troposphere/autoscaling.py", line 147, in validate
    maxCount = int(self.MaxSize)
TypeError: int() argument must be a string or a number, not 'If'
```

Let me know if you need any other details.


--- 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, Ref, FindInMap
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         'TerminationPolicies': ([basestring], False),
130         'VPCZoneIdentifier': (list, False),
131     }
132 
133     def validate(self):
134         if 'UpdatePolicy' in self.resource:
135             update_policy = self.resource['UpdatePolicy']
136 
137             if 'AutoScalingRollingUpdate' in update_policy.properties:
138                 rolling_update = update_policy.AutoScalingRollingUpdate
139 
140                 isMinNoCheck = isinstance(
141                     rolling_update.MinInstancesInService,
142                     (FindInMap, Ref)
143                 )
144                 isMaxNoCheck = isinstance(self.MaxSize, (FindInMap, Ref))
145 
146                 if not (isMinNoCheck or isMaxNoCheck):
147                     maxCount = int(self.MaxSize)
148                     minCount = int(rolling_update.MinInstancesInService)
149 
150                     if minCount >= maxCount:
151                         raise ValueError(
152                             "The UpdatePolicy attribute "
153                             "MinInstancesInService must be less than the "
154                             "autoscaling group's MaxSize")
155 
156         launch_config = self.properties.get('LaunchConfigurationName')
157         instance_id = self.properties.get('InstanceId')
158         if launch_config and instance_id:
159             raise ValueError("LaunchConfigurationName and InstanceId "
160                              "are mutually exclusive.")
161         if not launch_config and not instance_id:
162             raise ValueError("Must specify either LaunchConfigurationName or "
163                              "InstanceId: http://docs.aws.amazon.com/AWSCloud"
164                              "Formation/latest/UserGuide/aws-properties-as-gr"
165                              "oup.html#cfn-as-group-instanceid")
166 
167         availability_zones = self.properties.get('AvailabilityZones')
168         vpc_zone_identifier = self.properties.get('VPCZoneIdentifier')
169         if not availability_zones and not vpc_zone_identifier:
170             raise ValueError("Must specify AvailabilityZones and/or "
171                              "VPCZoneIdentifier: http://docs.aws.amazon.com/A"
172                              "WSCloudFormation/latest/UserGuide/aws-propertie"
173                              "s-as-group.html#cfn-as-group-vpczoneidentifier")
174         return True
175 
176 
177 class LaunchConfiguration(AWSObject):
178     resource_type = "AWS::AutoScaling::LaunchConfiguration"
179 
180     props = {
181         'AssociatePublicIpAddress': (boolean, False),
182         'BlockDeviceMappings': (list, False),
183         'ClassicLinkVPCId': (basestring, False),
184         'ClassicLinkVPCSecurityGroups': ([basestring], False),
185         'EbsOptimized': (boolean, False),
186         'IamInstanceProfile': (basestring, False),
187         'ImageId': (basestring, True),
188         'InstanceId': (basestring, False),
189         'InstanceMonitoring': (boolean, False),
190         'InstanceType': (basestring, True),
191         'KernelId': (basestring, False),
192         'KeyName': (basestring, False),
193         'Metadata': (Metadata, False),
194         'PlacementTenancy': (basestring, False),
195         'RamDiskId': (basestring, False),
196         'SecurityGroups': (list, False),
197         'SpotPrice': (basestring, False),
198         'UserData': (basestring, False),
199     }
200 
201 
202 class StepAdjustments(AWSProperty):
203     props = {
204         'MetricIntervalLowerBound': (integer, False),
205         'MetricIntervalUpperBound': (integer, False),
206         'ScalingAdjustment': (integer, True),
207     }
208 
209 
210 class ScalingPolicy(AWSObject):
211     resource_type = "AWS::AutoScaling::ScalingPolicy"
212 
213     props = {
214         'AdjustmentType': (basestring, True),
215         'AutoScalingGroupName': (basestring, True),
216         'Cooldown': (integer, False),
217         'EstimatedInstanceWarmup': (integer, False),
218         'MetricAggregationType': (basestring, False),
219         'MinAdjustmentMagnitude': (integer, False),
220         'PolicyType': (basestring, False),
221         'ScalingAdjustment': (integer, False),
222         'StepAdjustments': ([StepAdjustments], False),
223     }
224 
225 
226 class ScheduledAction(AWSObject):
227     resource_type = "AWS::AutoScaling::ScheduledAction"
228 
229     props = {
230         'AutoScalingGroupName': (basestring, True),
231         'DesiredCapacity': (integer, False),
232         'EndTime': (basestring, False),
233         'MaxSize': (integer, False),
234         'MinSize': (integer, False),
235         'Recurrence': (basestring, False),
236         'StartTime': (basestring, False),
237     }
238 
239 
240 class LifecycleHook(AWSObject):
241     resource_type = "AWS::AutoScaling::LifecycleHook"
242 
243     props = {
244         'AutoScalingGroupName': (basestring, True),
245         'DefaultResult': (basestring, False),
246         'HeartbeatTimeout': (integer, False),
247         'LifecycleHookName': (basestring, False),
248         'LifecycleTransition': (basestring, True),
249         'NotificationMetadata': (basestring, False),
250         'NotificationTargetARN': (basestring, True),
251         'RoleARN': (basestring, True),
252     }
253 
254 
255 class Trigger(AWSObject):
256     resource_type = "AWS::AutoScaling::Trigger"
257 
258     props = {
259         'AutoScalingGroupName': (basestring, True),
260         'BreachDuration': (integer, True),
261         'Dimensions': (list, True),
262         'LowerBreachScaleIncrement': (integer, False),
263         'LowerThreshold': (integer, True),
264         'MetricName': (basestring, True),
265         'Namespace': (basestring, True),
266         'Period': (integer, True),
267         'Statistic': (basestring, True),
268         'Unit': (basestring, False),
269         'UpperBreachScaleIncrement': (integer, False),
270         'UpperThreshold': (integer, True),
271     }
272 
273 
274 class EBSBlockDevice(AWSProperty):
275     # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-launchconfig-blockdev-template.html
276     props = {
277         'DeleteOnTermination': (boolean, False),
278         'Encrypted': (boolean, False),
279         'Iops': (integer, False),
280         'SnapshotId': (basestring, False),
281         'VolumeSize': (integer, False),
282         'VolumeType': (basestring, False),
283     }
284 
285 
286 class BlockDeviceMapping(AWSProperty):
287     # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-launchconfig-blockdev-mapping.html
288     props = {
289         'DeviceName': (basestring, True),
290         'Ebs': (EBSBlockDevice, False),
291         'NoDevice': (boolean, False),
292         'VirtualName': (basestring, False),
293     }
294
```
--- 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
@@ -3,7 +3,7 @@
 #
 # See LICENSE file for full license.
 
-from . import AWSHelperFn, AWSObject, AWSProperty, Ref, FindInMap
+from . import AWSHelperFn, AWSObject, AWSProperty, Ref, FindInMap, If
 from .validators import boolean, integer
 from . import cloudformation
 
@@ -141,7 +141,7 @@
                     rolling_update.MinInstancesInService,
                     (FindInMap, Ref)
                 )
-                isMaxNoCheck = isinstance(self.MaxSize, (FindInMap, Ref))
+                isMaxNoCheck = isinstance(self.MaxSize, (FindInMap, Ref, If))
 
                 if not (isMinNoCheck or isMaxNoCheck):
                     maxCount = int(self.MaxSize)

{"golden_diff": "diff --git a/troposphere/autoscaling.py b/troposphere/autoscaling.py\n--- a/troposphere/autoscaling.py\n+++ b/troposphere/autoscaling.py\n@@ -3,7 +3,7 @@\n #\n # See LICENSE file for full license.\n \n-from . import AWSHelperFn, AWSObject, AWSProperty, Ref, FindInMap\n+from . import AWSHelperFn, AWSObject, AWSProperty, Ref, FindInMap, If\n from .validators import boolean, integer\n from . import cloudformation\n \n@@ -141,7 +141,7 @@\n                     rolling_update.MinInstancesInService,\n                     (FindInMap, Ref)\n                 )\n-                isMaxNoCheck = isinstance(self.MaxSize, (FindInMap, Ref))\n+                isMaxNoCheck = isinstance(self.MaxSize, (FindInMap, Ref, If))\n \n                 if not (isMinNoCheck or isMaxNoCheck):\n                     maxCount = int(self.MaxSize)\n", "issue": "Validation of AutoScalingGroup with UpdatePolicy fails when maxSize is an expression\nTroposphere version: `troposphere==1.5.0`\nSnippet example:\n\n```\nt.add_resource(AutoScalingGroup(\n        \"WebserverAutoScalingGroup\",\n        AvailabilityZones=GetAZs(Ref(\"AWS::Region\")),\n        LaunchConfigurationName=Ref(r['webserver_lc']),\n        LoadBalancerNames=[Ref(r['webserver_elb'])],\n\n        UpdatePolicy=UpdatePolicy(\n            AutoScalingRollingUpdate=AutoScalingRollingUpdate(\n                PauseTime='PT5M',\n                MinInstancesInService=\"1\",\n                MaxBatchSize='1',\n                WaitOnResourceSignals=True\n            )\n        ),\n        CreationPolicy=CreationPolicy(\n            ResourceSignal=ResourceSignal(\n                Timeout='PT15M'\n            )\n        ),\n        HealthCheckGracePeriod=300,\n        HealthCheckType=\"EC2\",\n\n        DesiredCapacity=If(\n            \"IsStaging\",\n            '1',\n            '3',\n        ),\n        MinSize=If(\n            \"IsStaging\",\n            '1',\n            '3'\n        ),\n        MaxSize=If(\n            \"IsStaging\",\n            '1',\n            '5'\n        )\n    ))\n```\n\nThis gives the error:\n\n```\nTraceback (most recent call last):\n<-- snip -->\npackages/troposphere/__init__.py\", line 367, in default\n    return obj.JSONrepr()\n  File \"venv/lib/python2.7/site-packages/troposphere/__init__.py\", line 176, in JSONrepr\n    self.validate()\n  File \"venv/lib/python2.7/site-packages/troposphere/autoscaling.py\", line 147, in validate\n    maxCount = int(self.MaxSize)\nTypeError: int() argument must be a string or a number, not 'If'\n```\n\nLet me know if you need any other details.\n\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, Ref, FindInMap\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        '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 '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, (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, Ref, FindInMap, If\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        '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 '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, (FindInMap, Ref, If))\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"}]}