cfn-lint icon indicating copy to clipboard operation
cfn-lint copied to clipboard

Validate UpdatePolicy for AutoScalingRollingUpdate

Open adamchainz opened this issue 7 years ago • 5 comments

cfn-lint version: (cfn-lint --version) 0.7.2

Description of issue.

Using a template like:

Resources:
  AutoScalingGroup:
    Type: AWS::AutoScaling::AutoScalingGroup
    Properties:
      # ...
      MinSize: "1"
      MaxSize: "1"
      # ...
    UpdatePolicy:
      AutoScalingRollingUpdate:
        MinInstancesInService: 1

will fail at deployment time with an error from CloudFormation like:

AWS::AutoScaling::AutoScalingGroup AutoScalingGroup UPDATE_FAILED: MinInstancesInService must be less than the autoscaling group's MaxSize

It would be nice to have protection against this. I guess there are other constraints, some are in the docs. I submitted a docs PR for this one.

adamchainz avatar Sep 24 '18 21:09 adamchainz

Agreed. This would be a good business logic addition to compare values. I'll label this as an enhancement.

cmmeyer avatar Sep 25 '18 15:09 cmmeyer

Started with rule E3016 to check the basic configuration of the UpdatePolicy (attributes, values are of the correct type), etc.

Moving down the chain to this one next.

kddejong avatar Oct 02 '18 07:10 kddejong

I have an issue with UpdatePolicy validation. I am using a different update policy for spot instances (replacingupdate) and regular instances (rolling update)

So something like:

UpdatePolicy:
            !If
                - spotInstances
                - AutoScalingReplacingUpdate:
                      WillReplace: true
                - AutoScalingRollingUpdate:
                      MinInstancesInService: !Ref DedicatedIngestNodeCount
                      MinSuccessfulInstancesPercent: 100
                      MaxBatchSize: 1
                      PauseTime: PT15M
                      WaitOnResourceSignals: true
                      SuspendProcesses:
                          - HealthCheck
                          - ReplaceUnhealthy
                          - AZRebalance
                          - AlarmNotification
                          - ScheduledActions

But this gives the following linting error:

E3016 UpdatePolicy doesn't support type Fn::If

This code actually works in CFN, so can the linting be fixed for this?

Thanks!

kalpik avatar Nov 09 '18 08:11 kalpik

Sorry @kalpik I lost track of this. I have created pull request #468 totally rewritten to handle conditions on each level. Used your example for adding to tests. Thanks for reporting this.

kddejong avatar Nov 17 '18 02:11 kddejong

I am getting error E3016 UpdatePolicy doesn't support type AutoScalingRollingUpdate from this AWS example: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-autoscaling.html#scenario-as-updatepolicy

digash avatar Dec 15 '20 19:12 digash