Issue
Good evening. The question is about dotnet lambda deploy-serverless
command. This command is used to deploy .Net apps to AWS Lambda service using AWS CloudFormation. When I try to run this command in Jenkins pipeline in stage:
stage('Update AWS lambda') {
steps {
bat "cd MyFinance.Api"
bat "dotnet lambda deploy-serverless"
}
}
I receive errors about missing parameters:
C:\Program Files (x86)\Jenkins\workspace\MyFinanceApiPipeline>dotnet lambda deploy-serverless Amazon Lambda Tools for .NET Core applications (4.1.0) Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet Enter CloudFormation Stack Name: (CloudFormation stack name for an AWS Serverless application) Enter S3 Bucket: (S3 bucket to upload the build output) Enter CloudFormation Template: (Path to the CloudFormation template) Enter AWS Region: (The region to connect to AWS services, if not set region will be detected from the environment.) Can not determine AWS region. Either configure a default region or use the --region option.
But if I run this command via PowerShell in my project folder everything is ok. Near is a screenshot of command execution results. Successful command execution in PowerShell So, how to run this without parameters in Jenkins pipeline (like I made via PowerShell)? Thank you in advance.
Solution
This happens when you don't pass those requested parameters. You may pass these as arguments to the command
dotnet lambda deploy-serverless --stack-name replace-your-stack-name-here --s3-bucket replace-s3-bucket-name-here --region replace-with-region
You will have to navigate the folder where you have the "serverless.template" file before running this command. or optionally you can pass the path to the template file with the argument -t
Answered By - Kasun Dissanayake