CloudFormation Lint Version
1.52.1
What operating system are you using?
Mac
Describe the bug
Rule E3012 reports a type error when a Ref to a String-typed parameter is used where an integer is expected, even when the code path is guarded by an Fn::If condition that ensures the value is only evaluated when it contains a numeric string. CloudFormation accepts numeric strings in integer-typed properties and deploys successfully.
This pattern is common when a parameter serves dual purpose, with Fn::If + AWS::NoValue removing the property entirely when active.
Expected behavior
No error should be reported in this case as the condition prevents a non-integer value.
Reproduction template
Parameters:
MyCapacity:
Type: String
AllowedPattern: "\\d+|auto"
Default: "auto"
Conditions:
UseProvisionedCapacity:
!Not [!Equals [!Ref MyCapacity, "auto"]]
Resources:
MyTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: Example
KeySchema:
- { AttributeName: id, KeyType: HASH }
AttributeDefinitions:
- { AttributeName: id, AttributeType: S }
ProvisionedThroughput:
!If
- UseProvisionedCapacity
- ReadCapacityUnits: !Ref MyCapacity
WriteCapacityUnits: !Ref MyCapacity
- !Ref "AWS::NoValue"
cfn-lint output:
E3012 'auto' is not of type 'integer'
CloudFormation Lint Version
1.52.1
What operating system are you using?
Mac
Describe the bug
Rule E3012 reports a type error when a Ref to a String-typed parameter is used where an integer is expected, even when the code path is guarded by an
Fn::Ifcondition that ensures the value is only evaluated when it contains a numeric string. CloudFormation accepts numeric strings in integer-typed properties and deploys successfully.This pattern is common when a parameter serves dual purpose, with
Fn::If+AWS::NoValueremoving the property entirely when active.Expected behavior
No error should be reported in this case as the condition prevents a non-integer value.
Reproduction template
cfn-lint output: