I have a serverless project I am using with localstack and Docker. When i build my project everything runs and works as expected. When i add a plugin
serverless-plugin-export-endpoints
GitHub - ar90n/serverless-plugin-export-endpoints: Export lambda endpoints as json
to serverless yml file and add
CMD ["sls","exportEndpoints" ]
it results in the error
ServerlessError: ValidationError: Stack with id pond5-api-local does not exist
Here is my Dockerfile
FROM node:16-alpine
ARG SLS_DEBUG=*
RUN apk update
WORKDIR /app
RUN npm install -g serverless && \
npm install serverless-plugin-export-endpoints 0 && \
npm install -g serverless-localstack
COPY serverless.yml ./
COPY handler.py ./
COPY dynamo.py ./
COPY localstack_endpoints.json ./
EXPOSE 3000
CMD ["sls","deploy" ]
CMD ["sls","exportEndpoints" ]
Here is my Docker-compose file
version: '3.1'
services:
api:
build: .
image: pond5/items_api
environment:
- SLS_DEBUG=*
depends_on:
- localstack
ports:
- '49160:3000'
container_name: items_api
localstack:
image: localstack/localstack:latest
environment:
- AWS_DEFAULT_REGION=us-east-1
- EDGE_PORT=4566
- SERVICES=lambda,s3,cloudformation,sts,apigateway,iam,route53,dynamodb
ports:
- '4566-4597:4566-4597'
volumes:
- "${TEMPDIR:-/tmp/localstack}:/temp/localstack"
- "/var/run/docker.sock:/var/run/docker.sock"
All I have added is this to my serverless.yml file
plugins:
- serverless-plugin-export-endpoints
Might be worth mentioning i am running this config for localhost
provider:
name: aws
runtime: python3.8
region: us-east-1
stage: local
custom:
tableName: 'items-table-${self:provider.stage}'
environment:
ITEMS_TABLE: ${self:custom.tableName}
AWS_ACCESS_KEY_ID: 123
AWS_SECRET_ACCESS_KEY: 143
AWS_DEFAULT_REGION: us-east-1
localstack:
region: us-east-1
debug: true
stages:
- local
host: http://host.docker.internal