Repository: cloudtools/troposphere

Issue:
Support AutoScalingCreationPolicy
From the docs, this is a top-level property of a [CreationPolicy](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-creationpolicy.html#cfn-attributes-creationpolicy-properties). It is used for the [AutoScalingReplacingPolicy](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatepolicy.html#cfn-attributes-updatepolicy-replacingupdate) to specify the MinSuccessfulInstancesPercent property.

The docs have a good example of this:

``` json
"UpdatePolicy" : {
  "AutoScalingReplacingUpdate" : {
    "WillReplace" : "true"
  },
"CreationPolicy" : {
  "ResourceSignal" : {
    "Count" : { "Ref" : "ResourceSignalsOnCreate"},
    "Timeout" : "PT10M"
  },
  "AutoScalingCreationPolicy" : {
    "MinSuccessfulInstancesPercent" : { "Ref" : "MinSuccessfulPercentParameter" }
  }
}
```

I might take a crack at this but I figured I'd file an issue first if only so that I can reference it.



Discussion:

Resolving patch:
diff --git a/troposphere/policies.py b/troposphere/policies.py
--- a/troposphere/policies.py
+++ b/troposphere/policies.py
@@ -40,7 +40,14 @@ class ResourceSignal(AWSProperty):
     }
 
 
+class AutoScalingCreationPolicy(AWSProperty):
+    props = {
+        'MinSuccessfulInstancesPercent': (integer, False),
+    }
+
+
 class CreationPolicy(AWSAttribute):
     props = {
+        'AutoScalingCreationPolicy': (AutoScalingCreationPolicy, False),
         'ResourceSignal': (ResourceSignal, True),
     }


Test patch:
diff --git a/tests/test_policies.py b/tests/test_policies.py
--- a/tests/test_policies.py
+++ b/tests/test_policies.py
@@ -4,6 +4,7 @@
 from troposphere import awsencode, Parameter, Ref
 from troposphere.autoscaling import AutoScalingGroup
 from troposphere.policies import CreationPolicy, ResourceSignal, UpdatePolicy
+from troposphere.policies import AutoScalingCreationPolicy
 from troposphere.policies import AutoScalingRollingUpdate
 
 
@@ -35,6 +36,37 @@ def test_json(self):
         self.assertEqual(p['ResourceSignal']['Count'], 2)
         self.assertEqual(p['ResourceSignal']['Timeout'], 'PT10M')
 
+    def test_auto_scaling_creation_policy(self):
+        policy = CreationPolicy(
+            AutoScalingCreationPolicy=AutoScalingCreationPolicy(
+                MinSuccessfulInstancesPercent=50,
+            ),
+            ResourceSignal=ResourceSignal(
+                Count=2,
+                Timeout='PT10M'
+            )
+        )
+        self.assertEqual(
+            policy.AutoScalingCreationPolicy.MinSuccessfulInstancesPercent,
+            50
+        )
+
+    def test_auto_scaling_creation_policy_json(self):
+        policy = CreationPolicy(
+            AutoScalingCreationPolicy=AutoScalingCreationPolicy(
+                MinSuccessfulInstancesPercent=50,
+            ),
+            ResourceSignal=ResourceSignal(
+                Count=2,
+                Timeout='PT10M'
+            )
+        )
+        p = json.loads(json.dumps(policy, cls=awsencode))
+        self.assertEqual(
+            p['AutoScalingCreationPolicy']['MinSuccessfulInstancesPercent'],
+            50
+        )
+
 
 class TestUpdatePolicy(unittest.TestCase):