cfn-lint
cfn-lint copied to clipboard
Validate UpdatePolicy for AutoScalingRollingUpdate
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.
Agreed. This would be a good business logic addition to compare values. I'll label this as an enhancement.
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.
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!
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.
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