Error while publishing AWS Lambda - aws-lambda

We are trying to publish AWS Lambda function using .NET Core Web application and got the following error message

You didn't set your parameters during the publishing.
Open serverless.template file in your project. In "Parameters" section find out 'ShoudCreateBucket' and 'BucketName' items. Then you have to set/add 'Default' value of these items.
Also, you could set these parameters during deployment (click 'Next' instead of 'Publish' on the first deployment screen).
Check out more details in this tutorial Tutorial: Build and Test a Serverless Application with AWS Lambda.

Related

Using JavaScript ESM in Serverless Framework functions

I'm using the modern import/export syntax in my NodeJS functions for the Serverless Framework.
After deployment, when I try and invoke the URL I see HTTP 502 {"message": "Internal server error"} error. The CloudWatch logs say:
require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/var/task/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
When I inspect the code through the AWS Console > Lambda, I can see the Serverless Framework has generated a s_getDns.js file for my function, and inside it's using the legacy "require" syntax:
var serverlessSDK = require('./serverless_sdk/index.js');
serverlessSDK = new serverlessSDK({
// ...
});
I'm using v3.23.0 of the Serverless Framework.
I have tried:
Added "type": "module" to the packages.json file
Used the nodejs16.x runtime
(which lead to the error described above)
I have also tried manually editing the s_getDns.js file in the Lambda console to use the new import/export syntax, however I then start getting errors from the serverless_sdk/index.js file (which is minified, so I haven't been able to refactor that one).
This issue comment suggests that both AWS and the Serverless Framework now support ESM out of the box. I'm not sure why it's not working in my case.
What is the issue, or what can I do to troubleshoot this further?
It looks like you're using Serverless Dashboard plugin in your application (you have app and org defined in your config file) and at the moment, ESM modules are not supported by that integration: https://github.com/serverless/serverless/issues/11424#issuecomment-1266584167
You have several options:
Stop using the Serverless Dashboard plugin
Use CJS instead of ESModules
Write a thin wrapper for your handlers in CJS that imports the rest of your code as ESModules

Default AWS Lambda source code for .NET scratch build

I am trying to find the code for the default .NET AWS Lambda function. It does not appear to be one of the Lambda templates and I can't see it in the repository.
I'm talking about the code deployed when "Author from scratch" is selected - before any code is uploaded to the function.
Does anyone know where that source is made available?
I am specifically requesting the source of the .NET Lambda which returns "Hello from Lambda!" when the root Function URL is requested.

Unable to find Alexa-skill-kit-sdk-factskill blueprint on aws lamda

I'm quite a beginner to Alexa skill set. Trying to add a node.js skill to Alexa following few nuggets from the internet. I have created skill on amazon developer console and trying to create aws lambda function on aws console. Surprisingly, when I tried creating a lambda function, I could not find any blueprint matching to "Alexa" keyword.
Here are the steps -:
1.Got to aws.amazon.com and log in
2. Search for the Lambda service and go to it
3. Click on Create a function
4. Click on Blueprints
5. Search for “Alexa”
I did some research and it says, changing to North. Virginia region could help but no luck so far.
Any such leads would be really appreciated.
if you are unable to find "alexa-skills-kit-nodejs-factskill" under the section "Use a blueprint",
please look for it under the section "Browse serverless app repository",it doesnt matters whatever the location you choose.
Use cloudformation application templates instead. Though they are still outdated (like the blueprints out there). My advice is that you create an Alexa Hosted Skill instead

how to get the node_modules folder in an aws lambda function

So I am learning how to create alexa skills and I have create two sucessfully following the steps below but for some reason when I follow these steps now I am missing the node_modules folder and the package.json. This is causing the following error when I test my skill:
Unable to import module 'index': Error
The steps I am following are:
- go to the aws console select lambda
- select create new function
- blueprints -> select alexa-skill-kit-sdk-factskill -> configure
- select existing role -> lambda_basic_execution
- create function
It was my understanding that the alexa-skill-kit-sdk-factskill came with these dependencies. Is there a way to add them in manually if so how? I have tried to find a console but I don't see where that is in the lambda workspace.
Here is a screen shots of the project where it did add the folder and json file
Here is on of my current project
I have had this problem, but unfortunately, Lambda console doesn't give us console to install nodejs dependencies.
So, you have to actually deploy your lambda function. There are many ways to do that, but more popular are:
Node Lambda package (for node)
Create ZIP and deploy it in console (Not recommended because of size limitation)
AWS CLI
As you're learning the Alexa Skills, I would suggest you the way Amazon suggests devs to create and organise Alexa Skill and Lambda function.
Use ASK CLI
For creating new Alexa Skill.
This will create a directory, which will have:
Skill's intent Schema
Skill's lambda function
Plus, you can pass a template to create skill for a specific template. Here is list of templates created by Amazon devs.
For eg, command for creating Skill code, for a fact-template skill
ask new [--template [template-name] [--url <url>]]
[-n|--skill-name <name>]
[-p| --profile <profile>] [--lambda-name <lambda-name>]
Using ASK CLI, will give you the advantage of deploying your skill and lambda simultaneously.
I know ASK CLI is a lot to take in so quickly, but once you get the hang of it, it is a very useful tool for Alexa developers.
You can zip the whole directory content locally and upload the zip to
lambda. But yeah you can't edit the code in the console then.
Remember that your handler file name must be mentioned as it is in Handler section.
Like if your file name is app.js then app.handler.

Retrieve Test settings using Rest API from TFS

How can i retrieve Test settings using Rest API from TFS.
The below mentioned URL is the best i can get . but this is for Test result retention setting...... and what i am looking for is regular/ general Test settings.
Can some one please provide a sample URL for it.
Sample URL:- https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/Fabrikam/_apis/test/resultretentionsettings?api-version=2.0-preview"
If you mean the test settings file (See Specifying Test Settings for Visual Studio Tests), then you can get and open the file from web portal to check the settings.
If you mean Test configurations, you can refer to this link for the REST API : Test configurations:
e.g.: To Get a test configuration:
GET https://{instance}/DefaultCollection/{project}/_apis/test/configurations/{configurationId}?api-version={version}
Whatever, all the available test REST APIs are all here: Test Management
UPDATE:
According to your clarification (below answer), you just want to get the specific test run details. You can use below REST API to Get a test run:
GET http://{instance}/DefaultCollection/{project}/_apis/test/runs/{run ID}?api-version={version}
Then you will see all the settings/properties of the specific test run.
No what I really meant for was the "Test Settings" information. In MTM, we can specify the TestSettngs via TestSettings Manager.( See the below image.)
While creating a test run, we need to provide this "Test Settings" information.
Next, coming to REST API, we can create a test run using REST API too.
The below is the API reference url.
https://www.visualstudio.com/en-us/docs/integrate/api/test/overview
Under "Create a Test Run" section, you can see "test settings" under the content type. I wanted to know how to get that information via REST call(
Check see image 2 below)
(I am unable to embed pictures on the site as i have not earned 10 reputation points. please open the links provided below to view the images)

Resources