Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow HelperFn in UpdatePolicy for ASG #588

Merged
merged 1 commit into from
Oct 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 21 additions & 1 deletion tests/test_asg.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
from troposphere.autoscaling import AutoScalingGroup
from troposphere.policies import AutoScalingRollingUpdate, UpdatePolicy
from troposphere import If
from troposphere import If, Ref


class TestAutoScalingGroup(unittest.TestCase):
Expand Down Expand Up @@ -63,6 +63,26 @@ def test_size_if(self):
)
self.assertTrue(group.validate())

def test_helperfn_as_updatepolicy(self):
update_policy = UpdatePolicy(
AutoScalingRollingUpdate=AutoScalingRollingUpdate(
PauseTime='PT5M',
MinInstancesInService="1",
MaxBatchSize='1',
WaitOnResourceSignals=True
)
)
group = AutoScalingGroup(
'mygroup',
AvailabilityZones=['eu-west-1a', 'eu-west-1b'],
LaunchConfigurationName="I'm a test",
MaxSize=If("isstage", "1", "5"),
MinSize="1",
UpdatePolicy=If("UseUpdatePolicy",
update_policy, Ref("AWS::NoValue"))
)
self.assertTrue(group.validate())


if __name__ == '__main__':
unittest.main()
3 changes: 2 additions & 1 deletion troposphere/autoscaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ def validate(self):
if 'UpdatePolicy' in self.resource:
update_policy = self.resource['UpdatePolicy']

if 'AutoScalingRollingUpdate' in update_policy.properties:
if (not isinstance(update_policy, AWSHelperFn) and
'AutoScalingRollingUpdate' in update_policy.properties):
rolling_update = update_policy.AutoScalingRollingUpdate

isMinNoCheck = isinstance(
Expand Down