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

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

Closed
aaythapa opened this issue Dec 5, 2024 · 1 comment
Labels

Comments

@aaythapa
Copy link
Contributor

aaythapa commented Dec 5, 2024

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:
@aaythapa aaythapa added stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. type/feature type/bug and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. type/feature labels Dec 5, 2024
@aaythapa aaythapa closed this as completed Dec 5, 2024
Copy link
Contributor

github-actions bot commented Dec 5, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.

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

No branches or pull requests

1 participant