-
Notifications
You must be signed in to change notification settings - Fork 87
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
project-location is relative to the folder of the template, not the working directory #214
Comments
@hauntingEcho Could you please point to documentation source which has the issue? |
It looks like it's defined as a common option here. I don't know whether it's incorrect for anything other than package-ci, though CLI help message:
|
My thought process here is for |
@normj a little off-topic, but is there any documentation you could link on using it with multiple .NET projects? That would massively simplify a few of our builds. |
Digging into this, it looks like things just generally don't work right when the project is not in the same directory as the template: Taking just the first two steps of the setup ( Following that with So there's a good chance my initial diagnosis was wrong too. It looks like:
if I'm understanding correctly? |
Here is the post talking about how to use multiple projects with the CloudFormation template. https://aws.amazon.com/blogs/developer/aws-serverless-applications-with-multiple-net-core-projects/ From what I understand your Lambda code is in I would run the
But then you need to make sure the functions in declared in the CloudFormation template use the AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: An AWS Serverless Application.
Resources:
lambda_example:
Type: AWS::Serverless::Function
Properties:
Handler: LambdaExample::LambdaExample.Functions::Handler
Runtime: dotnet6
CodeUri: "./lambda_example"
MemorySize: 256
Timeout: 30
Role:
Policies:
- AWSLambdaBasicExecutionRole
Events:
RootGet:
Type: Api
Properties:
Path: "/foo"
Method: GET
lambda_second_project:
Type: AWS::Serverless::Function
Properties:
Handler: LambdaSecondProject::LambdaSecondProject.Functions::Handler
Runtime: dotnet6
CodeUri: "./lambda_second_project"
MemorySize: 256
Timeout: 30
Role:
Policies:
- AWSLambdaBasicExecutionRole
Events:
RootGet:
Type: Api
Properties:
Path: "/bar"
Method: GET |
Ah! Using
|
@hauntingEcho Please confirm if guidance provided by @normj resolves your issue. |
it gives me a workaround in which I don't need to use the project-location flag for my use-case, but doesn't resolve the issue with the help message |
Describe the bug
project-location is documented as: "The location of the project, if not set the current directory will be assumed."
It actually is relative to, and defaults to, the folder of your template file rather than your current working directory.
Expected Behavior
project location is relative to, and defaults to, the current working directory
Current Behavior
project location actually is relative to, and defaults to, the folder of your template file.
Reproduction Steps
Commands assume you're using git-bash on Windows 10:
dotnet new lambda.EmptyFunction && touch serverless.yaml
cd src/lambda-example
dotnet lambda package-ci -t ../../serverless.yaml -sb "${bucket}" --output-template compiled.yaml
using a bucket in your default region to which you have write-accesscp ../../serverless.yaml . && cd ../.. && dotnet lambda package-ci -t src/lambda-example/serverless.yaml -sb "${bucket}" --output-template compiled.yaml
serverless.yaml:
Possible Solution
Update the documentation - this would be a breaking change, and probably not worth actually changing the behavior.
Additional Information/Context
No response
Targeted .NET platform
$ dotnet --version
6.0.202
CLI extension version
$ dotnet tool list -g
Package Id Version Commands
amazon.lambda.testtool-3.1 0.12.1 dotnet-lambda-test-tool-3.1
amazon.lambda.testtool-6.0 0.12.1 dotnet-lambda-test-tool-6.0
amazon.lambda.tools 5.1.4 dotnet-lambda
dotnet-ef 5.0.9 dotnet-ef
dotnet-reportgenerator-globaltool 4.8.12 reportgenerator
Environment details (OS name and version, etc.)
Windows 10, git bash
The text was updated successfully, but these errors were encountered: