aws / aws-sam-cli

CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM
https://aws.amazon.com/serverless/sam/
Apache License 2.0
6.5k stars 1.17k forks source link

DefinitionUri for AWS::Serverless::StateMachine errors if it contains a - character #4615

Open jbesw opened 4 years ago

jbesw commented 4 years ago

Hyphen/dash character in DefinitionUrl causes error - error message does not indicate this is the problem.

Description

Deploying a template with a Uri like this:

  ResizerStateMachine:
    Type: AWS::Serverless::StateMachine
    Properties:
      DefinitionUri: definitions/1-resizer.asl.json

...causes the error "Property validation failure: [Encountered unsupported properties in {/}: [DefinitionUri]]" Removing the dash, it deploys correctly.

Steps to reproduce

Deploy a state machine with a dash in the DefinitionUri.

Observed result

"Property validation failure: [Encountered unsupported properties in {/}: [DefinitionUri]]"

Expected result

Either:

  1. Successful deployment (dash accepted).
  2. Error indicating that the dash character is problematic, not the "/" character as shown.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Windows
  2. sam --version: 0.53.0

Add --debug flag to command you are running

mndeveci commented 4 years ago

Hi @jbesw , can you run the following command (sam validate --debug) and provide the value for DefinitionUri in generated CFN template?

aaronlelevier commented 4 years ago

Hi, I am getting the same error. This is what I got when I ran sam validate --debug which came back as valid.

CustomResourceStateMachine:
    Type: AWS::StepFunctions::StateMachine
    Properties:
      DefinitionUri: statemachine/main.asl.json
hoffa commented 1 year ago

The SAM transform doesn't support local paths, while SAM CLI does.

I tried reproducing with the SAM transform using the closest valid template:

Transform: AWS::Serverless-2016-10-31
Resources:
  ResizerStateMachine:
    Type: AWS::Serverless::StateMachine
    Properties:
      DefinitionUri: s3://foo-bar/egg-baz

Which transformed (as expected) to the following template:

Resources:
  ResizerStateMachine:
    Type: AWS::StepFunctions::StateMachine
    Properties:
      DefinitionS3Location:
        Bucket: foo-bar
        Key: egg-baz
      RoleArn: !GetAtt 'ResizerStateMachineRole.Arn'
      Tags:
        - Key: stateMachine:createdBy
          Value: SAM
  ResizerStateMachineRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Action:
              - sts:AssumeRole
            Effect: Allow
            Principal:
              Service:
                - states.amazonaws.com
      ManagedPolicyArns: []
      Tags:
        - Key: stateMachine:createdBy
          Value: SAM