zalando-stups / senza

Deploy immutable application stacks and create and execute AWS CloudFormation templates in a sane way
https://pypi.python.org/pypi/stups-senza
Other
96 stars 72 forks source link

Senza Autoscaling Minimum doesn't allow conditionals #214

Open gnuton opened 8 years ago

gnuton commented 8 years ago

PROBLEM: As the title says sanza autoscaling group doesn't support conditionals for Minimum variable.

STEPS TO REPRODUCE THE ISSUE Copy the YAML below in a file and try to generate a cloudformation template out of it: senza print the_yaml_file_below.yaml 0

the exepected outcome is a cloudformation template, but the real outcome is a crash. python throws an exception File "/usr/local/lib/python3.5/dist-packages/senza/components/auto_scaling_group.py", line 151, in component_auto_scaling_group asg_properties["DesiredCapacity"] = max(int(as_conf["Minimum"]), int(as_conf.get('DesiredCapacity', 1)))

HOW TO FIX THIS ISSUE Replace asg_properties["DesiredCapacity"] = max(int(as_conf["Minimum"]), int(as_conf.get('DesiredCapacity', 1))) with: asg_properties["DesiredCapacity"] = as_conf["Minimum"]

ATTACHEMENTS:

SenzaInfo:
   StackName: elasticdiscovery
   Parameters:
      - ENV:
         Description: "environment name"
         Default: dev
         AllowedValues: ["dev", "ci", "stg", "prod"]

   Conditions:
      CreateProdResources:
          Fn::Equals:
            - Ref: "ENV"
            - "prod"

SenzaComponents:
   - Configuration:
      Type: Senza::StupsAutoConfiguration

   - AppServer:
      Type: Senza::TaupageAutoScalingGroup
      AutoScaling:
         Minimum:
             Fn::If:
                 - "CreateProdResources"
                 - 1
                 - 2

         Maximum:
             Fn::If:
                 - "CreateProdResources"
                 - 5
                 - 2
         MetricType: CPU
         ScaleUpThreshold: 80
         ScaleDownThreshold: 40
      InstanceType: "m1.small"
      IamRoles:
        - Ref: AppIamRole
      AssociatePublicIpAddress: false
      ElasticLoadBalancer: AppLoadBalancer
      TaupageConfig:
         application_id: "xx"
         application_version: "12"
         root: true
         runtime: Docker
         source: "z.x.y/xx"
gnuton commented 8 years ago

Nevermind it looks like boto doesn't like conditionals there too. I ll close the report.

botocore.exceptions.ClientError: An error occurred (ValidationError) when calling the CreateStack operation: Template format error: Every Mappings attribute must be a String or a List.

gnuton commented 8 years ago

The mapping problem was related to Conditions into SenzaInfo