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

v1: E1040 that does not match 'AWS::EC2::Image.Id' #3318

Closed
egut opened this issue Jun 20, 2024 · 0 comments · Fixed by #3346
Closed

v1: E1040 that does not match 'AWS::EC2::Image.Id' #3318

egut opened this issue Jun 20, 2024 · 0 comments · Fixed by #3346

Comments

@egut
Copy link

egut commented Jun 20, 2024

CloudFormation Lint Version

v1.3.0

What operating system are you using?

Ubuntu

Describe the bug

The full error is: E1040 {'Fn::GetAtt': ['SelectAMI', 'AMI']} that does not match 'AWS::EC2::Image.Id'

LaunchTemplate:
    Type: 'AWS::EC2::LaunchTemplate'
    Properties:
      LaunchTemplateName: !Sub '${ShortName}-Template'
      LaunchTemplateData:
        ImageId: !GetAtt 'SelectAMI.AMI'
        :

  SelectAMI:
    Type: 'Custom::SelectAMI'
    Properties:
      ServiceToken: !GetAtt 'SelectAMICustomLambda.Arn'
      :

The custom lambda use some more information to select right image to the LaunchTemplate and then return it as:

    import cfnresponse
     :      
 
     def lambda_handler(event, context):
           
            : 
            # ami is a string
            response_data = {"AMI": ami}
            cfnresponse.send(event, context, cfnresponse.SUCCESS, response_data)

Expected behavior

Expected is that the type check do accept string too as it say in the documentation https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-launchtemplate-launchtemplatedata.html

Reproduction template

---
AWSTemplateFormatVersion: 2010-09-09
Description: 'Bug E1040 and E3014'

Parameters:

  BuildId:
    Type: 'AWS::SSM::Parameter::Value<String>'

  ShortName:
    Type: 'String'

Resources:

  LaunchTemplate:
    Type: 'AWS::EC2::LaunchTemplate'
    Properties:
      LaunchTemplateName: !Sub '${ShortName}-Template'
      # E3014 - bug in cfn-lint 1.3.0 ?
      LaunchTemplateData:
        # E1040 - bug in cfn-lint 1.3.0 ?
        ImageId: !GetAtt 'SelectAMI.AMI'

  SelectAMI:
    Type: 'Custom::SelectAMI'
    Properties:
      # expected: E1010 - due to missing lambda function in this test
      ServiceToken: !GetAtt 'SelectAMICustomLambda.Arn'
      RandomNumber: !Ref 'BuildId'

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