Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E1017, E1019 missing key reported when value is falsy #3408

Closed
nosnilmot opened this issue Jun 26, 2024 · 2 comments · Fixed by #3410
Closed

E1017, E1019 missing key reported when value is falsy #3408

nosnilmot opened this issue Jun 26, 2024 · 2 comments · Fixed by #3410

Comments

@nosnilmot
Copy link

CloudFormation Lint Version

1.3.5

What operating system are you using?

Mac

Describe the bug

Thanks for fixing #3385

Now cfn-lint incorrectly complains about missing keys if the resolved value is falsy (0 or "")

E1019 'Idx' is not one of ['Idx'] for mapping 'Map' and key 'Key' when 'Ref' is resolved
map.yaml:10:7

E1019 'Idx' is not one of ['Idx'] for mapping 'Map' and key 'Key'
map.yaml:12:45

Expected behavior

no errors or warnings

Reproduction template

AWSTemplateFormatVersion: '2010-09-09'
Mappings:
  Map:
    Key:
      Idx: 0
Resources:
  Bucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: !Sub
        - "bucket-${number}"
        - number: !FindInMap ["Map", "Key", "Idx"]
@nosnilmot
Copy link
Author

Another variant of the same problem reports as E1017 (this is closer to what I distilled to the original reproducer but I didn't notice the error number changed):

E1017 'Idx' is not one of ['Idx'] for mapping 'Map' and key 'Key'
mapv.yaml:25:13
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
  CidrBlock:
    Type: String
    Default: "192.168.0.0/24"
  Ipv6CidrList:
    Type: CommaDelimitedList
    Default: ""
Mappings:
  Map:
    Key:
      Idx: 0
Resources:
  VPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: !Ref CidrBlock
  Subnet:
    Type: AWS::EC2::Subnet
    Properties:
      Ipv6CidrBlock: !Select
        - !FindInMap
          - Map
          - Key
          - Idx
        - !Ref Ipv6CidrList
      VpcId: !Ref 'VPC'

@nosnilmot nosnilmot changed the title E1019 missing key reported when value is falsy E1017, E1019 missing key reported when value is falsy Jun 26, 2024
@nosnilmot
Copy link
Author

Another FindInMap problem (do you need a separate issue for this?)

cfn-lint 1.3.0-1.3.5 do not report any problem with this template that is completely missing the map RegionMap

AWSTemplateFormatVersion: '2010-09-09'
Resources:
  VPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: !FindInMap
        - RegionMap
        - !Ref 'AWS::Region'
        - Key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant