Can't run a serverless & bref basic example locally - macos

I want to run a basic example of serverless & bref example.
What I did:
npm install -g serverless
composer require bref/bref
vendor/bin/bref init
serverless invoke local -f hello --docker
I getting this error:
Miroslavs-MacBook-Air:testing kosta90s$ serverless invoke local -f hello --docker
Serverless: Packaging service...
Serverless: Excluding development dependencies...
START RequestId: f815c369-8fa7-1671-cbbd-d623069bc9c2 Version: $LATEST
END RequestId: f815c369-8fa7-1671-cbbd-d623069bc9c2
REPORT RequestId: f815c369-8fa7-1671-cbbd-d623069bc9c2 Init Duration: 15.78 ms Duration: 1.35 ms Billed Duration: 100 ms Memory Size: 1024 MB Max Memory Used: 7 MB
{"errorType":"exitError","errorMessage":"RequestId: f815c369-8fa7-1671-cbbd-d623069bc9c2 Error: Couldn't find valid bootstrap(s): [/var/task/bootstrap /opt/bootstrap]"}
Error --------------------------------------------------
Error: Failed to run docker for provided image (exit code 1})
at /usr/local/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:536:21
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: darwin
Node Version: 14.14.0
Framework Version: 2.8.0
Plugin Version: 4.1.1
SDK Version: 2.3.2
Components Version: 3.2.7
serverless.yml
service: app
provider:
name: aws
region: us-east-1
runtime: provided
plugins:
- ./vendor/bref/bref
functions:
hello:
handler: index.php
description: ''
layers:
- ${bref:layer.php-74}
# Exclude files from deployment
package:
exclude:
- 'tests/**'
I working on MacOs Catalina.

serverless invoke local tries to use a Docker image named lambci/lambda:${runtime} where runtime is phpX.Y in your case.
https://github.com/serverless/serverless/blob/6a81137406fd2a2283663af93596ba79d23e38ef/lib/plugins/aws/invokeLocal/index.js#L478
There is no such image as you can see here:
https://hub.docker.com/r/lambci/lambda/tags
As the comments said, try without --docker. If you need Docker, you can follow the documentation and use the following docker-compose.yml:
version: "3.5"
services:
web:
image: bref/fpm-dev-gateway
ports:
- '8000:80'
volumes:
- .:/var/task
depends_on:
- php
environment:
HANDLER: index.php
php:
image: bref/php-74-fpm-dev
volumes:
- .:/var/task:ro

Related

AWS::CloudFormation::Stack creation through serverless framework failed on localstack

I'm deploying lambda on localstack using serverless framework. I've configured aws credentials in ~/.aws/credentials. When I run the deploy command, get the following error. Couldn't figure out the cause of failure...
Command: serverless deploy --stage local --aws-profile default
Output:
✖ Stack lambda-api-local failed to deploy (12s)
Environment: darwin, node 16.14.0, framework 3.17.0 (local) 3.17.0v (global), plugin 6.2.2, SDK 4.3.2
Credentials: Local, "default" profile
Docs: docs.serverless.com
Support: forum.serverless.com
Bugs: github.com/serverless/serverless/issues
Error:
CREATE_FAILED: lambda-api-local (AWS::CloudFormation::Stack)
undefined
This is my ~/.aws/credentials
[default]
aws_access_key_id = test
aws_secret_access_key = test
This is my serverless.yml
service: lambda-api
plugins:
- serverless-localstack
provider:
name: aws
stage: local
runtime: go1.x
profile: localstack
package:
patterns:
- '!./**'
- './bin/**'
functions:
hello:
handler: bin/lambda-practice
events:
- http:
path: /hello
method: get
custom:
localstack:
debug: true
endpointFile: localstack_endpoints.json
stages:
# Stages for which the plugin should be enabled
- local
host: http://localhost
edgePort: 4567
autostart: true
lambda:
mountCode: true
docker:
sudo: false
I'm trying to deploy and run lambda on localstack through serverless framework

sh: 1: nest: Permission denied in GitHub Action

For some reason the build step for my NestJS project in my GitHub Action fails for a few days now. I use Turborepo with pnpm in a monorepo and try to run the build with turbo run build. This works flawlessly on my local machine, but somehow in GitHub it fails with sh: 1: nest: Permission denied. ELIFECYCLE  Command failed with exit code 126. I'm not sure how this is possible, since I couldn't find any meaningful change I made to the code in the meantime. It just stopped working unexpectedly. I actually think it is an issue with GH Actions, since it actually works in my local Docker build as well.
Has anyone else encountered this issue with NestJS in GH Actions?
This is my action yml:
name: Test, lint and build
on:
push:
jobs:
test-lint-build:
runs-on: ubuntu-latest
services:
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_HOST: localhost
POSTGRES_USER: test
POSTGRES_PASSWORD: docker
POSTGRES_DB: financing-database
ports:
# Maps tcp port 5432 on service container to the host
- 2345:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout#v3
- name: Install pnpm
uses: pnpm/action-setup#v2.2.2
with:
version: latest
- name: Install
run: pnpm i
- name: Lint
run: pnpm run lint
- name: Test
run: pnpm run test
- name: Build
run: pnpm run build
env:
VITE_SERVER_ENDPOINT: http://localhost:8000/api
- name: Test financing-server (e2e)
run: pnpm --filter #project/financing-server run test:e2e
I found out what was causing the problem. I was using node-linker = hoisted to mitigate some issues the pnpm way of linking modules was causing with my jest tests. Removing this from my project suddenly made the action work again.
I still don't know why this only broke the build recently, since I've had this option activated for some time now.

configure serverless.yml laravel bref

i tried to deploy laravel serverless app with (bref) to AWS api gateway and lambda function
but i keet getting (strict-origin-when-cross-origin) with a black screen output:
**{"message":"Internal Server Error"}**
and this is my serverless.yml file
service: laravelproject
provider:
name: aws
# The AWS region in which to deploy (us-east-1 is the default)
region: eu-central-1
# The stage of the application, e.g. dev, production, staging… ('dev' is the default)
stage: dev
runtime: provided.al2
package:
# Directories to exclude from deployment
patterns:
- '!node_modules/'
- '!public/storage'
- '!resources/assets/'
- '!storage/'
- '!tests/'
functions:
# This function runs the Laravel website/API
web:
handler: public/index.php
timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds)
layers:
- ${bref:layer.php-80-fpm}
events:
- httpApi: '*'
# This function lets us run artisan commands in Lambda
artisan:
handler: artisan
timeout: 120 # in seconds
layers:
- ${bref:layer.php-80} # PHP
- ${bref:layer.console} # The "console" layer
plugins:
# We need to include the Bref plugin
- ./vendor/bref/bref
Try increasing the php version you are specifying
Please fix ${bref:layer.php-80} as follows
${bref:layer.php-81}
I got it working with this

Can't get CircleCI to post to Slack upon test failure

I'm getting no parsing errors and i believe my config.yml is correct, I just can't seem to get it to post to slack, i have all the backgrounc config correct such as the environment variables and the context part is what we call to our organization settings, it's just not posting upon failure, is there something i'm doing wrong?
version: 2.1
orbs:
cypress: cypress-io/cypress#1
slack: circleci/slack#4.5.0
workflows:
version: 2
test:
jobs:
- cypress/run
jobs:
steps:
executors:
with-chrome:
docker:
- image: 'cypress/browsers:node14.16.0-chrome90-ff88'
description: Runs cypress tests
steps:
- checkout
- run:
name: Run all cypress tests
command: npx cypress run
context: slack-context
- slack/notify:
event: fail
template: basic_fail_1
It appears you're using the CircleCI Cypress orb, and more specifically the cypress/run job defined in that orb. So I'm not sure what the part
jobs:
steps:
executors:
with-chrome:
docker:
- image: 'cypress/browsers:node14.16.0-chrome90-ff88'
description: Runs cypress tests
steps:
- checkout
- run:
name: Run all cypress tests
command: npx cypress run
context: slack-context
- slack/notify:
event: fail
template: basic_fail_1
is for.
The way your config looks, that part will never be executed. Your build will be simply the cypress/run job running with all the default parameters' values.
Further more, contexts need to be referenced within the workflows section (https://circleci.com/docs/2.0/contexts/).
I would suggest the below configuration:
version: 2.1
orbs:
cypress: cypress-io/cypress#1.29.0
slack: circleci/slack#4.10.1
executors:
with-chrome:
docker:
- image: 'cypress/browsers:node14.16.0-chrome90-ff88'
workflows:
version: 2
test:
jobs:
- cypress/run:
executor: with-chrome
browser: chrome
context: slack-context
post-steps:
- slack/notify:
event: fail
template: basic_fail_1

Serverless ApiGatewayMethodOptions template error

I'm trying to deploy AWS lambda using sls deploy command and got next error
Serverless Error ---------------------------------------
An error occurred while provisioning your stack: ApiGatewayMethodOptions - Template
error: API Gateway RestAPI nyq25wyiii doesn't exist.
Environment Information
OS: linux
Node Version: 4.2.6
Serverless Version: 1.18.1
my serverless.yml looks like below
service: test_service
provider:
name: aws
runtime: python3.6
region: eu-west-1
memorySize: 128
functions:
test_function:
handler: handler.handler
events:
- http:
path: /
method: any
cors: true

Resources