aws / aws/aws-extensions-for-dotnet-cli

Support StateMachine DefinitionUri for local files

Open
#314 2 comments 0 reactions 0 assignees View on GitHub
bug module/cli-ext p2 queued s
Dominant language
C#
Stars
393
Forks
90
Avg merge
2d 19m
Merged PRs (30d)
3

Description

### Describe the bug

According to [AWS docs for SAM-style _StateMachine_ declaration](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-statemachine.html#sam-statemachine-definitionuri), the `DefinitionUri` should support specifying a local file path. However, in practice deployment fails.

### Expected Behavior

Given a separate file in a subfolder `States/state-machine.yml`, I should be able to use the following in my `serverless.yml` template to deploy the stack:

AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
...
Resources:
StateMachine:
Type: AWS::Serverless::StateMachine
Properties:
Name: !Sub ${AWS::StackName}
Role: !GetAtt [StateMachineRole, Arn]
AutoPublishAlias: live
# DeploymentPreference:
# Type: Linear10PercentEvery10Minutes
PropagateTags: true
DefinitionSubstitutions:
MyFnMethod1.Arn: !GetAtt [MyFnMethod1, Arn]
MyFnMethod2.Arn: !GetAtt [MyFnMethod2, Arn]
# can't transclude b/c of issue #116
#DefinitionString: !Sub 'States\state-machine.json'

DefinitionUri: States/state-machine.yml <-- this fails

Definition: <-- this works if used instead
Comment: explicit inline declaration
StartAt: Begin
...

### Current Behavior

However, I'm getting the same error when trying to deploy as described in 4-year old closed issue https://github.com/aws-cloudformation/cfn-lint/issues/1561

> Failed to create CloudFormation change set: Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [StateMachine] is invalid. 'DefinitionUri' is not a valid S3 Uri of the form 's3://bucket/key' with optional versionId query parameter.

### Reproduction Steps

See above using `DefinitionUri`. Replacing it with an inline `Definition` works so the problem shouldn't be the definition itself.

### Possible Solution

Is something using an older transformation version or CDK? As far as I can tell there's nothing other than `Transform: AWS::Serverless-2016-10-31` as described [here](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-aws-serverless.html), and you're using almost the most recent [CloudFormation nuget package](https://www.nuget.org/packages/AWSSDK.CloudFormation) (3.7.307.11 is only 10 days newer than the version referenced here).

Per the definition of `DefinitionUri`, am I missing something to include the separate file in the deployment process? It's currently set to "None/Copy If Newer".

> If you provide a local file path, the template must go through the workflow that includes the sam deploy or sam package command to correctly transform the definition. To do this, you must use version 0.52.0 or later of the AWS SAM CLI.

### Additional Information/Context

_No response_

### Targeted .NET platform

.NET 8

### CLI extension version

Package Id Version Commands
------------------------------------------------------------------------
amazon.lambda.testtool-3.1 0.10.0 dotnet-lambda-test-tool-3.1
amazon.lambda.tools 5.10.4 dotnet-lambda
dotnet-xscgen 2.0.662 xscgen

### Environment details (OS name and version, etc.)

Windows 10

Contributor guide

Open the contributing guide

Research direction

Start with the reported serverless.yml reproduction using States/state-machine.yml as DefinitionUri, and compare it with the inline Definition case. Check the dotnet CLI's packaging or deployment entry point and the documented sam package or sam deploy workflow; done means a local DefinitionUri can be deployed successfully, or the issue is shown to belong to an external AWS transformation limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, csharp, yaml
Domain
cli, cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.