Open scottrmercer opened 8 months ago
I have the same problem. SAM template:
Conditions:
UseProductionSettings: !Equals [!Ref Env, "prod"]
Parameters:
Env:
Description: Deploying environment
Type: String
Default: dev
ProductionProvisionedConcurrency:
Description: Number of Lambda provisioned concurrency for production environment
Type: Number
Default: 2
...
MyFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "my-function-${Env}"
CodeUri: my_function/
Handler: app.lambda_handler
Role: !Ref LambdaRoleARN
AutoPublishAlias: live
ProvisionedConcurrencyConfig:
ProvisionedConcurrentExecutions:
!If [
UseProductionSettings,
!Sub "${ProductionProvisionedConcurrency}",
1,
]
E1019 {'Fn::Sub': '${ProductionProvisionedConcurrency}'} is not of type 'integer'
template.yaml:104:13
cfn-lint
version 1.3.3 (latest)I need to validate this (E1019 {'Fn::Sub': '${ProductionProvisionedConcurrency}'} is not of type 'integer'
). There is an odd issue when doing a GetAtt to an integer but I think in the case of a parameter it works as you have pointed out.
CloudFormation Lint Version
0.83.8
What operating system are you using?
MacOS
Describe the bug
When evaluating a Serverless.yml file,
Sub
parameters that use dot notation are not matched withvalid_params
, leading to false E1019 errors.I managed to make 2 adjustments that "fixed" the symptoms, although I am not familiar enough with the codebase to know if these qualify as anything more than hacks.
Resources
node under another node namedresources
(see my example). Because of this,Template.get_resource_names()
returns an empty list. As a hack, I changedget_resource_names
so thatresources = self.template.get("resources", {})
is replaced withresources = self.template.get("resources", {}).get("Resources", {})
, returning the full list.Sub
params that use dot notation do not match, as only the first segment of the parameter is in thevalid_params
list. In order to use dot notation to refer to properties on the resource param, I had to change line 131 ofSub.py
fromif parameter not in valid_params:
toif parameter.split('.')[0] not in valid_params:
. This resolves all issues, although it does seem hacky, like #1.Hopefully this is just something that I am doing wrong, rather than a real bug.
Expected behavior
E1019 is not returned, and linting passes.
Reproduction template