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

Error validando funciones en los tags #3829

Closed
cajlopezor opened this issue Nov 8, 2022 · 3 comments · Fixed by #3835
Closed

Error validando funciones en los tags #3829

cajlopezor opened this issue Nov 8, 2022 · 3 comments · Fixed by #3835

Comments

@cajlopezor
Copy link

Describe the issue
We are trying to execute checkov in a template which makes use of a function (IF) in the tags:

    - 'Fn::If':
       - cPdnEnv
       -
         Key: "Schedule"
         Value: "VISOR-02"
       - !Ref "AWS::NoValue"    

but it throws the following error message:

Failed to parse tags for entity {'rEC2Instance': ...

We updated to the latest version of checkov but the error continues

According to the AWS documentation, this IF function can be used on tags.

@gruebel
Copy link
Contributor

gruebel commented Nov 9, 2022

hey @cajlopezor thanks for reaching out. Can you provide the whole resource as an example? from the error message it looks like you added tags to an EC2 instance, right?

@cajlopezor
Copy link
Author

Hi @gruebel, I shareyou the yaml of the resource and the error

Resources:

  rEC2Instance:
    Condition: cAditionalEc2
    Type: AWS::EC2::Instance
    Properties:
      DisableApiTermination: true 
      NetworkInterfaces: 
        - AssociatePublicIpAddress: "false"              
          DeviceIndex: "0"
          GroupSet: 
            - !Join ["", ["{{resolve:ssm:", !Ref pPSGASt, "}}"]]
          SubnetId: !Ref pSubnetPriv5
      InstanceType: !Ref pEC2InstanceTypeSSAStqP
      ImageId: !FindInMap
        - EnvironmentToAMI
        - !Ref pEnvironment
        - AMIID
      IamInstanceProfile: !Join ["", ["{{resolve:ssm:", !Ref pInstanceProfile, "}}"]]
      BlockDeviceMappings:
        - DeviceName: /dev/sda1
          Ebs:
            VolumeSize: !Ref pOSSizeDisk
            VolumeType: !Ref pTypeDisk          
            Encrypted: 'true' 
            KmsKeyId: !Join ["", ["{{resolve:ssm:", !Ref pPSKMSARN, "}}"]]
        - DeviceName: /dev/sdb
          Ebs:
            VolumeSize: 50
            VolumeType: !Ref pTypeDisk
            Encrypted: 'true' 
            KmsKeyId: !Join ["", ["{{resolve:ssm:", !Ref pPSKMSARN, "}}"]]
      UserData:
        Fn::Base64:
          Fn::Sub:
            - |
              <powershell>
               query here
              </powershell>
      Tags:
        - Key: Name
          Value: !Ref xxxx
        - 'Fn::If':
           - cPdnEnv
           -
             Key: "Schedule"
             Value: "xxxx"
           - !Ref "AWS::NoValue"

The error is:

Current File Scanned=/template (4).yaml2022-11-09 09:30:23,665 [ThreadPoolEx] [WARNI] Failed to parse tags for entity {'rEC2Instance': {'Type': 'AWS::EC2::Instance', 'Properties': {'DisableApiTermination': True, 'NetworkInterfaces': [{'AssociatePublicIpAddress': 'false', 'DeviceIndex': '0', 'GroupSet': [{'Fn::Join': ['', ['{{resolve:ssm:', {'Ref': 'pPSGASt'}, '}}']]}], 'SubnetId': {'Ref': 'pSubnetPriv5'}, '__startline__': 134, '__endline__': 139}], 'InstanceType': {'Ref': 'pEC2InstanceTypeSSAStqP'}, 'ImageId': {'Fn::FindInMap': ['EnvironmentToAMI', {'Ref': 'pEnvironment'}, 'AMIID']}, 'IamInstanceProfile': {'Fn::Join': ['', ['{{resolve:ssm:', {'Ref': 'pInstanceProfile'}, '}}']]}, 'BlockDeviceMappings': [{'DeviceName': '/dev/sda1', 'Ebs': {'VolumeSize': {'Ref': 'pOSSizeDisk'}, 'VolumeType': {'Ref': 'pTypeDisk'}, 'Encrypted': 'true', 'KmsKeyId': {'Fn::Join': ['', ['{{resolve:ssm:', {'Ref': 'pPSKMSARN'}, '}}']]}, '__startline__': 148, '__endline__': 152}, '__startline__': 146, '__endline__': 152}, {'DeviceName': '/dev/sdb', 'Ebs': {'VolumeSize': 50, 'VolumeType': {'Ref': 'pTypeDisk'}, 'Encrypted': 'true', 'KmsKeyId': {'Fn::Join': ['', ['{{resolve:ssm:', {'Ref': 'pPSKMSARN'}, '}}']]}, '__startline__': 154, '__endline__': 158},

thanks

@gruebel
Copy link
Contributor

gruebel commented Nov 9, 2022

great thanks!

@gruebel gruebel added this to checkov Nov 9, 2022
@gruebel gruebel added this to the bugs milestone Nov 9, 2022
@gruebel gruebel moved this to 👀 In review in checkov Nov 9, 2022
Repository owner moved this from 👀 In review to 🚀 Done in checkov Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🚀 Done
Development

Successfully merging a pull request may close this issue.

2 participants