I am working on a project that involves the usage of Serverless Framwork and AWS. Although I am able to deploy my project successfully using the sls deploy command, but the sls deploy -v command fails to show me the deployment changes in my project.
Instead, it shows me something like this:
sls deploy -v
Framework Core: 3.24.1
Plugin: 6.2.2
SDK: 4.3.2
I want to see the changes in the deployment using the -v flag in the command. How can I achieve this?
Since v3 release of Serverless Framework, -v is no longer a shortcut for --verbose flag. In order to keep the old behavior, use sls deploy --verbose.
You can see that change on the list of breaking changes for v3 release: https://github.com/serverless/serverless/blob/main/CHANGELOG.md#-breaking-changes
Related
I am trying to deploy a service to aws using serverless. I am deploying it using gitlab cicd instead of doing it locally. Initially my serverless version was latest(had not mentioned any specific version) but then when I pushed my code to gitlab and i got few errors in the pipeline as the latest version is not stable. So had to change the version to a stable version. Now when i pushed my code changes to gitlab, my deployment failed and i got
Serverless Error ----------------------------------------
Cannot run local installation of the Serverless Framework by the outdated global version. Please upgrade via:
npm install -g serverless Note: Latest release can run any version of the locally installed Serverless Framework.
I dont want to upgrade my serverless version.
in my gitlab-ci.yml i have changed
- npm install -g serverless
to this
- npm install -g serverless#2.69.1
Is there any way I can fix this ?
Any help would be appreciated, thank you.
in your case, the most likely reason for that is the fact that you have a local installation of Serverless or some of the plugins/your other dependencies have Serverless v3 in peer dependencies and install it by default in npm#7 and higher.
To resolve it, either remove local installation or pin the version of the locally installed Serverless (in devDependencies of package.json of your project).
./node_modules/.bin/sls deploy does the trick.
However, the proper answer is in the docs:
There are 2 scenarios:
Using v3 globally, and v2 in specific projects.
This is the simplest. Upgrade the global version to v3, and install v2 in specific projects (via NPM). The serverless command will automatically run the correct version (v3 can run v2).
Using v2 globally, and v3 in specific projects.
To achieve that, install v3 in specific projects (via NPM). Then, use serverless for v2 projects, and npx serverless for v3 projects.
https://www.serverless.com/framework/docs/guides/upgrading-v3#using-v2-and-v3-in-different-projects
I have issues with cdk while trying to bundle lambdas with esbuild while working in my WSL2 debian
esbuild is installed as a global npm package and also in devDependencies of my cdk project
node --version
v14.16.0
cdk --version
1.95.1
esbuild --version
0.11.2
Examples of lambda definition
lex_create_bot = _lambda_node.NodejsFunction(
self,
id="lambda-lex-create-bot",
entry="lambdas_fns/lex_create_bot/lex-create-bot.ts",
handler="handler",
runtime=_lambda.Runtime.NODEJS_14_X,
bundling={"minify": True}
)
Everytime I try to deploy, check diff, cdk try to bundle the lambdas with docker instead of esbuild.
I work on this stack for a while and eveything was fine until I switched from remote-container to WSL2 to manage my dev environement in vscode.
docker is really slow for bundling and creates diff for already deployed lambdas that have no code changes.
Any idea how to solve this ?
EDIT
Same issue with Ubuntu-20.04 WSL2
I upgrade to cdk 1.97.0 and esbuild 0.11.5 this morning and all is working well now.
Still a strange behavior that I want to avoid in the future, if anyone got a more generic solution to this problem ...
I am using webpack and serverless to deploy to aws lambda. So far I have been able to configure it to bundle all dependencies into one ts file, but aws complains there is no package.json. So, I found a way to upload the node modules folder as well, which also brought in the package.json but since I am on windows the aws instances don't like the libraries.
How do I include package.json when I run the serverless package or deploy commands so that aws lambda can run the install?
include:
- package.json
Doesn't work.
If you're using the Serverless Webpack plugin, you should be able to get whatever native modules you need installed by using the packagerOptions config for the plugin and specifying the linux platform for x64 architecture along with the list of npm modules to package.
See the Custom scripts section of the plugin's documentation for more info.
For example, if your Lambda function depends on the sharp npm package, you'd add something like the following to your serverless.yml file:
custom:
webpack:
includeModules: true
packagerOptions:
scripts:
- npm_config_platform=linux npm_config_arch=x64 yarn add sharp
I am trying to run an AWS Lambda project locally on Ubuntu. When I run the project with AWS SAM Local it shows me this error: Error: Running AWS SAM projects locally requires Docker. Have you got it installed?
I had trouble installing it on Fedora.
When I followed the Docker postinstall instructions I managed to get past this issue.
https://docs.docker.com/install/linux/linux-postinstall/
I had to:
Delete the ~/.docker directory;
Create the "docker" group;
Add my user to the "docker" group;
Logout and back in again;
Restart the "docker" daemon.
I was then able to run the command:
sam local start-api
If you want to run local sam-cli, you have first install docker from docker official website then run sudo sam local start-api. Note that sudo is necessary for running local developer with needed privileges.
This error mostly arises due to lack of admin privilege to use docker. Just add sudo to your command. This will work.
eg: sudo sam local start-api --region eu-west-3
We are working on Mac and were seeing same message when using an older version of Docker (1.12.6). Have since updated to a newer (but not latest) version 17.12.0-ce-mac49 and it is now fine.
Another cause for this is this recent issue within Docker for Mac.
A quick workaround, as specified in the issue itself, is to run SAM with:
$ DOCKER_HOST=unix://$HOME/.docker/run/docker.sock sam local start-api
You don't need to run SAM as root.
I am using colima for docker on mac with intel chip. and faced this error. was able to resolve it by adding DOCKER_HOST in .zshrc file
vi ~/.zshrc
paste export DOCKER_HOST="unix://$HOME/.colima/docker.sock" in the .zshrc file
escape :wq
Currently I have a AWS EB stack setup using the default 64bit Amazon Linux 2016.03 v2.1.3 running Node.js AMI.
Our codebase is written in ES6 and we use Babel to transpile the code into ES5. Our current deployment process is running babel locally to build the /dist directory and commiting the dist into our git repository and using eb deploy to deploy the application to EB.
I would like to be able to remove the step of building the distribution locally and perform this operation on the EB server.
I have tried using .ebextensions with a command to execute npm run build which yields an error Return code: 127 Output: /bin/sh: npm: command not found.. I have also tried using files to insert the file into the appdeploy/pre which yields the same error. And I have tried using container_commands which also yields an error stating that npm is not available.
Which of the available deployment hooks that AWS EB provides would be the correct place to use npm run build?
You can use npm hooks.
For example:
Here I have a npm start command that fires my server but before it I have a babel . -d ./dist to compile the files on the dist directory. So I have a task called prestart ( using the npm hook pre naming convention ) that does that.