cfn-lint: AutoPublishAlias with a !Ref value marked as false positive

cfn-lint version: 0.11.1

I’m running into an issue with AutoPublishAlias. When using a !Ref as its value, I get the following error message:

E0001 Resource with id [SkillFunction] is invalid. 'AutoPublishAlias' must be a string or a Ref to a template parameter
foo.yml:1:1

Here’s the minimal template to reproduce the issue:

---

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31

Parameters:
  Stage:
    Description: Environment stage (deployment phase)
    Type: String
    AllowedValues:
      - beta
      - prod

Resources:
  SkillFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: '.'
      Handler: main.handler
      Runtime: python3.7
      Timeout: 30
      MemorySize: 128
      AutoPublishAlias: !Ref Stage

The error message is actually very helpful (👏 for that), but as you can see, I am using a !Ref to a template parameter, so this should not cause a linting error.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 21 (11 by maintainers)

Most upvoted comments

@kddejong my apologies, I had downloaded the latest version but still had an old version on my path that was run instead. I fixed my path to use the latest version and this works.

@keetonian the template in this issue still works for me in the newest version. Can you explain more about the template you are having an issue with so I can try replicate the issue.

Sounds fair. I can work on it our side. Trick from a lint-ing perspective is translate removes a Ref to a parameter and we will need to remove that parameter (if its no longer used) so we don’t flag false positives.

Yea sorry I didn’t explain that well. We can’t lint a pre-transformed template because there isn’t a CloudFormation spec for it. We pass it to the sam translator and then lint the results. In this case since they give us back an error we spit it back to you and don’t lint the file.