troposphere icon indicating copy to clipboard operation
troposphere copied to clipboard

AutoScalingGroup MinSize and MaxSize do not allow use of Select intrinsic function

Open johnctitus opened this issue 8 years ago • 2 comments

I am trying to consolidate the ASG Min, Max, and Desired values into a single parameter, and I am hitting an error. I have the parameter formatted as a list of | delimited values, and I am using Select and Split to separate the items. I currently have the following values set for three properties:

            MinSize=Select(0, Split("|", Ref(scaling_settings))),
            MaxSize=Select(2, Split("|", Ref(scaling_settings))),
            DesiredCapacity=Select(1, Split("|", Ref(scaling_settings))),

When trying to generate the template, I am hitting the following error:

...
  File "c:\python27\lib\site-packages\troposphere\__init__.py", line 556, in to_dict
    return encode_to_dict(t)
  File "c:\python27\lib\site-packages\troposphere\__init__.py", line 61, in encode_to_dict
    props[name] = encode_to_dict(prop)
  File "c:\python27\lib\site-packages\troposphere\__init__.py", line 61, in encode_to_dict
    props[name] = encode_to_dict(prop)
  File "c:\python27\lib\site-packages\troposphere\__init__.py", line 52, in encode_to_dict
    return encode_to_dict(obj.to_dict())
  File "c:\python27\lib\site-packages\troposphere\__init__.py", line 206, in to_dict
    self.validate()
  File "c:\python27\lib\site-packages\troposphere\autoscaling.py", line 146, in validate
    max_count = int(self.MaxSize)
RuntimeError: Failed to build JSON for template <TemplateName>: int() argument must be a string or a number, not 'Select'

It appears only the If, FindInMap, and Ref functions are currently allowed. I would like to propose adding Select to the allowed functions for the MinSize and MaxSize properties as well.

johnctitus avatar Jun 26 '17 18:06 johnctitus

@phobologic any reason why these checks shouldn't just be checking against AWSHelperFn? https://github.com/cloudtools/troposphere/blob/master/troposphere/autoscaling.py#L138

markpeek avatar Jun 26 '17 19:06 markpeek

I can't think of one, not sure why we only did the specific functions in the first place.

phobologic avatar Jun 27 '17 00:06 phobologic