Skip to content

Intrinsic functions don't work in AutoPublishAlias property in SAM StateMachine #3694

Closed
@aaythapa

Description

@aaythapa

Description

When using !Ref intrinsic in AutoPublishAlias in SAM StateMachine there is an error that pops up

'Logical ids must be alphanumeric.'

This is because SAM doesn't resolve the intrinsic used in AutoPublishAlias as its considered a pass through. This same behavior works in SAM Function and its AutoPublishAlias property as that property has its intrinsic resolved.

This causes sam deploy and other SAM CLI functions to fail.

Steps to reproduce

Example SAM template

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  test-sam-validate

  Sample SAM Template for test-sam-validate
  
Parameters:
  StateMachineNameParameter:
    Type: String
    Default: MyStateMachineName
  
  AutoPublishAliasParameter:
    Type: String
    Default: TestAliasRef

Resources:
  TestStateMachine:
    Type: AWS::Serverless::StateMachine
    Properties:
      Name: !Ref StateMachineNameParameter
      AutoPublishAlias: !Ref AutoPublishAliasParameter
      Definition:
        StartAt: MyLambdaState
        States:
          MyLambdaState:
            Type: Task
            Resource: arn:aws:lambda:us-east-1:<REDACTED>:function:print-event
            End: true
            
  TestLambdaFunction: 
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: python3.9
      InlineCode: |
        def handler(event, context):
          print("Hello, world!")
      AutoPublishAlias: !Ref AutoPublishAliasParameter

Observed result

Error when translating StateMachine part of the SAM template

Resource with id [TestStateMachineAlias{'Ref': 'AutoPublishAliasParameter'}] is invalid. Logical ids must be alphanumeric.

Expected result

AutoPublishAlias in SAM StateMachine should not error out and should work like SAM Function's AutoPublishAlias

Additional environment details

  1. OS:
  2. If using the SAM CLI, sam --version:
  3. AWS region:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions